/* ===== v2026 · responsive ladder — phone-portrait → 4K TV =====
   Breakpoints:
     ≤ 480   phones portrait
     ≤ 640   phones landscape / phablets
     ≤ 900   small tablets / portrait iPad
     ≤ 1200  tablets / small laptops
     ≥ 2200  4K / large displays
     ≥ 3200  8K / ultra-wide tv
   Modifier media:
     (pointer: coarse)         touch devices — hide crosshair, native cursor
     (orientation: portrait)   portrait tweaks for tablets/phones
   Component-local @media (e.g. invader-hud at ≤ 640, desktop-bar at ≤ 640,
   p-era at ≤ 640) live next to the component so the file stays focused.
   ============================================================================ */

/* ---------- Tablet (≤ 1200) — narrower panel, hide secondary stats ---------- */
@media (max-width: 1200px) {
    .hud-stats { display: none; }
    .hud-layers { top: 64px; }       /* slot under top bar since stats are gone */
    .panel { width: min(520px, 60vw); }
}

/* ---------- Small tablet / phone (≤ 900) — pill / drawer pattern ----------
   At ≤ 900 every narrow viewport (phone portrait → small iPad portrait)
   uses the same pill pattern: menu + layers collapse into small pills
   anchored under the top bar. Tap to expand a vertical drawer, tap an
   item to act + auto-collapse. The horizontal chip-row attempt was
   wrapping (9 missions + 5 layers) and sandwiching the panel into a
   sliver with no body room.
   The second media term catches large phones in LANDSCAPE: their width can
   exceed 900 (e.g. 932) but a touch device that short (≤500 tall) is a phone,
   not a laptop — so it gets the same pill UX. Big tablets in landscape
   (height > 500) stay on the desktop layout. */
