/* "Why it exists" (landing/story.js) and "The maker" (landing/maker.js). Apple-style: a sticky stage
   that changes with the chapter crossing the middle of the screen; chapters in large type that brighten
   as they arrive. Motion only transforms and opacity; none with reduced motion. */

.dl-story { padding-bottom: var(--dl-space); }
.dl-story-head { max-width: 760px; margin-bottom: clamp(24px, 4vw, 48px); }
.dl-story-head h2 { font-size: clamp(2rem, 1.2rem + 3vw, 3.6rem); line-height: 1.05; letter-spacing: -0.03em; }

.dl-story-track { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr); gap: clamp(24px, 5vw, 72px); align-items: start; }
.dl-story-stage {
  position: sticky; top: 12vh; height: 76vh; min-height: 380px; max-height: 720px;
  border-radius: 24px; overflow: hidden;
  background-color: var(--bench);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px), radial-gradient(120% 90% at 30% 20%, transparent 40%, var(--panel-2));
  background-size: 18px 18px, 100% 100%;
  box-shadow: 0 1px 0 var(--line), 0 40px 80px -40px rgba(38, 42, 74, 0.4);
  user-select: none; -webkit-user-select: none;
}

/* Scenes stack in the stage; the active one fades and rises in. */
.dl-scene {
  position: absolute; inset: 0; display: grid; place-items: center; padding: clamp(24px, 4vw, 48px);
  opacity: 0; transform: translateY(24px) scale(0.97);
  transition: opacity 600ms var(--dl-ease), transform 900ms var(--dl-ease);
  pointer-events: none;
}
.dl-story-stage[data-step="0"] [data-scene="0"],
.dl-story-stage[data-step="1"] [data-scene="1"],
.dl-story-stage[data-step="2"] [data-scene="2"],
.dl-story-stage[data-step="3"] [data-scene="3"] { opacity: 1; transform: none; pointer-events: auto; }
.dl-scene-art svg { width: min(100%, 520px); height: auto; display: block; }

.dl-pixelated { width: min(100%, 520px); height: auto; image-rendering: pixelated; filter: saturate(0.8); }
.dl-scene-locked .dl-scene-art { opacity: 0.18; filter: blur(1px); }
.dl-lock { position: absolute; color: var(--dl-navy); display: grid; place-items: center; width: 120px; height: 120px; border-radius: 50%; background: var(--bench); box-shadow: 0 20px 40px -18px rgba(38, 42, 74, 0.5); }

.dl-scene-chips { position: absolute; left: 24px; bottom: 24px; right: 24px; display: flex; flex-wrap: wrap; gap: 8px; }
.dl-chip { font: 500 0.78rem var(--font-mono); letter-spacing: 0.04em; padding: 6px 12px; border-radius: 999px; background: var(--bench); border: 1px solid var(--line); color: var(--ink-2); }
.dl-chip.is-bad { color: var(--error); border-color: color-mix(in srgb, var(--error) 35%, transparent); }
.dl-chip.is-good { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }

.dl-species { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: -28px; }
.dl-species figure { margin: 0; padding: 12px; border-radius: 16px; border: 2px dashed transparent; background: var(--bench); }
.dl-species figure.is-wrong { border-color: color-mix(in srgb, var(--error) 55%, transparent); }
.dl-species figure.is-right { border-color: color-mix(in srgb, var(--ok) 55%, transparent); border-style: solid; }
.dl-species figcaption { font-size: 0.86rem; color: var(--ink-2); text-align: center; }
.dl-species figure.is-wrong b { color: var(--error); }
.dl-species figure.is-right b { color: var(--ok); }
.dl-species .dl-scene-art svg { width: clamp(110px, 13vw, 170px); }
.dl-species figure { display: flex; align-items: center; gap: 14px; padding: 8px 16px; }
.dl-species figcaption { text-align: left; min-width: 9em; }
.dl-species-arrow { font: 500 0.8rem var(--font-mono); color: var(--muted); }
.dl-species-note { position: absolute; left: 24px; right: 24px; bottom: 24px; margin: 0; color: var(--ink-2); font-size: 0.9rem; }
.dl-scene-species { place-items: center; }

.dl-story-svg { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }

