/* Pandora en la Isla de las Emociones — web
   Palette: canopy, moss, parchment, ink, morpho blue, mango.
   Type: Playfair Display (display) + Atkinson Hyperlegible (text).
   Scale: 1.25 from an 18px base. */

:root {
  --canopy: #0e2a24;
  --moss: #173a32;
  --parchment: #f4ecdb;
  --paper: #fbf7ee;
  --ink: #1b2a26;
  --ink-soft: #4a5b56;
  --morpho: #2f7fc1;
  --mango: #e9a23b;
  --line-dark: rgba(244, 236, 219, 0.18);
  --line-light: rgba(27, 42, 38, 0.16);

  --font-display: "Playfair Display", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-text: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;

  --step--1: 0.8rem;
  --step-0: 1.125rem;
  --step-1: 1.3rem;
  --step-2: 1.625rem;
  --step-3: 2.03rem;
  --step-4: 2.54rem;
  --step-5: clamp(2.6rem, 1.6rem + 4.2vw, 4.6rem);

  --wrap: min(72rem, 100% - 2.5rem);
  --measure: 36rem;
}

/* Other scripts (lang.js loads the Noto fonts). Each CJK language keeps to its own fonts,
   so Han characters get the right glyph shapes. */
/* Atkinson Hyperlegible has no Cyrillic; Playfair Display does, so it stays for display. */
:root:lang(ru) {
  --font-text: "Noto Sans", "Segoe UI", system-ui, sans-serif;
}
:root:lang(ja) {
  --font-display: "Noto Serif JP", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --font-text: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
}
:root:lang(ko) {
  --font-display: "Noto Serif KR", "Batang", "AppleMyungjo", serif;
  --font-text: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
:root:lang(zh) {
  --font-display: "Noto Serif SC", "Songti SC", "SimSun", serif;
  --font-text: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-text);
  font-size: var(--step-0);
  line-height: 1.6;
  color: var(--ink);
  background: var(--parchment);
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
ol, ul, dl, dd, dt, p, h1, h2, h3, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }

:focus-visible {
  outline: 3px solid var(--mango);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: 1rem;
  top: -4rem;
  background: var(--paper);
  color: var(--ink);
  padding: 0.6rem 1rem;
  z-index: 100;
}
.skip:focus { top: 1rem; }

.wrap {
  width: var(--wrap);
  margin-inline: auto;
}

/* ---------- Header ---------- */

.site-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.1rem clamp(1.25rem, 4vw, 3rem);
  color: var(--parchment);
}

.brand {
  font-family: var(--font-display);
  font-size: var(--step-2);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
}

.site-header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
}

.site-header nav a {
  text-decoration: none;
  font-size: var(--step--1);
  padding: 0.35rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.site-header nav a:hover { border-bottom-color: var(--mango); }

/* Touch screens: 44px tap targets. Stays above the max-width: 40rem block, which still wins on phones. */
@media (pointer: coarse) {
  .site-header nav a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }
}

/* ---------- Language selector (created by lang.js) ---------- */

.site-header nav { min-width: 0; max-width: 100%; margin-left: auto; }

.lang { position: relative; display: inline-flex; align-items: center; color: var(--parchment); }
.lang svg { position: absolute; left: 0.8rem; width: 18px; height: 18px; pointer-events: none; }
/* Chevron */
.lang::after {
  content: "";
  position: absolute;
  right: 1rem;
  top: calc(50% - 5px);
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  pointer-events: none;
}
.lang select {
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
  max-width: 100%;
  padding: 0.35rem 2.3rem 0.35rem 2.35rem;
  font: inherit;
  font-size: max(16px, 1rem); /* under 16px iOS zooms on focus */
  line-height: 1.2;
  color: var(--parchment);
  background: rgba(14, 42, 36, 0.65);
  border: 2px solid rgba(244, 236, 219, 0.6);
  border-radius: 999px;
  cursor: pointer;
}
.lang select:hover { border-color: var(--parchment); }
.lang select:focus-visible { outline: 3px solid var(--mango); outline-offset: 3px; border-radius: 999px; }
.lang option { color: var(--ink); background: var(--paper); }
/* Each entry with Han characters keeps its own glyph shapes, whatever the page language. */
.lang option:lang(ja) { font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; }
.lang option:lang(zh) { font-family: "PingFang SC", "Microsoft YaHei", sans-serif; }

