/* lanes.css: the desktop stage and its lanes (structure and motion only).
   Contract: docs/plans/desktop/foundation.md sections 2 and 3; design: docs/plans/desktop/
   audit/stage-manager.md section 7 as amended (flex lanes, no px tracks, no width tiers).

   What lives here: #stage as a flex row; the four lane widths (data-w = off | spine | list |
   stage); .lane (the animated clip box), .lane-body (the scroller and the container-query
   container), .lane-spine (the slim live strip); the one resize movement; the arrival
   stagger; focus rings; reduced motion. What does NOT live here: how a panel, a card or a
   Spine looks beyond a neutral default, the progress line of a lane that is loading
   (kit.css draws it from the aria-busy this manager sets), and the shell (shell.css).

   A page talks to this sheet through four hooks only: data-bleed (opt out of the lane
   padding), data-travel-target (where a travelling image lands), data-arrive (its own
   arrival beats) and data-lane-restore (a control that steps back to a lane).

   Every rule is scoped to the stage's own lanes (.lane > .lane-body), so a page may use
   the class .lane-body on a container of its own (the kit page does) without inheriting
   the stage's geometry.

   Who writes what: desktop/assets/js/app.js builds this DOM at boot (in a territory only)
   and sets data-w, data-stage, data-active, data-rail, aria-busy, inert and the is-* classes
   below. It never writes a width. Every size comes from the custom properties in
   foundation.md section 3, which desktop.css defines; each is read here through a private
   --_ alias carrying the contract's fallback, so this sheet works before they exist.

   Fluid by construction: lanes share the stage by flex values with a minimum each, sizes
   are clamp() over container units (cqi resolves against #stage), and there is no viewport
   media query. The shell's own narrow re-lay (shell.css, 900px and under) reaches this sheet only as
   data-rail="off", which app.js mirrors from RT.shell.narrow, so that breakpoint stays in
   one file. prefers-reduced-motion and print are the two media blocks. */

/* ─── The stage ───────────────────────────────────────────────────────────── */
/* Everything right of the rail. Fixed, so the window never scrolls in a
   territory: each lane scrolls by itself. z 3 is the old .desktop-main's layer
   (over the aurora's fade, under the side panel and the label pill).
   --stage-left / --stage-top / --stage-pad (one length, all four sides) and --stage-lead
   are optional hooks; nothing sets them now, so the stage reads the shell's own
   --shell-gutter / --shell-top. The stage is a size container (cqi for the lane
   sizes), which also makes it the containing block for position: fixed inside
   a page: a fixed child is pinned to the stage, never to the viewport.

   The gap is registered as a length so it is computed ONCE, here, and inherited
   as px: a container unit means one thing on the stage (which is not its own
   container) and another inside it, and a closed lane has to hand back exactly
   the gap the row gave it. Where @property is missing the two differ by about
   a pixel per closed lane, nothing else. */

@property --stage-gap {
    syntax: '<length>';
    inherits: true;
    initial-value: 12px;
}

/* The lane padding, computed once per lane body and inherited as px, so a block
   that bleeds to the lane's edge pulls out by exactly what the body pushed in. */
@property --lane-pad-now {
    syntax: '<length>';
    inherits: true;
    initial-value: 16px;
}

