:root {
  --bg: #282C34;
  --fg: #ECEAE4;
  --muted: #A9AFBA;
  --red: #E06C75;
  --yellow: #E5C07B;
  --green: #98C379;
  --blue: #61AFEF;
  --purple: #C678DD;
  --cyan: #56B6C2;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --serif: 'Iowan Old Style', Georgia, serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
}

* { box-sizing: border-box; margin: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 300;
}

body.idle { cursor: none; }

img { display: block; }
h1 { font-weight: 300; line-height: 1.15; }

/* 1920×1080 canvas, scaled to fit by app.js */
.stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  transition: opacity 300ms ease;
}
body.black .stage { opacity: 0; }

.slide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 128px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 0s 200ms;
}
.slide.active {
  opacity: 1;
  visibility: visible;
  transition: opacity 200ms ease;
}
.slide .notes { display: none; }

/* Going back shows the finished slide instead of replaying it */
.slide.settled, .slide.settled * { animation-duration: 0s !important; animation-delay: 0s !important; }
.slide.settled * { transition-duration: 0s !important; transition-delay: 0s !important; }

.row { display: flex; align-items: center; }

/* 1 · what is technology for? */

#question .title {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
  text-align: center;
}
#question h1 { font-size: 96px; }
.byline { font-size: 32px; color: var(--muted); }

.noise { position: absolute; inset: 0; }

.w {
  position: absolute;
  white-space: nowrap;
  line-height: 1;
  transform: rotate(var(--rot));
  transition: transform 400ms var(--ease-out);
}
.w span { display: inline-block; }
.active .w span { animation: pop 300ms var(--ease-out) var(--d) both, var(--ambient); }

/* Step 2: the noise drops away */
#question[data-step="1"] .w {
  transform: translate(var(--dx), 1400px) rotate(var(--spin));
  transition: transform var(--fall) var(--ease-in) var(--fall-delay);
}

.k-plain span { color: var(--muted); }
.k-outline span { color: transparent; -webkit-text-stroke: 2px var(--c); font-weight: 400; }
.k-glow span { color: var(--c); font-weight: 400; text-shadow: 0 0 28px color-mix(in srgb, var(--c) 55%, transparent); }
.k-badge span { padding: 0.18em 0.6em; border-radius: 999px; background: var(--c); color: var(--bg); font-weight: 400; }
.k-cutout span { padding: 0.12em 0.4em; background: var(--fg); color: var(--bg); font-family: var(--serif); font-style: italic; box-shadow: 6px 8px 0 rgba(0, 0, 0, 0.3); }
.k-mono span { color: var(--c); font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.12em; }
.k-photo img { display: block; object-fit: cover; border-radius: 6px; background: var(--muted); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45); }
.k-photo .book { border-radius: 2px 6px 6px 2px; }

.ticker {
  position: absolute;
  left: 0;
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 22px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0.7;
  transition: opacity 300ms ease;
}
.ticker.top { top: 0; border-bottom: 1px solid rgba(169, 175, 186, 0.2); }
.ticker.bottom { bottom: 0; border-top: 1px solid rgba(169, 175, 186, 0.2); }
.ticker div { animation: ticker 80s linear infinite; }
.ticker.bottom div { animation-direction: reverse; }
.active .ticker { animation: fade 400ms ease both; }
#question[data-step="1"] .ticker { opacity: 0; }