.dl-story-dots { position: absolute; top: 20px; right: 20px; display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.dl-story-dots li { width: 18px; height: 4px; border-radius: 2px; background: var(--line); transition: background 300ms, width 300ms var(--dl-ease); }
.dl-story-stage[data-step="0"] [data-dot="0"], .dl-story-stage[data-step="1"] [data-dot="1"],
.dl-story-stage[data-step="2"] [data-dot="2"], .dl-story-stage[data-step="3"] [data-dot="3"] { background: var(--accent); width: 34px; }

/* Chapters: one per screen, dim until they cross the middle. */
.dl-chapters { list-style: none; margin: 0; padding: 0; }
.dl-chapter { min-height: 78vh; display: flex; flex-direction: column; justify-content: center; }
/* Chapters not being read are dimmed by colour, staying readable (WCAG AA), not faded out. */
.dl-chapter h3, .dl-chapter p:last-child { color: var(--muted); transition: color 500ms var(--dl-ease); }
.dl-chapter:first-child { min-height: 60vh; justify-content: flex-start; padding-top: 10vh; }
.dl-chapter:last-child { min-height: 70vh; }
.dl-story-stage[data-step="0"] ~ .dl-chapters [data-step="0"] h3,
.dl-story-stage[data-step="1"] ~ .dl-chapters [data-step="1"] h3,
.dl-story-stage[data-step="2"] ~ .dl-chapters [data-step="2"] h3,
.dl-story-stage[data-step="3"] ~ .dl-chapters [data-step="3"] h3 { color: var(--dl-navy); }
.dl-story-stage[data-step="0"] ~ .dl-chapters [data-step="0"] p:last-child,
.dl-story-stage[data-step="1"] ~ .dl-chapters [data-step="1"] p:last-child,
.dl-story-stage[data-step="2"] ~ .dl-chapters [data-step="2"] p:last-child,
.dl-story-stage[data-step="3"] ~ .dl-chapters [data-step="3"] p:last-child { color: var(--ink-2); }
.dl-chapter-tag { font: 500 0.76rem var(--font-mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; }
.dl-chapter-tag span { color: var(--accent); }
.dl-chapter h3 { font-size: clamp(1.8rem, 1rem + 2.6vw, 3rem); line-height: 1.08; letter-spacing: -0.025em; margin-bottom: 16px; text-wrap: balance; }
.dl-chapter p:last-child { font-size: clamp(1.02rem, 0.95rem + 0.35vw, 1.2rem); color: var(--ink-2); max-width: 40ch; margin: 0; }

/* The maker */
.dl-maker-sec { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(28px, 6vw, 80px); align-items: center; padding-bottom: var(--dl-space); }
.dl-portrait { margin: 0; position: relative; }
.dl-portrait img {
  display: block; width: clamp(200px, 26vw, 320px); height: auto; aspect-ratio: 1; object-fit: cover;
  border-radius: 28px; transform: rotate(-2deg); transition: transform 600ms var(--dl-ease);
  box-shadow: 22px 22px 0 -2px var(--accent-soft), 0 40px 70px -36px rgba(38, 42, 74, 0.55);
}
.dl-portrait:hover img { transform: rotate(0deg) translateY(-4px); }
.dl-maker-text h2 { font-size: clamp(2rem, 1.2rem + 3vw, 3.4rem); line-height: 1.05; letter-spacing: -0.03em; margin-bottom: 14px; }
.dl-maker-sec .dl-maker-role { display: flex; flex-wrap: wrap; gap: 4px 0; color: var(--muted); font-size: 1rem; margin: 0; }
.dl-maker-sec .dl-maker-role span + span::before { content: '·'; padding: 0 0.6em; color: var(--line); }

:root[lang="th"] .dl-chapter-tag, :root[lang="th"] .dl-chip { font-family: var(--font-body); letter-spacing: 0; text-transform: none; }
:root[lang="th"] .dl-chapter h3, :root[lang="th"] .dl-story-head h2 { line-height: 1.3; }

@media (max-width: 860px) {
  /* Stage pinned under the top of the screen, chapters scroll beneath it. */
  .dl-story-track { grid-template-columns: 1fr; }
  .dl-story-stage { top: 8px; height: 42vh; min-height: 260px; z-index: 1; }
  .dl-chapter, .dl-chapter:first-child, .dl-chapter:last-child { min-height: 58vh; padding-top: 0; justify-content: center; }
  .dl-maker-sec { grid-template-columns: 1fr; justify-items: start; }
  .dl-maker-sec .dl-maker-role { flex-direction: column; }
  .dl-maker-sec .dl-maker-role span + span::before { content: none; }
  .dl-species-note, .dl-scene-chips { left: 14px; right: 14px; bottom: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .dl-scene, .dl-chapter h3, .dl-chapter p, .dl-story-dots li, .dl-portrait img { transition: none; }
  .dl-scene { transform: none; }
}