.desktop-stage {
    --_gap:       var(--lane-gap, clamp(0.75rem, 1.2cqi, 1.5rem));
    --_spine:     var(--lane-spine, clamp(3.75rem, 4.5cqi, 5.25rem));
    --_list:      var(--lane-list, clamp(20rem, 27cqi, 30rem));
    --_stage-min: var(--lane-stage-min, min(100%, 26rem));
    --_comfort:   var(--lane-stage-comfort, 36rem);   /* with two Lists open the Stage is at least this, or the older List folds */
    --_dur:       var(--lane-dur, 520ms);
    --_ease:      var(--lane-ease, cubic-bezier(.2, .9, .25, 1.06));
    --_step:      var(--arrive-step, 45ms);
    --_pad:       var(--lane-pad, clamp(0.875rem, 1.5cqi, 1.75rem));
    --_grip:      2.5rem;
    --stage-gap:  var(--_gap);

    position: fixed;
    /* Left: the shell's gutter plus a lead, as the 09-08 .desktop-main sat (gutter + 3rem of
       padding): the lanes' glass starts clear of the rail's wave edge and of the menu's label
       pill instead of cutting across them. The shell itself is not touched (Joel 2026-11-11). */
    inset: var(--stage-top, var(--shell-top, 0px)) 0 0 var(--stage-left, calc(var(--shell-gutter, 110px) + var(--stage-lead, clamp(1.5rem, 3.4vw, 3rem))));
    z-index: 3;
    display: flex;
    flex-flow: row nowrap;
    align-items: stretch;
    gap: var(--stage-gap);
    padding: var(--stage-pad, 0px);
    box-sizing: border-box;
    container: stage / inline-size;
}

/* The shell hides its rail (narrow windows): the stage starts at the left edge, under the
   shell's top bar. The bar's height is the shell's number (shell.css, the 900px block:
   --shell-top: calc(44px + 1.2rem)), repeated here because that declaration is on `html` and
   desktop.css declares --shell-top: 0px on `:root`, which outranks it, so the variable never
   leaves 0. The shell is not edited (Joel 2026-11-11); if it is ever fixed there, drop this. */
.desktop-stage[data-rail="off"] {
    left: var(--stage-left-narrow, 0px);
    top: var(--stage-top, calc(44px + 1.2rem));
}

/* ─── A lane ──────────────────────────────────────────────────────────────── */
/* The clip box that moves. Its width is its flex values and nothing else:
   data-w picks them, the Stage lane takes whatever the others leave. All four
   lanes carry the same duration and easing on the same properties, so one
   change of data-w anywhere is one movement everywhere. */

.lane {
    position: relative;
    flex: 0 0 0px;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    overflow: clip;
    transition:
        flex-grow var(--_dur) var(--_ease),
        flex-shrink var(--_dur) var(--_ease),
        flex-basis var(--_dur) var(--_ease),
        margin-inline-end var(--_dur) var(--_ease),
        visibility 0s linear 0s;
}

/* off: a lane that is closed, or one the fit rule has tucked away because
   the stage is too narrow for even its Spine (its page and state stay; it
   returns with the width). No width, and its share of the row gap handed back,
   leaves no seam. Hidden only once the movement is over. */
.lane[data-w="off"] {
    flex: 0 0 0px;
    margin-inline-end: calc(-1 * var(--stage-gap));
    visibility: hidden;
    transition:
        flex-grow var(--_dur) var(--_ease),
        flex-shrink var(--_dur) var(--_ease),
        flex-basis var(--_dur) var(--_ease),
        margin-inline-end var(--_dur) var(--_ease),
        visibility 0s linear var(--_dur);
}

.lane[data-w="spine"] {
    flex: 0 0 var(--_spine);
}

/* The lane's surface (added 2026-11-11 after the second critic pass: bare lanes read grey-white
   on the shell's backdrop). A lane at List or Stage is a glass panel floating on the backdrop,
   inset a little from the window's top and bottom so its corners show: the "columns of defined
   purpose" are visible columns. Opt out for a page that paints to the window's edges (the Home
   hero): put data-surface="none" on the page root. Old pages (is-legacy) keep their bare frame. */
.lane:is([data-w="list"], [data-w="stage"], [data-w="spine"]) {
    margin-block: var(--stage-inset, clamp(0.5rem, 0.9cqi, 0.875rem));
}

.lane:is([data-w="list"], [data-w="stage"]) {
    border-radius: var(--r-feature, 1.75rem);
    background: var(--lane-surface, rgba(255, 255, 255, 0.42));
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.78), 0 18px 48px -28px rgba(30, 40, 53, 0.28);
}

