/* KulitKu Animated Illustrated Story Stylesheet
   Scoped to body.story-page so compliance subpages using /styles.css stay untouched.
   Warm editorial story palette locked to the illustrated plates:
   Twilight bedroom #3a5664 | Clarity paper #fefcef | Shelf paper #fbf7ea | Mirror paper #fdf9ed */

html:has(body.story-page) {
  color-scheme: light;
  scroll-behavior: smooth;
  background-color: #3a5664;
  color: #231f1b;
  font-family: 'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.story-page {
  color-scheme: light;
  --night: #3a5664;
  --paper-clarity: #fefcef;
  --paper-shelf: #fbf7ea;
  --paper-mirror: #fdf9ed;
  --bg: #fbf7ea;
  --bg-subtle: #f3ede0;
  --bg-elevated: #fffdf6;
  --ink: #231f1b;
  --ink-secondary: #5c544c;
  --ink-muted: #5c544c;
  --cream: #fffdf6;
  --cream-muted: rgba(255, 253, 246, 0.82);
  --teal: #0f7a6e;
  --teal-soft: #e6f3f1;
  --accent: #0f7a6e;
  --accent-hover: #0b5d54;
  --accent-soft: #e6f3f1;
  --accent-border: #bbd9d4;
  --accent-ink-on-fill: #fffdf6;
  --marigold: #f6b027;
  --marigold-soft: #fcf4df;
  --marigold-border: #9e6a06;
  --marigold-border-soft: #e8cd8b;
  --border: rgba(35, 31, 27, 0.11);
  --border-strong: rgba(35, 31, 27, 0.2);
  --hairline: rgba(35, 31, 27, 0.11);
  --hairline-light: rgba(255, 253, 246, 0.2);
  --focus-ring: #0f7a6e;
  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-body: 'DM Sans', ui-sans-serif, system-ui, -apple-system, sans-serif;

  display: block;
  margin: 0;
  background-color: var(--night);
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body.story-page .story-nav:not(.on-paper) :focus-visible,
body.story-page .chapter--night :focus-visible {
  outline-color: var(--marigold);
}

/* ===========================
   STICKY NAVIGATION
=========================== */
body.story-page .story-nav {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(58, 86, 100, 0.95);
  border-bottom: 1px solid var(--hairline-light);
  transition: background 0.28s ease, border-color 0.28s ease;
}

body.story-page .story-nav.on-paper {
  background: rgba(254, 252, 239, 0.92);
  border-bottom-color: var(--hairline);
}

body.story-page .nav-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 13px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

body.story-page .brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

body.story-page .brand-wordmark {
  height: 25px;
  width: auto;
  display: block;
}

body.story-page .brand-wordmark--light {
  display: none;
}

body.story-page .story-nav.on-paper .brand-wordmark--dark {
  display: none;
}

body.story-page .story-nav.on-paper .brand-wordmark--light {
  display: block;
}

body.story-page .chapter-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

body.story-page .chapter-nav a {
  color: rgba(255, 253, 246, 0.9);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease;
}

body.story-page .chapter-nav a:hover {
  background: rgba(255, 253, 246, 0.12);
  color: var(--cream);
}

body.story-page .story-nav.on-paper .chapter-nav a {
  color: var(--ink-muted);
}

body.story-page .story-nav.on-paper .chapter-nav a:hover {
  background: rgba(35, 31, 27, 0.06);
  color: var(--ink);
}

body.story-page .chapter-nav-divider {
  width: 1px;
  height: 16px;
  background: var(--hairline-light);
  margin: 0 4px;
  flex-shrink: 0;
}

body.story-page .story-nav.on-paper .chapter-nav-divider {
  background: var(--hairline);
}

body.story-page .nav-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

body.story-page .locale-picker {
  position: relative;
  display: inline-flex;
  align-items: center;
  color: var(--cream);
}

body.story-page .story-nav.on-paper .locale-picker {
  color: var(--ink-muted);
}

body.story-page .locale-globe,
body.story-page .locale-chevron {
  position: absolute;
  pointer-events: none;
  flex-shrink: 0;
  color: inherit;
  opacity: 0.88;
}

body.story-page .locale-globe {
  inset-inline-start: 11px;
  width: 15px;
  height: 15px;
}

body.story-page .locale-chevron {
  inset-inline-end: 10px;
  width: 14px;
  height: 14px;
}

body.story-page .locale-select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 36px;
  padding: 6px 32px 6px 32px;
  border-radius: 999px;
  border: 1px solid rgba(255, 253, 246, 0.3);
  background: rgba(26, 42, 51, 0.45);
  color: var(--cream);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
  max-width: 196px;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

body.story-page .locale-select:hover {
  background: rgba(26, 42, 51, 0.65);
  border-color: rgba(255, 253, 246, 0.5);
}

body.story-page .locale-select:focus-visible {
  outline: 2px solid var(--marigold);
  outline-offset: 2px;
}

body.story-page .locale-select option {
  background-color: #fffdf6;
  color: #231f1b;
}

body.story-page .story-nav.on-paper .locale-select {
  border-color: rgba(35, 31, 27, 0.22);
  background: rgba(255, 253, 246, 0.94);
  color: var(--ink);
}

body.story-page .story-nav.on-paper .locale-select:hover {
  background: #fffdf6;
  border-color: rgba(35, 31, 27, 0.38);
}

body.story-page .story-nav.on-paper .locale-select:focus-visible {
  outline-color: var(--teal);
}

body.story-page .seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--hairline-light);
  background: rgba(255, 253, 246, 0.08);
}

