:root {
  --night: #0e1a24;
  --night-deep: #08121a;
  --snow: #eaf0f3;
  --ink: #13212b;
  --on-night: #e6edf1;
  --muted-night: #9db0bd;
  --muted-snow: #4d606d;
  --rule-night: #243746;
  --rule-snow: #c9d6de;
  --gold: #d9a53f;
  --gold-deep: #8a6213;
  --live: #7fc08a;
  --trouble: #d9785f;

  --display: "Young Serif", "Iowan Old Style", Georgia, serif;
  --body: "Hanken Grotesk", "Segoe UI", system-ui, sans-serif;

  --edge: clamp(20px, 5vw, 72px);
  --chapter: clamp(88px, 13vw, 176px);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--night);
  color: var(--on-night);
  font: 400 17px/1.6 var(--body);
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p, dl, dd, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
a { color: inherit; }
img, video, canvas { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
[hidden] { display: none !important; }

h1, h2 { font-family: var(--display); font-weight: 400; line-height: 1.02; letter-spacing: -0.015em; text-wrap: balance; }
h2 { font-size: clamp(34px, 5.2vw, 72px); }
h3 { font: 800 21px/1.25 var(--body); }

/* ---------- actions ---------- */
.go {
  display: inline-block;
  padding: 15px 26px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--gold);
  color: #1b1403;
  font: 800 17px/1.2 var(--body);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 140ms ease-out, transform 140ms ease-out;
}
.go:hover { background: #e8b958; }
.go:active { transform: translateY(1px); }
.quiet {
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
  transition: text-decoration-color 140ms ease-out;
}
.quiet:hover { text-decoration-color: var(--gold); }

/* ---------- top bar ---------- */
.bar {
  position: fixed; inset: 0 0 auto 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  padding: 16px var(--edge);
  transition: background-color 180ms ease-out;
}
.bar.scrolled { background: var(--night-deep); }
.bar-name { display: flex; align-items: center; gap: 10px; font: 400 22px/1 var(--display); text-decoration: none; margin-right: auto; }
.bar-name img { display: block; border-radius: 50%; }
.bar-links { display: flex; gap: 26px; }
.bar-links a { font-weight: 600; font-size: 15px; text-decoration: none; color: var(--muted-night); transition: color 140ms ease-out; }
.bar-links a:hover { color: var(--on-night); }
.bar-ca {
  padding: 8px 14px; border: 1px solid var(--rule-night); border-radius: 4px;
  background: transparent; color: var(--muted-night);
  font: 600 14px/1.2 var(--body); cursor: pointer;
  transition: border-color 140ms ease-out, color 140ms ease-out;
}
.bar-ca.has-ca { color: var(--on-night); font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 400; }
.bar-ca:hover { border-color: var(--gold); color: var(--on-night); }

/* ---------- 1. the coin ---------- */
.stage { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: pan-y; }
.open {
  position: relative;
  min-height: 100svh;
  background: var(--night-deep);
  display: flex; align-items: flex-end;
  overflow: hidden;
}
.open::before {
  content: ""; position: absolute; inset: -40px;
  background: url(assets/forest.jpg) center 62% / cover;
  filter: blur(18px) brightness(.5) saturate(.85);
}
.open::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(8,18,26,.82) 0%, rgba(8,18,26,.35) 48%, rgba(8,18,26,0) 70%), linear-gradient(0deg, rgba(8,18,26,.75) 0%, rgba(8,18,26,0) 30%);
}
#open-stage { cursor: grab; z-index: 1; }
#open-stage.grabbing { cursor: grabbing; }
.open-copy {
  position: relative; z-index: 2;
  width: min(100%, 39rem);
  padding: 0 var(--edge) clamp(40px, 8vh, 96px);
  pointer-events: none;
}
.open-copy a { pointer-events: auto; }
.open h1 { font-size: clamp(64px, 11.5vw, 168px); margin-left: -0.04em; }
.open-line { margin-top: 22px; font-size: clamp(18px, 1.5vw, 21px); line-height: 1.5; max-width: 31rem; }
.open-act { margin-top: 30px; display: flex; flex-wrap: wrap; align-items: center; gap: 18px 28px; }

