/* ============================================================================
   TRam Studio — BLUEPRINT skin  (Phase 1)
   Loaded LAST so it wins the cascade. UI ONLY — no markup, JS, forms, or
   routes are touched; this file only overrides colors, type, and surfaces.

   ROLLBACK: restore Views/Shared/_Layout.legacy.cshtml over _Layout.cshtml
   (that removes the single <link> to this file and the old look returns).
   ============================================================================ */

/* ---- 1 · Blueprint grid backdrop ------------------------------------------ */
html[data-theme="dark"] body.studio-shell-body {
    background:
        linear-gradient(rgba(140,175,205,.035) 1px, transparent 1px) 0 0 / 26px 26px,
        linear-gradient(90deg, rgba(140,175,205,.035) 1px, transparent 1px) 0 0 / 26px 26px,
        radial-gradient(1100px 460px at 84% -8%, var(--glow1), transparent 62%),
        var(--app-bg);
    background-attachment: fixed;
}
html[data-theme="light"] body.studio-shell-body {
    background:
        linear-gradient(rgba(15,25,40,.04) 1px, transparent 1px) 0 0 / 26px 26px,
        linear-gradient(90deg, rgba(15,25,40,.04) 1px, transparent 1px) 0 0 / 26px 26px,
        var(--app-bg);
    background-attachment: fixed;
}

/* ---- 2 · Thin console strip ----------------------------------------------- */
.studio-topbar {
    background: var(--panel-3);
    border-bottom: 1px solid var(--line);
    font-family: var(--font-mono);
    font-size: 10.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
}

/* ---- 3 · Nav: dark, theme-aware console bar (was hard-coded white) -------- */
.studio-main-nav {
    background: var(--panel) !important;
    border-bottom: 1px solid var(--line) !important;
    box-shadow: none !important;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
.studio-main-nav .studio-shell-container { min-height: 64px; }

.studio-brand-mark { border-radius: 0; box-shadow: 0 0 0 1px var(--line), 0 8px 20px var(--glow1); }
.studio-brand-text { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--txt); }
.studio-brand-subtext { font-family: var(--font-mono); font-weight: 500; font-size: 9.5px; letter-spacing: 2px; color: var(--accent); }

.studio-nav-link {
    font-family: var(--font-mono) !important;
    font-size: 11.5px !important;
    font-weight: 500 !important;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: var(--muted) !important;
    padding: 10px 14px !important;
}
.studio-nav-link:hover,
.studio-nav-link:focus { color: var(--accent) !important; }
.studio-nav-link.active { color: var(--txt) !important; }
.studio-nav-link::after { left: 14px; right: 14px; background: var(--accent); }
.studio-nav-link.active::after { transform: scaleX(1); }

.studio-user-pill {
    border-radius: 0;
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--txt);
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
}

/* ---- 4 · Sharpen surfaces (drafting feel) --------------------------------- */
.tdx-card { border-radius: 0 !important; position: relative; }
.tdx-card::after {
    content: "";
    position: absolute; top: 7px; right: 7px; width: 6px; height: 6px;
    border-top: 1px solid var(--accent);
    border-right: 1px solid var(--accent);
    opacity: .45;
    transition: opacity .16s ease;
}
.tdx-card:hover::after { opacity: 1; }

.studio-btn,
.studio-btn-primary,
.studio-btn-ghost { border-radius: 0 !important; }
.studio-btn-primary { box-shadow: 0 6px 18px var(--glow1); }

/* Section kickers / mono labels get a touch more presence */
.studio-page-kicker,
.tdx-cat-name { letter-spacing: 1.4px; }

/* ---- 5 · Footer console ---------------------------------------------------- */
.studio-footer { background: var(--panel-3); border-top: 1px solid var(--line); }
.studio-footer-title { font-family: var(--font-display); }

/* ============================================================================
   Phase 2 · rail + top-bar shell layout
   ROLLBACK: restore _Layout.phase1.cshtml (keeps the skin, drops this layout)
   or _Layout.legacy.cshtml (removes everything).
   ============================================================================ */
body { overflow-x: clip; }
.bp-app { display: grid; grid-template-columns: 88px minmax(0, 1fr); min-height: 100vh; }