/* Narrow screens: brand and selector share the first line, the nav takes the next one. */
@media (max-width: 63.99rem) {
  .site-header { row-gap: 0.25rem; padding-block: 0.75rem; }
  .site-header nav { order: 1; flex-basis: 100%; margin-left: 0; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Long words (German, French, Russian...) must never overflow ---------- */

body { overflow-wrap: break-word; }
.split > *, .game > *, .buy > *, .route > *, .route__step > *,
.cast__row > *, .facts > div > *, .site-footer > * { min-width: 0; }
/* Hyphenation only in translations; Spanish keeps its original line breaks. */
html:not([lang="es"]) :is(h1, h2, h3, .hero__line, .lead, .route__step, .cast__row, .facts, .card, .story-page__main) {
  -webkit-hyphens: auto;
  hyphens: auto;
}
.button { text-align: center; max-width: 100%; }

/* ---------- Hero ---------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--parchment);
  background: var(--canopy);
  padding: 7rem 1.25rem 4rem;
  isolation: isolate;
}

.hero__bg {
  position: absolute;
  inset: -8% 0;
  width: 100%;
  height: 116%;
  object-fit: cover;
  object-position: 50% 40%;
  z-index: -2;
  transform: translateY(var(--py, 0px)) scale(1.04);
  will-change: transform;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(14, 42, 36, 0.72);
  z-index: -1;
}

.hero__inner {
  text-align: center;
  max-width: 52rem;
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.hero__line {
  display: block;
  font-size: clamp(1.6rem, 1.1rem + 2.4vw, 2.4rem);
  opacity: 0.9;
}

.hero__line--big {
  font-size: var(--step-5);
  font-weight: 350;
  margin-top: 0.35em;
  color: #f9f1dd;
}

.hero__lede {
  margin: 1.75rem auto 0;
  max-width: 34rem;
  font-size: var(--step-1);
  color: rgba(244, 236, 219, 0.88);
}

.hero__actions {
  margin-top: 2.25rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.9rem;
}

.hero__fly {
  position: absolute;
  right: clamp(1rem, 9vw, 9rem);
  bottom: clamp(3rem, 14vh, 9rem);
  z-index: 1;
  transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1);
  opacity: var(--fade, 1);
}

.hero__butterfly {
  width: clamp(72px, 9vw, 130px);
  height: auto;
  transform-origin: center;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.35));
  animation: drift 14s ease-in-out infinite alternate, flap 28s ease-in-out infinite;
}

/* Wing beat: the X scale closes and opens the wings. It uses the separate `scale` property,
   so it doesn't fight `drift` (transform) or the pointer lean (JS sets transform on .hero__fly).
   One 28s cycle: 4 slow beats (1.0s), 6s still, 3 beats (1.1s), 3s still, 4 beats (1.2s), 8s still. */
@keyframes flap {
  0%, 14.29%, 35.71%, 47.5%, 57.14%, 74.29%, 100% { scale: 1 1; }
  1.79%, 5.36%, 8.93%, 12.5% { scale: 0.3 1; }
  3.57%, 7.14%, 10.71% { scale: 1 1; }
  37.5%, 41.6%, 45.5% { scale: 0.3 1; }
  39.64%, 43.57% { scale: 1 1; }
  59.29%, 63.57%, 67.86%, 72.14% { scale: 0.3 1; }
  61.43%, 65.71%, 70% { scale: 1 1; }
}

@keyframes drift {
  0%   { transform: translate(0, 0) rotate(-4deg); }
  50%  { transform: translate(-2.5rem, -1.5rem) rotate(3deg); }
  100% { transform: translate(-6rem, 0.5rem) rotate(-2deg); }
}

/* Entrance: the one orchestrated moment on load */
.hero__line,
.hero__lede,
.hero__actions {
  animation: rise 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.hero__line--big { animation-delay: 0.15s; }
.hero__lede { animation-delay: 0.35s; }
.hero__actions { animation-delay: 0.5s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Buttons ---------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.5rem;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  border-radius: 999px;
  border: 2px solid transparent;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.button--primary {
  background: var(--mango);
  color: var(--canopy);
}
.button--primary:hover { background: #f2b351; }

.button--ghost {
  border-color: rgba(244, 236, 219, 0.6);
  color: var(--parchment);
}
.button--ghost:hover { border-color: var(--parchment); background: rgba(244, 236, 219, 0.08); }

/* ---------- Chapters (sections) ---------- */

.chapter {
  padding-block: clamp(4.5rem, 9vw, 7.5rem);
}

.chapter--paper { background: var(--paper); }

.chapter--night {
  background: var(--moss);
  color: var(--parchment);
}

.h2 {
  font-family: var(--font-display);
  font-weight: 450;
  font-size: clamp(var(--step-2), 1.4rem + 1.6vw, var(--step-4));
  line-height: 1.12;
  letter-spacing: -0.005em;
  text-wrap: balance;
}

.lead {
  margin-top: 1rem;
  max-width: var(--measure);
  font-size: var(--step-1);
  color: var(--ink-soft);
}

.split {
  display: grid;
  gap: 2.5rem;
  align-items: start;
}

.prose {
  max-width: var(--measure);
  font-size: var(--step-0);
}
.prose p + p { margin-top: 1.1rem; }

.section-head {
  max-width: 44rem;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

/* ---------- Route (nine sections) ---------- */

.route {
  counter-reset: sec;
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line-light);
}

.route__step {
  counter-increment: sec;
  display: grid;
  grid-template-columns: 3.5rem minmax(0, 1fr);
  gap: 0.25rem 1rem;
  align-items: baseline;
  padding-block: 1.25rem;
  border-bottom: 1px solid var(--line-light);
}

.route__step::before {
  content: counter(sec, decimal-leading-zero);
  grid-row: span 3;
  font-family: var(--font-display);
  font-size: var(--step-2);
  color: var(--morpho);
  line-height: 1;
}

.route__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--step-2);
  line-height: 1.2;
}

.route__meaning { color: var(--ink); }
.route__cast { color: var(--ink-soft); font-size: var(--step--1); }

/* ---------- Cast (characters) ---------- */

.cast {
  border-top: 1px solid var(--line-light);
}

.cast__row {
  display: grid;
  grid-template-columns: minmax(0, 8rem) minmax(0, 1fr);
  gap: 0.2rem 1rem;
  padding-block: 1rem;
  border-bottom: 1px solid var(--line-light);
}

.cast dt {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
}

.cast dd { color: var(--ink-soft); }

.cast__emotion {
  grid-column: 2;
  font-weight: 700;
  color: #1f5f96;
}
/* Two classes, so it beats `.cast dt` (the emotion is also a dt). */
.cast .cast__emotion {
  font-family: var(--font-text);
  font-size: var(--step--1);
}

/* ---------- Game ---------- */

.game {
  display: grid;
  gap: 3rem;
  align-items: center;
}

.game__art img {
  width: 100%;
  border-radius: 6px;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: 50% 0;
}

.game__art figcaption {
  margin-top: 0.7rem;
  font-size: var(--step--1);
  color: rgba(244, 236, 219, 0.75);
}

.game__copy p + p { margin-top: 1rem; }

.game__copy .h2 { margin-bottom: 1.25rem; }

.game__note {
  color: var(--mango);
  font-weight: 700;
}

/* ---------- Buy ---------- */

.buy {
  display: grid;
  gap: 2.5rem;
}

.facts {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line-light);
}

.facts > div {
  display: grid;
  grid-template-columns: minmax(6rem, 30%) minmax(0, 1fr);
  gap: 1rem;
  padding-block: 0.85rem;
  border-bottom: 1px solid var(--line-light);
}

.facts dt { color: var(--ink-soft); }
.facts dd { font-weight: 700; font-variant-numeric: tabular-nums; }
/* The values contain Spanish text, so translations must not auto-hyphenate them. */
html:not([lang="es"]) .facts dd { -webkit-hyphens: manual; hyphens: manual; }

.buy__actions { margin-top: 0; }

/* ---------- Footer ---------- */

.site-footer {
  background: var(--canopy);
  color: rgba(244, 236, 219, 0.8);
  padding: 2.5rem clamp(1.25rem, 4vw, 3rem);
  font-size: var(--step--1);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 2rem;
}

.site-footer p:first-child {
  font-family: var(--font-display);
  font-size: var(--step-1);
  color: var(--parchment);
}

/* ---------- Breakpoints ---------- */

@media (min-width: 40rem) {
  .game { grid-template-columns: 1.1fr 1fr; }
  .buy { grid-template-columns: 1fr 1fr; align-items: start; }
  .cast__row { grid-template-columns: minmax(10rem, 14rem) minmax(0, 1fr) fit-content(12rem); gap: 0.2rem 2rem; }
  .hero { padding-top: 9rem; } /* room for the two-line header */
  .cast__emotion { grid-column: auto; text-align: right; }
}

@media (min-width: 64rem) {
  .hero { padding-top: 7rem; } /* one-line header again */
}

@media (min-width: 56rem) {
  .split { grid-template-columns: minmax(14rem, 1fr) minmax(0, 2fr); gap: 4rem; }
  .game { gap: 5rem; }
  .route { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 4rem; }
  .route__step:nth-child(odd) { border-right: 1px solid var(--line-light); padding-right: 2rem; }
  .route__step:nth-child(even) { padding-left: 0; }
}

@media (max-width: 40rem) {
  .site-header { position: static; background: var(--canopy); }
  .site-header nav ul { gap: 0 0.6rem; }
  .site-header nav a { display: flex; align-items: center; min-height: 44px; justify-content: center; min-width: 44px; padding: 0.4rem 0.4rem; }
  .hero { min-height: auto; padding-top: 3rem; padding-bottom: 7.5rem; } /* keeps the butterfly below the buttons */
  .facts > div { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
  .hero__fly { right: 0.5rem; bottom: 1rem; }
  .hero__butterfly { width: 72px; }
  .hero__actions .button { width: 100%; }
  .route__step::before { font-size: var(--step-1); }
}

/* Short landscape screens: keep the drifting butterfly below the hero buttons. */
@media screen and (max-height: 32rem) and (min-width: 40.01rem) {
  .hero { padding-bottom: 11rem; }
  .hero__fly { bottom: 2rem; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}


/* ---------- Motion additions ---------- */

/* Reading progress */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--morpho), var(--mango));
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 50;
  pointer-events: none;
}

/* Fireflies */
.fireflies {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.chapter--night { position: relative; overflow: hidden; }
.chapter--night .wrap { position: relative; z-index: 1; }
.hero .fireflies { z-index: 0; }

.fireflies span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  border-radius: 50%;
  background: #ffe9a3;
  box-shadow: 0 0 10px 3px rgba(255, 224, 130, 0.55);
  opacity: 0;
  animation: glow var(--d) ease-in-out var(--delay) infinite;
}

@keyframes glow {
  0%   { opacity: 0;   transform: translate(0, 0); }
  20%  { opacity: 0.9; }
  50%  { opacity: 0.35; transform: translate(26px, -34px); }
  80%  { opacity: 0.9; }
  100% { opacity: 0;   transform: translate(-14px, -70px); }
}

/* Scroll reveal: only hides things when JS is running */
.js .reveal {
  opacity: 0;
  transform: translateY(26px);
  transition: opacity 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) var(--stagger, 0ms),
              transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) var(--stagger, 0ms);
}
.js .reveal.is-in { opacity: 1; transform: none; }