/* ---------- 2. the bear ---------- */
.polar { background: var(--snow); color: var(--ink); }
.film { position: relative; background: #000; }
.film-v { width: 100%; height: min(92svh, 56.25vw); object-fit: cover; }
.film-toggle {
  position: absolute; right: var(--edge); bottom: 20px;
  padding: 8px 12px; border: 1px solid rgba(255,255,255,.5); border-radius: 4px;
  background: rgba(8,18,26,.72); color: #fff;
  font: 600 14px/1.2 var(--body); cursor: pointer;
}
.film-toggle:hover { border-color: #fff; }
/* the narrated film */
.reel { position: relative; background: var(--night-deep); color: var(--on-night); }
.reel-screen { position: relative; background: #000; }
/* a full screen on wide windows, a square on tall ones (a taller frame would crop the cubs out) */
.reel-stage { position: relative; height: min(100svh, 100vw); overflow: hidden; cursor: pointer; }
.reel-pic, .reel-clip { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.reel-pic, .reel-clip { opacity: 0; transition: opacity 600ms ease-out; }
.reel-pic { will-change: transform, opacity; }
.reel-pic.on, .reel-clip.on { opacity: 1; }
.reel-start {
  position: absolute; inset: 0; width: 100%;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 8px;
  padding: 0 var(--edge) clamp(28px, 6vh, 64px);
  border: 0; background: linear-gradient(0deg, rgba(8,18,26,.78) 0%, rgba(8,18,26,0) 55%);
  color: #fff; text-align: left; cursor: pointer;
}
.reel-start-go {
  padding: 15px 26px 16px; border-radius: 999px;
  background: var(--gold); color: #1b1403; font: 800 17px/1.2 var(--body);
  transition: background-color 140ms ease-out;
}
.reel-start:hover .reel-start-go { background: #e8b958; }
.reel-start-note { font-size: 15px; }
/* the controls sit on the bottom edge of the picture */
.reel-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 2;
  display: flex; align-items: center; gap: 18px; padding: 44px var(--edge) 16px;
  background: linear-gradient(0deg, rgba(8,18,26,.82) 0%, rgba(8,18,26,0) 100%);
}
.reel-bar[hidden] { display: none; }
.reel-bar button { border: 0; background: none; color: inherit; font: 600 15px/1.2 var(--body); cursor: pointer; padding: 6px 0; }
.reel-toggle { min-width: 3.4rem; text-align: left; }
.reel-steps { flex: 1; display: flex; gap: 6px; }
.reel-steps button { flex: 1; padding: 10px 0; }
.reel-steps i { display: block; height: 3px; background: var(--gold); transform: scaleX(0); transform-origin: left; }
.reel-steps button { position: relative; }
.reel-steps button::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 3px; background: rgba(255,255,255,.3); }
.reel-steps i { position: relative; }
.reel-steps .done i { transform: scaleX(1) !important; }
.reel-again { color: rgba(255,255,255,.78) !important; }
/* the narrator's words are not shown; they stay in the page for screen readers and for the player, which reads its scenes from them */
.reel-lines { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.polar-copy {
  padding: var(--chapter) var(--edge);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: clamp(28px, 5vw, 88px);
}
/* Polar himself, cut out of his footage by js/polar.js, standing on the page beside the words */
.polar-bear { position: relative; width: clamp(240px, 32vw, 470px); margin: 0 clamp(0px, 5vw, 96px) 0 0; opacity: 0; transition: opacity 400ms ease-out; }
.polar-bear.on { opacity: 1; }
.polar-bear::before {
  content: ""; position: absolute; left: 6%; right: 6%; bottom: 0; height: 10%;
  background: radial-gradient(closest-side, rgba(19,33,43,.3), rgba(19,33,43,0));
}
.polar-bear-film { position: relative; display: block; width: 100%; height: auto; }
.polar-copy h2 { max-width: 15ch; }
.polar-lead { margin-top: clamp(28px, 4vw, 48px); max-width: 38rem; font-size: 21px; line-height: 1.5; }
.aside {
  margin-top: 40px; padding-top: 18px; max-width: 36rem;
  border-top: 1px solid var(--rule-snow);
  font-size: 15px; color: var(--muted-snow);
}

/* ---------- 3. the tree ---------- */
.tree {
  position: relative;
  min-height: 100svh;
  background: var(--night-deep);
  display: flex; align-items: flex-end;
  overflow: hidden;
}
.tree::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(90deg, rgba(8,18,26,.88) 0%, rgba(8,18,26,.6) 26%, rgba(8,18,26,0) 52%); }
#tree-stage { cursor: grab; }
#tree-stage.grabbing { cursor: grabbing; }
.tree-copy {
  position: relative; z-index: 1;
  width: min(100%, 31rem);
  padding: 0 var(--edge) clamp(36px, 7vh, 80px);
  pointer-events: none;
}
.tree-copy h2 { font-size: clamp(30px, 3.6vw, 52px); }
.tree-copy > p { margin-top: 18px; }
.tree-facts { margin-top: 26px; border-top: 1px solid var(--rule-night); }
.tree-facts div { display: flex; justify-content: space-between; gap: 20px; padding: 10px 0; border-bottom: 1px solid var(--rule-night); }
.tree-facts dt { color: var(--muted-night); }
.tree-facts dd { font-weight: 600; text-align: right; }
.tree-hint { margin-top: 16px; font-size: 15px; color: var(--muted-night); }

/* ---------- 4. the money ---------- */
.money { padding: var(--chapter) var(--edge); }
.money-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 16px 40px; }
.money-head h2 { max-width: 16ch; }
.live { font-weight: 600; font-size: 15px; color: var(--live); }
.live.is-idle { color: var(--muted-night); }
.live.is-error { color: var(--trouble); }

.total { position: relative; margin-top: clamp(48px, 7vw, 104px); }
.total-label { color: var(--muted-night); }
.total-usd { font: 800 clamp(72px, 15vw, 232px)/0.95 var(--body); letter-spacing: -0.04em; color: var(--gold); margin-left: -0.05em; }
.total-sol { margin-top: 10px; font-size: 21px; }
.total-lock { margin-top: 14px; max-width: 34rem; color: var(--muted-night); }
.total-pop {
  position: absolute; left: 0; top: -8px;
  font: 800 28px/1 var(--body); color: var(--live);
  animation: pop 2.6s ease-out forwards; pointer-events: none;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px); } 12% { opacity: 1; } 70% { opacity: 1; } to { opacity: 0; transform: translateY(-34px); } }

