/* ==========================================================================
   Hero: full-bleed paper diorama with the logo set into it
   ========================================================================== */

.hero {
  position: relative;
  height: 100vh;
  height: 100svh;
  min-height: 640px;
  max-height: 1200px;
  overflow: hidden;
  isolation: isolate;
  background: var(--c-night);
  display: grid;
  align-items: center;
}

/* Scene ------------------------------------------------------------------ */

.hero__scene {
  position: absolute;
  inset: 0;
  z-index: var(--z-scene);
  transform-origin: 62% 70%;
}

/* Every paper sheet is its own composited layer, so its shadow is drawn once
   and parallax only moves a texture (cheap). */
.paper-layer {
  position: absolute;
  inset: -5% -5% -4% -5%;
  will-change: transform;
  pointer-events: none;
}
.paper-layer > svg { width: 100%; height: 100%; overflow: visible; }

/* Cut-paper separation: soft dark halo where a sheet sits over the one behind */
.paper-layer--cast { filter: drop-shadow(0 -3px 10px rgba(10, 6, 3, 0.55)); }
.paper-layer--cast-deep { filter: drop-shadow(0 -6px 22px rgba(8, 5, 3, 0.7)); }

/* Light: beams and glow blend onto the paper, they don't paint over it */
.scene-light {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  will-change: opacity, transform;
}
.scene-beam {
  position: absolute;
  top: -20%;
  width: 9vw;
  height: 150%;
  transform-origin: 50% 0;
  background: linear-gradient(to bottom, rgba(244, 217, 160, 0.22), rgba(244, 217, 160, 0.06) 55%, transparent 80%);
  filter: blur(14px);
  opacity: 0;
}

.scene-dust {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  mix-blend-mode: screen;
}

/* Paper grain over everything in the scene */
.hero__scene::after {
  content: "";
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: 0.13;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 0.92  0 0 0 0 0.78  0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 0.9s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  33% { transform: translate(-3%, 2%); }
  66% { transform: translate(2%, -3%); }
  100% { transform: translate(0, 0); }
}

/* Keeps the logo and copy readable where they overlap the scene.
   --shade is a registered colour so it can fade between dark and light styles. */
@property --shade {
  syntax: "<color>";
  inherits: true;
  initial-value: rgb(18 13 10);
}
.hero__scene { --shade: rgb(18 13 10); transition: --shade 0.8s var(--ease-out); }
.hero__scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 18% 55%, color-mix(in srgb, var(--shade) 62%, transparent) 0%, color-mix(in srgb, var(--shade) 25%, transparent) 45%, transparent 70%),
    radial-gradient(140% 100% at 50% 50%, transparent 60%, color-mix(in srgb, var(--shade) 55%, transparent) 100%);
}

/* Content ---------------------------------------------------------------- */

.hero__content {
  position: relative;
  z-index: var(--z-content);
  padding-top: 4.75rem;
}

.hero__logo {
  font-family: var(--font-display);
  font-size: var(--step-display);
  font-weight: 600;
  font-variation-settings: "wdth" 100, "opsz" 96;
  line-height: 0.86;
  letter-spacing: -0.05em;
  color: var(--c-ember);   /* the logo's original orange */
  margin-left: -0.06em;
}
.hero__logo-line { display: block; }

.hero__title {
  margin-top: clamp(1.5rem, 3.5vh, 2.5rem);
  font-size: var(--step-2);
  font-weight: 500;
  white-space: nowrap;   /* one line where it fits; phones get a balanced break below */
}

.hero__lede {
  margin-top: var(--space-s);
  max-width: 36ch;
  color: var(--c-champagne-soft);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s);
  margin-top: var(--space-xl);
}

/* Style selector: text options with a progress line under the active one */
.hero__styles {
  position: absolute;
  z-index: var(--z-content);
  right: var(--gutter);
  bottom: clamp(1.25rem, 4.5vh, 2.75rem);
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: auto;   /* pause button sizes to itself */
  grid-auto-columns: 1fr;        /* every style option (and its bar) the same width */
  align-items: center;
  gap: var(--space-l);
}

