:root {
  color-scheme: light;
  --paper: #f4f1df;
  --paper-light: #fbf8e9;
  --ink: #354b39;
  --ink-soft: #6d775f;
  --soil: #8a6848;
  --ochre: #a9684e;
  --line: #92977e;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body {
  color: var(--ink);
  background:
    radial-gradient(ellipse at 18% 8%, rgb(231 232 199 / 48%), transparent 42%),
    radial-gradient(ellipse at 92% 94%, rgb(217 229 194 / 35%), transparent 38%),
    repeating-linear-gradient(112deg, rgb(132 142 109 / 2%) 0 1px, transparent 1px 8px),
    var(--paper);
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
}
button, input { font: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ochre); outline-offset: 3px; }

.soil-module {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto auto;
  min-height: 100svh;
  padding: clamp(18px, 3vw, 38px) clamp(18px, 5vw, 68px) 20px;
  overflow: hidden;
}
.soil-module::before {
  position: absolute;
  inset: 13px;
  border: 1px dashed rgb(89 105 75 / 46%);
  content: "";
  pointer-events: none;
}
.soil-header, .story-stage, .story-caption, .story-controls { position: relative; z-index: 1; }
.soil-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 0 0 12px;
  border-bottom: 1px solid rgb(89 105 75 / 30%);
}
.soil-eyebrow, .caption-kicker {
  margin: 0 0 7px;
  color: var(--ink-soft);
  font-size: 11px;
  letter-spacing: .16em;
}
h1 { margin: 0; font-size: clamp(24px, 3vw, 38px); font-weight: 500; letter-spacing: .1em; }
.soil-subtitle { margin: 5px 0 0; color: var(--ink-soft); font: 12px/1.4 Georgia, serif; letter-spacing: .16em; }
.soil-stage-label { margin: 0 0 4px; color: var(--soil); font-size: 13px; letter-spacing: .12em; }

.story-stage {
  position: relative;
  min-height: 0;
  margin: 16px 0 8px;
  overflow: hidden;
  border: 1px solid rgb(89 105 75 / 40%);
  background: rgb(251 248 233 / 66%);
  box-shadow: 0 5px 18px rgb(64 71 51 / 7%);
  touch-action: pan-y;
  user-select: none;
}
.story-stage::after {
  position: absolute;
  inset: 8px;
  z-index: 3;
  border: 1px solid rgb(138 104 72 / 18%);
  content: "";
  pointer-events: none;
}
.story-photo, .story-paper, .story-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.story-photo {
  z-index: 1;
  object-fit: cover;
  object-position: center 52%;
  opacity: 1;
  transform: scale(1);
  transition: opacity 700ms ease, transform 1500ms cubic-bezier(.35, .1, .3, 1);
}
.story-paper {
  z-index: 2;
  background:
    radial-gradient(ellipse at 30% 18%, rgb(224 227 194 / 37%), transparent 40%),
    repeating-linear-gradient(115deg, rgb(90 103 73 / 2%) 0 1px, transparent 1px 7px),
    var(--paper);
  opacity: 0;
  transition: opacity 850ms ease;
}
.story-art {
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: translate(calc(-50% + var(--pan-x, 0px)), calc(-50% + var(--pan-y, 0px))) scale(var(--zoom, 2));
  transform-origin: center;
  transition: opacity 700ms ease, transform 240ms ease-out;
  will-change: transform, opacity;
  pointer-events: none;
}
.stage-index {
  position: absolute;
  z-index: 4;
  top: 16px;
  left: 18px;
  padding: 5px 9px;
  color: var(--ink);
  background: rgb(251 248 233 / 84%);
  font-size: 11px;
  letter-spacing: .1em;
}
.story-stage.is-narrating .story-photo { opacity: 0; transform: scale(1.08); }
.story-stage.is-narrating .story-paper { opacity: 1; }
.story-stage.is-narrating .story-art { opacity: 1; }

.story-caption {
  min-height: 84px;
  padding: 5px 0 10px clamp(0px, 3vw, 40px);
  border-left: 2px solid var(--soil);
  transition: opacity 260ms ease;
}
.story-caption.is-changing { opacity: .25; }
.caption-kicker { margin-left: 12px; }
.story-caption h2 { margin: 0 12px 3px; font-size: clamp(18px, 2.2vw, 26px); font-weight: 500; letter-spacing: .06em; }
.caption-english { margin: 0 12px; color: var(--ink-soft); font: 12px/1.5 Georgia, serif; letter-spacing: .08em; }

.story-controls { padding-top: 8px; }
.slider-heading { display: flex; justify-content: space-between; gap: 18px; color: var(--ink-soft); font-size: 12px; letter-spacing: .06em; }
.slider-heading span:first-child { color: var(--ink); }
#story-slider {
  display: block;
  width: 100%;
  height: 24px;
  margin: 8px 0 1px;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
  touch-action: pan-x;
}
#story-slider::-webkit-slider-runnable-track { height: 2px; background: linear-gradient(90deg, var(--soil), rgb(109 119 95 / 35%)); }
#story-slider::-moz-range-track { height: 2px; background: linear-gradient(90deg, var(--soil), rgb(109 119 95 / 35%)); }
#story-slider::-webkit-slider-thumb {
  width: 16px; height: 16px; margin-top: -7px; appearance: none;
  border: 2px solid var(--paper-light); border-radius: 50%; background: var(--ochre);
  box-shadow: 0 0 0 1px var(--soil);
}
#story-slider::-moz-range-thumb { width: 13px; height: 13px; border: 2px solid var(--paper-light); border-radius: 50%; background: var(--ochre); box-shadow: 0 0 0 1px var(--soil); }
.story-nodes { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: 0 0 2px; }
.story-nodes button {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--ink-soft);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
  transition: color 260ms ease, border-color 260ms ease, background-color 260ms ease;
}
.story-nodes button:hover, .story-nodes button[aria-current="step"] { border-color: var(--soil); color: var(--paper-light); background: var(--soil); }
.loop-note { margin: 0; color: var(--ink-soft); text-align: right; font-size: 10px; letter-spacing: .06em; }

@media (max-width: 700px) {
  .soil-module { grid-template-rows: auto minmax(230px, 1fr) auto auto; min-height: 100svh; padding: 22px 17px 16px; }
  .soil-header { align-items: center; }
  .soil-stage-label { max-width: 110px; text-align: right; line-height: 1.6; }
  .story-stage { margin: 12px 0 8px; }
  .story-caption { min-height: 80px; padding-left: 4px; }
  .slider-heading { font-size: 10px; }
  .story-nodes { gap: 0; }
  .story-nodes button { width: 25px; height: 25px; }
  .loop-note { text-align: center; font-size: 9px; }
  .story-stage { touch-action: pan-y; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 1ms !important; animation-duration: 1ms !important; animation-iteration-count: 1 !important; }
}
