/*
    jgn-glass.css — the SHARED JARGAN glass system (BU-691).

    Extracted from Pages/Admin/AdminConsole.razor.css and Layout/ShellSidebar.razor.css so
    any page can use the same proven, AA-tested glass containers instead of hand-rolling a
    second implementation. This is a PURE MOVE: no value was restyled, renamed, re-tuned, or
    reformatted. /home renders identically to how it did when these rules were scoped.

    Contents, in cascade order (the order matters — the retint block MUST stay last):
      1. .mc            — the design-token block the glass classes read (--text, --brand, ...)
      2. .mc-side       — the glass rail + its no-vibe sentinel; .mc-nav — the glass nav item
      3. .mc-card*      — the glass card (head, title, view-all, CTA)
      4. .mc-fab*       — the pinned circular menu (mobile-only, portalled to <body>)
      5. BU-544 vibe retint — html[data-theme]:not([data-theme='default']) overrides that
         repaint every one of the above onto the active vibe's token layer, plus the
         --color-accent-aa / --color-tint-*-text AA text overrides.

    Loaded from index.html BEFORE Jargan.Client.styles.css: these rules are unscoped, so a
    component's own scoped [b-hash] rules keep the higher specificity and still win ties.
    Every responsive / collapsed / phone override of these classes was deliberately LEFT
    scoped for that reason.

    NOTE: `.mc-need > :global(svg)` and
    `.mc-engcard__sched > :global(svg)` were left in their scoped stylesheets ON PURPOSE.
    This project's scoped-CSS compiler emits :global() literally (`:global(svg)[b-hash]`),
    an invalid selector the browser drops — those rules are dead today, and unwrapping them
    here would switch them on and change the render.
*/

/* ===== 1. TOKENS — the variable block every glass class below reads.
   Moved from AdminConsole.razor.css `.mc`; that rule keeps its own layout
   declarations (position / z-index / background / color / font) scoped. ===== */
.mc {
    --bg: #0c0d10;
    --panel: #16181d;
    --panel-2: #1b1e24;
    --line: #262a31;
    --line-soft: #21242b;
    --brand: #DD5100;
    --text: #ffffff;
    --text-2: #cfd2d6;
    --text-3: #9aa0a6;
    --text-4: #8f9499; /* raised from #6b7075 so small muted labels clear 4.5:1 AA on dark panels */
    --red: #e0523b;
    --amber: #f4b740;
    --blue: #4f8ef7;
    --green: #3ecf7b;
    --purple: #a06bf0;
}

/* ===== 2. GLASS RAIL + GLASS NAV ITEM (from ShellSidebar.razor.css) ===== */
.mc-side {
    --ss-glass: color-mix(in srgb, var(--v-surface) 85%, transparent);
    --ss-edge: color-mix(in srgb, var(--v-ink) 12%, transparent);
    --ss-edge-inset: color-mix(in srgb, var(--v-ink) 6%, transparent);
    --ss-ink: var(--v-ink);
    --ss-ink-2: var(--v-ink-dim);
    --ss-ink-3: var(--v-ink-muted);
    --ss-ink-4: var(--v-ink-muted);
    --ss-hover: color-mix(in srgb, var(--v-ink) 6%, transparent);
    --ss-active: color-mix(in srgb, var(--v-ink) 10%, transparent);
    --ss-brand: var(--v-accent-brand);
    --ss-brand-deep: color-mix(in srgb, var(--v-accent-brand), black 22%);
    --ss-on-brand: var(--v-on-accent);
    --ss-panel: var(--v-surface-sunken);
    --ss-line: var(--v-border);

    width: 208px;
    flex: 0 0 208px;
    position: relative;
    z-index: 20;
    background: var(--ss-glass);
    backdrop-filter: blur(22px) saturate(1.25);
    -webkit-backdrop-filter: blur(22px) saturate(1.25);
    border-right: 1px solid var(--ss-edge);
    box-shadow: inset -1px 0 0 var(--ss-edge-inset), 2px 0 30px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    padding: 18px 12px 14px;
    gap: 6px;
    overflow: visible;
    color: var(--ss-ink);
    font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
}

