/* Apple style study deck. Unofficial. Fonts are local SIL OFL copies (fonts/FONTS.md). */

@font-face { font-family: 'Inter'; src: url('../fonts/Inter-VF.ttf') format('truetype'); font-weight: 100 900; font-display: block; }
@font-face { font-family: 'Cormorant Garamond'; src: url('../fonts/CormorantGaramond-VF.ttf') format('truetype'); font-weight: 300 700; font-display: block; }
@font-face { font-family: 'Pixelify Sans'; src: url('../fonts/PixelifySans-Medium.ttf') format('truetype'); font-weight: 500; font-display: block; }

:root {
  --black: #000000;
  --paper: #F5F5F7;
  --ink: #1D1D1F;
  --white: #FFFFFF;
  --sub-dark: #86868B;
  --sub-paper: #6E6E73;
  --action: #0071E3;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --g: #000000;
  --lit: .35;
}

html, body { margin: 0; height: 100%; background: #000; overflow: hidden; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

#deck {
  position: fixed; inset: 0; background: var(--g); overflow: hidden;
  transition: background-color .6s var(--ease);
  font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif; color: var(--white);
  cursor: default; user-select: none; -webkit-user-select: none; touch-action: pan-y;
}
#stage {
  position: absolute; left: 0; top: 0; width: 1920px; height: 1080px;
  transform-origin: 0 0; overflow: hidden; contain: layout paint;
}
#ground { position: absolute; inset: 0; background: var(--g); transition: background-color .6s var(--ease); }
#glfb { position: absolute; inset: 0; display: none;
  background: radial-gradient(circle at 50% 36%, rgba(255,255,255,.9) 0, rgba(255,255,255,.18) 1.2%, rgba(255,255,255,.04) 10%, rgba(255,255,255,0) 30%); }