/* The rightmost visible lane keeps the same inset from the window's right edge. */
.lane:is([data-w="list"], [data-w="stage"]):not(:has(~ .lane:not([data-w="off"]))) {
    margin-inline-end: var(--stage-inset, clamp(0.5rem, 0.9cqi, 0.875rem));
}

.lane:is([data-w="list"], [data-w="stage"]):has(> .lane-body.is-legacy),
.lane:is([data-w="list"], [data-w="stage"]):has(> .lane-body > [data-surface="none"]) {
    margin-block: 0;
    margin-inline-end: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
}

/* A Spine leans out a little under the pointer. An extra: the strip is a
   labelled button and a live strip's thumbnails are buttons, pointer or not. */
@media (hover: hover) and (pointer: fine) {
    .lane[data-w="spine"]:hover {
        flex-basis: calc(var(--_spine) + 1rem);
    }
}

/* A List may give a little under pressure (a window dragged narrower) until
   the fit rule folds the oldest one. */
.lane[data-w="list"] {
    flex: 0 1 var(--_list);
}

/* A share (routes.js: a companion's "share", stamped by app.js as data-share
   while the route that asked for it holds the Stage and this is the only List):
   about half the stage instead of the List basis, so the shelves beside the
   Home hero show the product instead of a strip. Never under a List; the cap
   `100cqi - 30rem` leaves the Stage beside it its minimum and a gap, so
   nothing folds that would not fold anyway and the fit rule (which measures
   the plain List) stays right. Still a flex basis: the lane shrinks a little
   under pressure like any List, and going to or from it is one movement. */
.lane[data-w="list"][data-share="half"] {
    flex-basis: clamp(var(--_list), min(47cqi, 100cqi - 30rem), 96rem);
}

/* The Stage starts from the List basis and takes all the free space, so going
   between List and Stage animates one number (flex-grow) and nothing snaps.
   Its minimum is a floor, not a basis: it never goes under it. */
.lane[data-w="stage"] {
    flex: 1 0 var(--_list);
    min-width: var(--_stage-min);
}

/* Boot: the server-rendered page takes its lane without a movement. */
.desktop-stage.is-booting > .lane,
.desktop-stage.is-booting > .lane > .lane-body,
.desktop-stage.is-booting > .lane > .lane-spine {
    transition: none;
}

/* ─── The lane body: the page ─────────────────────────────────────────────── */
/* The scroller and the query container (@container lane (...)). It is never
   narrower than the List basis: while its lane is slimmer than that (a Spine,
   or any lane on its way in or out) the body keeps its List form and the lane
   clips it, so nothing re-lays on the way to or from a Spine. Between List
   and Stage the body follows the lane and the content re-lays live.
   Inside a lane the shell's gutter and top bar are already accounted for.
   isolation: the body is its own stacking context at every setting, so a
   page's backdrop at z -1 stays inside its lane. */

.lane > .lane-body {
    --shell-gutter: 0px;
    --shell-top: 0px;

    position: absolute;
    isolation: isolate;
    inset-block: 0;
    inset-inline-start: 0;
    display: block;
    box-sizing: border-box;
    width: 100%;
    min-width: var(--_list);
    overflow: hidden auto;
    overscroll-behavior: contain;
    container: lane / inline-size;
    opacity: 1;
    transition: opacity calc(var(--_dur) * .5) linear, visibility 0s linear 0s;

    /* Padding: ONE place. The unit resolves against the stage, not the lane, so
       every lane has the same inset and their contents share a top edge. */
    --lane-pad-now: var(--_pad);
    padding: var(--lane-pad-now);
    scroll-padding: var(--lane-pad-now);
}

/* Opting out. On a block inside the page:
     data-bleed          runs to the lane's left and right edges
     data-bleed="top"    the same, and up to the lane's top edge (a hero)
   On the page's root element (a direct child of the lane body):
     data-bleed="lane"   the whole lane is unpadded (a map) */
.lane > .lane-body [data-bleed]:not([data-bleed="lane"]) {
    margin-inline: calc(-1 * var(--lane-pad-now));
}

.lane > .lane-body [data-bleed="top"] {
    margin-block-start: calc(-1 * var(--lane-pad-now));
}