.bp-rail {
    position: sticky; top: 0; align-self: start; height: 100vh;
    background: var(--panel); border-right: 1px solid var(--line);
    display: flex; flex-direction: column; align-items: center; padding: 14px 0 26px; gap: 2px; z-index: 90;
}
.bp-rail-brand { width: 42px; height: 42px; display: grid; place-items: center; margin-bottom: 12px; box-shadow: 0 0 0 1px var(--line), 0 8px 20px var(--glow1); }
.bp-rail-brand svg { width: 40px; height: 40px; display: block; }
.bp-rail-nav { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 100%; }
.bp-rail-i {
    width: 74px; padding: 11px 0 9px; display: flex; flex-direction: column; align-items: center; gap: 6px;
    color: var(--faint); font-family: var(--font-mono); font-size: 9px; letter-spacing: .6px; text-transform: uppercase;
    text-decoration: none; border-left: 2px solid transparent; transition: .14s;
}
.bp-rail-i i { font-size: 17px; line-height: 1; }
.bp-rail-i:hover { color: var(--txt); background: var(--panel-2); }
.bp-rail-i.on { color: var(--accent); background: var(--panel-2); border-left-color: var(--accent); }
.bp-rail-sp { flex: 1; }

.bp-canvas { display: flex; flex-direction: column; min-width: 0; }
.bp-top {
    position: sticky; top: 0; z-index: 80; min-height: 56px;
    display: flex; align-items: center; gap: 12px; padding: 0 24px;
    background: var(--panel); border-bottom: 1px solid var(--line);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.bp-crumb { font-family: var(--font-mono); font-size: 12px; color: var(--faint); letter-spacing: .4px; }
.bp-crumb .bp-crumb-root { color: var(--accent); }
.bp-crumb .bp-crumb-sep { margin: 0 5px; }
.bp-crumb b { color: var(--txt); font-weight: 600; }
.bp-top-sp { flex: 1; }
.bp-env { font-family: var(--font-mono); font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); padding: 3px 8px; }

.bp-main { flex: 1 0 auto; padding: 26px 30px 46px; min-width: 0; box-sizing: border-box; overflow-x: clip; }
.bp-canvas, .bp-main, .bp-top { max-width: 100%; box-sizing: border-box; }
.bp-footer { margin-top: 0; }

@media (max-width: 900px) {
    .bp-app { grid-template-columns: 1fr; }
    .bp-rail {
        position: static; height: auto; width: 100%; flex-direction: row; justify-content: flex-start;
        gap: 0; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto;
    }
    .bp-rail-brand { margin: 0 10px 0 0; }
    .bp-rail-nav { flex-direction: row; width: auto; }
    .bp-rail-i { width: auto; padding: 8px 12px; border-left: 0; border-bottom: 2px solid transparent; flex-direction: row; gap: 8px; font-size: 11px; }
    .bp-rail-i.on { border-left: 0; border-bottom-color: var(--accent); }
    .bp-rail-sp { display: none; }
    .bp-main { padding: 18px 16px 40px; }
}

/* ============================================================================
   Accent themes — swap --accent family via html[data-accent].
   Teal is the default (no override needed). Works over dark OR light base.
   ============================================================================ */
