/* Layer 4: control layer — extracted from index.html (lines 643–1117) */
    /* =========================================
       LAYER 4: THE LIQRIT CONTROL LAYER
       Full-viewport menu overlay originating from hamburger
       ========================================= */
    #control-layer {
        position: fixed;
        inset: 0;
        width: 100vw;
        height: 100vh;
        z-index: 100;
        pointer-events: none;
        opacity: 0;
        visibility: hidden;
    }

    .control-layer.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* =========================================
       CONTROL FIELD — Modular Propagation Transition
       Grid of rectangular masses propagating from hamburger origin
       ========================================= */
    .control-field {
        position: absolute;
        inset: 0;
        z-index: 0;
        pointer-events: none;
        display: grid;
        background: transparent;
    }

    .control-field-backing {
        position: absolute;
        inset: 0;
        background: var(--control-void);
        z-index: -1;
        will-change: clip-path;
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }

    .control-tile {
        position: relative;
        background-color: var(--control-surface-1);
        border: 1px solid var(--hairline);
        will-change: transform, opacity;
        transform-origin: center center;
        opacity: 0;
    }

    .control-tile::before {
        content: '';
        position: absolute;
        inset: 0;
        right: -1px;
        bottom: -1px;
        background: inherit;
        z-index: -1;
        pointer-events: none;
    }

    .control-tile::after {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(180deg, color-mix(in srgb, var(--text-primary) 0.4%, transparent) 0%, transparent 100%);
        pointer-events: none;
    }

    /* Base grid: 6×8 — narrow portrait (< 480px) */
    .control-field {
        grid-template-columns: repeat(6, 1fr);
        grid-template-rows: repeat(8, 1fr);
    }

    /* ≥ 480px: Standard Mobile — 8×8 grid */
    @media (min-width: 480px) {
        .control-field {
            grid-template-columns: repeat(8, 1fr);
            grid-template-rows: repeat(8, 1fr);
        }
    }

    /* ≥ 768px: Wide Portrait / Tablet — 8×8 grid */
    @media (min-width: 768px) {
        .control-field {
            grid-template-columns: repeat(8, 1fr);
            grid-template-rows: repeat(8, 1fr);
        }
    }

    /* ≥ 1024px: Tablet Landscape / Small Desktop — 10×8 grid */
    @media (min-width: 1024px) {
        .control-field {
            grid-template-columns: repeat(10, 1fr);
            grid-template-rows: repeat(8, 1fr);
        }
    }

    /* ≥ 1200px: Desktop — 10×8 grid (consistent density) */
    @media (min-width: 1200px) {
        .control-field {
            grid-template-columns: repeat(10, 1fr);
            grid-template-rows: repeat(8, 1fr);
        }
    }

    /* Tile classes will be assigned via JS for dynamic origin-based propagation */

    /* =========================================
       CONTROL LAYER CONTENT — Editorial Navigation + Destination Cards
       Two-zone composition: left (navigation), right (Vault/Cellar surfaces)
       ========================================= */
    .control-content {
        position: absolute;
        inset: 0;
        display: grid;
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        padding: clamp(2.5rem, 4vw, 4.5rem);
        pointer-events: none;
        z-index: 2;
    }

    .control-layer.active .control-content {
        pointer-events: auto;
    }

    /* Desktop: two-column layout */
    @media (min-width: 1024px) {
        .control-content {
            grid-template-columns: minmax(0, 1fr) minmax(0, min(34rem, 42%));
            grid-template-rows: auto 1fr auto;
            column-gap: clamp(3rem, 6vw, 8rem);
            /* Same inset as the header frame; past 1600px the composition is capped and centred */
            padding-inline: max(clamp(1.5rem, 4vw, 3.5rem), calc((100% - 1600px) / 2));
        }
    }

    /* Region A: Editorial Navigation Stack (left column on desktop, full width on mobile) */
    .control-editorial {
        grid-column: 1;
        grid-row: 2;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding-top: var(--menu-header-clearance);
        padding-left: clamp(2rem, 8vw, 4rem);
        pointer-events: auto;
    }

    @media (min-width: 1024px) {
        .control-editorial {
            grid-column: 1;
            grid-row: 2;
            padding-left: clamp(2rem, 8vw, 9rem);
        }
    }

    /* Editorial Navigation Stack — separator-free, fluid typography */
    .nav-editorial-stack {
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
        gap: clamp(0.5rem, 2.2vh, 1.5rem);
        counter-reset: nav;
    }

    /* Collapse the inline whitespace between index number and title,
       so nested items can align to the title axis exactly */
    .nav-editorial-stack > .nav-link,
    .nav-connect-toggle {
        font-size: 0;
    }

    /* Mono index beside each primary entry — editorial structure, no markup */
    .nav-editorial-stack > .nav-link::before,
    .nav-connect-toggle::before {
        counter-increment: nav;
        content: counter(nav, decimal-leading-zero);
        display: inline-block;
        width: clamp(2rem, 3vw, 3rem);
        font-family: var(--font-mono);
        font-size: 11px;
        letter-spacing: 0.1em;
        color: var(--text-dim);
        vertical-align: 0.9em;
        transition: color var(--nav-transition);
    }

    .nav-link:hover::before,
    .nav-link:focus-visible::before,
    .nav-connect-toggle.is-open::before {
        color: var(--accent);
    }

    .nav-link {
        display: block;
        width: 100%;
        text-decoration: none;
        padding-top: 0.15rem;
        padding-bottom: 0.15rem;
        cursor: pointer;
    }

    /* Fluid typography sizing */
    .nav-item-title {
        font-size: clamp(1.75rem, 3.2vw, 3rem);
        line-height: 1.1;
        letter-spacing: -0.03em;
        font-weight: 500;
        text-transform: uppercase;
        color: color-mix(in srgb, var(--text-primary) 72%, transparent);
        transition: color var(--nav-transition);
    }

    /* Hover & Active triggers on hover-capable devices */
    @media (hover: hover) {
        .nav-link:hover .nav-item-title,
        .nav-link.is-active .nav-item-title {
            color: var(--accent);
        }
    }

    /* Keyboard focus handling */
    .nav-link:focus-visible {
        outline: 1px solid color-mix(in srgb, var(--text-primary) 60%, transparent);
        outline-offset: 4px;
    }

    .nav-link:focus-visible .nav-item-title {
        color: var(--accent);
    }

    /* Touch fallback: active state */
    @media (hover: none) {
        .nav-link:active .nav-item-title {
            color: var(--accent);
        }
    }

    /* =========================================
       CONNECT DISCLOSURE GROUP — 6th top-level nav entity
       Button + expandable sub-panel; collapsed by default.
       Expansion happens only on click/keyboard activation (no hover-reveal).
       ========================================= */
    .nav-connect-toggle {
        /* Block flow (not flex) so the index number aligns exactly like sibling links */
        display: block;
        width: 100%;
        background: none;
        border: none;
        font: inherit;
        font-size: 0; /* after the font shorthand, which would otherwise reset it */
        text-align: left;
        padding: 0.15rem 0;
        cursor: pointer;
    }

    .nav-connect-indicator {
        font-family: var(--font-mono);
        font-size: clamp(0.9rem, 1.6vw, 1.4rem);
        font-weight: 400;
        line-height: 1;
        color: var(--text-muted);
        display: inline-block;
        margin-left: clamp(0.75rem, 2vw, 1.5rem);
        vertical-align: 0.35em;
        transition: transform 0.25s ease, color var(--nav-transition);
    }

    .nav-connect-toggle:hover .nav-connect-indicator,
    .nav-connect-toggle:focus-visible .nav-connect-indicator,
    .nav-connect-toggle.is-open .nav-connect-indicator {
        color: var(--accent);
    }

    /* Rotation reads as the collapsed → open state change */
    .nav-connect-toggle.is-open .nav-connect-indicator {
        transform: rotate(45deg);
    }

    .nav-connect-panel {
        display: flex;
        flex-direction: column;
        gap: clamp(0.35rem, 1.2vh, 0.75rem);
        padding-top: clamp(0.35rem, 1.2vh, 0.75rem);
        /* Matches the index-number column width */
        padding-left: clamp(2rem, 3vw, 3rem);
    }

    /* Desktop: sub-items sit as one row beneath Connect, taken out of flow,
       so expanding never changes the stack's height or moves the toggle */
    @media (min-width: 1024px) {
        .nav-connect-group {
            position: relative;
        }

        .nav-connect-panel {
            position: absolute;
            top: 100%;
            left: 0;
            flex-direction: row;
            flex-wrap: wrap;
            column-gap: clamp(1.25rem, 2.2vw, 2.25rem);
            row-gap: 0.25rem;
            white-space: nowrap;
        }

        .nav-connect-item {
            width: auto;
        }
    }

    /* The flex display above would override the UA's [hidden] rule;
       this restores the hidden attribute's authority */
    .nav-connect-panel[hidden] {
        display: none;
    }

    .nav-connect-item .nav-item-title {
        font-size: clamp(1.0625rem, 1.4vw, 1.375rem);
        letter-spacing: 0.02em;
        color: var(--text-secondary);
    }

    .nav-connect-item:hover .nav-item-title,
    .nav-connect-item:focus-visible .nav-item-title,
    .nav-connect-item:active .nav-item-title {
        color: var(--accent);
    }

    /* Region B: Destination Surfaces (right column on desktop, below nav on mobile) */
    .control-destinations {
        grid-column: 1;
        grid-row: 3;
        display: flex;
        flex-direction: column;
        gap: clamp(1rem, 2vh, 1.5rem);
        padding-top: clamp(1.5rem, 3vh, 2.5rem);
        padding-left: clamp(2rem, 8vw, 4rem);
        padding-right: clamp(2rem, 4vw, 4rem);
        pointer-events: auto;
        border-top: 1px solid var(--hairline);
    }

    @media (min-width: 1024px) {
        .control-destinations {
            grid-column: 2;
            grid-row: 2;
            flex-direction: column;
            justify-content: center;
            padding-top: var(--menu-header-clearance);
            padding-left: 0;
            padding-right: 0;
            padding-bottom: 0;
            border-top: none;
            /* Wide enough that Vault and Cellar read as two peers, not one block */
            gap: clamp(1.25rem, 3vh, 2rem);
        }
    }

    .surface-card {
        position: relative;
        background:
            linear-gradient(180deg, color-mix(in srgb, var(--text-primary) 2.5%, transparent) 0%, transparent 60%),
            var(--surface-prominent);
        border: 1px solid var(--hairline-strong);
        box-shadow: inset 0 1px 0 color-mix(in srgb, var(--text-primary) 3%, transparent);
        padding: clamp(1.5rem, 2.5vw, 2rem);
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        text-decoration: none;
        cursor: pointer;
        transition: background-color 0.25s ease, border-color 0.25s ease;
    }

    .surface-card:hover {
        background-color: var(--surface-hover);
        border-color: color-mix(in srgb, var(--text-primary) 14%, transparent);
    }

    .surface-card:hover .corner-mark,
    .surface-card:focus-visible .corner-mark {
        border-color: var(--accent);
    }

    @media (min-width: 1024px) {
        .surface-card {
            padding: clamp(1.5rem, 2.5vw, 2rem) clamp(2rem, 3vw, 2.5rem);
            min-height: clamp(180px, 22vh, 220px);
        }
    }

    /* Corner marks — explicit color in shorthand; per-corner width longhands
       avoid the shorthand's currentcolor reset that rendered these blue at rest */
    .corner-mark {
        position: absolute;
        width: 7px;
        height: 7px;
        pointer-events: none;
        border: 0 solid color-mix(in srgb, var(--text-primary) 28%, transparent);
        transition: border-color 0.25s ease;
    }
    .corner-mark-tl { top: -1px; left: -1px; border-top-width: 1px; border-left-width: 1px; }
    .corner-mark-tr { top: -1px; right: -1px; border-top-width: 1px; border-right-width: 1px; }
    .corner-mark-bl { bottom: -1px; left: -1px; border-bottom-width: 1px; border-left-width: 1px; }
    .corner-mark-br { bottom: -1px; right: -1px; border-bottom-width: 1px; border-right-width: 1px; }

    /* Keyboard focus handling — consistent with nav links */
    .surface-card:focus-visible {
        outline: 1px solid color-mix(in srgb, var(--text-primary) 60%, transparent);
        outline-offset: 4px;
    }

    /* Surface emphasis states - subtle and restrained */
    .surface-card.is-active {
        border-color: color-mix(in srgb, var(--text-primary) 38%, transparent);
        background-color: var(--surface-prominent);
    }
    .surface-card.is-active .corner-mark {
        border-color: var(--accent);
    }
    .surface-card.is-active .surface-accent-text {
        color: var(--text-emphasis);
    }

    .surface-card-header {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        margin-bottom: clamp(1rem, 2vh, 1.5rem);
    }

    .surface-designation {
        font-family: var(--font-mono);
        font-size: clamp(11px, 0.85vw, 13px);
        letter-spacing: 0.14em;
        text-transform: uppercase;
        color: var(--text-muted);
        transition: color var(--nav-transition);
    }

    .surface-card:hover .surface-designation,
    .surface-card:focus-visible .surface-designation {
        color: var(--text-primary);
    }

    .surface-affordance {
        font-family: var(--font-mono);
        font-size: clamp(14px, 1.2vw, 17px);
        line-height: 1;
        display: inline-block;
        color: var(--text-muted);
        transition: color var(--nav-transition), transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    .surface-card:hover .surface-affordance,
    .surface-card:focus-visible .surface-affordance,
    .surface-card.is-active .surface-affordance {
        color: var(--accent);
        transform: translate(3px, -3px);
    }

    .surface-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .surface-accent-text {
        font-family: var(--font-sans);
        font-size: clamp(1.75rem, 3vw, 2.75rem);
        font-weight: 600;
        line-height: 1;
        letter-spacing: -0.03em;
        text-transform: uppercase;
        color: var(--text-primary);
        transition: color 0.2s ease;
    }

    .surface-description {
        font-family: var(--font-mono);
        font-size: clamp(12px, 1vw, 13.5px);
        letter-spacing: 0.08em;
        text-transform: uppercase;
        color: var(--text-secondary);
        line-height: 1.5;
        margin-top: clamp(0.625rem, 1.2vh, 0.875rem);
        transition: color var(--nav-transition);
    }

    .surface-card:hover .surface-description,
    .surface-card:focus-visible .surface-description {
        color: var(--text-primary);
    }

    /* Social Icons — bottom anchor */
    .control-social-only {
        grid-column: 1;
        grid-row: 3;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: flex-end;
        gap: clamp(0.75rem, 1.5vw, 1.25rem);
        padding-left: clamp(2rem, 8vw, 4rem);
        padding-bottom: clamp(2rem, 4vw, 4rem);
        pointer-events: auto;
        border-top: 1px solid var(--hairline);
        padding-top: clamp(1.5rem, 3vh, 2.5rem);
    }

    @media (min-width: 1024px) {
        .control-social-only {
            grid-column: 2;
            grid-row: 3;
            flex-direction: row;
            align-items: flex-end;
            justify-content: flex-end;
            padding-left: 0;
            padding-right: 0;
            padding-bottom: clamp(1rem, 2vw, 2rem);
            border-top: none;
        }
    }

    .control-social-only .control-social-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        margin: -11px;
        color: var(--text-muted);
        transition: color var(--nav-transition);
    }

    .control-social-only .control-social-link:hover,
    .control-social-only .control-social-link:focus-visible {
        color: var(--accent);
    }

    .control-social-only .control-social-link:focus-visible {
        outline: 1px solid color-mix(in srgb, var(--text-primary) 60%, transparent);
        outline-offset: 0;
    }

    .control-social-only .control-social-link svg {
        width: clamp(18px, 2vw, 22px);
        height: clamp(18px, 2vw, 22px);
    }

    /* Mobile Account — upper-right quadrant (mobile only < 768px) */
    .control-account-mobile {
        display: none;
        position: absolute;
        /* Relative to the content region, which starts below the header */
        top: clamp(0.5rem, 3.5vh, 2rem);
        /* Shares the frame edge with the content padding and the close control above */
        right: clamp(1.5rem, 4vw, 3rem);
        flex-direction: column;
        align-items: flex-end;
        gap: 0.35rem;
        /* Container ignores taps so the nav beneath stays fully tappable;
           only the account trigger itself receives pointer events */
        pointer-events: none;
        z-index: 3;
    }

    /* The trigger re-enables pointer events within the pass-through container */
    .control-account-mobile-item {
        pointer-events: auto;
    }

    .control-account-mobile-label {
        font-family: var(--font-mono);
        font-size: clamp(11px, 1.5vw, 13px);
        letter-spacing: 0.15em;
        text-transform: uppercase;
        color: var(--text-muted);
        white-space: nowrap;
    }

    .control-account-mobile-item {
        font-size: clamp(14px, 2vw, 16px);
        font-weight: 400;
        color: var(--text-muted);
        cursor: pointer;
        transition: color 300ms ease;
        white-space: nowrap;
    }

    .control-account-mobile-item:hover {
        color: var(--text-primary);
    }

    @media (max-width: 767px) {
        .control-account-mobile {
            display: flex;
        }
    }

    /* Mobile adjustments for control content */
    @media (max-width: 1023px) {
        .control-editorial {
            padding-left: clamp(1.5rem, 7vw, 3rem);
            justify-content: flex-start;
        }
    }

    @media (max-width: 767px) {
        .control-content {
            /* Scroll region begins under the header controls (header padding + 48px
               hamburger box) so scrolled content never passes beneath the logo */
            top: calc(clamp(1.5rem, 4vw, 3.5rem) + 48px);
            padding: 0 clamp(1.5rem, 4vw, 3rem) clamp(1.5rem, 4vw, 3rem);
            -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 1.25rem);
            mask-image: linear-gradient(to bottom, transparent 0, #000 1.25rem);
            grid-template-rows: auto auto auto auto;
            /* Rows keep their content height; spare space must not be
               redistributed, or expanding Connect shifts items above it */
            align-content: start;
            /* Deliberate scrolling: on short viewports the destination cards
               and social links extend below the fold, so the content region
               itself becomes the scroll container */
            overflow-y: auto;
            overscroll-behavior: contain;
        }

        .control-editorial {
            grid-row: 2;
            padding-top: clamp(1rem, 5vh, 3rem);
            padding-left: clamp(1.5rem, 7vw, 3rem);
        }

        .nav-editorial-stack {
            /* Fixed rhythm instead of viewport-stretched space-between,
               so the stack reads as one deliberate block */
            justify-content: flex-start;
            height: auto;
            gap: clamp(0.55rem, 1.8vh, 1rem);
        }

        .control-destinations {
            grid-row: 3;
            padding-top: clamp(1.25rem, 3vh, 1.75rem);
            padding-left: clamp(1.5rem, 7vw, 5rem);
            padding-right: clamp(1.5rem, 7vw, 5rem);
            gap: clamp(0.75rem, 1.5vh, 1rem);
        }

        .control-social-only {
            grid-row: 4;
            flex-direction: row;
            flex-wrap: wrap;
            /* Joins the nav/card left axis instead of floating centered */
            justify-content: flex-start;
            align-items: center;
            gap: clamp(1rem, 2vw, 1.5rem);
            padding-left: clamp(1.5rem, 7vw, 3rem);
            padding-right: 0;
            padding-top: clamp(1rem, 2vh, 1.5rem);
            padding-bottom: clamp(1rem, 2vh, 1.5rem);
        }

        /* Compact card interiors on narrow screens — full padding is desktop scale */
        .surface-card {
            padding: 1.25rem 1.5rem;
        }

        .surface-card-header {
            margin-bottom: 0.75rem;
        }

        .nav-item-title {
            font-size: clamp(1.5rem, 4vw, 2.25rem);
        }

        .surface-card {
            min-height: auto;
        }
    }

    /* =========================================
       SHORT LANDSCAPE (wide but under 500px tall, below desktop width)
       Two-zone composition so the destinations are not pushed below the fold
       ========================================= */
    @media (min-width: 600px) and (max-width: 1023px) and (max-height: 500px) {
        .control-content {
            top: calc(clamp(1.5rem, 4vw, 3.5rem) + 48px);
            padding: 0 clamp(1.5rem, 4vw, 3.5rem);
            -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 0.75rem);
            mask-image: linear-gradient(to bottom, transparent 0, #000 0.75rem);
            grid-template-columns: minmax(0, 1fr) minmax(0, 46%);
            grid-template-rows: auto auto;
            column-gap: clamp(1.5rem, 4vw, 3rem);
            align-content: start;
            overflow-y: auto;
            overscroll-behavior: contain;
        }

        .control-editorial {
            grid-column: 1;
            grid-row: 1;
            padding-top: 0.5rem;
            padding-left: 0;
        }

        .nav-editorial-stack {
            gap: 0.25rem;
        }

        .nav-item-title {
            font-size: clamp(1.375rem, 3.6vw, 1.75rem);
        }

        .control-destinations {
            grid-column: 2;
            grid-row: 1;
            justify-content: flex-start;
            padding: 0.5rem 0 0;
            border-top: none;
            gap: 0.75rem;
        }

        .surface-card {
            padding: 0.9rem 1.25rem;
            min-height: auto;
        }

        .surface-card-header {
            margin-bottom: 0.4rem;
        }

        .surface-accent-text {
            font-size: 1.5rem;
        }

        .surface-description {
            margin-top: 0.35rem;
        }

        .control-social-only {
            grid-column: 2;
            grid-row: 2;
            flex-direction: row;
            justify-content: flex-end;
            align-items: center;
            padding: 0.5rem 11px 0 0;
            border-top: none;
        }

        /* Account joins the flow beneath the nav instead of floating over the card column */
        .control-account-mobile {
            position: static;
            grid-column: 1;
            grid-row: 2;
            flex-direction: row;
            align-items: baseline;
            gap: 0.75rem;
            padding-top: 0.5rem;
        }
    }

    /* Prelaunch: these blocks set display above, which would override the UA's [hidden] rule */
    .nav-connect-group[hidden],
    .control-account-mobile[hidden],
    .control-social-only[hidden] {
        display: none;
    }
