/* style.css, part 2 of 13: the control stack: grouped, collapsible sections.
   A contiguous range of the pre-M7 style.css, linked from index.html in
   source order so the cascade is unchanged; see src/tokens.css. */

/* ============================================================
   THE CONTROL STACK — grouped, collapsible, scannable (row E6).

   The stack was 7,434 px of permanently-open cards: a wall a first-time
   visitor scrolls past rather than reads. Each card now lives in a native
   <details> section whose <summary> carries a number, a name and a live
   one-line summary of that section's current settings, so the closed
   stack is a table of contents rather than a list of headings.
   ============================================================ */
.stack-nav {
    position: sticky;
    top: -1.75rem;
    z-index: 12;
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin: -0.35rem -0.35rem 0;
    padding: 0.6rem 0.35rem 0.7rem;
    background: var(--sidebar-bg);
    border-bottom: 1.5px dashed var(--border-color);
}
.stack-nav-chips {
    display: contents;
}
.stack-nav-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-chip);
    min-height: 30px;
    padding: var(--space-chip) var(--space-card);
    border: 1.5px solid var(--border-soft);
    border-radius: var(--radius-chip);
    background: var(--c-white);
    color: var(--text-primary);
    font: 700 0.72rem var(--font-ui);
    cursor: pointer;
}
.stack-nav-chip:hover { border-color: var(--accent-color); background: #fff3f8; }
.stack-nav-chip.is-open {
    border-color: var(--accent-color);
    background: #ffeaf3;
    color: var(--accent-text);
}
/* Opaque for the same reason as .section-index below: this pill sits on three
   different chip backgrounds (#fff, :hover #fff3f8, .is-open #ffeaf3) and a 12 %
   tint over each of them gave three different ratios — 5.15, 4.79 and 4.54:1.
   The last is inside a rounding error of failing, on a state no gate reads. */
.stack-nav-chip .chip-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.15rem;
    height: 1.15rem;
    border-radius: var(--radius-chip);
    background: #f7e4ed;
    color: var(--accent-text);
    font-size: 0.62rem;
}
.stack-nav-actions { display: flex; gap: 0.35rem; margin-left: auto; }
.stack-nav-all {
    min-height: 30px;
    padding: 0.25rem var(--space-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-inset);
    background: var(--c-white);
    color: var(--text-secondary);
    font: 700 0.68rem var(--font-ui);
    cursor: pointer;
}
.stack-nav-all:hover { color: var(--accent-text); border-color: var(--accent-color); }

/* `flex: none` matters: the sidebar is a flex column and `overflow: hidden`
   below sets these items' automatic minimum size to zero, so without it the
   browser shrinks every section to its 2 px border to fit the viewport. */
.stack-section {
    flex: none;
    border: 1.5px solid var(--border-card);
    border-radius: 22px;
    background: var(--card-bg);
    /* Two shadows doing different jobs. The wide soft one lifts the card off
       the sidebar; the 1px inset highlight along the top edge is what makes
       the border read as a raised edge rather than a drawn line, and it is the
       reason this can stay a pale pink instead of going grey. */
    box-shadow: 0 6px 18px var(--shadow-soft),
                inset 0 1px 0 var(--c-white-a90);
    overflow: hidden;
}
/* An open section is the one being worked in, so it gets the stronger edge and
   lifts further. Closed sections recede — which is the whole point of a
   collapsible stack and was not previously visible at all. */
.stack-section[open] {
    border-color: var(--border-card-open);
    box-shadow: 0 10px 26px var(--shadow-soft),
                inset 0 1px 0 var(--c-white-a90);
}
/* The summary holds ONE child, an <h2>, because that is all the HTML spec
   allows next to heading content inside <summary> — three siblings around a
   heading is invalid markup, and invalid markup is where assistive
   technology starts guessing. The flex row therefore lives on the heading. */
