/* Midnight Fable — ночь в шести главах */
:root {
  --ink-950: #05080f;
  --ink-900: #080d1f;
  --ink-800: #0c1326;
  --ink-700: #141d3a;
  --ink-600: #1d2b56;
  --paper: #f3ead7;
  --paper-dim: #c2bcae;
  --lantern: #f4b860;
  --ember: #e5674a;
  --moon: #cfe3e0;
  --dawn-1: #2b2350;
  --dawn-2: #b8607a;
  --dawn-3: #f2a974;
  --dawn-4: #f8d9a8;

  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Noto Serif", "DejaVu Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;

  --gutter: clamp(1.25rem, 5vw, 4rem);
  --maxw: 76rem;
  --night: 0; /* 0 — полночь, 1 — рассвет; задаётся скриптом */
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  /* Ночь светлеет по мере чтения: глубокая полночь вверху, предрассветная слива внизу */
  background: linear-gradient(to bottom, #070b1a 0%, #0a1026 18%, #0e152f 42%, #151a3b 64%, #1f1d46 84%, var(--dawn-1) 100%) var(--ink-800);
  color: var(--paper);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.6;
  overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 400; line-height: 1.2; }
p { margin: 0; }
strong { font-weight: 600; color: var(--paper); }

a { color: var(--lantern); text-underline-offset: 0.2em; }

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.skip {
  position: absolute;
  left: 1rem; top: -4rem;
  z-index: 100;
  padding: 0.75rem 1.1rem;
  background: var(--lantern);
  color: var(--ink-900);
  font-weight: 600;
  border-radius: 0 0 8px 8px;
  text-decoration: none;
}
.skip:focus { top: 0; }

/* ——— Небо: звёзды тают к рассвету ——— */
.sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, rgba(243,234,215,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 72%, rgba(243,234,215,.6) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 46% 34%, rgba(243,234,215,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 12%, rgba(243,234,215,.6) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 58%, rgba(243,234,215,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 26%, rgba(243,234,215,.6) 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 88%, rgba(243,234,215,.5) 50%, transparent 51%),
    radial-gradient(1px 1px at 55% 90%, rgba(243,234,215,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 94% 84%, rgba(243,234,215,.6) 50%, transparent 51%);
  background-size: 520px 520px;
  opacity: calc(1 - var(--night) * 0.85);
}
.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, var(--dawn-1), transparent 70%);
  opacity: var(--night);
}

/* ——— Шапка ——— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem var(--gutter);
  padding-inline: max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter)));
  background: rgba(7,11,26,.74);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(243,234,215,.08);
}
/* Сколько ночи уже прочитано: полоска под шапкой (--night из скрипта) */
.topbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--lantern), var(--dawn-2) 70%, var(--dawn-3));
  transform-origin: 0 50%;
  transform: scaleX(var(--night));
  pointer-events: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  color: var(--paper);
  text-decoration: none;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  letter-spacing: 0.01em;
}
.brand__mark { width: 30px; height: 30px; color: var(--paper); }
.brand:hover .brand__mark { color: var(--lantern); }

.chapters { position: relative; }

.chapters__toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  padding: 0.35rem 0.9rem;
  border: 1px solid rgba(243,234,215,.3);
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
.chapters__toggle:hover { border-color: var(--lantern); }
.chapters__icon {
  display: inline-block;
  position: relative;
  width: 14px; height: 10px;
  border-top: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
}
.chapters__icon::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  border-top: 1.5px solid currentColor;
  transform: translateY(-50%);
}
.chapters[data-open="true"] .chapters__icon { border-color: var(--lantern); }
.brand__name { white-space: nowrap; }
@media (max-width: 23.5rem) {
  .chapters__label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
  .brand { font-size: 1.05rem; }
}
.chapters__clock {
  font-family: var(--mono);
  font-size: 0.9rem;
  color: var(--lantern);
  font-variant-numeric: tabular-nums;
}

.chapters__list {
  list-style: none;
  margin: 0;
  padding: 0.5rem;
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  min-width: 15rem;
  background: var(--ink-900);
  border: 1px solid rgba(243,234,215,.15);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,.45);
  display: none;
}
.chapters[data-open="true"] .chapters__list { display: block; }
.no-js .chapters__list { display: block; position: static; }