body.story-page .story-nav.on-paper .seg,
body.story-page .legal-band .seg {
  border-color: var(--hairline);
  background: rgba(35, 31, 27, 0.05);
}

body.story-page .seg button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 253, 246, 0.94);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.16s ease, color 0.16s ease;
}

body.story-page .seg button[aria-pressed='true'] {
  background: var(--cream);
  color: var(--ink);
}

body.story-page .story-nav.on-paper .seg button,
body.story-page .legal-band .seg button {
  color: var(--ink-muted);
}

body.story-page .story-nav.on-paper .seg button[aria-pressed='true'],
body.story-page .legal-band .seg button[aria-pressed='true'] {
  background: var(--ink);
  color: var(--cream);
}

/* ===========================
   CHAPTER BASE & BACKGROUNDS
=========================== */
body.story-page .chapter {
  position: relative;
  width: 100%;
  overflow: hidden;
  scroll-margin-top: 64px;
}

body.story-page .chapter--night {
  background-color: var(--night);
  color: var(--cream);
}

body.story-page .chapter--clarity {
  background-color: var(--paper-clarity);
  color: var(--ink);
}

body.story-page .chapter--shelf {
  background-color: var(--paper-shelf);
  color: var(--ink);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}

body.story-page .chapter--mirror {
  background-color: var(--paper-mirror);
  color: var(--ink);
}

/* ===========================
   FULL-BLEED LOCKED-ASPECT STAGE
   Base art + sliced WebP sprites + SVG ambient layers share
   the exact 1376/768 coordinate space so overlays never drift.
=========================== */
body.story-page .stage {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
}

body.story-page .scene-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
}

body.story-page .scene-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 1376 / 768;
  direction: ltr;
}

body.story-page .scene-base {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

body.story-page .scene-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

body.story-page .sprite {
  position: absolute;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  will-change: transform, opacity;
}

body.story-page .sprite--interactive {
  pointer-events: auto;
  cursor: pointer;
}

/* Overlay copy positioned cleanly inside the open ~44% side of each full-bleed stage */
body.story-page .stage-copy {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  width: 44%;
  max-width: 550px;
}

body.story-page .stage-copy--left {
  left: 0;
  padding: 36px 24px 36px 68px;
}

body.story-page .stage-copy--right {
  right: 0;
  padding: 36px 68px 36px 24px;
}

body.story-page .chapter-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  margin: 0 0 14px;
  max-width: none;
  color: inherit;
  opacity: 0.78;
}

body.story-page .chapter-label-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--marigold);
  flex-shrink: 0;
}

body.story-page .chapter--clarity .chapter-label-dot,
body.story-page .chapter--shelf .chapter-label-dot,
body.story-page .chapter--mirror .chapter-label-dot {
  background: var(--teal);
}

body.story-page .chapter-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.05rem, 3.45vw, 3.25rem);
  line-height: 1.07;
  letter-spacing: -0.025em;
  color: inherit;
  max-width: none;
  margin: 0 0 18px;
}

body.story-page .chapter-title--sub {
  font-size: clamp(1.8rem, 2.85vw, 2.65rem);
}

body.story-page .chapter-body {
  font-size: clamp(0.98rem, 1.12vw, 1.1rem);
  line-height: 1.62;
  margin: 0 0 22px;
  max-width: 43ch;
}

