/* Soft Substrate tokens - lifted from promo/DESIGN-SYSTEM.md (v1). */

:root {
  --substrate: #E8E5F1;
  --shadow-dark: #C8C3DD;
  --shadow-light: #FBFAFF;
  --ink: #2A2547;
  --body: #5C5776;
  --secondary: #6B6588;
  --muted: #9A94B0;
  --violet: #8A72C0;
  --blue: #5F82C6;
  --ghost: #DEDAEB;
  --divider: #D9D5E7;
  --grad: linear-gradient(135deg, #9079C8, #5F82C6);
  --font-head: "Space Grotesk", sans-serif;
  --font-body: "Hanken Grotesk", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

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

html, body {
  background: var(--substrate);
  overflow: hidden;
  width: 100%;
  height: 100%;
}

/* The stage is a fixed 1080x1350 composition, scaled to fit the window for
   preview; capture runs the window at exactly 1080x1350 so scale = 1. */
#stage {
  position: absolute;
  width: 1080px;
  height: 1350px;
  left: 50%;
  top: 50%;
  transform-origin: center center;
  background: var(--substrate);
  font-family: var(--font-body);
}

/* World card: raised neumorphic surface holding the canvas. */
#world-card {
  position: absolute;
  left: 60px;
  top: 84px;
  width: 960px;
  height: 960px;
  border-radius: 26px;
  background: var(--substrate);
  box-shadow: -14px -14px 30px var(--shadow-light), 14px 14px 30px var(--shadow-dark);
  overflow: hidden;
}

#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Split-screen labels (beat 2). */
.pool-chip {
  position: absolute;
  top: 26px;
  padding: 10px 22px;
  border-radius: 999px;
  background: var(--substrate);
  box-shadow: inset 4px 4px 9px var(--shadow-dark), inset -4px -4px 9px var(--shadow-light);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 17px;
  letter-spacing: 0.12em;
  color: var(--ink);
  opacity: 0;
  border-bottom: 3px solid var(--divider);   /* neutral until the reveal */
}
#chip-a.chip-real { border-bottom-color: #35B5A2; }
#chip-b.chip-copy { border-bottom-color: #E0526E; }
.chip-sub {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  color: var(--secondary);
}
.chip-sub:empty { display: none; }
#chip-a { left: 34px; }
#chip-b { right: 34px; }

/* Gauge: a pressed well with a gradient fill bar and a mono readout. */
#gauge {
  position: absolute;
  left: 60px;
  top: 1050px;
  width: 960px;
  border-radius: 22px;
  padding: 15px 28px 13px;
  background: var(--substrate);
  box-shadow: inset 6px 6px 14px var(--shadow-dark), inset -6px -6px 14px var(--shadow-light);
  opacity: 0;
}
/* Header row: the question on the left, the meter's source on the right. */
#gauge-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 20px;
}
#gauge-label {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
#gauge-source {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--violet);
  white-space: nowrap;
}
#gauge-row { display: flex; align-items: center; gap: 22px; margin-top: 26px; }
#gauge-track {
  position: relative;
  flex: 1;
  height: 14px;
  border-radius: 999px;
  background: var(--ghost);
  box-shadow: inset 3px 3px 6px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
}
#gauge-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0%;
  border-radius: 999px;
  background: var(--grad);
}
/* Coin-flip mid-line: the track spans 0-100%, and 50% is marked so "chance"
   reads as a half-full bar sitting on this line. */
#gauge-mid {
  position: absolute;
  left: calc(50% - 1px);
  top: -5px;
  width: 2px;
  height: 24px;
  border-radius: 2px;
  background: var(--muted);
  opacity: 0.85;
}
#gauge-scale #gauge-mid-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

/* Pinned reference marker: where the outside watcher landed (99%), held on
   the mind beats so the live needle reads against it instead of falling. */
#gauge-ref {
  position: absolute;
  top: -7px;
  width: 3px;
  height: 28px;
  border-radius: 2px;
  background: var(--blue);
  opacity: 0;
}
#gauge-ref-label {
  position: absolute;
  top: -24px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--blue);
  opacity: 0;
}
#gauge-value {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 30px;
  color: var(--ink);
  min-width: 92px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#gauge-legend {
  margin-top: 5px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.03em;
  color: var(--secondary);
}
#gauge-scale {
  position: relative;
  display: flex;
  justify-content: space-between;
  margin-top: 9px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Caption zone. */