.chapters__list a {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: 48px;
  padding: 0.5rem 0.8rem;
  border-radius: 10px;
  color: var(--paper);
  text-decoration: none;
}
.chapters__list a:hover { background: var(--ink-700); }
.chapters__list .t { font-family: var(--mono); font-size: 0.85rem; color: var(--paper-dim); }
.chapters__list a[aria-current="true"] .t { color: var(--lantern); }
.chapters__list a[aria-current="true"] { background: var(--ink-700); }

@media (min-width: 60rem) {
  .chapters__toggle { display: none; }
  .chapters__list {
    display: flex;
    position: static;
    min-width: 0;
    padding: 0;
    gap: 0.15rem;
    background: none;
    border: 0;
    box-shadow: none;
  }
  .chapters__list a { min-height: 44px; padding: 0.4rem 0.75rem; font-size: 0.95rem; gap: 0.5rem; }
  .chapters__list .t { font-size: 0.75rem; }
}

/* ——— Общие элементы ——— */
.eyebrow {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.eyebrow__time { color: var(--lantern); margin-right: 0.6em; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .2s, color .2s, border-color .2s, transform .2s;
}
.btn--lantern { background: var(--lantern); color: var(--ink-900); }
.btn--lantern:hover { background: var(--dawn-4); }
.btn--ghost { color: var(--paper); border-color: rgba(243,234,215,.45); background: transparent; }
.btn--ghost:hover { border-color: var(--lantern); color: var(--lantern); }
.btn--ink { background: var(--ink-900); color: var(--paper); }
.btn--ink:hover { background: var(--ink-700); }
.btn:active { transform: translateY(1px); }

/* ——— 00:00 Пролог ——— */
.prologue {
  display: grid;
  gap: 2rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 4rem) var(--gutter) clamp(3rem, 8vw, 6rem);
}

.prologue__text { display: grid; gap: 1.4rem; align-content: center; }

.wordmark {
  font-family: var(--serif);
  line-height: 0.88;
  letter-spacing: -0.02em;
  font-size: clamp(3.4rem, 15vw, 8.5rem);
}
.wordmark span { display: block; }
.wordmark__a { font-style: italic; color: var(--paper); }
.wordmark__b {
  padding-left: 0.9em;
  color: var(--lantern);
}

.lede {
  max-width: 32rem;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  line-height: 1.5;
  color: var(--paper);
}

.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.countdown {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--paper-dim);
  border-left: 2px solid var(--lantern);
  padding-left: 0.8rem;
  max-width: 30rem;
}

.prologue__art { margin: 0; position: relative; isolation: isolate; }
.prologue__art::before {
  content: "";
  position: absolute;
  inset: 8% 0 -4%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(244,184,96,.13), rgba(184,96,122,.06) 55%, transparent);
  pointer-events: none;
}
.prologue__art svg { width: 100%; height: auto; max-height: 78vh; margin-inline: auto; }

.stars circle, .stars path { animation: twinkle 4s ease-in-out infinite; }
.stars :nth-child(3n) { animation-delay: -1.3s; animation-duration: 5s; }
.stars :nth-child(3n+1) { animation-delay: -2.7s; animation-duration: 3.4s; }
.lamp { animation: flicker 3.2s ease-in-out infinite; transform-origin: 250px 512px; }
.layer { transition: transform .6s cubic-bezier(.2,.7,.2,1); }

@keyframes twinkle { 50% { opacity: .35; } }
@keyframes flicker { 0%, 100% { opacity: 1; } 40% { opacity: .75; } 60% { opacity: .95; } }

@media (min-width: 56rem) {
  .prologue {
    grid-template-columns: 1.05fr 1fr;
    align-items: center;
    min-height: calc(100vh - 4rem);
    min-height: calc(100svh - 4rem);
  }
}