.path { margin-top: clamp(48px, 6vw, 88px); counter-reset: step; border-top: 1px solid var(--rule-night); }
.path li {
  counter-increment: step;
  display: grid; grid-template-columns: 3.4rem minmax(0, 5fr) minmax(0, 4fr); gap: 6px 28px;
  padding: 26px 0; border-bottom: 1px solid var(--rule-night);
}
.path li::before { content: counter(step); font: 400 34px/1 var(--display); color: var(--muted-night); grid-row: span 2; }
.path h3 { grid-column: 2; }
.path li > p:not(.path-n) { grid-column: 2; color: var(--muted-night); max-width: 34rem; }
.path-n { grid-column: 3; grid-row: 1 / span 2; align-self: center; text-align: right; }
.path-n b { display: block; font: 800 28px/1.1 var(--body); }
.path-n a { font-size: 15px; color: var(--muted-night); text-underline-offset: 4px; }
.path-n a:hover { color: var(--on-night); }
.path-n a.off { display: none; }

.money-note { margin-top: 30px; max-width: 40rem; color: var(--muted-night); }
.money-note b { color: var(--on-night); }
.market { margin-top: 40px; display: flex; flex-wrap: wrap; gap: 14px 56px; }
.market dt { font-size: 15px; color: var(--muted-night); }
.market dd { font: 800 21px/1.3 var(--body); }
.market .up { color: var(--live); }
.market .down { color: var(--trouble); }
.money-foot { margin-top: 28px; font-size: 15px; color: var(--muted-night); }

/* ---------- 5. the coin's details ---------- */
.coin { background: var(--snow); color: var(--ink); padding: var(--chapter) var(--edge); }
.coin-line { margin-top: 26px; max-width: 38rem; font-size: 21px; line-height: 1.5; }
.coin-facts { margin-top: 44px; max-width: 46rem; border-top: 1px solid var(--rule-snow); }
.coin-facts div { display: grid; grid-template-columns: 11rem 1fr; gap: 20px; padding: 14px 0; border-bottom: 1px solid var(--rule-snow); }
.coin-facts dt { color: var(--muted-snow); }
.coin-facts dd { font-weight: 600; }
.address { margin-top: 56px; max-width: 46rem; }
.address-label { color: var(--muted-snow); }
.address-value {
  display: block; margin-top: 8px; padding: 18px 20px;
  border: 1px solid var(--ink); border-radius: 4px;
  font: 600 21px/1.4 var(--body);
  overflow-wrap: anywhere;
}
.address-value.is-address { font: 400 clamp(15px, 2.1vw, 21px)/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; }
.address-act { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; }
.coin .go { background: var(--ink); color: var(--snow); }
.coin .go:hover { background: #22384a; }
.address-warn { margin-top: 20px; font-size: 15px; color: var(--muted-snow); max-width: 34rem; }

/* ---------- 6. small print ---------- */
.small { padding: 72px var(--edge) 56px; }
.small h2 { font-size: 28px; }
.small-links { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px 32px; }
.small-links a { text-underline-offset: 4px; }
.small p { margin-top: 26px; max-width: 54rem; font-size: 15px; color: var(--muted-night); }
.foot {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 32px;
  padding: 22px var(--edge) 30px; border-top: 1px solid var(--rule-night);
  font-size: 15px; color: var(--muted-night);
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 40;
  transform: translate(-50%, 12px);
  padding: 12px 18px; border-radius: 4px;
  background: var(--snow); color: var(--ink); font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- smaller screens ---------- */
@media (max-width: 860px) {
  .bar-links { display: none; }
  .polar-copy { grid-template-columns: 1fr; }
  .polar-bear { width: min(68vw, 300px); margin: 8px auto 0; }
  .open { align-items: flex-end; }
  .tree { display: block; min-height: 0; }
  .tree::after { display: none; }
  #tree-stage { position: relative; height: 74svh; }
  .tree-copy { width: 100%; padding-top: 28px; }
  .path li { grid-template-columns: 2.4rem minmax(0, 1fr); }
  .path-n { grid-column: 2; grid-row: auto; text-align: left; margin-top: 8px; }
  .coin-facts div { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .total-pop { animation: none; }
  * { transition-duration: 0ms !important; }
}