#deck.nogl #glfb { display: block; }
#deck.nogl[data-theme="light"] #glfb { display: none; }
#gl, #fx { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; display: block; }
#fx { image-rendering: pixelated; image-rendering: crisp-edges; opacity: 0; transition: opacity .7s ease; pointer-events: none; }
#fx.show { opacity: 1; transition: none; }
#flash { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; opacity: 0; pointer-events: none; transform-origin: 50% 33%; z-index: 2;
  background: radial-gradient(circle at 50% 33%, #fff 0, #fff 22%, rgba(255,255,255,.75) 34%, rgba(255,255,255,.25) 48%, rgba(255,255,255,0) 66%); }

#slides { position: absolute; inset: 0; z-index: 1; }

/* ---------- slides */
.slide { position: absolute; inset: 0; opacity: 0; visibility: hidden; transform-origin: 50% 48%;
  transition: opacity .9s var(--ease), scale .9s var(--ease), filter .9s var(--ease), visibility 0s linear .9s; }
.slide.active { opacity: 1; visibility: visible; transition: opacity .9s var(--ease), visibility 0s; }
.slide.leaving { opacity: 0; visibility: visible; transition: opacity .9s var(--ease), scale .9s, filter .9s; }
#slides[data-trans="zoom"] .slide.leaving { scale: 1.07; filter: blur(10px); transition: opacity .55s cubic-bezier(.5,0,.75,0), scale .7s cubic-bezier(.5,0,.75,0), filter .55s ease-in; }
#slides[data-trans="zoom"] .slide.active { animation: zin 1.6s var(--ease) both; }
@keyframes zin { from { scale: .955; } to { scale: 1; } }
#slides[data-trans="bloom"] .slide.leaving { transition: opacity .45s ease-in; }
#slides[data-trans="cut"] .slide.leaving,
#slides.inst .slide, #slides.inst .slide * { transition: none !important; animation: none !important; }
#slides[data-trans="cont"] .slide.leaving { transition: opacity .7s ease; }

/* ---------- lines */
.ln { position: absolute; left: 140px; right: 140px; top: var(--y); margin: 0; text-align: center;
  transform: translateY(-50%); white-space: nowrap; }
.rv { opacity: 0; filter: blur(12px); translate: 0 12px;
  transition: opacity .8s var(--ease), filter .8s var(--ease), translate .8s var(--ease); }
.rv.on { opacity: 1; filter: blur(0); translate: 0 0; }
.rv.on.off { opacity: 0; filter: blur(10px); translate: 0 -10px; transition-duration: .5s; transition-delay: 0s !important; }
.reduced .rv { filter: none; translate: none; transition-duration: .2s !important; transition-delay: 0s !important; }
.still .rv, .still .slide { transition: none !important; animation: none !important; }

.date { font-weight: 500; font-size: 28px; line-height: 1.2; letter-spacing: 0; color: var(--sub); }
.word { font-weight: 650; font-size: 220px; line-height: .95; letter-spacing: -0.045em; color: var(--fg); }
.title { font-weight: 650; font-size: 150px; line-height: 1; letter-spacing: -0.042em; color: var(--fg); }
.sub { font-weight: 400; font-size: 40px; line-height: 1.25; letter-spacing: -0.01em; color: var(--sub); }
.sub.soft { color: var(--sub2); }
.line { font-weight: 600; font-size: 64px; line-height: 1.1; letter-spacing: -0.03em; color: var(--fg); }
.line.big { font-size: 96px; letter-spacing: -0.035em; }
.quote { font-family: 'Cormorant Garamond', Georgia, serif; font-variant-numeric: lining-nums; font-weight: 500; font-size: 60px; line-height: 1.1; letter-spacing: -0.01em; color: var(--fg); }
.cite { font-weight: 500; font-size: 26px; letter-spacing: .02em; color: var(--sub); }
.disclaimer { font-weight: 400; font-size: 18px; letter-spacing: 0; color: var(--sub); }
.micro { font-weight: 400; font-size: 16px; color: var(--sub2); }
.num { font-variant-numeric: tabular-nums; }
.g.num { font-variant-numeric: lining-nums tabular-nums; }
.g { font-family: 'Cormorant Garamond', Georgia, serif; font-variant-numeric: lining-nums proportional-nums; font-weight: 600; letter-spacing: -0.03em; line-height: .9; scale: .85 1; }
.word.g { font-size: 250px; }
.ninety { font-size: 420px; line-height: .8; letter-spacing: -0.05em;
  color: rgb(calc(30 + 120 * var(--lit)) calc(30 + 112 * var(--lit)) calc(32 + 100 * var(--lit))); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.settle { animation: settle .3s var(--ease); display: inline-block; }
@keyframes settle { from { scale: 1.02; } to { scale: 1; } }

.endline { font-size: 60px; }
.linkline { font-size: 30px; font-weight: 500; letter-spacing: -0.01em; }
.linkline a { color: var(--action); text-decoration: none; padding: 10px 18px; border-radius: 30px; cursor: pointer; pointer-events: auto; }
.linkline a:hover { text-decoration: underline; text-underline-offset: 6px; }
.linkline a:focus-visible { outline: 2px solid var(--action); outline-offset: 3px; }

/* theme colours */
.slide[data-theme="dark"] { --fg: var(--white); --sub: var(--sub-dark); --sub2: #6E6E73; }
.slide[data-theme="light"] { --fg: var(--ink); --sub: var(--sub-paper); --sub2: #86868B; }
.slide[data-theme="light"] .sub.soft { color: var(--sub-paper); }

/* ---------- A13 race */
.race { position: absolute; left: 240px; right: 240px; top: 540px; height: 260px; }
.lane { position: absolute; left: 0; right: 0; height: 64px; }
.lane.l1 { top: 30px; } .lane.l2 { top: 150px; }
.lname { position: absolute; left: 0; top: -8px; font-weight: 600; font-size: 30px; color: var(--ink); letter-spacing: -0.01em; }
.track { position: absolute; left: 0; right: 0; top: 40px; height: 10px; }
.track::before { content: ''; position: absolute; left: 0; right: 0; top: 4px; height: 2px; background: rgba(29,29,31,.08); border-radius: 2px; }
.bar { position: absolute; left: 0; top: -2px; height: 14px; width: 0; border-radius: 6px; background: var(--ink); }
.l1 .bar { transition: width 2.4s cubic-bezier(.2,.7,.2,1) .6s; }
.race.on .l1 .bar { width: 10.3%; }
.l2 .bar { background: linear-gradient(90deg, #1D1D1F 0, #1D1D1F 74%, rgba(29,29,31,0) 100%); transition: width 3.6s cubic-bezier(.35,.1,.25,1) .1s; }
.race.on .l2.on .bar { width: 100%; }
.end { position: absolute; top: -40px; font-weight: 600; font-size: 30px; color: var(--ink); white-space: nowrap; opacity: 0; transition: opacity .6s var(--ease); }
.l1 .end { left: calc(10.3% + 20px); top: -12px; font-variant-numeric: tabular-nums; }
.race.on .l1 .end { opacity: 1; transition-delay: 2.9s; }
.l2 .end { right: 0; top: -46px; color: var(--sub-paper); font-weight: 500; }
.race.on .l2.on .end { opacity: 1; transition-delay: 3.3s; }
.axis { position: absolute; left: 0; top: 230px; font-size: 18px; color: var(--sub-paper); font-weight: 500; }
.axis::before { content: ''; position: absolute; left: 0; top: -232px; width: 1px; height: 226px; background: rgba(29,29,31,.14); }
.slide.inst .bar, #slides.inst .bar { transition: none !important; }
.reduced .bar, .still .bar, .reduced .end, .still .end { transition: none !important; }

/* ---------- A15 skyline labels */
.sky { position: absolute; inset: 0; }
.sky.off .tick { opacity: 0; filter: blur(8px); transition-duration: .5s; transition-delay: 0s !important; }
.tick { position: absolute; left: var(--x); top: 740px; width: 420px; margin-left: -210px; text-align: center; }
.tick b { display: block; font-weight: 650; font-size: 38px; letter-spacing: -0.03em; color: var(--white); }
.tick span { display: block; font-size: 24px; line-height: 1.35; color: var(--sub-dark); margin-top: 6px; }
.tick span + span { margin-top: 0; }

/* ---------- chrome outside the stage */
#embedNote { display: none; position: absolute; left: 40px; bottom: 30px; margin: 0; font-size: 16px; line-height: 1.45; color: var(--sub-dark); z-index: 3; }
#deck[data-slide="pixel"] #embedNote { display: block; }
#deck.embed #embedNote { display: block; }
#deck[data-theme="light"] #embedNote { color: var(--sub-paper); }

#hud { position: fixed; left: 0; right: 0; bottom: 18px; text-align: center; font: 500 13px/1 'Inter', sans-serif;
  color: var(--sub-dark); opacity: 0; transition: opacity .6s ease; pointer-events: none; font-variant-numeric: tabular-nums; z-index: 10; }
#deck[data-theme="light"] #hud { color: var(--sub-paper); }
#hud.show { opacity: 1; }
#deck.embed #hud, #deck.still #hud { display: none; }
#msg { position: fixed; left: 50%; top: 24px; translate: -50% 0; font: 500 13px 'Inter', sans-serif; color: var(--sub-dark);
  padding: 8px 14px; border-radius: 20px; background: rgba(128,128,128,.14); opacity: 0; transition: opacity .4s; pointer-events: none; z-index: 10; }
#msg.show { opacity: 1; }
#helpline { position: fixed; left: 0; right: 0; bottom: 44px; margin: 0; text-align: center; font: 400 14px 'Inter', sans-serif;
  color: var(--sub-dark); opacity: 0; transition: opacity .8s ease; pointer-events: none; z-index: 10; }
#helpline.show { opacity: 1; }
#hint { display: none; position: fixed; left: 0; right: 0; bottom: 18%; text-align: center; font: 500 15px 'Inter', sans-serif; color: var(--sub-dark); z-index: 10; }
#hint.show { display: block; }
#notes { position: fixed; right: 0; top: 0; bottom: 0; width: min(420px, 92vw); box-sizing: border-box; padding: 28px 28px 40px;
  background: rgba(22,22,24,.94); color: #f5f5f7; font: 400 14px/1.55 'Inter', sans-serif; overflow: auto;
  translate: 100% 0; transition: translate .5s var(--ease); z-index: 20; user-select: text; -webkit-user-select: text; }
#notes.show { translate: 0 0; }
#notes .nh { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #86868B; margin: 0 0 14px; }
#notes .nt { font-weight: 600; font-size: 17px; margin: 0 0 10px; }
#notes .nb { margin: 0; color: #d2d2d7; word-break: break-word; white-space: pre-wrap; }
#help { position: fixed; left: 50%; top: 50%; translate: -50% -50%; padding: 26px 32px; border-radius: 18px; z-index: 21;
  background: rgba(22,22,24,.94); color: #f5f5f7; font: 400 15px/1.5 'Inter', sans-serif; opacity: 0; pointer-events: none; transition: opacity .3s; }
#help.show { opacity: 1; pointer-events: auto; }
#help .hh { margin: 0 0 12px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #86868B; }
#help dl { display: grid; grid-template-columns: auto auto; gap: 6px 26px; margin: 0; }
#help dt { color: #86868B; } #help dd { margin: 0; }
#deck.embed #helpline, #deck.embed #notes, #deck.embed #help, #deck.still #helpline { display: none; }
.slide .notes { display: none; }

/* ---------- wow round: era labels, hint, drag */
.era { font-weight: 500; font-size: 30px; letter-spacing: -0.01em; color: var(--sub); }
.era.scrub { opacity: 0; transition: opacity .2s ease; }
.slide[data-scrub] .era.rv { opacity: 0 !important; filter: none; transition: opacity .2s ease; }
.slide[data-scrub="-1"] .era.scrub[data-era="-1"], .slide[data-scrub="0"] .era.scrub[data-era="0"],
.slide[data-scrub="1"] .era.scrub[data-era="1"], .slide[data-scrub="2"] .era.scrub[data-era="2"] { opacity: 1; }
.hint { font-size: 18px; color: #86868B; opacity: 0; transition: opacity .8s var(--ease); }
.hint.show { opacity: 1; }
#deck[data-slide="light"]:not(.embed):not(.still) { cursor: grab; }
#deck.dragging { cursor: grabbing !important; }
.reduced .slide[data-id="pixel"] .date { --y: 860px !important; }
/* slide 16: the full stop is the light (the glyph keeps its place, the light sits in it) */
#deck:not(.reduced):not(.nogl) .slide[data-id="one-more-thing"] .dot { color: transparent; }

/* ---------- phones: the 16:9 stage letterboxes to about 390 by 219, so the legal note leaves the
   scaled stage and becomes a fixed line at a legible size (title, cold open, last slide, embed) */
#legal { display: none; position: fixed; left: 16px; right: 16px; bottom: max(12px, env(safe-area-inset-bottom)); margin: 0; z-index: 30;
  padding: 6px 10px; border-radius: 8px; background: rgba(0, 0, 0, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font: 400 11px/1.45 'Inter', 'Helvetica Neue', Arial, sans-serif; letter-spacing: 0; color: #D2D2D7; text-align: center; pointer-events: none; }
@media (max-width: 600px) {
  #deck[data-slide="pixel"] #legal, #deck[data-slide="title"] #legal, #deck[data-slide="end"] #legal, #deck.embed #legal { display: block; }
  #deck #embedNote, #deck .slide .disclaimer { visibility: hidden; }
}
/* a still is a finished frame: the ground never shows mid transition outside the stage */
#deck.still, #deck.still #ground { transition: none !important; }
/* phones (under 600 px wide): the WebGL stage stays fitted; only the small copy grows by --mob (set
   by the engine: 600 / viewport width, 1 to 2.4) and reflows inside the stage, so captions read */
@media (max-width: 600px) {
  #deck .ln.sub, #deck .ln.date, #deck .ln.era, #deck .ln.cite, #deck .ln.hint,
  #deck .ln.line:not(.big):not(.endline) { white-space: normal; left: 40px; right: 40px; }
  #deck .ln.sub { font-size: calc(40px * var(--mob, 1)); }
  #deck .ln.date { font-size: calc(28px * var(--mob, 1)); }
  #deck .ln.era { font-size: calc(30px * var(--mob, 1)); }
  #deck .ln.cite { font-size: calc(26px * var(--mob, 1)); }
  #deck .ln.hint { font-size: calc(18px * var(--mob, 1)); }
  #deck .ln.line:not(.big):not(.endline) { font-size: calc(64px * var(--mob, 1)); }
  #deck .tick span { font-size: calc(24px * var(--mob, 1)); }
  #deck .tick { width: 520px; margin-left: -260px; }
  /* keep stacks apart as they grow: a sub keeps its top edge, a soft line under it moves down by the
     sub's growth as well as its own, a date above a word keeps its bottom edge */
  #deck .ln.sub:not(.soft) { top: calc(var(--y) + (var(--mob, 1) - 1) * 22px); }
  #deck .ln.sub.soft { top: calc(var(--y) + (var(--mob, 1) - 1) * 72px); }
  #deck .ln.date { top: calc(var(--y) - (var(--mob, 1) - 1) * 16px); }
}