body.story-page .chapter--night .chapter-body {
  color: var(--cream-muted);
}

body.story-page .chapter--clarity .chapter-body,
body.story-page .chapter--shelf .chapter-body,
body.story-page .chapter--mirror .chapter-body {
  color: var(--ink-muted);
}

body.story-page .cta-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 24px;
}

body.story-page .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 24px;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border: 0;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

body.story-page .btn-primary:hover {
  transform: translateY(-1px);
}

body.story-page .btn-primary:active {
  transform: translateY(1px);
}

body.story-page .btn-primary--marigold,
body.story-page .btn-primary--marigold:hover {
  background: var(--marigold);
  color: var(--ink);
  box-shadow: 0 10px 24px -12px rgba(246, 176, 39, 0.55);
}

body.story-page .btn-primary--teal,
body.story-page .btn-primary--teal:hover {
  background: var(--teal);
  color: var(--cream);
  box-shadow: 0 12px 26px -14px rgba(15, 122, 110, 0.55);
}

body.story-page .quiet-note {
  font-size: 13.5px;
  margin: 14px 0 0;
  max-width: none;
  color: inherit;
  opacity: 0.74;
}

/* ===========================
   CHAPTER 1 ANIMATED LAYERS
   Night in bed: lamp glow + sequential thought dots + floating bottle cloud + cat blink
=========================== */
body.story-page .f1-cloud {
  left: 55.1599%;
  top: 7.5521%;
  width: 19.2587%;
  height: 28.125%;
  transform-origin: 72% 96%;
  opacity: 0;
}

body.story-page .is-visible .f1-cloud {
  animation:
    cloudPopIn 0.85s cubic-bezier(0.22, 1.24, 0.36, 1) 0.72s forwards,
    cloudFloat 5.6s ease-in-out 1.57s infinite;
}

body.story-page .f1-cloud.is-nudged {
  animation:
    cloudNudge 0.55s cubic-bezier(0.22, 1.35, 0.36, 1) forwards,
    cloudFloat 5.6s ease-in-out 0.55s infinite !important;
  opacity: 1 !important;
}

body.story-page .f1-dot-sm {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
}

body.story-page .is-visible .f1-dot-sm {
  animation:
    dotPopIn 0.48s cubic-bezier(0.22, 1.4, 0.36, 1) 0.25s forwards,
    dotBobSm 4.4s ease-in-out 0.73s infinite;
}

body.story-page .f1-dot-md {
  transform-box: fill-box;
  transform-origin: center;
  opacity: 0;
}

body.story-page .is-visible .f1-dot-md {
  animation:
    dotPopIn 0.52s cubic-bezier(0.22, 1.4, 0.36, 1) 0.48s forwards,
    dotBobMd 4.8s ease-in-out 1s infinite;
}

body.story-page .f1-lamp-glow {
  animation: lampBreathe 5.2s ease-in-out infinite;
  transform-origin: 797px 370px;
}

body.story-page .f1-phone-glow {
  animation: phoneGlow 3.9s ease-in-out infinite;
}

body.story-page .f1-cat-blink {
  opacity: 0;
  animation: catBlink 5.8s ease-in-out 2.1s infinite;
}

@keyframes dotPopIn {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.35);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes dotBobSm {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-2.5px);
  }
}

@keyframes dotBobMd {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes cloudPopIn {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.76) rotate(-2deg);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1) rotate(0deg);
  }
}

@keyframes cloudFloat {
  0%,
  100% {
    transform: translateY(0) rotate(-0.6deg);
  }
  50% {
    transform: translateY(-8px) rotate(0.8deg);
  }
}

@keyframes cloudNudge {
  0% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-10px) scale(1.04) rotate(1.2deg);
  }
  100% {
    transform: translateY(0) scale(1) rotate(-0.6deg);
  }
}

@keyframes lampBreathe {
  0%,
  100% {
    opacity: 0.48;
    transform: scale(0.98);
  }
  50% {
    opacity: 0.92;
    transform: scale(1.04);
  }
}

@keyframes phoneGlow {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 0.45;
  }
}

@keyframes catBlink {
  0%,
  95.5%,
  100% {
    opacity: 0;
  }
  97%,
  98.5% {
    opacity: 1;
  }
}