/* ——— Главы ——— */
.chapter {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(4rem, 10vw, 8rem) var(--gutter);
  display: grid;
  gap: 2.25rem;
}
/* Разделитель глав — та же пунктирная тропа, что у путника на иллюстрации */
.chapter::before {
  content: "";
  position: absolute;
  top: 0;
  left: var(--gutter);
  right: var(--gutter);
  height: 2px;
  background: repeating-linear-gradient(90deg, rgba(244,184,96,.55) 0 2px, transparent 2px 11px);
  -webkit-mask-image: linear-gradient(90deg, #000 0%, rgba(0,0,0,.7) 70%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 0%, rgba(0,0,0,.7) 70%, transparent 100%);
}

.chapter__head { display: grid; gap: 0.8rem; align-content: start; }
/* Маркер главы — циферблат: часовая стрелка показывает час главы (--h) */
.chapter__time {
  --dial: clamp(3.5rem, 2.8rem + 2vw, 4.5rem);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 1rem;
  font-family: var(--mono);
  font-size: clamp(1.15rem, 1rem + 0.5vw, 1.4rem);
  line-height: 1;
  color: var(--lantern);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}
.chapter__time::before {
  content: "";
  flex: none;
  width: var(--dial);
  height: var(--dial);
  border-radius: 50%;
  border: 1.5px solid rgba(243,234,215,.55);
  background:
    radial-gradient(circle, var(--lantern) 0 3px, transparent 3.5px),
    linear-gradient(var(--paper), var(--paper)) 50% 14% / 1.5px 37% no-repeat,
    radial-gradient(circle closest-side, var(--ink-900) 0 76%, transparent 77%),
    repeating-conic-gradient(from -1.5deg, rgba(243,234,215,.5) 0 3deg, transparent 3deg 30deg),
    var(--ink-900);
  box-shadow: 0 0 0 6px rgba(244,184,96,.06), 0 0 40px rgba(244,184,96,.12);
}
.chapter__time::after {
  content: "";
  position: absolute;
  left: calc(var(--dial) / 2 - 1.25px);
  top: 50%;
  width: 2.5px;
  height: calc(var(--dial) * 0.26);
  border-radius: 2px;
  background: var(--lantern);
  transform-origin: 50% 0;
  transform: rotate(calc(var(--h, 0) * 30deg + 180deg));
}
.chapter h2 {
  font-family: var(--serif);
  font-size: clamp(2rem, 1.4rem + 3vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-wrap: balance;
  overflow-wrap: break-word;
}
.chapter__note { color: var(--paper-dim); max-width: 34rem; }

@media (min-width: 60rem) {
  .chapter { grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); gap: 3rem 4rem; }
  .chapter h2 { font-size: clamp(1.9rem, 1rem + 2.2vw, 3rem); }
  .chapter__head { position: sticky; top: 6rem; }
  .studio h2, .fable h2, .craft h2 { font-size: clamp(2.2rem, 1.2rem + 2.6vw, 3.4rem); }
}

/* 01:00 Студия */
.dropcap { font-size: clamp(1.1rem, 1rem + 0.4vw, 1.3rem); max-width: 40rem; }
.dropcap::first-letter {
  float: left;
  font-family: var(--serif);
  font-style: italic;
  font-size: 4.2em;
  line-height: 0.8;
  margin: 0.08em 0.12em 0 0;
  color: var(--lantern);
}

.principles {
  list-style: none;
  margin: 3rem 0 0;
  padding: 0;
  display: grid;
  gap: 2.25rem;
}
@media (min-width: 40rem) and (max-width: 53.99rem) {
  .principles li { display: grid; grid-template-columns: 34px minmax(0, 1fr); column-gap: 1.25rem; }
  .principles li > * { grid-column: 2; }
  .principles .phase { grid-column: 1; grid-row: 1 / span 2; margin-top: 0.15rem; }
  .principles h3 { margin-top: 0; }
}
@media (min-width: 54rem) { .principles { grid-template-columns: repeat(3, 1fr); gap: 2rem; } }
.principles li { padding-top: 1.4rem; border-top: 1px solid rgba(243,234,215,.14); }
.principles h3 { font-family: var(--serif); font-size: 1.45rem; margin: 1rem 0 0.5rem; }
.principles p { color: var(--paper-dim); }

.phase {
  display: block;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 0 24px rgba(243,234,215,.25);
}
.phase--1 { box-shadow: inset 12px -4px 0 0 var(--ink-800), 0 0 18px rgba(243,234,215,.15); }
.phase--2 { background: linear-gradient(90deg, var(--ink-700) 50%, var(--paper) 50%); }
.phase--3 { background: var(--lantern); box-shadow: 0 0 28px rgba(244,184,96,.45); }

/* 02:00 Две сцены */
.tabs__list {
  display: inline-flex;
  padding: 0.3rem;
  gap: 0.3rem;
  border-radius: 999px;
  background: var(--ink-900);
  border: 1px solid rgba(243,234,215,.14);
  margin-bottom: 2rem;
}
.tabs__list[hidden] { display: none; }
.tabs__tab {
  min-height: 48px;
  min-width: 7.5rem;
  padding: 0.5rem 1.4rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--paper-dim);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .2s, color .2s;
}
.tabs__tab:hover { color: var(--paper); }
.tabs__tab[aria-selected="true"] { background: var(--paper); color: var(--ink-900); }