/* Characters carousel */
.js .cast.is-replaced { display: none; }

.carousel { position: relative; }

.carousel__track {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 0.25rem;
  padding: 0.5rem 0.25rem 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--morpho) transparent;
  -webkit-overflow-scrolling: touch;
}

.card {
  display: block;
  position: relative; /* keeps the .sr-only text inside the scrolling card */
  min-width: 0;
  font: inherit;
  color: inherit;
  text-decoration: none;
  -webkit-user-drag: none;
  text-align: left;
  cursor: pointer;
  flex: 0 0 min(78%, 17rem);
  scroll-snap-align: start;
  background: var(--paper);
  border: 1px solid var(--line-light);
  border-radius: 14px;
  padding: 0.9rem 0.9rem 1.2rem;
  box-shadow: 0 8px 24px rgba(14, 42, 36, 0.08);
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1), box-shadow 0.35s ease;
}
.card:hover { transform: translateY(-6px) rotate(-0.8deg); box-shadow: 0 16px 34px rgba(14, 42, 36, 0.16); }

.card:focus-visible { outline: 3px solid var(--mango); outline-offset: 3px; }

.card__art {
  aspect-ratio: 4 / 5;
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(145deg, var(--hue), color-mix(in srgb, var(--hue) 55%, #0e2a24));
  display: grid;
  /* One fixed cell: a tall picture can't stretch the row beyond the frame. */
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
}
/* Whole animal always visible: contain, no zoom (a hover zoom would crop it). The hue gradient shows in any letterbox. */
.card__art img { width: 100%; height: 100%; object-fit: contain; }
.card__art--contain img { padding: 8%; box-sizing: border-box; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
.card__art--initial {
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--font-display);
  font-size: 4rem;
}

.card__name, .card__emotion, .card__text { display: block; }
.card__name {
  margin-top: 0.8rem;
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.2;
}
.card__emotion { margin-top: 0.2rem; font-weight: 700; color: #1f5f96; font-size: var(--step--1); }
.card__text { margin-top: 0.5rem; color: var(--ink-soft); font-size: 1rem; line-height: 1.45; }

.carousel__btn {
  position: absolute;
  top: 38%;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 0;
  background: var(--canopy);
  color: var(--parchment);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  transition: background-color 0.2s ease, opacity 0.2s ease;
}
.carousel__btn:hover:not(:disabled) { background: var(--morpho); }
.carousel__btn:disabled { opacity: 0.25; cursor: default; }
.carousel__btn--prev { left: -0.4rem; }
.carousel__btn--next { right: -0.4rem; }

@media (min-width: 40rem) { .card { flex-basis: 15rem; } }

/* ---------- Story pages (cuentos/<slug>.html, built by build-cuentos.mjs) ---------- */

.story-page-body { background: var(--parchment); }

/* The home header is absolute over the hero; here it sits on a solid band. */
.story-page-body .site-header { position: static; background: var(--canopy); }
.story-page-body .site-header nav a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; }

.story-page {
  width: var(--wrap);
  margin-inline: auto;
  padding-block: 2rem 4rem;
  display: grid;
  gap: 2rem;
  overflow-wrap: anywhere;
}
.story-page__main { min-width: 0; }
.story-page__title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 1.2rem + 2.4vw, var(--step-4));
  font-weight: 500;
  line-height: 1.15;
}
.story-page__who { margin-top: 0.6rem; font-weight: 700; color: #1f5f96; }
/* Cover: the picture crops to the landscape frame around a per-animal focal point. */
.story-page__art {
  --hue: var(--morpho);
  position: relative;
  margin-top: 1.25rem;
  aspect-ratio: 3 / 2;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(145deg, var(--hue), color-mix(in srgb, var(--hue) 55%, #0e2a24));
}
/* Square frame for animals whose face needs more height (Ris, Tobi). */
.story-page__art--square { aspect-ratio: 1 / 1; }
/* The picture fills the whole frame; each page sets object-position (focal point) inline. */
.story-page__art .story-page__pic {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.story-page__art--contain img { filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35)); }
.story-page__text { margin-top: 1.5rem; max-width: var(--measure); }
.story-page__text p + p { margin-top: 1rem; }
.story-page__actions { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: center; }
.story-page__back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 0.25rem;
  font-weight: 700;
}
.story-page__video {
  align-self: start;
  background: var(--canopy);
  color: var(--parchment);
  border-radius: 14px;
  padding: 1rem;
}
.story-page__frame {
  aspect-ratio: 16 / 9;
  display: grid;
  place-content: center;
  gap: 0.4rem;
  text-align: center;
  padding: 1rem;
  border: 2px dashed var(--line-dark);
  border-radius: 10px;
}
.story-page__soon { font-family: var(--font-display); font-size: var(--step-2); }
.story-page__note { font-size: var(--step--1); color: rgba(244, 236, 219, 0.8); }

@media (min-width: 56rem) {
  .story-page { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 3.5rem; padding-top: 3rem; }
  .story-page__video { position: sticky; top: 1.5rem; }
}
@media (max-width: 40rem) {
  .story-page__actions .button { width: 100%; }
}

/* Animation only when the visitor has no reduced-motion preference */
@media (prefers-reduced-motion: no-preference) {
  .story-page__main, .story-page__video { animation: story-page-in 0.5s ease-out both; }
  .story-page__video { animation-delay: 0.12s; }
  @keyframes story-page-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
}

@media print {
  .story-page-body { background: #fff; color: #000; }
  .story-page-body .site-header, .story-page-body .site-footer, .skip,
  .story-page__video, .story-page__actions { display: none !important; }
  .story-page { display: block; width: 100%; padding: 0; }
  .story-page__title, .story-page__who { color: #000; }
  .story-page__art, .story-page__art--square { background: none; max-height: 16rem; }
  .story-page__art img { filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .carousel__track { scroll-behavior: auto; }
  .card, .card__art img { transition: none; }
  .fireflies span { animation: none !important; opacity: 0.5; }
  .hero__bg { transform: scale(1.02) !important; }
  .hero__butterfly { scale: 1 1; }
}

.hero__inner { position: relative; z-index: 1; }

/* ---------- Print (keep at the end so it wins) ---------- */

@media print {
  *, *::before, *::after { animation: none !important; transition: none !important; }

  /* Story pages: each one fits a single A4 or Letter sheet. */
  .story-page-body { font-size: 11pt; line-height: 1.45; }
  .story-page__title { font-size: 20pt; }
  .story-page__who { margin-top: 0.2rem; }
  /* Width follows the max height, so the frame keeps its shape and focal point. */
  .story-page__art { width: 18rem; max-width: 100%; max-height: 12rem; margin: 0.6rem auto 0; }
  .story-page__art.story-page__art--square { width: 12rem; }
  .story-page__text { margin-top: 0.8rem; max-width: none; }
  .story-page__text p + p { margin-top: 0.4rem; }

  /* Home page: dark text on white, everything visible. */
  body:not(.story-page-body) { background: #fff; color: #000; }
  .site-header, .hero, .chapter, .chapter--paper, .chapter--night, .site-footer { background: #fff; color: #000; }
  .hero__line--big, .hero__lede, .game__art figcaption, .game__note, .site-footer p:first-child { color: #000; }
  .site-header { position: static; padding-block: 0; }
  .hero { min-height: auto; padding-block: 1rem; overflow: visible; }
  .chapter { padding-block: 1.25rem; }
  .chapter--night { overflow: visible; }
  .section-head { margin-bottom: 1rem; }
  .js .reveal { opacity: 1; transform: none; }
  .fireflies, .progress, .hero__bg, .hero::before, .hero__fly,
  .site-header nav, .lang, .skip, .carousel, .hero__actions { display: none !important; }
  .js .cast.is-replaced { display: block; }
}