/* ===========================
   CHAPTER 2 ANIMATED LAYERS (FLIPPED ART LEFT)
   3 sliced hand-drawn sprites above bottle + subtle rising mug steam
=========================== */
body.story-page .f2-leaf {
  left: 37.718%;
  top: 19.6615%;
  width: 4.6512%;
  height: 10.4167%;
  transform-origin: 50% 80%;
  opacity: 0;
}

body.story-page .f2-drop {
  left: 43.8953%;
  top: 24.349%;
  width: 3.9971%;
  height: 10.2865%;
  transform-origin: 50% 60%;
  opacity: 0;
}

body.story-page .f2-sparkle {
  left: 35.9012%;
  top: 30.0781%;
  width: 4.6512%;
  height: 9.2448%;
  transform-origin: 50% 50%;
  opacity: 0;
}

body.story-page .is-visible .f2-drop {
  animation:
    iconBloom 0.65s cubic-bezier(0.22, 1.35, 0.36, 1) 0.12s forwards,
    floatDrop 4.1s ease-in-out 0.77s infinite;
}

body.story-page .is-visible .f2-leaf {
  animation:
    iconBloom 0.7s cubic-bezier(0.22, 1.35, 0.36, 1) 0.28s forwards,
    floatLeaf 4.8s ease-in-out 0.98s infinite;
}

body.story-page .is-visible .f2-sparkle {
  animation:
    iconBloom 0.65s cubic-bezier(0.22, 1.35, 0.36, 1) 0.42s forwards,
    floatSparkle 3.5s ease-in-out 1.07s infinite;
}

/* Synchronized micro-pop whenever user taps an ingredient in Kamus */
body.story-page .f2-burst .f2-drop,
body.story-page .f2-burst .f2-leaf,
body.story-page .f2-burst .f2-sparkle {
  opacity: 1 !important;
}

body.story-page .f2-burst .f2-drop {
  animation:
    inciPop 0.52s cubic-bezier(0.22, 1.4, 0.36, 1) 0s forwards,
    floatDrop 4.1s ease-in-out 0.52s infinite !important;
}

body.story-page .f2-burst .f2-leaf {
  animation:
    inciPop 0.56s cubic-bezier(0.22, 1.4, 0.36, 1) 0.06s forwards,
    floatLeaf 4.8s ease-in-out 0.62s infinite !important;
}

body.story-page .f2-burst .f2-sparkle {
  animation:
    inciPop 0.52s cubic-bezier(0.22, 1.4, 0.36, 1) 0.12s forwards,
    floatSparkle 3.5s ease-in-out 0.64s infinite !important;
}

body.story-page .f2-steam-1 {
  animation: steamRise 4.4s ease-in-out infinite;
}

body.story-page .f2-steam-2 {
  animation: steamRise 4.4s ease-in-out 2.1s infinite;
}

@keyframes iconBloom {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.55);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes floatDrop {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-9px);
  }
}

@keyframes floatLeaf {
  0%,
  100% {
    transform: translateY(0) rotate(-4deg);
  }
  50% {
    transform: translateY(-7px) rotate(5deg);
  }
}

@keyframes floatSparkle {
  0%,
  100% {
    transform: scale(0.88) rotate(-6deg);
    opacity: 0.78;
  }
  50% {
    transform: scale(1.1) rotate(7deg);
    opacity: 1;
  }
}

@keyframes inciPop {
  0% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-13px) scale(1.16);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes steamRise {
  0% {
    opacity: 0;
    transform: translateY(8px);
  }
  30% {
    opacity: 0.42;
  }
  75% {
    opacity: 0.24;
  }
  100% {
    opacity: 0;
    transform: translateY(-28px);
  }
}

/* Signature KulitKu dotted-underlined interactive ingredient links */
body.story-page .inci-link {
  display: inline;
  padding: 0 2px 1px;
  border: 0;
  border-bottom: 2px dotted var(--teal);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

body.story-page .inci-link:hover,
body.story-page .inci-link[aria-expanded='true'] {
  background: var(--teal-soft);
  color: var(--teal);
  border-radius: 3px;
}

body.story-page .kamus-card {
  margin-top: 18px;
  padding: 17px 20px;
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.96);
  border: 1px solid rgba(15, 122, 110, 0.24);
  box-shadow: 0 14px 32px -24px rgba(35, 31, 27, 0.24);
  max-width: 430px;
  transition: transform 0.22s ease;
}

body.story-page .kamus-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

