/* Plan 1.5 Story 1.2 — collapsible desktop left nav across subsystems.
   Shared CSS loaded by app/partners/admin layouts. Target any nav with
   [data-collapsible-nav] so subsystem templates opt-in. State is
   persisted per-user via localStorage keyed by the data-collapsible-nav
   value. Mobile (<768px) is unaffected — hamburger behavior stays. */

/* ===========================================================
   Vector-First disappearing scrollbar
   ===========================================================
   Standard for any internal scroll container that lives inside a chrome
   surface (left nav, side panel, drawer, modal body). Idle: invisible.
   Hover/focus-within: 6px thumb at rgba(140,140,140,0.5). Active thumb
   hover: rgba(180,180,180,0.7).

   Auto-applied to .app-sidebar (app + learn + partners) and surfaces
   tagged [data-disappearing-scroll]. The .subsys-sidebar class used by
   exchange + id/registry receives the same treatment via inline CSS in
   internal/subsystemchrome/chrome.go so it survives without a shared
   stylesheet.
*/
.app-sidebar,
[data-disappearing-scroll] {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
    transition: scrollbar-color 220ms ease;
}
.app-sidebar:hover,
.app-sidebar:focus-within,
[data-disappearing-scroll]:hover,
[data-disappearing-scroll]:focus-within {
    scrollbar-color: rgba(140, 140, 140, 0.5) transparent;
}
.app-sidebar::-webkit-scrollbar,
[data-disappearing-scroll]::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.app-sidebar::-webkit-scrollbar-track,
[data-disappearing-scroll]::-webkit-scrollbar-track {
    background: transparent;
}
.app-sidebar::-webkit-scrollbar-thumb,
[data-disappearing-scroll]::-webkit-scrollbar-thumb {
    background-color: transparent;
    border-radius: 3px;
    transition: background-color 220ms ease;
}
.app-sidebar:hover::-webkit-scrollbar-thumb,
.app-sidebar:focus-within::-webkit-scrollbar-thumb,
[data-disappearing-scroll]:hover::-webkit-scrollbar-thumb,
[data-disappearing-scroll]:focus-within::-webkit-scrollbar-thumb {
    background-color: rgba(140, 140, 140, 0.5);
}
.app-sidebar::-webkit-scrollbar-thumb:hover,
[data-disappearing-scroll]::-webkit-scrollbar-thumb:hover {
    background-color: rgba(180, 180, 180, 0.7);
}
@media (prefers-reduced-motion: reduce) {
    .app-sidebar,
    .app-sidebar::-webkit-scrollbar-thumb,
    [data-disappearing-scroll],
    [data-disappearing-scroll]::-webkit-scrollbar-thumb {
        transition: none;
    }
}

@media (min-width: 768px) {
    [data-collapsible-nav] {
        transition: transform 220ms ease, width 220ms ease, opacity 200ms ease;
    }
    [data-collapsible-nav].is-collapsed {
        transform: translateX(-110%);
        width: 0 !important;
        min-width: 0 !important;
        opacity: 0;
        pointer-events: none;
    }
    .subsystem-nav-toggle {
        position: fixed;
        left: 12px;
        bottom: 16px;
        z-index: 50;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: var(--color-surface-2, #111);
        border: 1px solid var(--color-border, #333);
        color: var(--color-text-primary, #fff);
        font-size: 18px;
        line-height: 1;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: transform 220ms ease, background 120ms;
    }
    .subsystem-nav-toggle:hover { background: var(--color-surface-3, #1a1a1a); }
    .subsystem-nav-toggle--expanded { transform: translateX(calc(var(--subsystem-nav-width, 240px) - 40px)); }
}
@media (max-width: 767px) {
    .subsystem-nav-toggle { display: none; }
}

/* ===========================================================
   Subsystem-header hamburger + animated mobile drawer
   Used by app, partners, and learn layouts.  Desktop hides the
   hamburger; mobile collapses the sidebar into a slide-in drawer
   anchored to the left edge of the viewport.
   =========================================================== */

.subsystem-header__hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 4px;
    background: transparent;
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    border-radius: 6px;
    transition: background 120ms;
}
.subsystem-header__hamburger:hover { background: var(--color-surface-2, rgba(255,255,255,0.04)); }
.subsystem-header__hamburger:focus-visible {
    outline: 2px solid var(--color-accent-cyan);
    outline-offset: 2px;
}

/* Backdrop sits behind the drawer; only visible when the drawer is open. */
.subsystem-drawer-backdrop {
    display: none;
}

@media (max-width: 767px) {
    .subsystem-header__hamburger { display: inline-flex; }

    /* Mobile subsystem header — make the sticky bar fully opaque so
     * page content doesn't bleed through it when the drawer is open
     * (the design-system surface tokens are 0.02-alpha rgba).  Use
     * a near-bg hex with theme branches. */
    .subsystem-header {
        background: #0a0a0a;
    }
    [data-theme="light"] .subsystem-header {
        background: #ffffff;
    }

    /* Slide-in drawer for the left sidebar on mobile.  Keep the sidebar
     * always rendered (no display:none) so the transform animation has
     * a layout to animate from.  Opaque background so the page beneath
     * never shows through the drawer panel itself. */
    .app-sidebar {
        display: block;
        position: fixed;
        left: 0;
        top: 56px;
        height: calc(100vh - 56px);
        width: min(280px, 80vw);
        background: #0a0a0a;
        border-right: 1px solid var(--color-border);
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 240ms cubic-bezier(0.2, 0, 0, 1);
        overflow-y: auto;
        padding: var(--space-md);
    }
    [data-theme="light"] .app-sidebar {
        background: #ffffff;
    }
    .app-sidebar.is-open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .subsystem-drawer-backdrop {
        display: block;
        position: fixed;
        inset: 56px 0 0 0;
        background: rgba(0, 0, 0, 0.55);
        opacity: 0;
        pointer-events: none;
        transition: opacity 240ms ease;
        z-index: 59;
    }
    .subsystem-drawer-backdrop.is-open {
        opacity: 1;
        pointer-events: auto;
    }
    .subsystem-drawer-backdrop[hidden] {
        /* Browsers with the [hidden] attribute respect display:none, but
         * we override above for the inset-stretched layer; manual hide
         * via display takes precedence over the inset rule. */
        display: none;
    }

    /* Lock body scroll when drawer is open. */
    body.subsystem-drawer-open {
        overflow: hidden;
    }
}