@keyframes pop { from { opacity: 0; transform: scale(0.9); } }
@keyframes bob { to { transform: translateY(-8px); } }
@keyframes wobble { from { transform: rotate(-2deg); } to { transform: rotate(2deg); } }
@keyframes flicker { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes ticker { to { transform: translateX(-50%); } }
@keyframes fade { from { opacity: 0; } }

/* 2 · the 99 and the 1 */

#myself .row { gap: 96px; }
.covers { display: flex; gap: 32px; }
.covers img {
  width: 360px;
  height: 546px;
  object-fit: cover;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
}
.line { display: flex; flex-direction: column; gap: 48px; }
#myself h1 { width: 800px; font-size: 72px; }
#myself mark { background: none; color: inherit; }
.word { display: inline-block; }

/* Filled by app.js: the ninety-nine graze together, the one warms with its words */
.flock { width: 800px; height: 200px; overflow: visible; }
.flock circle { fill: var(--muted); opacity: 0.55; }
.flock .one { opacity: 1; }

#myself.active .covers img { animation: rise 400ms var(--ease-out) both; }
#myself.active .covers img + img { animation-delay: 60ms; }
#myself.active .word { animation: rise 400ms var(--ease-out) calc(100ms + var(--i) * 40ms) both; }
#myself.active mark { animation: warm 500ms ease 1000ms both; }
#myself.active .flock circle { animation: fade 400ms ease calc(300ms + var(--d)) both, graze var(--graze) ease-in-out calc(1000ms + var(--d)) infinite alternate; }
#myself.active .flock .one { animation: fade 400ms ease 1000ms both, found 500ms ease 1000ms both; }

@keyframes rise { from { opacity: 0; transform: translateY(24px); } }
@keyframes warm { to { color: var(--yellow); } }
@keyframes graze { to { transform: translate(var(--gx), var(--gy)); } }
@keyframes found { to { fill: var(--yellow); filter: drop-shadow(0 0 10px var(--yellow)); } }

/* 3 · walk */

#walk .row { gap: 64px; }
.frame { width: 618px; height: 824px; overflow: hidden; }
.frame img { width: 100%; height: 100%; object-fit: cover; }
.tweet { width: 982px; height: 382px; object-fit: contain; border-radius: 16px; }

#walk.active .frame { animation: fade 300ms ease both; }
#walk.active .frame img { animation: settle 9s var(--ease-out) both; }
#walk.active .tweet { animation: post 400ms var(--ease-out) 200ms both; }

@keyframes settle { from { transform: scale(1.08); } }
@keyframes post { from { opacity: 0; transform: translateY(32px) scale(0.97); } }

/* Step 2: every walk since, drawing itself */
#walk .row { transition: opacity 250ms ease; }
#walk[data-step="1"] .row { opacity: 0; }
.walks {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(8, 176px);
  gap: 48px;
  place-content: center;
  opacity: 0;
}
.walks svg { width: 176px; height: 176px; overflow: visible; }
.walks path { fill: none; stroke: var(--yellow); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
#walk[data-step="1"] .walks { opacity: 1; }
#walk[data-step="1"] .walks path {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1000ms var(--ease-in-out) calc(150ms + var(--i) * 40ms);
}

/* 4 · train */

#train { flex-direction: column; gap: 40px; padding: 0; --ride: 20s; }

.route { position: relative; }
.route svg { display: block; overflow: visible; }
.rail, .ridden { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.rail { stroke: rgba(169, 175, 186, 0.25); }
.ridden { stroke: var(--red); stroke-dasharray: 1; }
.route circle { fill: var(--bg); stroke: var(--muted); stroke-width: 3; }
.route text { fill: var(--muted); font-size: 24px; }
.train {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--red) 25%, transparent);
  offset-rotate: 0deg;
  offset-distance: 100%;
}
.trip { position: absolute; right: 20px; bottom: 0; text-align: right; }
.trip h1 { font-family: var(--serif); font-size: 64px; font-weight: 700; letter-spacing: 1px; line-height: 1; }
.trip p { margin-top: 12px; color: var(--muted); font-family: var(--mono); font-size: 20px; letter-spacing: 2px; }

/* The trip's photos pass behind four lounge-car windows */
.view { position: relative; width: 1744px; height: 540px; overflow: hidden; }
.strip { display: flex; height: 100%; margin-left: -24px; }
.strip img { flex: none; width: 448px; height: 100%; object-fit: cover; }
.wall { position: absolute; inset: 0; }
.wall > rect { fill: var(--bg); }