body.story-page .kamus-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17.5px;
  color: var(--ink);
}

body.story-page .kamus-phonetic {
  font-size: 12.5px;
  color: var(--ink-muted);
}

body.story-page .kamus-hook {
  margin: 0 0 12px;
  max-width: none;
  font-size: 14.5px;
  line-height: 1.52;
  color: var(--ink);
}

body.story-page .kamus-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--hairline);
  font-size: 12.5px;
  color: var(--ink-muted);
}

body.story-page .size-orbs {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

body.story-page .orb {
  border-radius: 999px;
  background: var(--hairline);
}

body.story-page .orb.sm {
  width: 7px;
  height: 7px;
}

body.story-page .orb.md {
  width: 10px;
  height: 10px;
}

body.story-page .orb.lg {
  width: 13px;
  height: 13px;
}

body.story-page .orb.active {
  background: var(--teal);
}

/* ===========================
   CHAPTER 3 — CENTERED STORYBOOK INTERLUDE
   Breaks Left/Right alternation with a calm centered gallery plate.
=========================== */
body.story-page .shelf-section {
  max-width: 1020px;
  margin: 0 auto;
  padding: 88px 28px 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

body.story-page .shelf-header {
  max-width: 660px;
  margin-bottom: 36px;
}

body.story-page .shelf-header .chapter-body {
  margin: 0 auto;
  max-width: 54ch;
}

body.story-page .shelf-plate-frame {
  width: 100%;
  max-width: 660px;
  border-radius: 28px;
  overflow: hidden;
  border: 1.5px solid rgba(35, 31, 27, 0.14);
  background: var(--paper-shelf);
  box-shadow: 0 26px 56px -32px rgba(35, 31, 27, 0.24);
}

/* Exact cropped dimensions: 808 x 768 (from x=568..1376 of 1376x768) */
body.story-page .shelf-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 808 / 768;
  direction: ltr;
}

/* 3 sliced hand-drawn sparkle stars from original Frame 3 locked to 808x768 crop */
body.story-page .f3-star-1 {
  left: 89.1089%;
  top: 40.1042%;
  width: 6.3119%;
  height: 7.0312%;
  transform-origin: center;
  animation: twinkleStar 3.4s ease-in-out infinite;
}

body.story-page .f3-star-2 {
  left: 56.1881%;
  top: 45.9635%;
  width: 6.3119%;
  height: 7.4219%;
  transform-origin: center;
  animation: twinkleStar 4.1s ease-in-out 1.1s infinite;
}

body.story-page .f3-star-3 {
  left: 91.7079%;
  top: 59.375%;
  width: 6.0644%;
  height: 6.25%;
  transform-origin: center;
  animation: twinkleStar 3.8s ease-in-out 2.2s infinite;
}

@keyframes twinkleStar {
  0%,
  100% {
    opacity: 0.42;
    transform: scale(0.78) rotate(-8deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.08) rotate(8deg);
  }
}

body.story-page .shelf-rail {
  width: 100%;
  max-width: 820px;
  margin-top: 32px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--hairline);
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.85);
  overflow: hidden;
  text-align: start;
}

body.story-page .shelf-slot {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-inline-end: 1px solid var(--hairline);
}

body.story-page .shelf-slot:last-child {
  border-inline-end: 0;
}

body.story-page .shelf-slot-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

body.story-page .bottle-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  flex-shrink: 0;
}

body.story-page .bottle-dot--cream {
  background: #f5ebd0;
}

body.story-page .bottle-dot--teal {
  background: var(--teal);
}

body.story-page .bottle-dot--marigold {
  background: var(--marigold);
}

body.story-page .shelf-slot-meta {
  font-size: 13.5px;
  color: var(--teal);
  font-weight: 600;
  padding-inline-start: 18px;
}

/* ===========================
   CHAPTER 4 ANIMATED LAYERS (FLIPPED ART LEFT — MORNING MIRROR)
   Subtle mirror glass sheen + drifting golden sunlight motes
=========================== */
body.story-page .f4-mirror-sheen {
  animation: mirrorSheen 7.4s ease-in-out infinite;
}

body.story-page .f4-beam-glow {
  animation: beamBreathe 6.4s ease-in-out infinite;
}

body.story-page .f4-mote-1 {
  animation: moteDrift1 7.6s ease-in-out infinite;
}

body.story-page .f4-mote-2 {
  animation: moteDrift2 8.8s ease-in-out 1.4s infinite;
}