html[data-accent="blue"]  { --accent:#3b82f6; --accent-2:#2563eb; --accent-tint:rgba(59,130,246,.12); --glow1:rgba(59,130,246,.14); --glow2:rgba(59,130,246,.07); --ok:#3b82f6; }
html[data-accent="green"] { --accent:#22c55e; --accent-2:#16a34a; --accent-tint:rgba(34,197,94,.12);  --glow1:rgba(34,197,94,.14);  --glow2:rgba(34,197,94,.07);  --ok:#22c55e; }
html[data-accent="red"]   { --accent:#f43f5e; --accent-2:#e11d48; --accent-tint:rgba(244,63,94,.12);  --glow1:rgba(244,63,94,.14);  --glow2:rgba(244,63,94,.07);  --ok:#f43f5e; }
html[data-theme="dark"][data-accent="blue"],
html[data-theme="dark"][data-accent="red"]   { --accent-ink:#ffffff; }
html[data-theme="dark"][data-accent="green"]  { --accent-ink:#04160b; }

/* accent swatch switcher (top bar) */
.bp-accent { display: flex; align-items: center; gap: 6px; padding: 0 6px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.bp-sw { width: 16px; height: 16px; border: 1px solid var(--line-2); cursor: pointer; padding: 0; position: relative; }
.bp-sw:hover { transform: scale(1.12); }
.bp-sw.on::after { content: ""; position: absolute; inset: -4px; border: 1px solid var(--accent); }

/* rail user (bottom-left) + minimal footer */
.bp-rail-user { width: 34px; height: 34px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent); font-family: var(--font-mono); font-size: 12px; font-weight: 600; margin-bottom: 8px; }
.bp-rail-signout { display: flex; margin-bottom: 2px; }
.bp-rail-signout .studio-signout-btn { border: 1px solid var(--line); background: transparent; color: var(--muted); width: 34px; height: 30px; display: grid; place-items: center; cursor: pointer; }
.bp-rail-signout .studio-signout-btn:hover { color: var(--accent); border-color: var(--accent); }

.bp-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 30px; border-top: 1px dashed var(--line); font-family: var(--font-mono); font-size: 11px; letter-spacing: .4px; color: var(--faint); }
.bp-foot-env { text-transform: uppercase; color: var(--muted); }

/* ============================================================================
   Real tooltips (data-tip) — sharp Blueprint style, replaces title attributes
   ============================================================================ */
.tip { position: relative; }
.tip::after {
    content: attr(data-tip);
    position: absolute; z-index: 400;
    background: var(--panel); color: var(--txt);
    border: 1px solid var(--line-2);
    font-family: var(--font-mono); font-size: 10px; letter-spacing: .4px;
    padding: 5px 9px; white-space: nowrap;
    box-shadow: 0 10px 26px rgba(0,0,0,.35);
    display: none; pointer-events: none;
}
.tip:hover::after, .tip:focus-visible::after { display: block; animation: tipin .12s ease .12s both; }
@keyframes tipin { from { opacity: 0; } to { opacity: 1; } }
.tip-right::after { left: calc(100% + 10px); top: 50%; transform: translateY(-50%); }
.tip-bottom::after { top: calc(100% + 8px); left: 50%; transform: translateX(-50%); }

/* ============================================================================
   Rail: sign-out as nav item, toggle, user row, expanded state
   ============================================================================ */
.bp-rail-form { display: contents; }
button.bp-rail-i { background: transparent; cursor: pointer; border: 0; border-left: 2px solid transparent; font-family: var(--font-mono); font-size: 9px; letter-spacing: .6px; text-transform: uppercase; }
html[data-rail="expanded"] button.bp-rail-i { font-size: 11px; letter-spacing: .8px; }
.bp-rail-out:hover { color: var(--danger) !important; }

.bp-rail-toggle { width: 34px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; margin-bottom: 10px; transition: .15s; }
.bp-rail-toggle:hover { color: var(--accent); border-color: var(--accent); }
.bp-rail-toggle i { transition: transform .2s ease; }
html[data-rail="expanded"] .bp-rail-toggle i { transform: rotate(180deg); }

.bp-rail-user-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; max-width: 100%; }
.bp-rail-user { width: 34px; height: 34px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent); font-family: var(--font-mono); font-size: 12px; font-weight: 600; flex-shrink: 0; }
.bp-rail-user-name { display: none; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- expanded rail ---- */
html[data-rail="expanded"] .bp-app { grid-template-columns: 224px minmax(0, 1fr); }
html[data-rail="expanded"] .bp-rail { align-items: stretch; padding: 14px 10px 26px; }
html[data-rail="expanded"] .bp-rail-brand { margin-left: 8px; margin-right: auto; }
html[data-rail="expanded"] .bp-rail-nav { align-items: stretch; }
html[data-rail="expanded"] .bp-rail-i { width: 100%; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 11px 14px; font-size: 11px; letter-spacing: .8px; text-align: left; }
html[data-rail="expanded"] .bp-rail-i i { width: 18px; text-align: center; font-size: 15px; }
html[data-rail="expanded"] .bp-rail-toggle { align-self: flex-start; margin-left: 8px; }
html[data-rail="expanded"] .bp-rail-user-row { padding: 0 4px; }
html[data-rail="expanded"] .bp-rail-user-row.tip::after { display: none; }
html[data-rail="expanded"] .bp-rail-user-name { display: block; }

@media (max-width: 900px) {
    html[data-rail="expanded"] .bp-app { grid-template-columns: 1fr; }
    html[data-rail="expanded"] .bp-rail { flex-direction: row; align-items: center; padding: 8px 10px; }
    html[data-rail="expanded"] .bp-rail-i { width: auto; }
    .bp-rail-toggle { display: none; }
    .bp-rail-user-name { display: none !important; }
}
