/* Afterglow site: the front page. Sections run full width and wrap their content in .wrap; on large
   screens the hero pins for one extra screen so the scroll can re-pair the four panels. No gradients, no
   shadows; the one strong colour is the gain numeral in the navy band. */

/* hero: the first screen is the scene alone, the drawn cell under its sun, centred; the headline and the two ways in sit
   below the fold. While the intro plays (html.is-intro) the cell waits lower and out of sight until .is-placed. */
.hero { position: relative; }
.hero__scene { position: relative; z-index: 1; min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 24px var(--gutter); }
.hero__slot { position: relative; aspect-ratio: 4 / 3; width: min(88vw, calc(62vh * 4 / 3)); }
.hero .display { font-size: clamp(2.4rem, 5.2vw, 4.8rem); }
/* the headline in a high-contrast serif (the Mac's Bodoni or Didot, else Georgia), one block per line, centred */
.hero .display { font-family: "Bodoni 72", Didot, "Playfair Display", Georgia, "Times New Roman", serif; font-weight: 600; font-stretch: normal; letter-spacing: -0.02em; line-height: 0.98; }
.hero .display .wipe { display: block; width: fit-content; margin-inline: auto; }
html.is-intro .hero__panel { translate: 0 14vh; opacity: 0; transition: translate 1100ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 800ms ease; }
html.is-intro .hero.is-placed .hero__panel { translate: 0 0; opacity: 1; }
/* the drawing in the slot: the sun's frame reaches 14% above the slot (its own 400x342 box, so nothing stretches);
   the panel leans with the pointer through a perspective transform that motion.js drives (--tx, --ty), its shadow slides (--sx, --sy) */