body.story-page .f4-mote-3 {
  animation: moteDrift1 9.4s ease-in-out 3.2s infinite;
}

body.story-page .f4-mote-4 {
  animation: moteDrift2 7.2s ease-in-out 2.5s infinite;
}

@keyframes mirrorSheen {
  0%,
  62%,
  100% {
    transform: translate(-240px, -160px);
    opacity: 0;
  }
  72% {
    opacity: 0.42;
  }
  88% {
    transform: translate(240px, 160px);
    opacity: 0;
  }
}

@keyframes beamBreathe {
  0%,
  100% {
    opacity: 0.08;
  }
  50% {
    opacity: 0.22;
  }
}

@keyframes moteDrift1 {
  0%,
  100% {
    transform: translate(0, 0) scale(0.85);
    opacity: 0.16;
  }
  50% {
    transform: translate(18px, -14px) scale(1.15);
    opacity: 0.62;
  }
}

@keyframes moteDrift2 {
  0%,
  100% {
    transform: translate(0, 0) scale(0.9);
    opacity: 0.2;
  }
  50% {
    transform: translate(-14px, -18px) scale(1.1);
    opacity: 0.56;
  }
}

/* ===========================
   CALM TRANSPARENCY, LEGAL & SCIENTIFIC REFERENCES BAND
=========================== */
body.story-page .legal-band {
  background-color: var(--paper-shelf);
  border-top: 1px solid var(--hairline);
  scroll-margin-top: 64px;
}

body.story-page .legal-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 72px 28px 80px;
}

body.story-page .legal-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px 28px;
  flex-wrap: wrap;
  margin-bottom: 36px;
}

body.story-page .legal-header {
  max-width: 68ch;
  margin-bottom: 0;
}

body.story-page .seg--legal {
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 4px;
}

body.story-page .legal-heading {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.55rem, 2.3vw, 2.05rem);
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--ink);
  margin: 0 0 12px;
}

body.story-page .legal-lead {
  font-size: 1rem;
  line-height: 1.62;
  color: var(--ink-muted);
  max-width: 62ch;
  margin: 0;
}

body.story-page .legal-lang-block + .legal-lang-block {
  margin-top: 48px;
  padding-top: 40px;
  border-top: 1px solid var(--border-strong);
}

body.story-page .legal-lang-block h3 {
  font-family: var(--font-display);
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--ink);
  margin: 26px 0 10px;
}

body.story-page .legal-lang-block p {
  color: var(--ink-muted);
  font-size: 0.96rem;
  line-height: 1.65;
  max-width: 68ch;
  margin: 0 0 14px;
}

body.story-page .legal-lang-block p strong {
  color: var(--ink);
}

body.story-page .legal-lang-block .callout {
  max-width: 78ch;
  margin: 18px 0 28px;
}

body.story-page .legal-lang-block .callout-body p {
  font-size: 0.92rem;
  color: var(--ink);
  margin-bottom: 6px;
}

body.story-page .legal-lang-block .callout-body p:last-child {
  margin-bottom: 0;
}

body.story-page .legal-directory {
  list-style: none;
  padding: 0;
  margin: 14px 0 26px;
  max-width: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 36px;
  border-top: 1px solid var(--hairline);
}

body.story-page .legal-directory-item {
  margin: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--hairline);
}

body.story-page .legal-directory-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

body.story-page .legal-directory-link:hover .legal-directory-title {
  color: var(--teal);
  text-decoration: underline;
  text-underline-offset: 3px;
}

body.story-page .legal-directory-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 12px;
  margin-bottom: 4px;
}

body.story-page .legal-directory-title {
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--ink);
}

body.story-page .legal-directory-path {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--teal);
  white-space: nowrap;
}

body.story-page .legal-directory-desc {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--ink-muted);
  max-width: none;
}

body.story-page .legal-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  margin-top: 8px;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

body.story-page .legal-contacts span {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

/* ===========================
   FOOTER
=========================== */
body.story-page .story-footer {
  background: var(--paper-shelf);
  border-top: 1px solid var(--hairline);
  padding: 44px 28px 56px;
}

body.story-page .story-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 32px;
  align-items: start;
}

body.story-page .footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

body.story-page .footer-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: block;
}

body.story-page .footer-disclaimer {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-muted);
  max-width: 54ch;
}

body.story-page .story-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 22px;
  justify-content: flex-end;
  padding-top: 6px;
}