@media (max-width: 900px), (pointer: coarse) and (max-height: 500px) {
    /* Node labels stay visible on touch/small screens (per request). Shrink the
       primary card + mini chips so 9 missions + 5 stacks crowd less. */
    .graph-label-primary { padding: 5px 9px; gap: 1px; }
    .graph-label-primary .gl-name  { font-size: 11px; }
    .graph-label-primary .gl-stack { font-size: 8.5px; }
    .graph-label-mini { font-size: 8.5px; padding: 2px 5px; }
    :root { --pad: 12px; }

    /* Top bar — drop separators, smaller type. Clock + status label stay
       visible (per request); a min gap keeps the brand from gluing to them. */
    .hud-top { padding: 9px 12px; font-size: 11px; }
    .brand-sep, .hud-sep { display: none; }
    .brand-name { font-size: 12px; }
    .brand-node { font-size: 11px; }
    .brand-role { display: none; }                            /* keep top bar single-line */
    .hud-clock { font-size: 11px; }                           /* base is 14.5px — shrink so it fits beside the brand */
    .hud-status { font-size: 10px; white-space: nowrap; }
    .hud-brand { flex: 0 0 auto; min-width: 0; }              /* hug content — never shrink the box under the text (was overlapping the clock) */
    .hud-meta { gap: 7px; flex: 0 1 auto; padding-left: 10px; min-width: 0; }

    /* MENU — the sidebar/pill is gone on narrow. The ☰ MENU fab (bottom-right,
       thumb zone) summons the mission list as a full-screen sheet. Hidden until
       .open so the office/OSI canvas keeps the whole viewport. */
    .hud-menu { display: none; }
    .hud-menu.open {
        position: fixed;
        inset: 0;
        width: 100vw; max-width: none;
        height: 100vh; height: 100dvh;
        transform: none;
        margin: 0; padding: 0;
        border: none;
        border-radius: 0;
        background: rgba(5, 8, 18, 0.97);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        display: flex;
        flex-direction: column;
        z-index: 90;       /* over panel (35/60), desktop overlay (80) and fab (85) */
        animation: phone-menu-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
    }
    @keyframes phone-menu-in {
        from { opacity: 0; transform: translateY(16px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .hud-menu.open .menu-head {
        flex: 0 0 auto;
        display: flex;
        padding: 18px 20px;
        padding-top: max(18px, env(safe-area-inset-top));
        margin: 0;
        font-size: 13px;
        letter-spacing: 0.16em;
        border-bottom: 1px solid var(--border-2);
    }
    .hud-menu.open .menu-head .hud-toggle {
        width: 44px; height: 44px;
        font-size: 22px; line-height: 1;
        opacity: 1;
    }
    .hud-menu.open .menu-list {
        flex: 1 1 auto;
        width: 100%; max-width: none;
        gap: 0;
        padding: 4px 0;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        animation: phone-menu-rows-in 0.5s 0.06s cubic-bezier(0.22, 1, 0.36, 1) both;
    }
    @keyframes phone-menu-rows-in {
        from { opacity: 0; transform: translateY(10px); }
        to   { opacity: 1; transform: translateY(0); }
    }
    .hud-menu.open .menu-btn {
        width: 100%;
        min-height: 52px;
        font-size: 16px;
        padding: 16px 24px;
        gap: 14px;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    .hud-menu.open .menu-btn span { font-size: 15px; }
    .hud-menu.open .menu-btn span:first-child { opacity: 0.5; min-width: 22px; }
    .hud-menu.open .menu-foot { display: none; }

    /* ☰ MENU fab — fixed bottom-right, 52px tap target, always reachable */
    .menu-fab {
        position: fixed;
        right: max(14px, env(safe-area-inset-right));
        bottom: max(16px, env(safe-area-inset-bottom));
        z-index: 85;       /* above panels + desktop overlay — menu always reachable */
        display: inline-flex;
        align-items: center;
        gap: 8px;
        min-height: 52px;
        padding: 14px 20px;
        background: rgba(7, 11, 24, 0.92);
        border: 1px solid var(--accent);
        border-radius: 999px;
        color: var(--fg);
        font-family: var(--font-mono);
        font-size: 13px;
        letter-spacing: 0.14em;
        text-transform: uppercase;
        cursor: pointer;
        box-shadow:
            0 0 0 1px rgba(111, 214, 255, 0.10),
            0 12px 36px rgba(3, 8, 30, 0.65),
            0 0 24px rgba(42, 92, 255, 0.18);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
    .menu-fab .fab-icon { color: var(--accent); font-size: 16px; line-height: 1; }
    .menu-fab.fab-pulse { animation: fab-pulse 2.2s ease-in-out 3; }
    @keyframes fab-pulse {
        0%, 100% { box-shadow: 0 0 0 0 rgba(111, 214, 255, 0.45), 0 12px 36px rgba(3, 8, 30, 0.65); }
        50%      { box-shadow: 0 0 0 12px rgba(111, 214, 255, 0),  0 12px 36px rgba(3, 8, 30, 0.65); }
    }

    /* LAYERS / STACKS card — off on narrow; secondary control, not worth the
       screen space next to the fab pattern. Desktop keeps it. */
    .hud-layers { display: none !important; }

    /* Operator card — compact, above bottom hud */
    .hud-hero {
        bottom: calc(var(--hud-bottom-h) + 12px);
        max-width: min(94vw, 520px);
        white-space: normal;
        padding: 7px 11px;
        gap: 8px;
    }
    .op-bar { height: 18px; }
    .op-row1, .op-row2 { flex-wrap: wrap; gap: 6px; }
    .op-row2, .op-hint, .op-tag, .op-eyebrow { display: none; }
    .op-name { font-size: 12.5px; }
    .op-role { font-size: 10.5px; }

    /* Bottom HUD — strip non-essentials, single line */
    .hud-bottom {
        padding: 8px 12px;
        font-size: 10px;
        flex-wrap: wrap;
        gap: 4px;
        overflow: hidden;
        white-space: nowrap;
    }
    .hud-controls {
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1 1 auto;
        min-width: 0;
    }
    .hud-controls kbd:nth-of-type(n+4) { display: none; }
    .hud-tag { display: none; }

    /* Panel — full middle band between top bar and bottom hud.
       At ≤900 the pills sit on top of the panel (overlay), so the
       panel can use the full vertical space without subtracting
       --hud-menu-h / --hud-layers-h. */
    .panel {
        top: calc(var(--hud-top-h) + 12px);
        left: 12px; right: 12px;
        bottom: calc(var(--hud-bottom-h) + 12px);
        width: auto;
        max-height: none;
    }
    .panel-head { padding: 10px 14px; font-size: 10px; }
    .panel-body { padding: 16px 16px 22px; }
    .p-title    { font-size: clamp(18px, 5vw, 24px); }
    .p-node-title { font-size: clamp(20px, 6vw, 28px); }
    .p-lead     { font-size: 13.5px; }
    .p-bullets li { font-size: 13px; }
    .p-skillgrid   { grid-template-columns: 1fr; }
    .p-timeline li { grid-template-columns: 1fr; gap: 2px; }
}

/* ---------- Phone (≤ 640) — extra-tight delta on top of the ≤900 rules ---------- */
@media (max-width: 640px) {
    /* Boot card compact */
    .boot-card     { padding: 20px 22px 18px; width: 92vw; }
    .boot-title    { font-size: 16px; }
    .boot-subtitle { font-size: 9.5px; }
    .boot-log      { font-size: 11.5px; }
    .boot-mark     { font-size: 24px; }
}

/* ---------- Phone portrait (≤ 480) — strip to bare essentials ---------- */
@media (max-width: 480px) {
    .hud-top .hud-meta { gap: 6px; }
    .hud-status > .dot-pulse { width: 6px; height: 6px; }

    .hud-hero   { display: none; }                             /* operator card off — too crowded */

    /* Bottom HUD — only first 3 hints */
    .hud-bottom { padding: 6px 10px; font-size: 9.5px; }
    .hud-controls kbd:nth-of-type(n+3) { display: none; }

    /* Boot — even more compact */
    .boot-card     { padding: 16px 18px 14px; }
    .boot-title    { font-size: 14px; letter-spacing: 0.12em; }
    .boot-subtitle { font-size: 9px; }
    .boot-log      { font-size: 10.5px; }
    .boot-mark     { font-size: 22px; }
    .boot-tag      { min-width: 26px; font-size: 9px; }

    .panel-no    { font-size: 11px; }
    .p-chips     { gap: 4px; }
    .p-chip      { font-size: 9.5px; padding: 2px 6px; }
}

/* (former ≤640 "MISSIONS full-screen" block — superseded: the sheet now lives
   in the ≤900 block above as .hud-menu.open, driven by the ☰ MENU fab.) */

/* ---------- 4K TV / big display (≥ 2200) — scale typography + breathing room ---------- */
@media (min-width: 2200px) {
    :root {
        --pad: 40px;
    }
    html { font-size: 18px; }                                  /* root scale for relative units */
    .hud-top    { padding: 22px var(--pad); font-size: 14px; }
    .hud-bottom { padding: 16px var(--pad); font-size: 13px; }
    .hud-menu   { width: 280px; padding: 18px; font-size: 14px; }
    .menu-btn   { font-size: 14.5px; padding: 11px 14px; }
    .hud-stats  { font-size: 13px; padding: 16px 18px; gap: 8px 22px; }
    .hud-layers { width: 220px; padding: 14px 16px; top: 270px; }
    .layer-btn  { font-size: 13px; padding: 9px 10px; }
    .panel      { width: min(1030px, 53vw); }
    .panel-head { padding: 18px 22px; font-size: 13px; }
    .panel-body { padding: 28px 28px 32px; }
    .hud-hero   { padding: 14px 22px; max-width: min(1000px, 60vw); }
    .op-name    { font-size: 17px; }
    .op-role    { font-size: 13px; }
    .boot-card  { width: min(720px, 42vw); }
    .boot-title { font-size: 22px; }
    .boot-log   { font-size: 14px; }
}

/* ---------- 8K-ish / ultra-wide (≥ 3200) ---------- */
@media (min-width: 3200px) {
    :root { --pad: 56px; }
    html { font-size: 20px; }
    .hud-menu   { width: 340px; }
    .panel      { width: min(1280px, 44vw); }
}

/* ---------- Touch devices: no crosshair, native cursor ---------- */
@media (pointer: coarse) {
    .reticle { display: none; }
    #osi   { cursor: default; }
    /* Bigger tap targets */
    .menu-btn    { min-height: 36px; }
    .layer-btn   { min-height: 34px; }
    .panel-close { width: 36px; height: 36px; }

    /* Keyboard-hint footer (DRAG/WHEEL/CLICK/ESC) is meaningless on touch and
       was overflowing into an `op…` ellipsis. Drop it entirely. */
    .hud-bottom  { display: none; }
}