.hero__sun { position: absolute; left: 0; top: -14%; width: 100%; height: 114%; display: block; overflow: visible; pointer-events: none; fill: none; stroke: var(--sun); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hero__sun .sun__disc { fill: var(--sun); }
.hero__sun .sun__beam { stroke-width: 2; stroke-dasharray: 5 11; opacity: 0.85; }
.hero__panel { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; transform: perspective(1200px) rotateX(calc(var(--tx, 14) * 1deg)) rotateY(calc(var(--ty, 0) * 1deg)); transform-origin: 50% 55%; }
.pnl__shadow { transform: translate(calc(var(--sx, 10) * 1px), calc(var(--sy, 12) * 1px)); }
.hero__text { position: relative; z-index: 1; display: grid; gap: 20px; justify-items: center; text-align: center; max-width: 60ch; margin: 0 auto; padding: 56px var(--gutter) 104px; }
.hero__text .lede { margin: 0; }
.hero__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
/* the comparison. On phones a navy section; on large screens its own pinned screen: a navy bubble at the bottom centre
   (its radius --r from motion.js) swells until it covers the screen, the four panels sit large in the middle and the band
   of facts runs along the bottom edge */
.repair { position: relative; color: #fff; background: var(--cell); }
.repair__pin { position: relative; overflow: clip; display: grid; grid-template-rows: 1fr auto; }
.repair__fill { display: none; }
.repair__stage { display: grid; justify-items: center; align-content: center; gap: 10px; padding: 24px var(--gutter) 32px; position: relative; z-index: 1; }
.rp { width: min(100%, 900px); height: auto; max-height: 270px; }
.rp text { font-family: var(--font); }
.rp-cell text { fill: #fff; font-weight: 600; font-size: 14px; }
.rp-cell polygon:first-child { fill: #24356e; stroke: rgba(255, 255, 255, 0.28); stroke-width: 1.5; }
.rp-wire { fill: none; stroke: rgba(255, 255, 255, 0.85); stroke-width: 2; }
.rp-rail { fill: none; stroke: rgba(255, 255, 255, 0.3); stroke-width: 2; }
.rp-num { font-size: 58px; font-weight: 700; font-stretch: 112.5%; letter-spacing: -0.03em; fill: var(--sun); }
.rp-label { font-size: 13px; fill: rgba(255, 255, 255, 0.72); }
.hero__caption { display: none; color: rgba(255, 255, 255, 0.72); }  /* the svg's own caption is too small on a phone */
@media (max-width: 600px) {
  .rp-label { display: none; }
  .rp-num { font-size: 76px; }
  .rp-cell text { font-size: 20px; }
  .hero__caption { display: block; }
}
@media (min-width: 900px) and (min-height: 700px) {
  .hero .display { font-size: clamp(2.4rem, 4.2vw, 4.6rem); }
  .hero__slot { width: min(70vw, calc(64vh * 4 / 3)); }
  /* the pinned comparison: the section is pale like the hero, and only the bubble brings the navy */
  .repair { background: var(--page); min-height: 260vh; }
  .repair__pin { position: sticky; top: 0; height: 100vh; }
  /* the bubble is a layer fixed to the screen (so it can rise before the section pins), a navy circle at the bottom
     centre whose radius motion.js sets in vmax (--r); the pin's own navy (::before) comes with the panels (--show) and
     carries on as the section scrolls out */
  .repair__fill { display: block; position: fixed; inset: 0; background: var(--cell); clip-path: circle(calc(var(--r, 0) * 1vmax) at 50% 100%); z-index: 0; pointer-events: none; }
  .repair__fill.is-off, html.reduced .repair__fill { display: none; }
  .repair__pin::before { content: ""; position: absolute; inset: 0; background: var(--cell); opacity: var(--show, 1); }
  .repair__stage { opacity: var(--show, 1); transform: translateY(calc((1 - var(--show, 1)) * 40px)); }
  .repair .rp { width: min(92vw, 1500px); max-height: 60vh; }
  .repair .ticker { position: relative; z-index: 1; opacity: var(--show, 1); }
}
@media (min-width: 1800px) {   /* 1920x1080: a little more room for the cell */
  .hero__slot { width: min(70vw, calc(68vh * 4 / 3)); }
}

/* the problem: three figures, then the two sentences */
.problem { padding-block: var(--section) 0; }
.problem__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; }
.problem .num-big { font-size: clamp(2.4rem, 4.6vw, 4.2rem); white-space: nowrap; }
.fig__line { color: var(--ink-2); margin-top: 10px; max-width: 26ch; }
.problem__text { max-width: var(--measure); margin-top: 56px; font-size: 1.2rem; line-height: 1.45; }

/* how the bench works: the four steps hang in order on one wire, like panels on a string; order comes from position, not numerals */
.how { padding-block: var(--section); }
.string-box { position: relative; margin-top: 48px; }
.string { list-style: none; padding: 0; margin: 0; position: relative; display: grid; grid-template-columns: repeat(4, 1fr); gap: 32px 40px; }
.string__wire { position: absolute; pointer-events: none; overflow: visible; }
.string__wire path { fill: none; stroke: var(--cell); stroke-width: 2; vector-effect: non-scaling-stroke; }
.string__wire--h { left: 0; right: 0; top: 55px; width: 100%; height: 2px; }  /* through each drawing's rail (y 32 of 40, at 70 px tall) */
.string__wire--v { display: none; }
.step { position: relative; display: grid; gap: 10px; align-content: start; }
.step__glyph { width: 126px; height: 70px; display: block; }
.step__glyph .g-line { fill: none; stroke: var(--cell); stroke-width: 1.5; }
.step__glyph .g-rail { stroke: var(--busbar); }
.step__glyph .g-curve { fill: none; stroke: var(--cell); stroke-width: 2; }
.step h3 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; color: var(--cell); margin-top: 10px; }
.step p { color: var(--ink-2); }

/* the strip: three wirings side by side; a swipe row by default, turned sideways by the scroll on fine pointers */
.strip { overflow: clip; }
.strip__pin { padding-block: var(--section); }
.strip__stage { transform-origin: 50% 42%; }
.strip__track { display: flex; gap: 20px; margin-top: 32px; padding-inline: var(--gutter); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.strip__track::-webkit-scrollbar { display: none; }
.wiring { flex: 0 0 min(78vw, 520px); scroll-snap-align: start; background: var(--surface); border-radius: var(--radius); padding: 22px 24px 24px; display: grid; gap: 12px; }
.wiring__head { display: flex; justify-content: space-between; align-items: baseline; }
.wiring__letter { font-size: var(--title); font-weight: 700; font-stretch: 112.5%; }
.wiring__svg { width: 100%; height: auto; }
.wiring__svg text { fill: #fff; font-family: var(--font); font-weight: 600; font-size: 12px; }
.w-wire { fill: none; stroke: var(--cell); stroke-width: 2; }
.w-rail { fill: none; stroke: var(--busbar); stroke-width: 2; }
.wiring__w { font-size: 2.1rem; font-weight: 700; font-stretch: 112.5%; letter-spacing: -0.025em; line-height: 1; color: var(--ink-2); }
.wiring.is-best .wiring__w { color: var(--cell); }
.strip__note { margin-top: 20px; }
@media (pointer: fine) {
  /* the swipe row on a mouse: show it can scroll */
  .strip.is-row .strip__track { scrollbar-width: thin; scrollbar-color: var(--busbar) transparent; padding-bottom: 10px; }
  .strip.is-row .strip__track::-webkit-scrollbar { display: block; height: 6px; }
  .strip.is-row .strip__track::-webkit-scrollbar-thumb { background: var(--busbar); border-radius: 3px; }
}
@media (min-width: 760px) and (pointer: fine) {
  /* only while motion.js drives it; it adds .is-row (the swipe row) when it cannot */
  html.has-motion .strip:not(.is-row) .strip__pin { position: sticky; top: 0; }
  html.has-motion .strip:not(.is-row) .strip__track { overflow: visible; scroll-snap-type: none; gap: 44px; padding-bottom: 150px;   /* room for the arc's dipping ends, so they never cover the note */ padding-inline: max(var(--gutter), calc((100% - var(--wrap)) / 2 + var(--gutter))); will-change: transform; }
  /* when the scroll drives it, each wiring is most of a screen wide, so the strip travels well over a screen sideways */
  html.has-motion .strip:not(.is-row) .wiring { flex-basis: min(72vw, 920px); padding: 32px 36px 36px; }
  html.has-motion .strip:not(.is-row) .wiring__w { font-size: clamp(2.1rem, 3.2vw, 3.4rem); }
  html.has-motion .strip:not(.is-row) .wiring__svg { max-width: 560px; }
}

/* the gain: the page's one strong colour */
.front-band { border-radius: 0; padding: var(--section) 0; }

/* passports: the four newest, or the way to see an example */
.fpass { padding-block: var(--section); }
.ppass-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 8px; }
.ppass { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; row-gap: 4px; align-items: baseline; padding: 18px; background: var(--surface); border-radius: var(--radius); text-decoration: none; color: inherit; }
.ppass .cell-svg { grid-column: 1 / -1; width: 100%; max-width: 128px; margin-bottom: 10px; }
.ppass__id { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.01em; color: var(--cell); overflow-wrap: anywhere; }
.ppass__grade { font-size: 1.5rem; letter-spacing: -0.02em; }
.ppass__facts { grid-column: 1 / -1; }
.fpass__actions { margin-top: 28px; gap: 12px; }

/* builder teaser */
.teaser { padding-block: 0 var(--section); }
.teaser__box { display: flex; gap: 24px; align-items: center; justify-content: space-between; flex-wrap: wrap; background: var(--surface); border-radius: var(--radius); padding: 26px 28px; }
.teaser__text { font-size: 1.15rem; max-width: 46ch; }

/* close */
.close { background: var(--surface); padding: 40px 0 48px; }

@media (max-width: 900px) {
  .ppass-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .problem__grid { grid-template-columns: 1fr; gap: 28px; }
  .problem__text { margin-top: 40px; font-size: 1.1rem; }
  /* on a phone the string runs down the left and each step hangs to its right */
  .string { grid-template-columns: 1fr; gap: 28px; }
  .string__wire--h { display: none; }
  .string__wire--v { display: block; left: 47px; top: 0; bottom: 0; width: 2px; height: 100%; }
  .step { grid-template-columns: 96px 1fr; column-gap: 16px; row-gap: 4px; align-items: start; }
  .step__glyph { grid-row: 1 / span 2; width: 96px; height: 53px; }
  .step h3 { grid-column: 2; margin-top: 8px; }
  .step p { grid-column: 2; }
  .rp { max-height: none; }
}
@media (max-width: 480px) {
  .ppass-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ppass { padding: 12px; }
}


/* chapters change ground: paper for the problem and the steps, navy for the wirings and the gain */
body[data-page="front"] #view > section { position: relative; z-index: 1; }
.paper { position: relative; overflow: clip; background: var(--surface); }
.paper > section { position: relative; z-index: 1; }   /* the sections and their text above the written word */
.problem { padding-block: var(--section); }
.how { margin-top: calc(-1 * var(--section) + 24px); padding-top: 24px; }
.strip { background: var(--cell); }
.strip .title, .strip__note { color: #fff; }
.strip__note { opacity: 0.72; }
.strip__pin { padding-block: var(--section) calc(var(--section) * 0.6); }
.strip .wiring__label { color: var(--ink-2); }
.front-band { padding-top: calc(var(--section) * 0.5); }
.repair { z-index: 1; }

@media (max-width: 760px) { .hero__sun { display: none; } }   /* phones: the panel alone */

/* the ticker: a slow band of sourced facts under the hero, paused under the pointer */
.ticker { overflow: hidden; background: var(--cell); color: #fff; border-top: 1px solid rgba(255, 255, 255, 0.1); }   /* lives at the bottom of the comparison */
.ticker__track { display: flex; width: max-content; animation: marquee 56s linear infinite; }
.ticker:hover .ticker__track { animation-play-state: paused; }
.ticker__item { display: inline-flex; align-items: center; white-space: nowrap; padding: 16px 0; font-size: 1.02rem; font-weight: 600; font-stretch: 105%; }
.ticker__item::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sun); margin: 0 30px; flex: none; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* amber on one key figure per chapter: the hero's gain, the first problem numeral, the best wiring's power */
.rp-num { fill: var(--sun); }
.problem .fig:first-child .num-big { color: var(--sun); }
.wiring.is-best .wiring__w { color: var(--sun); }

/* "RECYCLE" by hand behind the problem's numerals: thick, uneven amber strokes, drawn one after another once the section
   is on screen (motion.js adds .is-in); under reduced motion the word is simply there */
/* anchored to the sheet's bottom left corner (xMinYMax), mostly transparent, under the text of both sections */
.recycle { position: absolute; left: 0.5%; bottom: 1%; width: 99%; height: 92%; pointer-events: none; z-index: 0; fill: none; stroke: var(--sun); stroke-linecap: round; stroke-linejoin: round; opacity: 0.2; shape-rendering: geometricPrecision; }
.recycle path { stroke-dasharray: 1 2; stroke-dashoffset: 1.001; }   /* parked just past the start, so no round cap shows before the pen arrives */
.paper:has(.problem.is-in) .recycle path { animation: draw-stroke var(--t, 600ms) linear both; animation-delay: calc(var(--d, 0s) + 300ms); }
html.reduced .recycle path { stroke-dashoffset: 0; }
@keyframes draw-stroke { to { stroke-dashoffset: 0; } }
.problem { padding-block: var(--section); }
/* doodles: a drawn full stop at the end of a block of text */
.doodle { display: inline-block; vertical-align: -0.35em; width: 1.5em; height: 1.5em; margin-left: 0.35em; fill: none; stroke: var(--sun); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.doodle--sun circle { fill: var(--sun); stroke: none; }
.doodle--string { width: 2.4em; }
.step .doodle { width: 1.3em; height: 1.3em; }

/* the inversion: the dark chapters meet the paper on a shallow curve (after the Lando Norris site's editorial turn from
   olive to cream), and the passports lie scattered like snapshots on a table: each on its own height, the whole row
   panning diagonally as the reader scrolls (--pan 0..1 from motion.js), each card grey and quiet until it is hovered
   or passes the middle of the screen */
.strip { border-radius: 50% 50% 0 0 / 40px 40px 0 0; }
.front-band { border-radius: 0 0 50% 50% / 0 0 40px 40px; }
@media (min-width: 900px) {
  .ppass-row { width: calc(100% + 12vw); align-items: start; transform: translate(calc(var(--pan, 0) * -12vw), calc(var(--pan, 0) * 56px)); }
  .ppass:nth-child(1) { margin-top: 40px; } .ppass:nth-child(3) { margin-top: 72px; } .ppass:nth-child(4) { margin-top: 24px; }
}
html.has-motion .ppass { filter: grayscale(1); opacity: 0.72; }
html.has-motion .ppass:hover, html.has-motion .ppass:focus-visible, html.has-motion .ppass.is-near { filter: none; opacity: 1; }

/* the landscape along the bottom of a white block: pen work in sage and ink, under the text */
.landscape { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 30%; z-index: 0; pointer-events: none; fill: none; stroke: #3f6139; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: 0.72; }
.land__fill { stroke: none; }
.land__back { fill: #dde8d4; } .land__mid { fill: #c6d9b9; } .land__front { fill: #aac89a; }
.land__ink { stroke-width: 2; }
.land__ink--2 { stroke-width: 1.1; opacity: 0.55; }
.land__hatch { stroke-width: 1.2; opacity: 0.6; }
.land__grass { stroke-width: 1.5; }
.land__trunk { stroke-width: 2.4; }
.land__crown { stroke-width: 1.4; fill: #b9d4aa; fill-opacity: 0.6; }
.close { position: relative; }
.close .wrap { position: relative; z-index: 1; }

/* footnotes: small numbered markers after the statistics, and the notes themselves at the foot of the page */
.fn { font-size: 0.62em; line-height: 0; vertical-align: super; margin-left: 2px; }
.fn a { color: var(--ink-2); text-decoration: none; font-weight: 600; }
.fn a:hover { color: var(--cell); text-decoration: underline; }
.band .fn a, .strip .fn a { color: rgba(255, 255, 255, 0.7); }
.footnotes { margin: 0 auto; padding-top: 12px; border-top: 1px solid var(--busbar-2); padding-left: calc(var(--gutter) + 1.2em); display: grid; gap: 2px; font-size: 0.7rem; line-height: 1.4; color: var(--ink-3); max-width: var(--wrap); }
.footnotes li { padding-left: 2px; }
.footnotes a { color: var(--ink-2); text-decoration-color: var(--busbar-2); }
.footnotes a:hover { color: var(--cell); }
.footnotes li:target { color: var(--ink); }
.footnotes li:target { color: var(--ink); }