body.story-page .story-footer-links a {
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 1px solid transparent;
}

body.story-page .story-footer-links a:hover {
  border-bottom-color: var(--teal);
  color: var(--teal);
}

/* ===========================
   TABLET & MOBILE RESPONSIVE (< 960px)
   Never overlap text over artwork on smaller viewports:
   zoom cleanly into the character side while keeping every
   sliced WebP sprite & SVG overlay 100% pixel-locked.
=========================== */
@media (max-width: 960px) {
  body.story-page .chapter-nav {
    display: none;
  }

  body.story-page .nav-inner {
    padding: 12px 18px;
    gap: 10px;
  }

  body.story-page .brand-wordmark {
    height: 22px;
  }

  body.story-page .nav-controls {
    gap: 6px;
  }

  body.story-page .seg button {
    font-size: 12px;
    padding: 5px 10px;
  }

  body.story-page .stage-copy {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    transform: none;
    width: 100%;
    max-width: none;
    padding: 28px 22px 52px;
  }

  /* Focus tightly on the illustrated half without breaking sprite coordinate math */
  body.story-page .scene-viewport--focus-right .scene-canvas {
    width: 150%;
    margin-left: -50%;
  }

  body.story-page .scene-viewport--focus-left .scene-canvas {
    width: 158%;
    margin-left: 0;
  }

  body.story-page .scene-viewport--focus-mirror .scene-canvas {
    width: 164%;
    margin-left: 0;
  }

  body.story-page .shelf-section {
    padding: 64px 20px 72px;
  }

  body.story-page .shelf-rail {
    grid-template-columns: 1fr;
  }

  body.story-page .shelf-slot {
    border-inline-end: 0;
    border-bottom: 1px solid var(--hairline);
  }

  body.story-page .shelf-slot:last-child {
    border-bottom: 0;
  }

  body.story-page .locale-select {
    font-size: 13px;
    max-width: 172px;
  }

  body.story-page .legal-inner {
    padding: 56px 20px 64px;
  }

  body.story-page .legal-directory {
    grid-template-columns: 1fr;
  }

  body.story-page .story-footer {
    padding: 36px 20px 48px;
  }

  body.story-page .story-footer-inner {
    grid-template-columns: 1fr;
  }

  body.story-page .story-footer-links {
    justify-content: flex-start;
  }
}

/* ===========================
   ACCESSIBILITY: REDUCED MOTION
=========================== */
@media (prefers-reduced-motion: reduce) {
  body.story-page .f1-cloud,
  body.story-page .f1-dot-sm,
  body.story-page .f1-dot-md,
  body.story-page .f2-drop,
  body.story-page .f2-leaf,
  body.story-page .f2-sparkle {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
  }

  body.story-page .f1-lamp-glow,
  body.story-page .f1-phone-glow,
  body.story-page .f1-cat-blink,
  body.story-page .f2-steam-1,
  body.story-page .f2-steam-2,
  body.story-page .f3-star-1,
  body.story-page .f3-star-2,
  body.story-page .f3-star-3,
  body.story-page .f4-mirror-sheen,
  body.story-page .f4-beam-glow,
  body.story-page .f4-mote-1,
  body.story-page .f4-mote-2,
  body.story-page .f4-mote-3,
  body.story-page .f4-mote-4 {
    animation: none !important;
  }

  body.story-page .f3-star-1,
  body.story-page .f3-star-2,
  body.story-page .f3-star-3 {
    opacity: 1 !important;
  }
}

/* ===========================
   RTL COPY SUPPORT (ar, fa, ur)
   Applies strictly to text containers while keeping
   illustrated sprite canvases locked to LTR coordinates.
=========================== */
body.story-page .story-rtl-target[dir='rtl'] {
  direction: rtl;
}

body.story-page .stage-copy[dir='rtl'] {
  text-align: right;
}

body.story-page .stage-copy[dir='rtl'] .chapter-body,
body.story-page .stage-copy[dir='rtl'] .kamus-card {
  margin-inline-start: 0;
}

body.story-page .shelf-section[dir='rtl'] .shelf-rail {
  text-align: right;
}

body.story-page .shelf-section[dir='rtl'] .shelf-slot {
  align-items: flex-start;
}

body.story-page .legal-header[dir='rtl'] {
  text-align: right;
}

body.story-page .story-footer[dir='rtl'] {
  text-align: right;
}