html:not([data-theme]) .mc-side,
html[data-theme="light"] .mc-side,
html[data-theme="default"] .mc-side {
    --ss-glass: rgba(9, 11, 14, 0.66);
    --ss-edge: rgba(255, 255, 255, 0.07);
    --ss-edge-inset: rgba(255, 255, 255, 0.03);
    --ss-ink: #ffffff;
    --ss-ink-2: #cfd2d6;
    --ss-ink-3: #9aa0a6;
    --ss-ink-4: #8f9499;
    --ss-hover: #14161b;
    --ss-active: #1c1f26;
    --ss-brand: #DD5100;
    --ss-brand-deep: #b23f00;
    --ss-on-brand: #ffffff;
    --ss-panel: #101216;
    --ss-line: #262a31;
}

.mc-nav {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--ss-ink-3);
    text-decoration: none;
    font-weight: 500;
    transition: background .12s, color .12s;
    flex: 0 0 auto;
}
.mc-nav:hover { background: var(--ss-hover); color: var(--ss-ink-2); }
.mc-nav--active { background: var(--ss-active); color: var(--ss-ink); }
.mc-nav__accent {
    position: absolute;
    left: 0; top: 8px; bottom: 8px;
    width: 3px; border-radius: 0 3px 3px 0;
    background: var(--ss-brand);
}
.mc-nav__label { font-size: 13.5px; white-space: nowrap; }

/* ===== 3. GLASS STAT / URGENCY TILE ===== */
/* Trailing chevron wrapped in a scoped span so the phone tiles can hide it (the
   scoped-CSS rewriter drops :global(svg) inside @media). Desktop appearance is
   preserved here: same muted colour, same fixed sizing, on the right of the row. */