/* Keyframes come from app.js, keyed to where each photo was taken */
#train.active .strip { animation: ride-strip var(--ride) linear 200ms both; }
#train.active .train { animation: ride-train var(--ride) linear 200ms both; }
#train.active .ridden { animation: ride-line var(--ride) linear 200ms both; }

/* Steps 2–3: Maja's posts from the same ride */
.quote p { font-family: var(--serif); font-size: 52px; line-height: 1.25; }
.quote cite { display: block; margin-top: 24px; color: var(--muted); font-family: var(--mono); font-size: 22px; font-style: normal; letter-spacing: 1px; }

.route > * { transition: opacity 250ms ease; }
.route .quote { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 20px; opacity: 0; }
#train:not([data-step="0"]) .route > :not(.quote) { opacity: 0; }
#train:not([data-step="0"]) .route .quote { opacity: 1; }

.panes { position: absolute; inset: 0; display: flex; gap: 48px; }
.panes img { flex: none; width: 400px; height: 100%; object-fit: cover; opacity: 0; transition: opacity 350ms ease; }
.panes img:nth-child(2) { transition-delay: 60ms; }
.panes img:nth-child(3) { transition-delay: 120ms; }
.panes img:nth-child(4) { transition-delay: 180ms; }
#train:not([data-step="0"]) .panes img { opacity: 1; }

.arrival { position: absolute; inset: 0; opacity: 0; transition: opacity 350ms ease; }
.arrival img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.06); transition: transform 8s var(--ease-out); }
.arrival .quote {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 200px 160px 88px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
}
.arrival cite { color: rgba(236, 234, 228, 0.75); }
#train[data-step="2"] .arrival { opacity: 1; }
#train[data-step="2"] .arrival img { transform: none; }

/* 5 · notes off the printer */

#notes { padding: 0; }
/* Step 1: close on Maja's note. Step 2: pull back to every note from the ride */
.spread { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform-origin: 0 0; transform: translate(0, -796px) scale(4.5); transition: transform 1200ms var(--ease-in-out); }
#notes[data-step="1"] .spread { transform: none; }

@media (prefers-reduced-motion: reduce) {
  .stage *, .stage *::before { animation: none !important; transition: none !important; }
  #question[data-step="1"] .w { opacity: 0; }
}

/* Chapters along the bottom, sized by each slide's time budget */
.timeline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  display: flex;
  gap: 4px;
  height: 6px;
  background: rgba(0, 0, 0, 0.45);
}
.timeline span { position: relative; flex-basis: 0; background: rgba(169, 175, 186, 0.25); }
.timeline i {
  position: absolute;
  inset: 0;
  background: var(--fg);
  transform: scaleX(var(--fill, 0));
  transform-origin: left;
  transition: transform 400ms var(--ease-in-out);
}

.legend {
  position: fixed;
  left: 24px;
  bottom: 24px;
  z-index: 1;
  padding: 20px 24px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.6);
  color: var(--muted);
  font-size: 18px;
}
.legend dl { display: grid; grid-template-columns: auto auto; gap: 8px 24px; }
.legend dt { color: var(--fg); font-family: var(--mono); }

/* Presenter window (?notes) */

.presenter .stage { display: none; }
.presenter-view {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 24px;
  height: 100%;
  padding: 32px 40px;
}
.pv-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: var(--muted);
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.pv-time { color: var(--fg); font-size: 56px; cursor: pointer; }
.pv-time.waiting { color: var(--muted); }
.pv-time.soon { color: var(--yellow); }
.pv-time.over { color: var(--red); }
.pv-notes { overflow: auto; font-size: 30px; line-height: 1.4; white-space: pre-wrap; }
.pv-next { color: var(--muted); font-size: 22px; }
.presenter-view .timeline { position: relative; height: 10px; margin-bottom: 32px; }
.presenter-view .timeline span::after {
  content: attr(data-budget);
  position: absolute;
  top: 18px;
  left: 0;
  color: var(--muted);
  font-size: 18px;
}
.presenter-view .now { position: absolute; top: -8px; bottom: -8px; width: 3px; background: var(--yellow); transition: left 250ms linear; }
