/* Room entries, the Shorts row, the marquee and the item-page stories (Stage 3, Nov 28 2026).
   Linked inside <body> just before the entries, so it never holds up the first paint of the room render. Tokens: style.css. */
/* ---- catalogue: sticky index beside the entries ---- */
.cat { margin-top: 56px; display: grid; gap: 20px; }
.cat-h { font-family: var(--head); font-size: clamp(26px, 3vw, 34px); margin: 0; }
.cat-grid { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 40px; align-items: start; }
.cat.no-index .cat-grid { grid-template-columns: minmax(0, 1fr); }
.cat-index { position: sticky; top: 72px; display: grid; gap: 14px; max-height: calc(100vh - 96px); overflow: auto; padding: 4px 6px 4px 0; scrollbar-width: thin; }
.ci-h { margin: 0 0 4px; font: 700 12px/1.2 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.ci-h::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c); }
.cat-index ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cat-index a { display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: 11px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; line-height: 1.25;
  transition: background var(--m-2) var(--m-out), transform var(--m-2) var(--m-out); }
.cat-index a img { width: 24px; height: 24px; border-radius: 7px; flex: none; object-fit: cover; }
.ci-glyph { width: 24px; height: 24px; flex: none; display: grid; place-items: center; border-radius: 7px; background: var(--bg-2); font-size: 13px; }
.cat-index a:hover { background: var(--bg-2); }
.cat-index a.cur { background: color-mix(in srgb, var(--tint) 26%, var(--surface)); transform: translateX(var(--m-lift)); }
.cat-list { display: grid; gap: 28px; min-width: 0; }

/* ---- an entry ---- */
.entry { --tint: var(--accent); position: relative; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(18px, 2.6vw, 30px);
  background: var(--surface); border-radius: var(--r-lg); padding: clamp(14px, 2.2vw, 24px); box-shadow: 0 4px 0 var(--block); scroll-margin-top: 80px; }