.lane > .lane-body:has(> [data-bleed="lane"]) {
    --lane-pad-now: 0px;
}

.lane[data-w="spine"] > .lane-body,
.lane[data-w="off"] > .lane-body {
    opacity: 0;
    visibility: hidden;
    transition: opacity calc(var(--_dur) * .5) linear, visibility 0s linear var(--_dur);
}

/* A live Spine (routes.js spine: "live"): the page itself stays on screen and
   usable at Spine width, re-laid by its own container queries (a board of
   cards becomes a filmstrip). The body follows the lane all the way down, the
   strip above it shrinks to a grip, and the lane keeps a slim inset. */
.lane[data-spine="live"] > .lane-body {
    transition: opacity calc(var(--_dur) * .5) linear, visibility 0s linear 0s, inset-block-start var(--_dur) var(--_ease);
}

.lane[data-w="spine"][data-spine="live"] > .lane-body {
    --lane-pad-now: 0.4rem;
    inset-block-start: var(--_grip);
    min-width: 0;
    opacity: 1;
    visibility: visible;
    scrollbar-width: none;
}

/* Old single-page designs (routes.js legacy: true) keep the frame they were
   drawn in: the old .desktop-main padding, and no size containment, so their
   position: fixed pieces resolve against the stage rather than scroll away
   inside the lane. A full-bleed one (the map) owns its whole lane. */
.lane > .lane-body.is-legacy {
    container-type: normal;
    padding: 2.5rem 3rem;
}

.lane > .lane-body.is-legacy.is-bleed {
    padding: 0;
}

.desktop-stage[data-rail="off"] > .lane > .lane-body.is-legacy:not(.is-bleed) {
    padding-block-start: 1rem;
}

/* ─── The Spine: a slim live strip ────────────────────────────────────────── */
/* What a lane two or more steps back becomes when its page did not declare a
   live Spine: its current item as a thumbnail, the lane's name, its title, a
   count. The page supplies them (ctx.setSpine({ thumb, title, count }) and
   ctx.setLabel); one click or Enter widens the lane again. A neutral default
   look; kit.css dresses it (and gives each lane its icon and return mark). */