.scene {
  display: grid;
  gap: 1.75rem;
  align-items: center;
  padding: clamp(1.4rem, 4vw, 2.5rem);
  border-radius: 28px;
  border: 1px solid rgba(243,234,215,.12);
  background:
    radial-gradient(90% 80% at 12% 40%, rgba(244,184,96,.09), transparent 60%),
    rgba(7,11,26,.5);
}
.scene:focus-visible { border-radius: 28px; }
.scene + .scene { margin-top: 1.25rem; }
.scene__art svg { width: min(100%, 20rem); height: auto; }
.scene__kicker {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--lantern);
}
.scene h3 { font-family: var(--serif); font-style: italic; font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.6rem); margin: 0.4rem 0 1rem; line-height: 1.1; }
.scene__text > p:not(.scene__kicker) { max-width: 34rem; }
@media (min-width: 44rem) { .scene { grid-template-columns: minmax(12rem, 18rem) 1fr; gap: 2.5rem; } }

.ticks__title {
  margin-top: 1.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.ticks { list-style: none; padding: 0; margin: 0.8rem 0 0; display: grid; gap: 0.6rem; }
.ticks li { position: relative; padding-left: 1.6rem; color: var(--paper-dim); }
.ticks li::before {
  content: "";
  position: absolute;
  left: 0; top: 0.62em;
  width: 0.55rem; height: 0.55rem;
  border-radius: 50%;
  border: 1.5px solid var(--lantern);
}

/* 03:00 Сказка */
.loom { display: grid; gap: 2rem; align-items: start; }
@media (min-width: 60rem) {
  .fable { grid-template-columns: 1fr; }
  .fable .chapter__head { position: static; max-width: 46rem; }
  .loom { grid-template-columns: 1.15fr 1fr; gap: 3rem; }
  .loom__result { position: sticky; top: 6rem; }
}

.pick { border: 0; margin: 0 0 1.6rem; padding: 0; min-width: 0; }
.pick legend {
  padding: 0;
  margin-bottom: 0.8rem;
  font-family: var(--serif);
  font-size: 1.3rem;
}
.pick__n {
  display: inline-block;
  min-width: 2.2rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--lantern);
  letter-spacing: 0.1em;
}
.pick__options { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.pick label { position: relative; display: inline-flex; cursor: pointer; }
.pick input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}
.pick label span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(243,234,215,.28);
  color: var(--paper);
  font-size: 0.95rem;
  line-height: 1.25;
  transition: background-color .2s, border-color .2s, color .2s;
}
.pick label:hover span { border-color: var(--lantern); }
.pick input:checked + span { background: var(--lantern); border-color: var(--lantern); color: var(--ink-900); font-weight: 600; }
.pick input:focus-visible + span { outline: 3px solid var(--lantern); outline-offset: 3px; }