.entry::before { content: ""; position: absolute; inset: 0 0 auto; height: 5px; border-radius: var(--r-lg) var(--r-lg) 0 0; background: var(--tint); opacity: .9; }
.e-media { position: relative; display: block; align-self: start; aspect-ratio: 16 / 10; border-radius: 16px; overflow: hidden; background: color-mix(in srgb, var(--tint) 22%, var(--bg-2)); }
.e-media .e-still, .e-media .e-reveal { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.e-media.is-logo .e-still { object-fit: contain; padding: 18%; }
.e-media .e-reveal { clip-path: circle(0% at var(--mx, 50%) var(--my, 50%)); transition: clip-path var(--m-3) var(--m-out); }
.e-media.live .e-reveal { clip-path: circle(150% at var(--mx, 50%) var(--my, 50%)); }
.e-cover { position: absolute; left: 12px; bottom: 12px; width: 21%; height: auto; border-radius: 4px; transform: rotate(-4deg); box-shadow: 0 8px 18px rgba(0, 0, 0, .3); }
.e-glyph { display: grid; place-content: center; text-align: center; gap: 8px; text-decoration: none; color: var(--ink); padding: 20px; }
.e-glyph b { font: 600 clamp(44px, 6vw, 72px)/1 var(--head); color: var(--accent); }
.e-glyph small { font-size: 13px; color: var(--muted); max-width: 30ch; }
.e-main { display: grid; gap: 11px; align-content: start; min-width: 0; }
.e-kick { margin: 0; font: 700 12px/1.4 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.e-new { color: var(--accent); } .e-pop { color: var(--ink); }
.e-title { margin: 0; font-family: var(--head); font-size: clamp(26px, 3vw, 36px); line-height: 1.1; text-wrap: balance; display: flex; align-items: center; gap: 10px; }
.e-title a { color: inherit; text-decoration: none; } .e-title a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.e-title .icon { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.e-hook { margin: 0; font: 500 clamp(17px, 1.6vw, 20px)/1.35 var(--head); }
.e-desc { margin: 0; color: var(--muted); font-size: 15.5px; }
.e-label { display: inline-block; font: 700 11px/1 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 4px; vertical-align: 2px; }
.e-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.e-chips li { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--bg-2); }
.e-facts { margin: 2px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 12px; }
.e-facts div { display: grid; gap: 2px; }
.e-facts dt { font: 600 clamp(21px, 2.2vw, 27px)/1.1 var(--head); color: color-mix(in srgb, var(--tint) 62%, var(--ink)); font-variant-numeric: tabular-nums; }
.e-facts dd { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.3; }
.e-proof { margin: 0; font-size: 14px; color: var(--muted); } .e-proof b { font: 600 19px var(--head); color: var(--ink); }
.e-cta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.e-btn { font: 600 15px/1 var(--head); text-decoration: none; padding: 11px 16px; border-radius: 12px; color: var(--ink); border: 1.5px solid var(--line); background: var(--surface);
  transition: transform var(--m-1) var(--m-out), box-shadow var(--m-1) var(--m-out), border-color var(--m-1) var(--m-out); }
.e-btn:hover { border-color: var(--ink); }
.e-btn.primary { background: var(--tint); border-color: transparent; color: #17121f; box-shadow: 0 3px 0 color-mix(in srgb, var(--tint) 55%, #000); }
.e-btn.primary:hover { transform: translateY(-2px); box-shadow: 0 5px 0 color-mix(in srgb, var(--tint) 55%, #000); }
.e-btn.primary:active { transform: translateY(1px); box-shadow: 0 1px 0 color-mix(in srgb, var(--tint) 55%, #000); }
.e-cols { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 22px 28px; border-top: 1.5px dashed var(--line); padding-top: 18px; }
.e-col { display: grid; gap: 8px; align-content: start; min-width: 0; font-size: 15px; }
.e-col.wide { grid-column: 1 / -1; }
.e-col h4, .e-sub { margin: 0; font: 700 12px/1.2 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.e-sub { margin-top: 6px; }
.e-col p { margin: 0; }
.e-list { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.e-list li::marker { color: color-mix(in srgb, var(--tint) 70%, var(--muted)); font-weight: 700; }
.e-shorts { list-style: none; padding: 0; } .e-shorts a { font-weight: 600; } .e-shorts time { color: var(--muted); font-size: 13px; }
.e-tl { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid color-mix(in srgb, var(--tint) 55%, var(--line)); display: grid; gap: 8px; }
.e-tl time { display: block; font: 700 11px/1.3 "JetBrains Mono", ui-monospace, monospace; color: var(--muted); }
.e-tl a { color: var(--ink); text-decoration: none; } .e-tl a:hover { text-decoration: underline; }
.e-status { font-weight: 600; }
.e-plats { display: flex; flex-wrap: wrap; gap: 6px; }
.e-plat { font-size: 13px; font-weight: 600; color: var(--ink); text-decoration: none; border: 1.5px solid var(--line); padding: 4px 10px; border-radius: 999px; transition: border-color var(--m-1) var(--m-out); }
.e-plat:hover { border-color: var(--ink); }
.e-formula { overflow-x: auto; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--tint) 12%, var(--bg-2)); display: grid; gap: 10px; }
.e-formula math { font-size: 1.15em; }
.entry :is(a, button):focus-visible, .cat-index a:focus-visible, .drag-row:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.glist-foot { margin-top: 28px; }

/* ---- scroll reveal (CSS scroll-driven; with no support, or reduced motion, nothing is hidden) ---- */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .entry, .sc, .story-step { animation: m-rise linear both; animation-timeline: view(); animation-range: entry 0% entry 45%; }
  }
}
/* a rise without a fade: text is never shown at low contrast mid-way */
@keyframes m-rise { from { translate: 0 var(--m-rise); } }

/* ---- Media: the Shorts as a drag row ---- */
.shorts { margin-top: 48px; display: grid; gap: 12px; }
.drag-wrap { display: grid; gap: 8px; }
.drag-hint { margin: 0; font-size: 13px; color: var(--muted); }
.drag-row { list-style: none; margin: 0; padding: 4px 2px 16px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(232px, 260px); gap: 16px; overflow-x: auto;
  scroll-snap-type: x mandatory; scroll-padding-inline: 2px; overscroll-behavior-x: contain; scrollbar-width: thin; border-radius: 12px; }
.drag-row > li { scroll-snap-align: start; }
.drag-row.dragging { scroll-snap-type: none; cursor: grabbing; user-select: none; } .drag-row.dragging * { pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .drag-row { cursor: grab; } }
.sc { display: grid; gap: 10px; align-content: start; background: var(--surface); border-radius: var(--r-md); padding: 10px 10px 14px; box-shadow: 0 3px 0 var(--block);
  transition: transform var(--m-2) var(--m-out), box-shadow var(--m-2) var(--m-out); }
@media (hover: hover) { .sc:hover { transform: translateY(calc(-1 * var(--m-lift))); box-shadow: 0 7px 0 var(--block); } }
.sc-pic { position: relative; display: block; aspect-ratio: 9 / 16; max-height: 300px; width: 100%; border-radius: 12px; overflow: hidden; background: #0d0b16; }
.sc-pic img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.sc-play { position: absolute; inset: 0; margin: auto; width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: rgba(0, 0, 0, .55); color: #fff; font-size: 20px; }
.sc-len { position: absolute; right: 8px; bottom: 8px; font: 700 12px "JetBrains Mono", monospace; color: #fff; background: rgba(0, 0, 0, .6); padding: 2px 6px; border-radius: 6px; }
.sc-text { display: grid; gap: 7px; padding-inline: 4px; }
.sc h3 { margin: 0; font-family: var(--head); font-size: 18px; line-height: 1.2; } .sc h3 a { color: var(--ink); text-decoration: none; } .sc h3 a:hover { text-decoration: underline; }
.sc-what { margin: 0; font-size: 14px; color: var(--muted); }
.sc-about { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 13.5px; } .sc-about a { color: var(--accent); font-weight: 600; }
.sc-about .e-sub { margin: 0; }

/* ---- "Also on" marquee ---- */
.marquee { margin-top: 48px; display: flex; align-items: center; gap: 14px; border-block: 1.5px solid var(--line); padding-block: 14px; }
.mq-h { margin: 0; flex: none; font: 700 12px "JetBrains Mono", ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.mq-track { flex: 1; min-width: 0; display: flex; overflow: hidden; mask-image: linear-gradient(90deg, transparent, #000 7%, #000 93%, transparent); }
.mq-track ul { flex: none; display: flex; gap: 44px; margin: 0; padding: 0 22px; list-style: none; animation: mq 38s linear infinite; }
.mq-track a { font: 600 21px var(--head); color: var(--muted); text-decoration: none; white-space: nowrap; transition: color var(--m-1) var(--m-out); }
.mq-track a:hover, .mq-track a:focus-visible { color: var(--ink); }
.marquee:hover ul, .marquee:focus-within ul, .marquee.paused ul { animation-play-state: paused; }
@keyframes mq { to { transform: translateX(-100%); } }
.mq-btn { flex: none; font: 600 13px inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer; }

/* ---- item pages: the structured summary and the scroll-told story ---- */
.dx { --tint: var(--accent); display: grid; gap: 16px; margin: 28px 0; padding: clamp(16px, 2.4vw, 24px); border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 4px 0 var(--block); }
.dx-problem { margin: 0; font: 500 19px/1.4 var(--head); }
.dx .e-cols { border-top: 0; padding-top: 0; }
.story { margin: 40px 0; display: grid; gap: 18px; }
.story h2 { font-family: var(--head); margin: 0; }
.story-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 40px; align-items: start; }
.story-fig { position: sticky; top: 90px; margin: 0; padding: 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 4px 0 var(--block); display: grid; gap: 6px; }
.story-fig figcaption { font-size: 12px; color: var(--muted); min-height: 1em; }
.st-art { width: 100%; height: auto; display: block; }
.story-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 34vh; padding-block: 6vh 20vh; }
.story-step { display: grid; gap: 6px; padding: 18px 20px; border-radius: var(--r-md); background: var(--surface); border: 1.5px solid var(--line); transition: border-color var(--m-2) var(--m-out), box-shadow var(--m-2) var(--m-out); }
.story-step.cur { border-color: var(--accent); box-shadow: 0 4px 0 var(--block); }
.story-step h3 { margin: 0; font-family: var(--head); font-size: 21px; }
.story-step p { margin: 0; color: var(--muted); }
.ss-n { font: 700 12px "JetBrains Mono", monospace; color: var(--accent); }
/* the illustrations: each step adds a layer (data-step on the figure; without JS it shows the last step) */
.st-art * { transition: opacity var(--m-3) var(--m-out), fill var(--m-3) var(--m-out), width var(--m-3) var(--m-out), stroke-dashoffset var(--m-4) var(--m-out); }
.st-draw .g-grid line { stroke: var(--line); }
.st-draw path { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.st-draw .g-seen { stroke: var(--ink); } .st-draw .g-cut { fill: var(--bg-2); opacity: .7; }
.st-draw .g-guess { stroke: var(--accent); stroke-dasharray: 9 7; } .st-draw .g-real { stroke: #2f9e57; stroke-dasharray: 400; stroke-dashoffset: 0; }
.st-draw .g-gap { fill: color-mix(in srgb, var(--accent) 18%, transparent); stroke: none; } .st-draw .g-ruler { stroke: var(--muted); stroke-width: 2.5; stroke-dasharray: 3 6; }
.st-draw .g-link rect { fill: var(--accent); } .st-draw .g-link text { fill: #fff; font: 600 15px var(--head); text-anchor: middle; }
.story-fig[data-step="1"] .st-draw :is(.g-guess, .g-gap, .g-real, .g-ruler, .g-link), .story-fig[data-step="2"] .st-draw :is(.g-gap, .g-real, .g-ruler, .g-link), .story-fig[data-step="3"] .st-draw :is(.g-ruler, .g-link), .story-fig[data-step="4"] .st-draw .g-link { opacity: 0; }
.story-fig:is([data-step="1"], [data-step="2"]) .st-draw .g-real { stroke-dashoffset: 400; }
.story-fig:not([data-step="1"]) .st-draw .g-cut { opacity: .25; }
.st-fog .f-doc rect { fill: var(--bg-2); stroke: var(--line); stroke-width: 2; } .st-fog line { stroke: var(--muted); stroke-width: 5; stroke-linecap: round; opacity: .5; } .st-fog line.hl { stroke: var(--accent); opacity: 1; }
.st-fog .q rect { fill: var(--surface); stroke: var(--accent); stroke-width: 2; } .st-fog .q circle { fill: var(--line); } .st-fog .q2 { opacity: .35; }
.st-fog .f-back { fill: none; stroke: var(--accent); stroke-width: 3; stroke-dasharray: 6 6; } .st-fog .f-queue rect { fill: color-mix(in srgb, var(--accent) 35%, var(--surface)); }
.story-fig[data-step="1"] .st-fog :is(.f-q, .f-back, .f-queue), .story-fig[data-step="1"] .st-fog line.hl { opacity: 0; }
.story-fig[data-step="2"] .st-fog :is(.f-q, .f-back, .f-queue) { opacity: 0; }
.story-fig[data-step="3"] .st-fog :is(.f-back, .f-queue) { opacity: 0; } .story-fig[data-step="4"] .st-fog .f-queue { opacity: 0; }
.story-fig:is([data-step="3"], [data-step="4"], [data-step="5"]) .st-fog .q2 { opacity: 0; }
.st-amt .a-tile rect { fill: var(--bg-2); stroke: var(--line); stroke-width: 2; } .st-amt .a-tile circle { fill: var(--muted); opacity: .5; }
.st-amt .a-tile.up circle { fill: #2f9e57; opacity: 1; }
.story-fig:not([data-step="1"]) .st-amt .a-tile:not(.up) { opacity: .25; }
.story-fig:not([data-step="1"]) .st-amt .a-tile.up rect { fill: color-mix(in srgb, #2f9e57 calc(var(--h) * 60%), var(--surface)); }
.st-amt .a-cash { fill: var(--accent); width: 0; } .st-amt .a-cash-t { fill: var(--ink); font: 600 13px var(--head); opacity: 0; }
.story-fig:is([data-step="4"], [data-step="5"]) .st-amt .a-cash { width: 140px; } .story-fig:is([data-step="4"], [data-step="5"]) .st-amt .a-cash-t { opacity: 1; }
.st-amt .a-time rect { fill: var(--muted); opacity: .5; } .st-amt .a-time .oos { fill: var(--accent); opacity: 1; } .st-amt .a-time text { fill: var(--muted); font: 600 11px "JetBrains Mono", monospace; }
.story-fig:not([data-step="5"]) .st-amt .a-time { opacity: 0; }

/* ---- narrow screens ---- */
@media (max-width: 900px) {
  .cat-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .cat-index { position: sticky; top: 44px; z-index: 20; max-height: none; display: flex; gap: 6px; overflow-x: auto; padding: 8px 16px; margin-inline: -16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); scrollbar-width: none; }
  .ci-group { display: contents; } .ci-h { display: none; }
  .cat-index ol { display: contents; }
  .cat-index a { flex: none; white-space: nowrap; background: var(--bg-2); padding: 5px 10px 5px 6px; font-size: 14px; }
  .cat-index a.cur { transform: none; }
  .entry { grid-template-columns: minmax(0, 1fr); scroll-margin-top: 104px; }
  .story-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .story-fig { top: 52px; z-index: 2; }
  .story-steps { gap: 40vh; }
  .marquee { flex-wrap: wrap; } .mq-track { order: 3; flex-basis: 100%; }
}
@media (max-width: 520px) { .e-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; } .e-cover { width: 26%; } }

@media (prefers-reduced-motion: reduce) {
  .entry, .sc, .story-step, .dx, .cnav, .cat-index a, .e-btn, .nav-pv, .nav-pv li, .st-art * { animation: none !important; transition: none !important; }
  .e-media .e-reveal { display: none; }
  .mq-track { mask-image: none; } .mq-track ul { animation: none; flex-wrap: wrap; gap: 8px 28px; } .mq-track ul + ul { display: none; } .mq-btn { display: none; }
  html.intro .intro { display: none; }
}
.e-title a { display: inline-flex; align-items: center; gap: 10px; }
@media (min-width: 1280px) { .is-room .cat { margin-top: 128px; } }
.e-media.e-art { position: relative; top: auto; display: grid; place-items: center; padding: 12px; background: var(--bg-2); box-shadow: none; border-radius: 16px; }
.e-media.e-art .st-art { width: 100%; height: auto; }
/* off-screen entries skip layout and paint (and their lazy pictures wait) until they come near */
.entry, .sc, .story-step { content-visibility: auto; contain-intrinsic-width: none; contain-intrinsic-height: auto 760px; }
.sc { contain-intrinsic-width: none; contain-intrinsic-height: auto 560px; } .story-step { contain-intrinsic-width: none; contain-intrinsic-height: auto 180px; }
/* contrast: the facts' numbers and labels in plain ink */
.e-facts dt { color: var(--ink); text-decoration: underline 3px color-mix(in srgb, var(--tint) 70%, transparent); text-underline-offset: 5px; }
.e-facts dd { color: var(--ink); opacity: .78; }
.e-col h2, .e-col h3 { margin: 0; font: 700 12px/1.2 "JetBrains Mono", ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
/* the whole list below the room is skipped until it comes near, so the first paint only lays out the room render */
.shorts .drag-row { content-visibility: auto; contain-intrinsic-width: none; contain-intrinsic-height: auto 2400px; }
.shorts .drag-row { contain-intrinsic-width: none; contain-intrinsic-height: auto 560px; }
.mq-btn { min-height: 32px; min-width: 64px; }
.cat-list > .entry:last-child { content-visibility: visible; }