#caption {
  position: absolute;
  left: 60px;
  right: 60px;
  top: 1108px;
  text-align: left;
}
#kicker {
  font-family: var(--font-mono);
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 10px;
}
#headline {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 44px;
  letter-spacing: -0.02em;
  line-height: 1.08;
  color: var(--ink);
}
#headline .grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
#subline {
  margin-top: 12px;
  font-size: 21px;
  line-height: 1.5;
  color: var(--body);
  max-width: 900px;
}

/* Closing card (beat 6): a full-stage overlay on the substrate. */
#endcard {
  position: absolute;
  inset: 0;
  background: var(--substrate);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  opacity: 0;
}
#endcard .glyph { margin-bottom: 44px; }
/* Crown-stage teal Blob, cropped from the sprite sheet at 8x. */
#endcard .blob-glyph {
  width: 208px;
  height: 208px;
  background: url("blob-spritesheet.png") no-repeat -624px -1040px;
  background-size: 832px 1248px;
  image-rendering: pixelated;
}
#end-headline {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 58px;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--ink);
  max-width: 800px;
}
/* One-glance recap of the arc: 99% -> 50% -> 73%, above the URL. */
#end-recap {
  display: flex;
  gap: 22px;
  margin-top: 40px;
  justify-content: center;
}
.recap-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 24px;
  border-radius: 18px;
  background: var(--substrate);
  box-shadow: inset 4px 4px 9px var(--shadow-dark), inset -4px -4px 9px var(--shadow-light);
}
.recap-pct {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 40px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.recap-label {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.05em;
  color: var(--secondary);
}
#end-url {
  margin-top: 34px;
  font-family: var(--font-mono);
  font-size: 18px;
  color: var(--blue);
}
#end-foot {
  position: absolute;
  bottom: 46px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--muted);
}

/* When any element carries data-fade, the player drives opacity by keyframe. */
.layer { will-change: opacity, transform; }

/* Transport bar (browser viewing only - hidden by the capture rig). */
#controls {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  width: min(560px, calc(100vw - 40px));
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--substrate);
  box-shadow: -8px -8px 18px var(--shadow-light), 8px 8px 18px var(--shadow-dark);
  z-index: 10;
}
#ctl-play {
  flex: none;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--substrate);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
}
#ctl-scrub {
  flex: 1;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: var(--ghost);
  box-shadow: inset 2px 2px 5px var(--shadow-dark), inset -2px -2px 5px var(--shadow-light);
  cursor: pointer;
}
#ctl-scrub::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--grad);
  box-shadow: 2px 2px 6px var(--shadow-dark);
}
#ctl-scrub::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: #8A72C0;
  box-shadow: 2px 2px 6px var(--shadow-dark);
}
#ctl-time {
  flex: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#ctl-views {
  flex: none;
  padding: 8px 16px;
  border: none;
  border-radius: 999px;
  background: var(--substrate);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--violet);
  cursor: pointer;
}

/* Overlay gallery: companion animations without leaving the player. */
#gallery {
  position: fixed;
  inset: 0;
  display: none;              /* flex when open */
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(232, 229, 241, 0.82);
  backdrop-filter: blur(6px);
  z-index: 20;
}
#gallery-panel {
  width: min(880px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 26px 30px 22px;
  border-radius: 26px;
  background: var(--substrate);
  box-shadow: -14px -14px 30px var(--shadow-light), 14px 14px 30px var(--shadow-dark);
}
#gallery-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
#gallery-title {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--violet);
}
#gallery-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--substrate);
  box-shadow: inset 3px 3px 7px var(--shadow-dark), inset -3px -3px 7px var(--shadow-light);
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}
#gallery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
@media (max-width: 720px) {
  #gallery-grid { grid-template-columns: 1fr; }
}
#gallery-grid video {
  display: block;
  width: 100%;
  border-radius: 14px;
  background: #12101F;
  box-shadow: 6px 6px 14px var(--shadow-dark), -6px -6px 14px var(--shadow-light);
}
#gallery-grid figcaption {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
  color: var(--secondary);
  margin-top: 10px;
}
#gallery-grid figcaption a {
  color: var(--accent, #8a72c0);
  text-decoration: none;
  border-bottom: 1px solid rgba(138, 114, 192, 0.35);
}
#gallery-grid figcaption a:hover { border-bottom-color: currentColor; }
#gallery-foot {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 24px;
}
#gallery-foot a {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--blue);
  text-decoration: none;
}
#gallery-foot a:hover { text-decoration: underline; }
