/* Act structure and chapter composition. Loaded after motion.css: it overrides the
   stacked masthead and adds the act rail, the act-change M wipe and view transitions. */
:root{--frame-top:58px;--frame-bottom:56px;--act-bar:30px;--vt-ease:cubic-bezier(.16,1,.3,1);--vt-exit:cubic-bezier(.55,0,.75,.2)}
::selection{background:var(--cyan);color:var(--ink)}

/* ---------- Act bar: segmented progress directly above the footer ---------- */
/* It replaces the old 4px progress line: one segment per act, sized by its chapter count. */
.deck-progress{display:none!important}
.act-rail{position:fixed;z-index:20;left:0;right:0;bottom:var(--frame-bottom);height:var(--act-bar);padding:0 var(--gutter);background:var(--paper);color:var(--ink);--rule:rgba(17,35,51,.14);--done:rgba(17,35,51,.36);--on:var(--blue)}
body[data-surface=dark] .act-rail{background:var(--night);color:white;--rule:rgba(255,255,255,.16);--done:rgba(255,255,255,.42);--on:var(--cyan)}
body[data-field=blue] .act-rail{background:var(--blue);color:white;--rule:rgba(255,255,255,.28);--done:rgba(255,255,255,.55);--on:white}
body[data-act="-1"] .act-rail{display:none}
.screen-deck main>.chapter:not(#intro){bottom:calc(var(--frame-bottom) + var(--act-bar))}
.rail-track{position:relative;list-style:none;margin:0;padding:0;height:100%;display:flex;gap:6px}
.rail-track li{position:relative;flex:var(--n) 1 0;min-width:0}
.rail-track button{position:absolute;inset:0;width:100%;padding:0;background:none;border:0;cursor:pointer}
.rail-track button::before{content:'';position:absolute;left:0;right:0;bottom:6px;height:3px;background:var(--rule);transition:background-color 220ms}
.rail-track li.done button::before{background:var(--done)}
.rail-track li.current button::before{background:var(--on)}
.rail-track button:hover::before{background:var(--done)}
.rail-track button:focus-visible{outline:3px solid var(--cyan);outline-offset:-1px}
.rail-label{position:absolute;left:0;bottom:13px;white-space:nowrap;font-size:12px;line-height:1;letter-spacing:.01em;opacity:0;pointer-events:none;transition:opacity 200ms}
.rail-track li.label-end .rail-label{left:auto;right:0}
.rail-label b{font-family:'Barlow Condensed',Arial,sans-serif;font-weight:500;font-size:13px;margin-right:6px;color:var(--on)}
.rail-track li.current .rail-label{opacity:1}
.rail-track li:not(.current):has(button:hover,button:focus-visible) .rail-label{opacity:.8;z-index:2}
.rail-track:has(li:not(.current) button:hover,li:not(.current) button:focus-visible) li.current .rail-label{opacity:0}
.rail-marker{position:absolute;left:0;bottom:3px;width:3px;height:9px;margin-left:-1.5px;background:var(--on);pointer-events:none;transform:translateX(-20px);transition:transform 520ms var(--vt-ease)}
/* Up to 900px the bar is a single segmented line: the footer title already names the area, and
   dense chapters keep their height by giving the bar their bottom padding. */
@media(max-width:900px){
 :root{--act-bar:12px}
 .rail-label{display:none}
 .rail-track button::before{bottom:4px}
 .rail-marker{bottom:2px;height:7px}
 .screen-deck main>.chapter:not(#intro){padding-bottom:6px}
 .screen-deck main>.chapter>.deck-heading,.screen-deck main>.chapter>.heading-split{margin-bottom:10px}
}
@media(max-width:760px){.act-rail{padding:0 14px}.rail-track{gap:4px}}

/* Header, footer and act bar change field colour gradually while a chapter changes. The class is
   only present during navigation, so hover and press feedback keep their own quick timing. */
body.field-shift :is(.header,.presentation-bar,.act-rail),
body.field-shift :is(.header,.presentation-bar,.act-rail) *:not(.rail-marker),
body.field-shift :is(.header,.presentation-bar,.act-rail) *::before,
body.field-shift :is(.header,.presentation-bar,.act-rail) *::after{transition:background-color var(--field-ms,600ms) var(--vt-ease),color var(--field-ms,600ms) var(--vt-ease),border-color var(--field-ms,600ms) var(--vt-ease),fill var(--field-ms,600ms) var(--vt-ease),stroke var(--field-ms,600ms) var(--vt-ease),box-shadow var(--field-ms,600ms) var(--vt-ease)!important}

/* ---------- Chapter masthead: conclusion left, explanation right, one hairline ---------- */
@media(min-width:901px){
 .screen-deck main>.chapter>.deck-heading,.screen-deck main>.chapter>.heading-split{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr);column-gap:clamp(32px,4.4vw,80px);align-items:end;position:relative;padding-bottom:clamp(14px,2.2vh,22px);margin-bottom:clamp(18px,3vh,30px)}
 .screen-deck main>.chapter>.deck-heading::after,.screen-deck main>.chapter>.heading-split::after{content:'';position:absolute;left:0;right:0;bottom:0;height:1px;background:currentColor;opacity:.16;transform-origin:left}
 .screen-deck main>.chapter>.deck-heading h2,.screen-deck main>.chapter>.heading-split h2{margin:0;font-size:clamp(44px,4vw,66px);line-height:.98;text-wrap:balance}
 .screen-deck main>.chapter>.deck-heading>p,.screen-deck main>.chapter>.heading-split>p{margin:0;justify-self:end;width:100%;max-width:50ch;font-size:17px;line-height:1.45;text-wrap:pretty}
 .screen-deck main>.chapter.light>.deck-heading>p,.screen-deck main>.chapter.light>.heading-split>p,.screen-deck main>.chapter.map-page>.deck-heading>p{color:var(--muted)}
 .screen-deck main>.chapter.dark:not(.map-page)>.deck-heading>p,.screen-deck main>.chapter.dark:not(.map-page)>.heading-split>p{color:#c3d1e0}
 .screen-deck main>.chapter.studio-blue>.deck-heading>p{color:#e3f0ff}
 /* The synthesis title stands alone; give it the same rule beneath. */
 #sintesi>h2{padding-bottom:clamp(14px,2.2vh,22px);margin-bottom:clamp(18px,3vh,30px);box-shadow:inset 0 -1px 0 rgba(17,35,51,.16)}
 /* Saved comparison values read from the back of the room. */
 .analysis-table tbody td[data-numeric]{font-size:clamp(30px,2.6vw,44px);line-height:1.1}
 .analysis-table th,.analysis-table td{padding-left:clamp(16px,1.6vw,26px);padding-right:clamp(16px,1.6vw,26px)}
}
@media(min-width:901px) and (max-height:780px){
 .screen-deck main>.chapter>.deck-heading h2,.screen-deck main>.chapter>.heading-split h2{font-size:42px}
 .screen-deck main>.chapter>.deck-heading>p,.screen-deck main>.chapter>.heading-split>p{font-size:15px}
 .analysis-table tbody td[data-numeric]{font-size:28px}
}
@media(min-width:901px) and (max-width:1180px){
 .screen-deck main>.chapter>.deck-heading,.screen-deck main>.chapter>.heading-split{grid-template-columns:minmax(0,1.15fr) minmax(0,1fr);column-gap:32px}
 .screen-deck main>.chapter>.deck-heading>p,.screen-deck main>.chapter>.heading-split>p{font-size:15px}
}

/* Between phone and desktop the inherited tokens fell to 11px; keep supporting text readable. */
@media(min-width:761px) and (max-width:900px){
 :root{--small:13px;--body:15px}
 /* The two complete compressor maps are the densest screens; they keep their original compact sizes. */
 .screen-deck main>.map-page{--small:11px;--body:13px}
 .micro,.source-note,.scene-hint,.image-credit,.sources-grid a,.range-ends span{font-size:12px}
}

/* Stage 3 labels sit in front of the team CAD model and point at its real layout:
   intake duct with the electric pod on the left, compressor in the centre, turbine on the right. */
#stage3 .scene-label{z-index:8;text-shadow:0 1px 3px #0c1729,0 0 10px #0c1729}
@media(min-width:761px){#stage3 .label-motor{left:20%;top:auto;bottom:16%}#stage3 .label-compressor{left:48%;bottom:6%}}

/* Decision labels stay readable in front of the two team-CAD crank mechanisms. */
.decision-model-labels{z-index:8;text-shadow:0 1px 3px #073d76,0 0 10px #073d76}

/* The burned-mass-fraction marker slides to its new position when timing or configuration changes. */
#burn-indicator{transition:left 420ms cubic-bezier(.16,1,.3,1)}
@media(prefers-reduced-motion:reduce){#burn-indicator{transition:none}}

/* Stage 1 values show their change versus Stock: green for an increase, red for a decrease. */
.stock-delta{display:inline-block;margin-left:10px;font:500 .92em/1 'Barlow Condensed',Arial,sans-serif;font-variant-numeric:tabular-nums;letter-spacing:.01em;white-space:nowrap}
.stock-delta.up{color:#17773f}
.stock-delta.down{color:#b3263a}
.baseline-delta{display:block;margin-top:8px;font-size:17px}
.baseline-delta:empty{display:none}
.baseline-delta .stock-delta{margin-left:0;font-size:22px}
.stock-delta-label{margin-left:6px;color:var(--muted);font-size:14px}

/* Images do not react to the cursor: the dyno cards and plots keep their background on hover. */
.reference-card:hover,.reference-plot:hover{background:white}

/* Figures settle from a slight scale inside their own frame, never past its edges. */
:is(.evidence-image,.reference-plot,.benchmark-figure,.screen-map-figure,.cfd-field-figure,.cfd-case-image,.cfd-team-image,.thermal-pod-drawing){overflow:clip}

/* ---------- Lists that stretched to the frame become ruled rows ---------- */
@media(min-width:901px){
 /* Four mechanical checks: component · check · requirement, one ruled row each. */
 #motor-checks .motor-verification-grid{display:grid;grid-template-columns:none;grid-template-rows:repeat(4,1fr);gap:0;flex:1;min-height:0}
 #motor-checks .motor-verification-grid article,#motor-checks .motor-verification-grid article:nth-child(2){display:grid;grid-template-columns:minmax(150px,.55fr) minmax(0,.95fr) minmax(0,1.6fr);column-gap:clamp(24px,3vw,56px);align-items:center;padding:0!important;background:none;color:white;border-top:1px solid rgba(255,255,255,.3)}
 #motor-checks .motor-verification-grid article:last-child{border-bottom:1px solid rgba(255,255,255,.3)}
 #motor-checks .motor-verification-grid article>span{display:block;font:500 15px/1.2 'Barlow',Arial,sans-serif;letter-spacing:.06em;color:#d9ecff}
 #motor-checks .motor-verification-grid h3{margin:0;font-size:clamp(26px,2.2vw,36px);line-height:1.05}
 #motor-checks .motor-verification-grid p,#motor-checks .motor-verification-grid article:nth-child(2) p{margin:0;font-size:clamp(16px,1.2vw,19px);line-height:1.5;color:#e3f0ff}
 /* Baselines to reconcile: label left, finding right. */
 #reconciliation .audit-list{display:grid;grid-template-columns:none;grid-template-rows:repeat(4,1fr);gap:0}
 #reconciliation li{display:grid;grid-template-columns:minmax(150px,.32fr) minmax(0,1fr);column-gap:clamp(24px,3vw,56px);align-items:center;padding:0 0 0 0;background:none;border-top:1px solid rgba(17,35,51,.16);font-size:clamp(17px,1.3vw,21px);line-height:1.5}
 #reconciliation li:last-child{border-bottom:1px solid rgba(17,35,51,.16)}
 #reconciliation li b{display:block;margin:0;font:500 clamp(28px,2.4vw,40px)/1 'Barlow Condensed',Arial,sans-serif}
 /* Three matching checks: the saved values fill their tall rows. */
 #g25-matching-checks .analysis-table tbody td[data-numeric],#efr-matching-checks .analysis-table tbody td[data-numeric]{font-size:clamp(48px,4.4vw,76px);line-height:1}
}
@media(min-width:901px) and (max-height:780px){
 #motor-checks .motor-verification-grid h3{font-size:24px}
 #motor-checks .motor-verification-grid p{font-size:15px}
 #reconciliation li{font-size:16px}
 #reconciliation li b{font-size:26px}
 #g25-matching-checks .analysis-table tbody td[data-numeric],#efr-matching-checks .analysis-table tbody td[data-numeric]{font-size:44px}
}

/* ---------- Spacing scale ----------
   One scale replaces the drifted one-off values (72/60/57.6, 40/30/24/18 gaps; 18–30px insets):
   section gap between figure and explanation, group gap between sibling blocks, one panel inset,
   one callout inset and a small, constant space under panel headings. */
:root{--space-section:clamp(40px,4vw,64px);--space-group:24px;--space-tight:8px;--inset-panel:clamp(18px,2vw,30px);--inset-callout:14px 18px;--heading-gap:12px}
@media(min-width:901px){
 .screen-deck main>.chapter :is(.baseline-layout,.rod-layout,.sources-grid,.benchmark-layout,.map-screen,.comb-layout,.combustion-evidence,.motor-page-layout,.thermal-layout,.cfd-study-layout,.tolerance-layout){gap:var(--space-section)}
 .screen-deck main>.chapter :is(.decision-showcase,.thermal-implications,.tolerance-formulas,.evidence-strip,.course-grid,.reference-comparison){gap:var(--space-group)}
 .screen-deck main>.chapter :is(.lab-panel,.reference-card,.dfx-grid>button,.dfx-detail,.tolerance-formulas article,.course-grid article,.decision-verdict>div){padding:var(--inset-panel)}
 .screen-deck main>.chapter .callout{padding:var(--inset-callout)}
 .screen-deck main>.chapter :is(.cfd-study-reason,.sources-grid>div,.decision-verdict,.thermal-layout,.motor-structure)>h3{margin-bottom:var(--heading-gap)}
 /* Chapter-specific rules used id selectors; these bring them onto the same scale. */
 #struttura .lab-panel,#disciplines .course-grid article{padding:var(--inset-panel)}
 #thermal-checks .thermal-implications{gap:var(--space-group)}
 :is(#decision .decision-verdict,#thermal-case-detail) h3{margin-bottom:var(--heading-gap)}
 /* The synthesis title closes with the same 27px masthead interval as every other chapter. */
 #sintesi>h2{margin-bottom:clamp(18px,3vh,30px)}
 #sintesi>h2+*{margin-top:0}
}
/* Smaller screens use the same roles at a tighter step; layouts restack, so gaps stay their own. */
@media(max-width:900px){
 :root{--inset-panel:18px;--inset-callout:12px 14px;--heading-gap:10px}
 .screen-deck main>.chapter :is(.lab-panel,.reference-card,.dfx-grid>button,.dfx-detail,.tolerance-formulas article,.course-grid article,.decision-verdict>div),#struttura .lab-panel,#disciplines .course-grid article{padding:var(--inset-panel)}
 .screen-deck main>.chapter .callout{padding:var(--inset-callout)}
 .screen-deck main>.chapter :is(.cfd-study-reason,.sources-grid>div,.decision-verdict,.thermal-layout,.motor-structure)>h3,:is(#decision .decision-verdict,#thermal-case-detail) h3{margin-bottom:var(--heading-gap)}
}
@media(max-width:760px){:root{--inset-panel:14px;--heading-gap:8px}}

/* DfX: the selected choice explains, the four cards lead; the detail no longer outweighs them. */
.dfx-grid p{font-size:clamp(14px,1vw,16px);line-height:1.45}
.dfx-detail{font-size:clamp(16px,1.25vw,19px);line-height:1.5}

/* ---------- Chapter index grouped by act ---------- */
.deck-index-list .deck-index-act{grid-column:1/-1;display:flex;gap:12px;align-items:baseline;margin:22px 0 6px;padding-bottom:8px;border-bottom:1px solid rgba(17,35,51,.16);font:500 22px/1.1 'Barlow Condensed',Arial,sans-serif;letter-spacing:-.005em}
.deck-index-list .deck-index-act:first-child{margin-top:0}
.deck-index-list .deck-index-act b{margin:0;font-weight:500;color:var(--blue);font-variant-numeric:tabular-nums}

/* ---------- Act change: the three M stripes sweep the stage ---------- */
.act-wipe{position:fixed;z-index:28;top:var(--frame-top);bottom:var(--frame-bottom);left:0;right:0;overflow:hidden;pointer-events:none}
/* One band: the M logo's three stripes lead and trail a navy body wide enough to cover the stage.
   Stripe colours and the ~30.6° slant are taken from the supplied BMW M logo. */
.act-wipe{--m-light:#0071b7;--m-dark:#00468b;--m-red:#e52b1a}
.act-wipe-band{position:absolute;top:0;bottom:0;left:0;display:flex;transform:translate3d(-300vw,0,0) skewX(-30.6deg)}
.act-wipe-band i,.act-wipe-band b{flex:none;height:100%}
.act-wipe-band i{width:var(--stripe,48px)}
.act-wipe-band i.l{background:var(--m-light)}
.act-wipe-band i.d{background:var(--m-dark)}
.act-wipe-band i.r{background:var(--m-red)}
.act-wipe-band b{width:var(--body,100vw);background:var(--night)}
.act-wipe-mark{position:absolute;left:50%;top:50%;width:clamp(150px,18vw,260px);height:auto;margin:0;translate:-50% -50%;opacity:0;overflow:visible}
/* Stage slate: on entering a Stage act the cover names the stage. The numeral rolls from the stage
   just left; the 0–3 track fills to the new stage. Reading size, no oversized type. */
.stage-slate{position:absolute;left:50%;top:50%;translate:-50% -50%;width:clamp(240px,24vw,360px);display:grid;grid-template-columns:auto 1fr;column-gap:clamp(14px,1.4vw,22px);align-items:end;color:#fff;opacity:0}
.slate-head{display:contents}
.slate-eyebrow{grid-column:2;grid-row:1;align-self:start;padding-top:.45em;font:500 clamp(18px,1.6vw,26px)/1 'Barlow',Arial,sans-serif;letter-spacing:.22em;text-transform:uppercase;color:#fff}
.slate-num{grid-column:1;grid-row:1/3;display:inline-grid;overflow:clip;font:500 clamp(104px,10.5vw,168px)/.8 'Barlow Condensed',Arial,sans-serif;letter-spacing:-.03em;font-variant-numeric:tabular-nums;padding-top:.06em}
.slate-num>span{grid-area:1/1;opacity:0}
.slate-name{grid-column:2;grid-row:2;overflow:clip;padding-bottom:.2em;margin-bottom:-.16em;font:500 clamp(26px,2.4vw,38px)/1 'Barlow Condensed',Arial,sans-serif;letter-spacing:-.01em}
.slate-name span{display:block;transform:translateY(110%)}
.slate-track{grid-column:1/-1;position:relative;height:30px;margin-top:clamp(18px,1.8vw,26px)}
.slate-rail,.slate-fill{position:absolute;left:0;right:0;top:4px;height:1px;background:rgba(255,255,255,.24)}
.slate-fill{height:2px;top:3.5px;background:#fff;transform-origin:0 50%;transform:scaleX(0)}
.slate-track b{position:absolute;top:0;left:calc(var(--x)*100%);width:9px;height:9px;margin-left:-4.5px;opacity:.4}
.slate-track b[data-n="0"]{--x:0}.slate-track b[data-n="1"]{--x:.3333}.slate-track b[data-n="2"]{--x:.6667}.slate-track b[data-n="3"]{--x:1}
.slate-track b i{position:absolute;inset:0}
.slate-track b i::before{content:"";position:absolute;inset:0;transform:skewX(-30.6deg);background:var(--night);box-shadow:inset 0 0 0 1.5px rgba(255,255,255,.55)}
.slate-track b.done{opacity:1}.slate-track b.done i::before{background:#fff;box-shadow:none}
.slate-track b.current{opacity:1}.slate-track b.current i::before{background:var(--m-red);box-shadow:none}
.slate-track em{position:absolute;top:16px;left:50%;translate:-50% 0;font:500 12px/1 'Barlow',Arial,sans-serif;font-style:normal;letter-spacing:.08em;color:rgba(255,255,255,.55);font-variant-numeric:tabular-nums}
.slate-track b.current em{color:#fff}
/* The header links are already hidden on phones, so presenter mode would change nothing there. */
@media(max-width:760px){:root{--frame-top:54px;--frame-bottom:52px}#present{display:none}}

/* ---------- Within an act: native view transitions ---------- */
.screen-deck main>.chapter.active-screen{view-transition-name:chapter}
/* Footer page number: the old number rolls out and the new one rolls in through a one-line mask. */
.count-roll{display:inline-grid;overflow:clip;vertical-align:bottom;font-variant-numeric:tabular-nums}
.count-roll>span{grid-area:1/1;text-align:right}
.rail-marker{view-transition-name:rail-marker}
::view-transition-old(root),::view-transition-new(root){animation-duration:220ms}
/* The new chapter slides up as a sheet over the old one, which recedes and dims against a navy
   group background. Only transform and opacity animate, so the compositor carries the whole move. */
::view-transition-group(chapter){background:var(--night);overflow:clip}
::view-transition-old(chapter){animation:b48-chapter-out 620ms var(--vt-ease) both}
::view-transition-new(chapter){animation:b48-chapter-in-next 620ms var(--vt-ease) both}
html[data-nav=prev]::view-transition-new(chapter){animation-name:b48-chapter-in-prev}
::view-transition-group(rail-marker){animation-duration:620ms;animation-timing-function:var(--vt-ease)}
::view-transition-group(*){animation-timing-function:var(--vt-ease)}
@keyframes b48-chapter-out{to{transform:scale(.94);opacity:.45}}
@keyframes b48-chapter-in-next{from{transform:translate3d(0,100%,0)}to{transform:none}}
@keyframes b48-chapter-in-prev{from{transform:translate3d(0,-100%,0)}to{transform:none}}

@media(prefers-reduced-motion:reduce){
 .act-wipe{display:none}
 .rail-marker{transition:none}
 ::view-transition-group(*),::view-transition-old(*),::view-transition-new(*){animation:none!important}
}
@media print{.act-rail,.act-wipe{display:none!important}.screen-deck main>.chapter{left:auto}}