.lane-spine {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .7rem;
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: .8rem 0;
    border: 0;
    border-radius: var(--radius, 18px);
    background: color-mix(in srgb, var(--surface-2, #fff) 78%, transparent);
    color: var(--text, #1E2835);
    font: inherit;
    font-family: var(--font-head, inherit);
    font-weight: normal;
    line-height: 1.15;
    text-align: start;
    cursor: pointer;
    container: spine / inline-size;   /* its children size themselves from the strip's own width */
    opacity: 0;
    visibility: hidden;
    transition:
        opacity calc(var(--_dur) * .5) linear,
        background-color 160ms ease-out,
        visibility 0s linear var(--_dur);
}

.lane[data-w="spine"] > .lane-spine {
    opacity: 1;
    visibility: visible;
    transition:
        opacity calc(var(--_dur) * .5) linear calc(var(--_dur) * .4),
        background-color 160ms ease-out,
        visibility 0s linear 0s;
}

.lane-spine-thumb {
    flex: none;
    width: 68cqi;
    aspect-ratio: 1;
    border-radius: 24cqi;
    overflow: hidden;
    background: color-mix(in srgb, var(--accent, #EB5D8F) 16%, var(--surface, #F6F7F9));
    transition: transform 220ms var(--_ease);
}

.lane-spine-thumb:empty {
    display: none;
}

.lane-spine-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* The lane's own name, shown above the title when the title says something
   else ("Ask" over the words that were asked). Empty otherwise. */
.lane-spine-name {
    flex: none;
    writing-mode: vertical-rl;
    rotate: 180deg;
    font-size: 0.8125rem;
    opacity: .7;
}

.lane-spine-name:empty {
    display: none;
}

/* The title runs up the strip (bottom to top), cut with an ellipsis. */
.lane-spine-title {
    flex: 1 1 auto;
    min-height: 0;
    writing-mode: vertical-rl;
    rotate: 180deg;
    text-align: end;   /* the title hangs from the thumbnail, not from the foot of the strip */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: clamp(0.82rem, 24cqi, 1.05rem);
    letter-spacing: -.01em;
}

.lane-spine-count {
    flex: none;
    min-width: 2.2em;
    padding: .3em .55em;
    border-radius: 999px;
    background: var(--accent, #EB5D8F);
    color: var(--on-accent, #fff);
    font-family: var(--font-mono, inherit);
    font-size: clamp(0.7rem, 19cqi, 0.82rem);
    line-height: 1;
    text-align: center;
}

.lane-spine-count:empty {
    display: none;
}

/* The grip of a live Spine: the strip reduced to a handle across the top (the
   count, and three dots that say "this widens"). The page below it is live. */
.lane[data-w="spine"][data-spine="live"] > .lane-spine {
    inset: 0 0 auto 0;
    height: calc(var(--_grip) - 0.4rem);
    flex-direction: row;
    justify-content: center;
    gap: .35rem;
    padding: 0 .3rem;
}

.lane[data-spine="live"] > .lane-spine > .lane-spine-thumb,
.lane[data-spine="live"] > .lane-spine > .lane-spine-name,
.lane[data-spine="live"] > .lane-spine > .lane-spine-title {
    display: none;
}

.lane[data-spine="live"] > .lane-spine::before {
    content: "";
    flex: none;
    width: .95rem;
    height: .3rem;
    background: radial-gradient(circle, currentColor 1.4px, transparent 1.9px) 0 50% / .34rem .3rem repeat-x;
    opacity: .55;
}

/* The strip answers the pointer (an extra, never the only cue: it is a labelled
   button with a focus ring). */
.lane-spine:hover {
    background: color-mix(in srgb, var(--surface-2, #fff) 94%, transparent);
}

.lane-spine:hover .lane-spine-thumb {
    transform: scale(1.06);
}

.lane-spine:active .lane-spine-thumb {
    transform: scale(.97);
}

/* ─── The way back at a narrow window ─────────────────────────────────────── */
/* When the fit rule has tucked away every lane left of the leftmost lane
   still showing (a 900px window with a booking open: Ask and Browse are
   off), app.js marks that lane data-back and shows its .lane-back: one small
   chip naming the nearest tucked lane ("Results"); a click widens it exactly
   as its Spine would (data-lane-restore). The page starts under the chip, so
   it covers nothing. Never shown otherwise (Core.wayBack in stage-core.js). */

/* The chip is the lane's header row (the body starts under it): a clear pill, the pink
   return disc of every Spine, then the tucked lane's NAME ("Results", "Logan Local's
   Storefront", "Ask Hoku": its label) at 15px, so the way back is unmistakable. */
.desktop-stage {
    --_back: 3.6rem;
}

.lane-back {
    display: none;
}

.lane[data-back] > .lane-back:not([hidden]) {
    position: absolute;
    z-index: 1;
    inset-block-start: 0.65rem;
    inset-inline-start: var(--_pad);
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    box-sizing: border-box;
    max-width: calc(100% - 2 * var(--_pad));
    height: 2.5rem;
    margin: 0;
    padding: 0 1.1rem 0 0.3rem;
    border: 0;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface-2, #fff) 94%, transparent);
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent, #EB5D8F) 55%, transparent), 0 0.45rem 1.1rem -0.5rem rgba(30, 40, 53, 0.4);
    color: var(--text, #1E2835);
    font: inherit;
    font-family: var(--font-head, inherit);
    font-weight: normal;
    font-size: 0.9375rem;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 160ms ease-out, transform 160ms ease-out;
}

.lane-back > i {
    flex: none;
    display: grid;
    place-items: center;
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 50%;
    background: var(--accent, #EB5D8F);
    color: var(--on-accent, #fff);
    font-size: 0.8rem;
}

.lane-back-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lane[data-back] > .lane-body {
    inset-block-start: var(--_back);
}

.lane-back:hover,
.lane-back:focus-visible {
    background: var(--surface-2, #fff);
}

.lane-back:active {
    transform: scale(0.97);
}

.lane-back:focus-visible {
    outline: 3px solid var(--accent, #EB5D8F);
    outline-offset: 2px;
}

/* ─── Arrival: a lane's contents come in one after another ────────────────── */
/* app.js marks the children of a lane body that has just received its page
   (.lane-arrive, --arrive-i = its place in the queue); each mark comes off as
   its own beat lands. A page asks for the same for content it builds later
   with ctx.arrive(container). A lane that only changes width is never marked,
   so a resize does not replay it. `backwards` only: nothing stays transformed. */

.lane .lane-arrive {
    animation: lane-arrive calc(var(--_dur) * .8) var(--_ease) backwards;
    animation-delay: calc(var(--arrive-i, 0) * var(--_step));
}

@keyframes lane-arrive {
    from {
        opacity: 0;
        transform: translate3d(0, clamp(0.5rem, 2cqi, 1.1rem), 0);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* ─── Slots ───────────────────────────────────────────────────────────────── */
/* .stage-travel: the layer an element the user chose travels across.
   .stage-probe: zero-height rulers app.js measures the lane sizes from, so
   the fit rule reads its minimums out of this sheet's own values. */

.stage-travel,
.stage-probe {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.stage-travel {
    z-index: 5;
}

/* The travelling image: a clone of the photo the user chose, flown by app.js
   (Web Animations API) to the opening lane's [data-travel-target], which the
   lane keeps hidden until the clone has landed on it. */
.stage-flight {
    position: absolute;
    top: 0;
    left: 0;
    background: center / cover no-repeat;
    box-shadow: 0 1.2rem 2.6rem rgba(21, 56, 105, 0.28);
    will-change: transform, width, height;
}

.lane.is-receiving [data-travel-target] {
    visibility: hidden;
}

.stage-probe {
    inset: 0 var(--stage-pad, 0px) auto var(--stage-pad, 0px);   /* the row's content box: percentages mean what they mean for a lane */
    height: 0;
    visibility: hidden;
}

.stage-probe > i {
    display: block;
    height: 0;
}

.stage-probe > [data-probe="spine"] { width: var(--_spine); }
.stage-probe > [data-probe="list"]  { width: var(--_list); }
.stage-probe > [data-probe="stage"] { width: var(--_stage-min); }
.stage-probe > [data-probe="comfort"] { width: var(--_comfort); }

/* ─── Focus ───────────────────────────────────────────────────────────────── */
/* Inset rings: a lane clips, so an outset ring would be cut off. The lane body
   takes focus when the stage moves (app.js); the ring shows for keyboard use. */

.lane-spine:focus-visible,
.lane > .lane-body:focus-visible {
    outline: 3px solid var(--accent, #EB5D8F);
    outline-offset: -3px;
}

.lane [data-lane-restore]:focus-visible {
    outline: 3px solid var(--accent, #EB5D8F);
    outline-offset: 2px;
}

.lane-spine:focus-visible {
    background: color-mix(in srgb, var(--surface-2, #fff) 94%, transparent);
}

/* ─── Reduced motion: instant layout ──────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .lane,
    .lane[data-w="off"],
    .lane > .lane-body,
    .lane[data-w] > .lane-body,
    .lane-spine,
    .lane[data-w] > .lane-spine,
    .lane-spine-thumb,
    .lane-back {
        transition: none;
    }

    .lane .lane-arrive {
        animation: none;
    }
}

/* ─── Print: the page the URL names, alone ────────────────────────────────── */

@media print {
    .desktop-stage {
        position: static;
        display: block;
        padding: 0;
    }

    .lane,
    .lane > .lane-body {
        position: static;
        overflow: visible;
        min-width: 0;
    }

    .lane:not([data-w="stage"]),
    .lane-spine,
    .lane-back,
    .stage-travel,
    .stage-probe {
        display: none;
    }
}