.tale {
  position: relative;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  border-radius: 200px 200px 18px 18px;
  padding-top: clamp(4rem, 9vw, 5.5rem);
  background:
    radial-gradient(circle at 50% 0%, rgba(244,184,96,.16), transparent 60%),
    var(--paper);
  color: var(--ink-900);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,.4);
}
.tale::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 190px 190px 12px 12px;
  border: 1px solid rgba(12,19,38,.22);
  pointer-events: none;
}
.tale__meta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #5a4d3b;
}
.tale__emblem { width: 56px; height: 56px; margin: 1.2rem auto 0.6rem; color: #8a4a1c; }
.tale__title {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.5rem, 1.2rem + 1.3vw, 2.1rem);
  line-height: 1.15;
  text-wrap: balance;
}
.tale__text { margin: 1rem auto 0; max-width: 28rem; line-height: 1.6; }
.tale__scene {
  margin: 1.4rem auto 0;
  padding-top: 1rem;
  border-top: 1px dashed rgba(12,19,38,.3);
  font-size: 0.92rem;
  color: #4a3f30;
  max-width: 26rem;
}
.tale.is-fresh { animation: tale-in .5s ease; }
@keyframes tale-in { from { opacity: .4; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.loom__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1.4rem; justify-content: center; }
.loom__actions .btn[hidden] { display: none; }
.loom__status { flex-basis: 100%; text-align: center; min-height: 1.6em; font-size: 0.9rem; color: var(--moon); }

/* 04:00 Ремесло */
.night-path { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; position: relative; }
.night-path li {
  position: relative;
  padding: 0 0 2.4rem 2.6rem;
}
.night-path li::before {
  content: "";
  position: absolute;
  left: 0.45rem; top: 0.5rem; bottom: 0;
  width: 1px;
  background: repeating-linear-gradient(to bottom, rgba(244,184,96,.6) 0 3px, transparent 3px 10px);
}
.night-path li:last-child::before { display: none; }
.night-path li::after {
  content: "";
  position: absolute;
  left: 0; top: 0.3rem;
  width: 0.95rem; height: 0.95rem;
  border-radius: 50%;
  background: var(--ink-800);
  border: 2px solid var(--lantern);
}
.night-path li:last-child::after { background: var(--lantern); box-shadow: 0 0 18px rgba(244,184,96,.6); }
.night-path__time { font-family: var(--mono); font-size: 0.85rem; color: var(--lantern); }
.night-path h3 { font-family: var(--serif); font-size: 1.5rem; margin: 0.2rem 0 0.4rem; }
.night-path p { color: var(--paper-dim); max-width: 34rem; }

@media (min-width: 60rem) {
  .craft { grid-template-columns: 1fr; }
  .craft .chapter__head { position: static; max-width: 46rem; }
  .night-path { grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }
  .night-path li { padding: 2.2rem 0 0; }
  .night-path li::before {
    left: 1.2rem; right: -1.5rem; top: 0.45rem; bottom: auto;
    width: auto; height: 1px;
    background: repeating-linear-gradient(to right, rgba(244,184,96,.6) 0 3px, transparent 3px 10px);
  }
  .night-path li::after { top: 0; }
}

/* 05:00 Дверь */
.door__body { display: grid; gap: 2rem; align-items: center; }
.door__art { position: relative; isolation: isolate; }
.door__art::before {
  content: "";
  position: absolute;
  inset: auto 0 -8% 0;
  height: 45%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(244,184,96,.28), transparent);
  pointer-events: none;
}
.door__art svg { width: min(60vw, 15rem); height: auto; }
.door__light { animation: flicker 4s ease-in-out infinite; }
.door__lead { font-family: var(--serif); font-size: clamp(1.35rem, 1.1rem + 1vw, 1.8rem); line-height: 1.3; margin-bottom: 1rem; max-width: 34rem; }
.door__text > p:not(.door__lead):not(.door__sign) { color: var(--paper-dim); max-width: 34rem; }
.door__sign { margin-top: 1.4rem; font-family: var(--mono); font-size: 0.85rem; letter-spacing: 0.08em; color: var(--lantern); }
@media (min-width: 44rem) { .door__body { grid-template-columns: auto 1fr; gap: 3rem; } }

/* ——— 06:00 Рассвет ——— */
.dawn {
  margin-top: clamp(3rem, 8vw, 6rem);
  background: linear-gradient(to bottom, var(--ink-800) 0%, var(--dawn-1) 18%, var(--dawn-2) 42%, var(--dawn-3) 70%, var(--dawn-4) 100%);
  color: var(--ink-900);
  position: relative;
  overflow: hidden;
}
.dawn::before {
  content: "";
  position: absolute;
  right: 6%;
  bottom: clamp(-16rem, -20vw, -8rem);
  width: clamp(16rem, 34vw, 30rem);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff3d6 0 46%, rgba(255,243,214,.55) 52%, rgba(255,243,214,0) 70%);
  pointer-events: none;
}
.dawn__inner {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(8rem, 18vw, 14rem) var(--gutter) 2.5rem;
  display: grid;
  gap: 1.5rem;
  justify-items: start;
}
.dawn__time { color: var(--paper); }
.dawn__time::before { border-color: rgba(243,234,215,.75); box-shadow: 0 0 0 6px rgba(255,243,214,.1), 0 0 50px rgba(255,243,214,.25); }
.dawn__line {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.6rem, 1.2rem + 2vw, 2.8rem);
  line-height: 1.15;
  max-width: 36rem;
  color: var(--ink-900);
}
.dawn__legal {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(8,13,31,.25);
  width: 100%;
  display: grid;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #2a1f2e;
}

/* ——— 404 ——— */
.lost {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 1.2rem;
  max-width: 40rem;
  margin: 0 auto;
  padding: 2rem var(--gutter);
}
.lost h1 { font-family: var(--serif); font-style: italic; font-size: clamp(2.2rem, 1.5rem + 3vw, 3.6rem); line-height: 1.1; }
.lost p:not(.eyebrow) { color: var(--paper-dim); }