.stack-section > summary {
    display: block;
    list-style: none;
    cursor: pointer;
    min-height: 48px;
    padding: 0.7rem 1rem;
    user-select: none;
    /* A faint band, so the title belongs to a header rather than floating
       above the first control. This is EIGHT bands stacked down the panel and
       it was the largest pink area in the app at rest, which is why it was
       #fdf4fa and is now #f8f5fb — the same luminance, without the blush.
       --text-primary on it is 7.37:1, so it stays well clear of 4.5:1; the
       whole point of the note at the top of this file is that a band like this
       must not quietly become a contrast failure. */
    background: #f8f5fb;
}
.stack-section > summary::-webkit-details-marker { display: none; }
.stack-section > summary:hover { background: #efecf2; }
/* Only when open: a closed section is a single band and a line across it
   would look like an empty card rather than a collapsed one. */
.stack-section[open] > summary {
    border-bottom: 1px solid var(--border-card);
}
.stack-section .section-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 34px;
}
/* `content: 'x' / ''` gives the generated glyph an EMPTY alternative text, so
   it stays out of the accessibility tree. Without the `/ ''`, NVDA reads the
   chevron aloud on every section — "1 Start here, Flat button, ▾, heading,
   level 2, button, expanded" — which is the state the button already
   announces, said twice, once as a symbol. Found in the NVDA pass. */
.stack-section .section-title::after {
    content: '▸' / '';
    margin-left: auto;
    color: var(--accent-text);
    font-size: var(--fs-sm);
    flex: none;
}
.stack-section[open] .section-title::after { content: '▾' / ''; }
/* The pill behind the number is OPAQUE, and that is the point of it.
   It used to be `rgba(179, 39, 93, 0.12)`, which composites against whatever it
   is sitting on — so its contrast changed with the surface, and on the summary
   HOVER band (then #fbe8f4, now #efecf2) the digit measured 4.46:1: under 4.5,
   on a state nothing checks, because tests/a11y-dom.mjs ignores :hover by
   design. An opaque pill is one number on every surface: --accent-text on
   #f7e4ed is 5.13:1.

   THIS PILL STAYS PINK, deliberately, when the surfaces around it went neutral.
   It is a numbered heading marker — an accent doing a job — and its 5.13:1 is a
   measured value that neutralising the fill would move for no gain. */
.stack-section .section-index {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: var(--radius-chip);
    background: #f7e4ed;
    color: var(--accent-text);
    font: 700 0.78rem var(--font-ui);
}
/* An <h2> so the stack has a real outline for heading navigation: h1 product
   name → h2 section → h3 card. */
.stack-section .section-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: var(--fs-lg);
    font-weight: var(--fw-strong);
    /* THE ONE PLACE THIS SWEEP ADDS TYPE RATHER THAN RENAMING IT. The family
       contract puts --tracking-title on the section and dialog titles in all
       three apps; this app carried no letter-spacing here at all. At 17 px it
       is -0.17 px per character — "Shape or picture" loses 2.7 px — so it is
       the smallest of the changes listed for the owner, and it is listed. */
    letter-spacing: var(--tracking-title);
    color: var(--text-primary);
}
.stack-section .section-name { flex: none; }
/* THIS WRAPS, AND IT USED TO ELLIPSISE. That change is what let the panel
   get narrower, so it is worth saying why rather than only that.

   Narrowing --sidebar-width was measured control by control (see the note on
   the declaration). Nothing in the panel overflows and no target drops under
   24 px all the way down to 320 px — the single thing that measurably breaks
   is this line, the summary under a section heading. With `nowrap` +
   `ellipsis` it started truncating at 460 px and got worse from there: at
   440 px "Top wraps bottom · all edges…" lost 26 px, at 400 px it lost 66.

   Truncating a summary is the one outcome the brief for that change ruled
   out — a label clipped to something ambiguous is worse than a wide panel.
   Wrapping loses nothing instead: the cost is that ONE section header goes
   to two lines when its summary is long, and only then. The narrow block at
   420 px already did exactly this, so this is the same answer applied at the
   width where the problem actually starts rather than 40 px too late. */
.stack-section .section-meta {
    min-width: 0;
    flex: 1;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 0.74rem;
    font-weight: var(--fw-strong);
    line-height: var(--lh-tight);
    white-space: normal;
    overflow-wrap: anywhere;
}
.stack-section .section-meta:empty { display: none; }
.stack-section > .section-body {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding: 0 0.6rem 0.6rem;
}
/* Cards inside a section drop their own frame and most of their padding —
   the section is the card now, and the double frame was pure height. */
.stack-section .control-group {
    gap: 0.7rem;
    padding: var(--space-air);
    border-radius: var(--radius-card);
    box-shadow: none;
    border-color: var(--border-soft);
    background: var(--c-white);
}
.stack-section .control-group h3 {
    font-size: var(--fs-base);
    padding-bottom: 0.5rem;
    margin-bottom: 0.1rem;
}
/* …except when the viewport selection points at one, which is exactly when
   it has to stand out from its neighbours. */
.stack-section .control-group.viewport-selected {
    background: var(--c-white);
}
.stack-section.section-empty { display: none; }