/* ===== 4. GLASS CARD ===== */
.mc-card {
    background: rgba(19, 21, 26, 0.6);
    min-width: 0;
    backdrop-filter: blur(22px) saturate(1.3);
    -webkit-backdrop-filter: blur(22px) saturate(1.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px 17px 14px; display: flex; flex-direction: column;
    box-shadow: 0 10px 34px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}
.mc-card--urgent {
    border-color: rgba(224,82,59,0.5);
    background: linear-gradient(180deg, rgba(224,82,59,0.14), rgba(19,21,26,0.66) 42%);
    box-shadow: 0 0 0 1px rgba(224,82,59,0.14), 0 10px 34px rgba(0,0,0,0.4),
                0 0 30px rgba(224,82,59,0.08), inset 0 1px 0 rgba(255,255,255,0.05);
}
.mc-card__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.mc-card__title { margin: 0; font-size: 14.5px; font-weight: 700; letter-spacing: .01em; color: #fff; text-transform: uppercase; letter-spacing: .05em; }
.mc-card__viewall { font-size: 12px; color: var(--text-3); text-decoration: none; }
.mc-card__viewall:hover { color: #fff; }
.mc-card__viewall--red { color: #f0836f; }

.mc-card__cta {
    margin-top: auto; padding-top: 12px; display: inline-flex; align-items: center; gap: 5px;
    font-size: 12.5px; font-weight: 600; color: #ff6f24; text-decoration: none; /* lightened Traffic Orange for AA on dark; same brand hue */
}
.mc-card__cta:hover { color: #ff8038; }
.mc-card__cta--red { color: #f0836f; }
.mc-card__cta--red:hover { color: #ff8a72; }

/* ===== 5. PINNED CIRCULAR MENU (FAB) ===== */
/* BU-560 bullet 6: the FAB is portalled to <body> (out of .mc's overflow box) so iOS Safari
   can't clip it. At body level it no longer inherits .mc's --brand, so define it here (global
   Traffic-Orange accent, brand-invariant across vibes) — the toggle + item icons read it. */
.mc-fab { display: none; --brand: var(--color-accent, #DD5100); }

@media (max-width: 480px) {
    /* =====================================================================
       PINNED CIRCULAR MENU (BU-558 ask 1) — corner FAB, bottom-LEFT.
       Closed: one brand-orange launcher node (the single bold element). Tap fans the
       five destinations UP as glass pills with a staggered reveal; a scrim dims the
       cockpit and closes the menu on tap-outside. Anchored opposite the bottom-right
       vibe pill, so the two never collide. Pure app CSS + a Blazor toggle — no jQuery. */
    .mc-fab { display: block; }

    .mc-fab__scrim {
        position: fixed; inset: 0; z-index: 2147482998; border: none; padding: 0;
        background: rgba(6, 7, 9, 0.55);
        opacity: 0; pointer-events: none; transition: opacity .2s ease;
    }
    .mc-fab--open .mc-fab__scrim { opacity: 1; pointer-events: auto; }

    .mc-fab__toggle {
        position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        /* BU-560 bullet 6 (footer-Z fix): the footer band was painting over the FAB on iOS.
           Two-part fix:
           1. z-index raised to 2147483000 — above every in-flow element AND any nested
              stacking context in .mc, so the footer/Brand-Voices band can never win by order.
              (Kept just below the vibe pill's 2147483647 so the pill still tops everything.)
           2. will-change: transform promotes the toggle to its OWN compositor layer. On iOS
              Safari a position:fixed child of an overflow ancestor (.mc has overflow:hidden,
              .mc-main overflow:auto) can get absorbed into the scroll layer and painted UNDER
              later scrolling content — layer promotion forces it into the top layer so the
              footer can't cover it. Chromium already stacked it correctly; this hardens iOS. */
        z-index: 2147483000; width: 56px; height: 56px; border-radius: 50%;
        display: inline-flex; align-items: center; justify-content: center;
        background: var(--brand); color: #fff; border: none; cursor: pointer;
        font-family: inherit; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
        box-shadow: 0 6px 22px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
        transition: transform .18s ease, background .12s;
        will-change: transform;
    }
    .mc-fab__toggle:active { transform: scale(0.94); }
    .mc-fab--open .mc-fab__toggle { transform: rotate(90deg); }
    .mc-fab__toggle-ico { display: inline-flex; }

    .mc-fab__items {
        position: fixed; left: 16px; z-index: 2147482999;
        bottom: calc(16px + 56px + 12px + env(safe-area-inset-bottom, 0px));
        margin: 0; padding: 0; list-style: none;
        display: flex; flex-direction: column-reverse; align-items: flex-start; gap: 10px;
        will-change: transform;
    }
    .mc-fab__item {
        opacity: 0; transform: translateY(14px) scale(0.92); pointer-events: none;
        transition: opacity .16s ease, transform .16s ease;
    }
    .mc-fab--open .mc-fab__item {
        opacity: 1; transform: none; pointer-events: auto;
        transition-delay: calc(var(--i) * 0.04s);
    }
    .mc-fab__link {
        display: inline-flex; align-items: center; gap: 10px;
        min-height: 44px; padding: 5px 15px 5px 5px; border-radius: 24px; text-decoration: none;
        background: rgba(20, 22, 27, 0.92);
        backdrop-filter: blur(18px) saturate(1.25);
        -webkit-backdrop-filter: blur(18px) saturate(1.25);
        border: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
    }
    .mc-fab__ico {
        display: inline-flex; align-items: center; justify-content: center;
        width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%;
        background: #22262d; color: var(--brand);
    }
    .mc-fab__lbl { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; }

    /* Reduced motion: reveal instantly, no stagger/rotate/scale. */
    @media (prefers-reduced-motion: reduce) {
        .mc-fab__scrim, .mc-fab__item, .mc-fab__toggle { transition: none; }
        .mc-fab--open .mc-fab__item { transition-delay: 0s; }
        .mc-fab--open .mc-fab__toggle { transform: none; }
    }
}

/* ===== 6. VIBE RETINT (must remain last) ===== */
/* ============================================================================
   BU-544 — VIBE-FOLLOWING OVERRIDES
   ----------------------------------------------------------------------------
   Everything above is the APPROVED DARK COCKPIT and is the DEFAULT state
   (no <html data-theme> / 'default'), left byte-identical.

   When an EXPLICIT vibe is chosen (the pill / theme controls set <html data-theme>),
   /home repaints onto the --color-* / signal-tint token layer like any other page:
     • surfaces  -> rgba(var(--color-surface-rgb), a) glass that tints over the vibe canvas
     • borders   -> rgba(var(--color-ink-rgb), a) hairlines
     • text/ink  -> --color-ink / --color-ink-dim / --color-ink-muted (dark on light vibes,
                    light on dark vibes)
     • signals   -> saturated --color-status-* fills for dots/bars/badges; theme-aware
                    --color-tint-*-text for signal TEXT (AA on both orientations)
     • brand     -> stays JARGAN Traffic Orange (--color-accent), never a vibe colour
   koi-home.js drives the koi water from the same live vibe tokens.
   ============================================================================ */

html[data-theme]:not([data-theme='default']) .mc {
    --bg: var(--color-canvas);
    --panel: var(--color-surface);
    --panel-2: var(--color-surface-raised);
    --line: var(--color-line);
    --line-soft: var(--color-line);
    --brand: var(--color-accent);
    --text: var(--color-ink);
    --text-2: var(--color-ink-dim);
    --text-3: var(--color-ink-muted);
    --text-4: var(--color-ink-muted);
    --red: var(--color-status-error);
    --amber: var(--color-status-warning);
    --blue: var(--color-status-info);
    --green: var(--color-status-success);
    --purple: var(--color-indigo);
    color: var(--color-ink);
}

/* Glass panels: dark-tint literals -> vibe surface, hairlines -> vibe ink.
   (.mc-side moved to ShellSidebar.razor.css, which chains --v-* directly.) */

html[data-theme]:not([data-theme='default']) .mc-card,
html[data-theme]:not([data-theme='default']) .mc-jump__card {
    background: rgba(var(--color-surface-rgb), 0.85);
    border-color: rgba(var(--color-ink-rgb), 0.12);
}

/* Signal glass (urgency strip + urgent card): retint onto status-rgb over the vibe surface. */
html[data-theme]:not([data-theme='default']) .mc-card--urgent {
    background: linear-gradient(180deg, rgba(var(--color-status-error-rgb), 0.14), rgba(var(--color-surface-rgb), 0.85) 42%);
    border-color: rgba(var(--color-status-error-rgb), 0.5);
}

/* Hardcoded white text that bypasses --text -> ink so it reads on the vibe surface/water. */
html[data-theme]:not([data-theme='default']) .mc-head__title,
html[data-theme]:not([data-theme='default']) .mc-card__title,
html[data-theme]:not([data-theme='default']) .mc-row__title,
html[data-theme]:not([data-theme='default']) .mc-donut__num,
html[data-theme]:not([data-theme='default']) .mc-util__pct,
html[data-theme]:not([data-theme='default']) .mc-jump__title,
html[data-theme]:not([data-theme='default']) .mc-btn--ghost:hover,
html[data-theme]:not([data-theme='default']) .mc-card__viewall:hover,
html[data-theme]:not([data-theme='default']) .mc-foot__link:hover,
html[data-theme]:not([data-theme='default']) .mc-need:hover .mc-need__title {
    color: var(--color-ink);
}

/* Dark-surface literals used for chips / tracks / icon tiles.
   (Sidebar hover/active/workspace rules moved to ShellSidebar.razor.css.) */
html[data-theme]:not([data-theme='default']) .mc-tag,
html[data-theme]:not([data-theme='default']) .mc-sched__track {
    background: var(--color-surface-sunken);
}
html[data-theme]:not([data-theme='default']) .mc-btn--ghost {
    background: var(--color-surface);
}
html[data-theme]:not([data-theme='default']) .mc-btn--ghost:hover {
    background: var(--color-surface-raised);
}
html[data-theme]:not([data-theme='default']) .mc-need__icon,
html[data-theme]:not([data-theme='default']) .mc-jump__icon {
    background: rgba(var(--color-ink-rgb), 0.06);
}

/* Signal TEXT (icons, status/health words, primary badge, CTAs) -> theme-aware tint-text. */

html[data-theme]:not([data-theme='default']) .mc-status--red,
html[data-theme]:not([data-theme='default']) .mc-card__viewall--red,
html[data-theme]:not([data-theme='default']) .mc-card__cta--red {
    color: var(--color-tint-error-text);
}

html[data-theme]:not([data-theme='default']) .mc-health--under {
    color: var(--color-tint-warning-text);
}

html[data-theme]:not([data-theme='default']) .mc-status--green,
html[data-theme]:not([data-theme='default']) .mc-health--ok {
    color: var(--color-tint-success-text);
}
html[data-theme]:not([data-theme='default']) .mc-voice__primary,
html[data-theme]:not([data-theme='default']) .mc-tag--muted {
    color: var(--color-tint-success-text);
    background: rgba(var(--color-status-success-rgb), 0.12);
    border-color: rgba(var(--color-status-success-rgb), 0.4);
}
html[data-theme]:not([data-theme='default']) .mc-card__cta {
    /* BU-559 item 7/8 AA: the "Go to X" CTA is accent-colored TEXT. Raw --color-accent
       (bright #DD5100) is only ~3.4:1 on the pastel-mondrian cream surface (now the mobile
       default). Use the design system's purpose-built accent-as-text token (--color-accent-aa:
       #8a3d1c ~7:1 on cream on light vibes, #ff8a4d on dark vibes) — AA on every vibe, still
       recognizably Traffic Orange. */
    color: var(--color-accent-aa, var(--color-accent));
}

/* (Profile-avatar gate rule moved to ShellSidebar.razor.css — solid brand
   background-color is now part of the component's base .mc-profile__avatar.) */
/* Error banner: light-pink-on-dark-tint -> theme-aware error tint + AA text. */
html[data-theme]:not([data-theme='default']) .mc-error {
    background: rgba(var(--color-status-error-rgb), 0.12);
    border-color: rgba(var(--color-status-error-rgb), 0.4);
    color: var(--color-tint-error-text);
}

/* BU-558 pinned circular menu (mobile-only; invisible above 480px) follows the vibe:
   the fanned pills retint onto the vibe surface + ink, labels flip to ink. The toggle
   stays brand orange automatically (background: var(--brand) -> var(--color-accent)). */
html[data-theme]:not([data-theme='default']) .mc-fab__link {
    background: rgba(var(--color-surface-rgb), 0.92);
    border-color: rgba(var(--color-ink-rgb), 0.12);
}
html[data-theme]:not([data-theme='default']) .mc-fab__ico {
    background: rgba(var(--color-ink-rgb), 0.06);
}
html[data-theme]:not([data-theme='default']) .mc-fab__lbl {
    color: var(--color-ink);
}

/* BU-558 bullet 9 starburst cards follow the vibe: the ring track + center % flip to the
   vibe line/ink (the stage segments already use --color-stage-* tokens, so they vibe-follow). */
html[data-theme]:not([data-theme='default']) .mc-donut__track { stroke: var(--color-line); }
html[data-theme]:not([data-theme='default']) .mc-donut__pct { fill: var(--color-ink); }
html[data-theme]:not([data-theme='default']) .mc-engcard__name { color: var(--color-ink); }

/* BU-562: composition-starburst track + center number flip to the vibe line/ink so the empty
   tracks and the total-media count stay legible on the light pastel-mondrian skin. The arc
   segments keep their categorical hex (graphics, >=3:1) like the voice-utilization donut. */
html[data-theme]:not([data-theme='default']) .mc-starburst__track { stroke: var(--color-line); }
html[data-theme]:not([data-theme='default']) .mc-starburst__center { fill: var(--color-ink); }