/* ——— Уважение к reduced motion ——— */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .stars circle, .stars path, .lamp, .door__light { animation: none !important; }
  .layer { transform: none !important; }
}

.dawn :focus-visible { outline-color: var(--ink-900); }

/* Финальная подгонка ритма и пропорций */
.dawn { margin-top: 0; background: linear-gradient(to bottom, rgba(43,35,80,0) 0%, var(--dawn-1) 12%, var(--dawn-2) 40%, var(--dawn-3) 70%, var(--dawn-4) 100%); }
.dawn__inner { padding-top: clamp(5rem, 11vw, 9rem); }
.prologue { padding-bottom: clamp(2rem, 5vw, 4rem); }
@media (min-width: 56rem) {
  .prologue { min-height: min(calc(100svh - 4rem), 46rem); }
  .wordmark { font-size: clamp(3.4rem, 7vw, 7.25rem); }
}
@media (min-width: 60rem) {
  .chapter__head { align-self: start; }
  .studio, .scenes { grid-template-columns: 1fr; }
  .studio .chapter__head, .scenes .chapter__head { position: static; max-width: 46rem; }
  /* Обе сцены рядом: платформы видны сразу, без переключателя */
  .scenes__pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; align-items: stretch; }
  .scene { grid-template-columns: 1fr; align-content: start; gap: 1.5rem; padding: 2.25rem clamp(1.75rem, 2.6vw, 2.75rem) 2.5rem; }
  .scene + .scene { margin-top: 0; }
  .scene__art svg { width: min(100%, 13rem); }
  .scene h3 { text-wrap: balance; }
}
@media (max-width: 55.99rem) { .prologue__art svg { max-width: 28rem; } }
@media (max-width: 59.99rem) { .tale { max-width: 30rem; margin-inline: auto; } }
@media (max-width: 43.99rem) { .door__art svg { margin-inline: auto; } }
@media (max-width: 30rem) {
  .actions, .loom__actions { display: grid; grid-template-columns: 1fr; }
  .actions .btn, .loom__actions .btn { width: 100%; }
}

/* Без JavaScript: оглавление показывается списком, переключатель не нужен */
.no-js .topbar { position: static; flex-wrap: wrap; }
.no-js .chapters__list a { min-height: 44px; padding: 0.3rem 0.6rem; }
.no-js .loom__controls { display: none; }
.no-js .chapters__toggle { display: none; }
.no-js .chapters__list { display: flex; flex-wrap: wrap; justify-content: flex-end; position: static; min-width: 0; padding: 0; background: none; border: 0; box-shadow: none; }

/* Тексты для режима без JavaScript */
.nojs-only { display: none; }
.no-js .nojs-only { display: block; }
.no-js h2 .nojs-only { display: inline; }
.no-js .js-only { display: none; }

/* Мобильный первый экран: иллюстрация попадает в первый экран, таймер — под неё */
@media (max-width: 55.99rem) {
  .prologue { gap: 1.25rem; padding-top: 1.25rem; }
  .prologue__text { display: contents; }
  .prologue__art { order: 1; margin-top: 0.75rem; }
  .countdown { order: 2; }
  .wordmark { font-size: clamp(3.2rem, 14vw, 6.5rem); }
}
@media (max-width: 30rem) {
  .actions { display: flex; flex-wrap: wrap; }
  .actions .btn { width: auto; flex: 1 1 auto; padding-inline: 1.1rem; }
}

/* Компактные заголовки глав на телефоне: циферблат и «Глава …» в одной строке */
@media (max-width: 39.99rem) {
  .chapter { gap: 1.75rem; }
  .chapter__head { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 0.9rem; row-gap: 0.7rem; }
  .chapter__head > :not(.chapter__time):not(.eyebrow) { grid-column: 1 / -1; }
  .chapter__time { --dial: 2.9rem; gap: 0.7rem; font-size: 1.05rem; }
  .scene { gap: 1.25rem; }
  .scene__art svg { width: min(100%, 11rem); }
}

@media (forced-colors: active) {
  .pick input:checked + span { outline: 2px solid CanvasText; }
  .tabs__tab[aria-selected="true"] { outline: 2px solid CanvasText; }
  .chapter__time::before, .chapter__time::after { forced-color-adjust: none; }
}