/* Pause / play */
.hero-pause {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--c-line-strong);
  background: rgba(18, 13, 10, 0.35);
  color: #FFF3DC;
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), color 0.6s var(--ease-out);
}
.hero-pause:hover { border-color: #FFF3DC; }
.hero-pause__icon { width: 14px; height: 14px; fill: currentColor; }
.hero-pause__icon--play { display: none; }
.hero-pause[aria-pressed="true"] .hero-pause__icon--pause { display: none; }
.hero-pause[aria-pressed="true"] .hero-pause__icon--play { display: block; }
.hero.is-paused .hero__scene::after { animation-play-state: paused; }
[data-hero-tone="light"] .hero-pause { color: #1E1B18; border-color: rgba(30, 27, 24, 0.35); background: rgba(246, 241, 231, 0.6); }
/* Placed by script: stays at the bottom, centred under the captions */
.hero__styles.is-anchored { right: auto; }
.style-option {
  display: grid;
  gap: 0.5rem;
  min-height: 44px;
  align-content: center;
  padding: 0;
  background: none;
  border: 0;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  color: var(--c-champagne-soft);
  text-shadow: 0 1px 2px rgba(10, 6, 3, 0.9), 0 0 14px rgba(10, 6, 3, 0.75);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}
.style-option:hover,
.style-option[aria-pressed="true"] { color: #FFF3DC; }
.style-option__track {
  position: relative;
  height: 2px;
  border-radius: 2px;
  background: rgba(244, 217, 160, 0.28);
  box-shadow: 0 1px 3px rgba(10, 6, 3, 0.7);
  overflow: hidden;
}
.style-option[aria-pressed="true"] .style-option__track { background: rgba(244, 217, 160, 0.4); }
.style-option__bar {
  position: absolute;
  inset: 0;
  background: #FFB866;
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* Stages: one per mounted style (two during a cross-fade) */
.hero__stage { position: absolute; inset: 0; }

/* Pixel style: low-res canvas scaled up with crisp pixels */
.pixel-canvas {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Grain belongs to paper cut-out; other styles fade it out */
.hero__scene::after { transition: opacity 0.6s var(--ease-out); }
.hero__scene[data-grain="off"]::after { opacity: 0; }

/* Stick figure: full-resolution canvas */
.stick-canvas { width: 100%; height: 100%; }

/* Watercolour: inner wrapper that sways (clouds, mist) without re-filtering */
.wc-drift { position: absolute; inset: 0; will-change: transform; }
.wc-drift > svg { width: 100%; height: 100%; overflow: visible; }
.wc-bitmap { display: block; width: 100%; height: 100%; }

/* VHS: low-res frame scaled up soft, fine scanlines and the tape HUD on top */
.vhs-canvas { width: 100%; height: 100%; }
.vhs-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0, rgba(0, 0, 0, 0.28) 1px, transparent 1px, transparent 3px);
}
.vhs-hud {
  position: absolute;
  z-index: 46;
  top: 6.25rem;
  right: var(--gutter);
  display: grid;
  justify-items: end;
  gap: 0.2rem;
  font-family: ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #E8EEDF;
  text-shadow: 2px 0 rgba(255, 40, 80, 0.55), -2px 0 rgba(40, 200, 255, 0.55), 0 0 8px rgba(232, 238, 223, 0.45);
  pointer-events: none;
}
@media (max-width: 760px) {
  /* One line under the nav so it clears the logo; the date is dropped */
  .vhs-hud { top: 4.85rem; font-size: 0.72rem; grid-auto-flow: column; gap: 0.9rem; }
  .vhs-hud span:last-child { display: none; }
  /* Watercolour branch would sit behind the copy on phones */
  .wc-layer--branch { display: none; }
}

/* Paper texture for the light styles, multiplied over the drawing */
.paper-texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: 0.5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='300' height='300'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.45  0 0 0 0 0.41  0 0 0 0 0.36  0 0 0 0.22 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
}
.paper-texture--cold-press {
  opacity: 0.65;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='360' height='360'><filter id='c'><feTurbulence type='fractalNoise' baseFrequency='0.035 0.05' numOctaves='4' seed='7' stitchTiles='stitch'/><feDiffuseLighting lighting-color='%23ffffff' surfaceScale='1.6'><feDistantLight azimuth='45' elevation='58'/></feDiffuseLighting><feColorMatrix values='0.32 0 0 0 0.68  0.32 0 0 0 0.66  0.32 0 0 0 0.62  0 0 0 0 1'/></filter><rect width='100%' height='100%' filter='url(%23c)'/></svg>");
}

/* Captions: a few words at a time, the way users' shorts are captioned.
   Sits above the vignette so it stays bright. */
.caption-layer { z-index: 45; }
.scene-caption {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 31px;
  letter-spacing: -0.01em;
  fill: #FFF3DC;
  stroke: #120D0A;
  stroke-width: 6px;
  stroke-linejoin: round;
  paint-order: stroke;
}

/* Intro starting states (only when JS runs). A timed fallback reveals them
   if the animation library never arrives. */
.js .hero__logo-line,
.js .hero__title,
.js .hero__lede,
.js .hero__actions,
.js .hero-pause,
.js .style-option {
  opacity: 0;
  animation: hero-fallback 0.6s var(--ease-out) 2.5s forwards;
}
.anim-on .hero__logo-line,
.anim-on .hero__title,
.anim-on .hero__lede,
.anim-on .hero__actions,
.anim-on .hero-pause,
.anim-on .style-option { animation: none; }

@keyframes hero-fallback { to { opacity: 1; } }

/* Small screens: copy sits higher, scene reads below it */
@media (max-width: 760px) {
  .hero { align-items: start; }
  .hero__content { padding-top: 7.5rem; }
  .hero__logo { font-size: clamp(4.5rem, 27vw, 8.5rem); }
  .hero__title { white-space: normal; text-wrap: balance; }
  .hero__scene::before {
    background:
      linear-gradient(to bottom, color-mix(in srgb, var(--shade) 70%, transparent) 0%, color-mix(in srgb, var(--shade) 35%, transparent) 50%, transparent 75%),
      radial-gradient(140% 100% at 50% 50%, transparent 60%, color-mix(in srgb, var(--shade) 50%, transparent) 100%);
  }
  .hero__styles { right: auto; left: var(--gutter); }
  /* Four options: span the width instead of centring under the captions */
  .hero__styles.is-anchored { left: var(--gutter) !important; right: var(--gutter); gap: 0.5rem; grid-template-columns: 40px; grid-auto-columns: minmax(0, 1fr); }
  .hero-pause { width: 40px; height: 40px; }
  .style-option { font-size: 0.74rem; white-space: normal; line-height: 1.15; align-content: end; }
}

@media (prefers-reduced-motion: reduce) {
  .hero__scene::after { animation: none; }
}

/* Tone ------------------------------------------------------------------------
   Light styles (stick figure, watercolour) switch the hero text and nav to dark
   ink, fading with the background. Set on <body> by main.js. */

.wordmark, .site-nav__links, .site-nav__login,
.hero__logo, .hero__title, .hero__lede, .style-option {
  transition: color 0.6s var(--ease-out), text-shadow 0.6s var(--ease-out);
}
.hero .btn--quiet {
  transition: color 0.6s var(--ease-out), border-color 0.6s var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

[data-hero-tone="light"] .hero__scene { --shade: rgb(246 241 231); }
[data-hero-tone="light"] .wordmark,
[data-hero-tone="light"] .hero__title { color: #1E1B18; }
[data-hero-tone="light"] .site-nav__links,
[data-hero-tone="light"] .site-nav__login,
[data-hero-tone="light"] .hero__lede { color: #4A423A; }
[data-hero-tone="light"] .site-nav__links a:hover,
[data-hero-tone="light"] .site-nav__login:hover { color: #1E1B18; }
[data-hero-tone="light"] .hero .btn--quiet { color: #1E1B18; border-color: rgba(30, 27, 24, 0.35); }
[data-hero-tone="light"] .hero .btn--quiet:hover { border-color: #1E1B18; }
[data-hero-tone="light"] .hero :focus-visible,
[data-hero-tone="light"] .site-nav :focus-visible { outline-color: #1E1B18; }

[data-hero-tone="light"] .style-option { color: #5A5148; text-shadow: 0 0 10px rgba(246, 241, 231, 0.95), 0 0 2px rgba(246, 241, 231, 0.9); }
[data-hero-tone="light"] .style-option:hover,
[data-hero-tone="light"] .style-option[aria-pressed="true"] { color: #1E1B18; }
[data-hero-tone="light"] .style-option__track { background: rgba(30, 27, 24, 0.18); box-shadow: none; }
[data-hero-tone="light"] .style-option[aria-pressed="true"] .style-option__track { background: rgba(30, 27, 24, 0.28); }

/* Per-style logo and accent */
[data-hero-style="vhs"] .hero__logo { text-shadow: 2px 0 rgba(255, 40, 80, 0.35), -2px 0 rgba(40, 200, 255, 0.35); }
[data-hero-style="stick"] .hero__logo { color: #1E1B18; }
[data-hero-style="stick"] .style-option__bar { background: #1E1B18; }
[data-hero-style="watercolour"] .hero__logo { color: #C8321F; }
[data-hero-style="watercolour"] .style-option__bar { background: #C8321F; }

/* Toon 3D, Paper and Pixel: a thin dark outline keeps the hero text readable over the bright, busy scenes */
body[data-hero-style="toon3d"] .hero__logo-line,
body[data-hero-style="paper"] .hero__logo-line,
body[data-hero-style="pixel"] .hero__logo-line {   /* a ring of tight shadows: follows only the outer edge of each letter */
  text-shadow: 2px 0 0 #1A1410, -2px 0 0 #1A1410, 0 2px 0 #1A1410, 0 -2px 0 #1A1410,
    1.5px 1.5px 0 #1A1410, -1.5px 1.5px 0 #1A1410, 1.5px -1.5px 0 #1A1410, -1.5px -1.5px 0 #1A1410, 0 3px 6px rgba(18, 13, 10, 0.6);
}
body[data-hero-style="toon3d"] .hero__title,
body[data-hero-style="toon3d"] .hero__lede,
body[data-hero-style="toon3d"] .site-nav a,
body[data-hero-style="toon3d"] .style-option,
body[data-hero-style="paper"] .hero__title,
body[data-hero-style="paper"] .hero__lede,
body[data-hero-style="paper"] .site-nav a,
body[data-hero-style="paper"] .style-option,
body[data-hero-style="pixel"] .hero__title,
body[data-hero-style="pixel"] .hero__lede,
body[data-hero-style="pixel"] .site-nav a,
body[data-hero-style="pixel"] .style-option {
  text-shadow: 1px 0 0 #1A1410, -1px 0 0 #1A1410, 0 1px 0 #1A1410, 0 -1px 0 #1A1410, 0 1px 3px rgba(18, 13, 10, 0.85);
}

/* Buttons keep clean text: no outline on "Start free" (the rules above outline every link in the top bar) */
body[data-hero-style] .site-nav .btn,
body[data-hero-style] .hero .btn {
  text-shadow: none;
}

/* The top-left wordmark is the same orange as the big logo */
.site-nav .wordmark { color: var(--c-ember); }
