/* Концепция: витрина. Год лежит в одной горизонтальной ленте: обложка → месяцы → кадры на общей полке → записка.
   Снизу карта из 365 дней служит ползунком времени. Интро-сцена открывает страницу.
   Единая тёмная «вечерняя» тема выбрана осознанно: фотографии на тёмном фоне, тёплый свет свечи как акцент. */
:root {
  --bg: #0f0d13;
  --bg-2: #17141d;
  --bg-3: #221d2b;
  --fg: #f3ebe1;
  --fg-2: #b3a79b;
  --fg-3: #7d7369;
  --line: rgba(243, 235, 225, 0.12);
  --line-strong: rgba(243, 235, 225, 0.28);
  --gold: #d8a65b;
  --gold-soft: rgba(216, 166, 91, 0.18);
  --gold-glow: rgba(216, 166, 91, 0.55);
  --rose: #e38c9c;

  --font-display: 'Prata', 'Times New Roman', Georgia, serif;
  --font-body: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-script: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;

  --gutter-l: max(16px, env(safe-area-inset-left, 0px));
  --gutter-r: max(16px, env(safe-area-inset-right, 0px));

  color-scheme: dark;
}

* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 400; text-wrap: balance; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ------------------------------------------------------------ общие */
.eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-2);
}
.link-btn {
  background: none;
  border: 0;
  padding: 0.4em 0;
  color: var(--fg-2);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 0.25em;
}
.link-btn:hover { color: var(--fg); text-decoration-color: var(--gold); }

/* ------------------------------------------------------------ интро */
.intro {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: var(--bg);
  overflow: hidden;
  display: grid;
  place-items: center;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
}
.intro-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.intro-stage {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 820px;
  text-align: center;
  display: grid;
  gap: 0.6rem;
  transform: translateY(-16vh);
}
.intro-kicker {
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0;
}
.intro-counter {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35em;
  opacity: 0;
}
.intro-num {
  font-family: var(--font-display);
  font-size: clamp(5.5rem, 22vw, 13rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  text-shadow: 0 0 60px var(--gold-soft);
}
.intro-num-label {
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(1.4rem, 4.5vw, 2.4rem);
  color: var(--fg-2);
}
.intro-line {
  min-height: 2.6em;
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(1.25rem, 3.6vw, 1.9rem);
  color: var(--fg);
  opacity: 0;
}
.intro-final {
  position: absolute;
  inset: 0;
  z-index: 4;
  margin: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 7.5rem);
  line-height: 1.05;
  color: var(--fg);
  opacity: 0;
  pointer-events: none;
}
.intro-final small {
  display: block;
  margin-top: 0.4em;
  font-family: var(--font-script);
  font-style: italic;
  font-size: 0.32em;
  color: var(--gold);
  letter-spacing: 0.02em;
}
.intro-photos { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.intro-photo {
  position: absolute;
  left: 0; top: 0;
  width: clamp(84px, 16vw, 150px);
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  opacity: 0;
  will-change: transform, opacity;
}
.intro-skip {
  position: absolute;
  z-index: 4;
  right: calc(var(--gutter-r) + 4px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
  background: rgba(15, 13, 19, 0.5);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.55em 1.1em;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--fg-2);
  cursor: pointer;
  opacity: 0;
  transition: color 0.2s, border-color 0.2s;
}
.intro-skip:hover { color: var(--fg); border-color: var(--gold); }

/* экран «Открыть»: весь экран кнопка, касание запускает музыку и интро */
.intro-gate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1.7rem;
  padding-left: var(--gutter-l);
  padding-right: var(--gutter-r);
  background: transparent;
  border: 0;
  font: inherit;
  color: var(--fg);
  text-align: center;
  cursor: pointer;
  opacity: 0;
  -webkit-tap-highlight-color: transparent;
}
.gate-title {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 9vw, 4rem);
  line-height: 1.1;
  text-wrap: balance;
}
.gate-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.85em 1.8em;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--gold-soft);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  animation: gate-breathe 2.6s ease-in-out infinite;
}
.gate-hint { font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-3); }
@keyframes gate-breathe {
  0%, 100% { box-shadow: 0 0 16px var(--gold-soft); }
  50% { box-shadow: 0 0 40px var(--gold-glow); }
}

/* ------------------------------------------------------------ каркас: одна сцена на весь экран */
.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg);
  touch-action: manipulation;
}

/* ------------------------------------------------------------ финал: слова, мем и её фото после ленты */
.finale {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) var(--gutter-r) calc(env(safe-area-inset-bottom, 0px) + 16px) var(--gutter-l);
  background: radial-gradient(70% 60% at 50% 40%, rgba(216, 166, 91, 0.12), transparent 70%), var(--bg);
  overflow: hidden;
}
.fn-stage { display: grid; place-items: center; width: 100%; max-width: 820px; }
.fn-word, .fn-photo, .fn-meme { grid-area: 1 / 1; opacity: 0; will-change: transform, opacity; }
.fn-word {
  margin: 0;
  max-width: 17em;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 5.2vw, 2.7rem);
  line-height: 1.25;
  text-align: center;
  text-wrap: balance;
  color: var(--fg);
  text-shadow: 0 0 40px rgba(216, 166, 91, 0.25);
}
.fn-photo { margin: 0; display: grid; gap: 14px; justify-items: center; }
.fn-frame {
  height: min(62vh, 560px);
  aspect-ratio: var(--fr, 3 / 4);
  max-width: 100%;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg-3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(216, 166, 91, 0.35);
}
.fn-img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; will-change: transform; }
.fn-cap { font-family: var(--font-script); font-style: italic; font-size: 1.15rem; color: var(--fg-2); text-align: center; }
.fn-meme {
  margin: 0;
  width: min(100%, 560px);
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 14px;
  padding: 16px;
  background: #0a080d;
  border: 1px solid rgba(243, 235, 225, 0.12);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 0 6px #050407;
}
.meme-pic { width: 128px; aspect-ratio: 5 / 6; overflow: hidden; background: #15101a; filter: saturate(0.6) contrast(1.08); }
.meme-draw, .meme-img { display: block; width: 100%; height: 100%; object-fit: cover; }
.meme-text { display: grid; gap: 10px; text-align: center; }
.meme-quote {
  margin: 0;
  font-family: 'Times New Roman', Times, 'Noto Serif', serif;
  font-weight: 700;
  font-size: clamp(1.05rem, 3.5vw, 1.4rem);
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  text-wrap: balance;
}
.meme-author { font-family: 'Times New Roman', Times, serif; font-style: italic; font-size: 0.95rem; color: #d9d2cb; }
.meme-author::before { content: "© "; }
@media (min-width: 560px) {
  .fn-meme { grid-template-columns: 160px 1fr; align-items: center; gap: 22px; padding: 20px; }
  .meme-pic { width: 160px; }
  .meme-text { text-align: left; }
}
/* кнопка финала в конце ленты */
.finale-cta { margin: 0 0 1.4rem; text-align: center; }
.finale-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.8em 1.5em;
  border: 1px solid var(--gold);
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 0 24px var(--gold-soft);
  transition: background 0.2s, box-shadow 0.2s;
}
.finale-btn:hover { background: rgba(216, 166, 91, 0.3); box-shadow: 0 0 40px var(--gold-glow); }

/* ------------------------------------------------------------ фон: ночная деревня
   Четыре слоя из scripts/build_scenery.py лежат под всем содержимым (z-index -1 внутри .app). Небо стоит на месте,
   три слоя земли едут вбок вместе с лентой: js/scenery.js кладёт прогресс ленты (0..1) в --p, у каждого слоя свой размах.
   Одна единица рисунка = --k пикселей, поэтому деревня одного размера на всех экранах; земля лежит под полкой,
   на месте таблички и карты года. */
.scenery {
  --k: clamp(0.8px, 0.135vh, 1.6px);
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.sc-defs { position: absolute; width: 0; height: 0; }
.sc-layer { position: absolute; left: 0; bottom: 0; display: block; }
.sc-sky { inset: 0; width: 100%; height: 100%; }
.sc-far, .sc-mid, .sc-near {
  height: calc(400 * var(--k));
  width: max(100%, calc(var(--w) * var(--k)));
  transform: translate3d(calc(var(--p, 0) * -1 * max(0px, calc(var(--w) * var(--k) - 100vw))), 0, 0);
  will-change: transform;
}
.sc-far { --w: 2000; }
.sc-mid { --w: 2400; }
.sc-near { --w: 3200; }

.sc-smoke { opacity: 0; transform-box: fill-box; transform-origin: center; animation: sc-smoke 9s ease-out infinite; }
.sc-small { animation-duration: 12s; }
@keyframes sc-smoke {
  0% { transform: translate(0, 0) scale(0.5); opacity: 0; }
  15% { opacity: 0.22; }
  100% { transform: translate(18px, -70px) scale(2.3); opacity: 0; }
}
.sc-twinkle { animation: sc-twinkle 5s ease-in-out infinite; }
@keyframes sc-twinkle { 50% { opacity: 0.12; } }
.sc-glow { animation: sc-glow 5.5s ease-in-out infinite; }
@keyframes sc-glow { 0%, 100% { opacity: 1; } 45% { opacity: 0.78; } 70% { opacity: 0.92; } }
.sc-hop { animation: sc-hop 3.4s ease-in-out infinite; }
@keyframes sc-hop { 0%, 68%, 100% { transform: translateY(0); } 76% { transform: translateY(-9px); } 84% { transform: translateY(0); } 90% { transform: translateY(-5px); } }

/* ------------------------------------------------------------ верхняя строка */
.topbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 0 var(--gutter-r) 0 var(--gutter-l);
}
.topbar-title {
  background: none;
  border: 0;
  padding: 8px 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: 0.01em;
  color: var(--fg);
  cursor: pointer;
}
.topbar-tools { display: flex; align-items: center; gap: 10px; }
.counter {
  min-width: 4.8em;
  text-align: right;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--fg-3);
  font-variant-numeric: tabular-nums;
}
.tool {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(243, 235, 225, 0.04);
  color: var(--fg-2);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.tool:hover { color: var(--fg); border-color: var(--gold); }
.tool[aria-pressed="true"] { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
.tool-play .ico-pause { display: none; }
.tool-play[aria-pressed="true"] .ico-play { display: none; }
.tool-play[aria-pressed="true"] .ico-pause { display: block; }
.music { gap: 0.5em; font-size: 0.8rem; }
.music-icon { font-size: 1rem; line-height: 1; }
.music-title { display: none; }
.music[aria-pressed="true"] .music-icon { animation: beat 1.2s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.25); } }
@media (min-width: 760px) {
  .music { width: auto; padding: 0 1em; border-radius: 999px; grid-auto-flow: column; }
  .music-title { display: inline; }
}
.topbar-progress {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 1px;
  width: 0;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
  transition: width 0.25s ease-out;
}

/* ------------------------------------------------------------ сцена
   Все размеры рамок считаются от двух чисел, которые скрипт кладёт на сцену: --sw и --sh (её ширина и высота).
   --fh: высота рамки, одна на все кадры, чтобы они стояли на общей полке. Ограничена и высотой сцены, и шириной экрана:
   самая широкая вертикальная рамка 4:5 должна помещаться с полями, чтобы по бокам выглядывали соседние кадры. */
.stage {
  --sw: 100vw;
  --sh: 60vh;
  --pad: 26px;
  --fill: 0.84;
  --fh: min(calc(var(--sh) * var(--fill)), calc((var(--sw) - var(--pad) * 2) / 0.8));
  --pb: calc((var(--sh) - var(--fh)) / 2 + 6px);
  --pt: calc((var(--sh) - var(--fh)) / 2 - 6px);
  position: relative;
  min-height: 0;
  background:
    radial-gradient(60% 75% at 50% 24%, rgba(216, 166, 91, 0.14), transparent 72%),
    linear-gradient(to top, rgba(216, 166, 91, 0.07) var(--pb), transparent calc(var(--pb) + 70px));
}
/* полка, на которой стоят кадры */
.stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--pb);
  height: 1px;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(216, 166, 91, 0.5) 20%, rgba(216, 166, 91, 0.5) 80%, transparent);
  box-shadow: 0 0 22px rgba(216, 166, 91, 0.28);
}
@media (min-width: 700px) { .stage { --pad: 72px; --fill: 0.86; } }

.track {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: flex-end;
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--pt) 0 var(--pb);
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  cursor: grab;
}
.track::-webkit-scrollbar { display: none; }
/* половина экрана с каждого края, чтобы первый и последний слайды вставали по центру */
.track::before, .track::after { content: ""; flex: 0 0 50%; }
.track.is-free, .track.is-dragging { scroll-snap-type: none; }
.track.is-dragging { cursor: grabbing; }

/* Слайд. Скрипт пишет в --a расстояние до центра (0 в центре, 1 и дальше у соседей): центральный кадр яркий и крупный,
   остальные уходят в тень и чуть уменьшаются, оставаясь стоять на полке. */
.slide {
  --a: 1;
  --d: 0;
  flex: 0 0 auto;
  height: var(--fh);
  margin: 0 9px;
  display: grid;
  align-items: end;
  scroll-snap-align: center;
  transform-origin: 50% 100%;
  transform: scale(calc(1 - var(--a) * 0.13));
  opacity: calc(1 - var(--a) * 0.6);
}
.slide.is-near { will-change: transform, opacity; }
.slide--day { margin-left: 34px; }
.slide--plate, .slide--cover, .slide--end { margin-left: 26px; margin-right: 26px; }

/* ------------------------------------------------------------ рамка с фотографией */
.frame {
  position: relative;
  margin: 0;
  height: var(--fh);
  width: calc(var(--fh) * var(--fr, 0.75));
  border-radius: 6px;
  overflow: hidden;
  background: var(--c, var(--bg-3));
  box-shadow: 0 0 0 1px rgba(243, 235, 225, 0.1), 0 22px 40px -24px rgba(0, 0, 0, 0.85);
  cursor: pointer;
  outline-offset: 4px;
  transition: box-shadow 0.4s;
}
.slide.is-active .frame {
  cursor: zoom-in;
  box-shadow: 0 0 0 1px rgba(216, 166, 91, 0.4), 0 30px 60px -24px rgba(0, 0, 0, 0.85), 0 0 90px rgba(216, 166, 91, 0.13);
}
/* пока кадр грузится, и за горизонтальным кадром: размытая копия его же цветов */
.frame::before {
  content: "";
  position: absolute;
  inset: -24px;
  background: var(--lqip) center / cover no-repeat;
  filter: blur(22px) saturate(1.25);
}
.frame--contain::before { filter: blur(26px) saturate(1.3) brightness(0.72); }
.frame--cover.is-loaded::before { display: none; }
.frame img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--focus, 50% 30%); /* лица обычно в верхней трети */
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
  -webkit-user-drag: none;
}
.frame--contain img { object-fit: contain; object-position: 50% 50%; }
.frame.is-loaded img { opacity: 1; }
/* блик на стекле витрины */
.frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.13) 0%, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.04) 100%);
}
/* отражение в полированной полке; там, где не поддерживается, его просто нет */
@supports (-webkit-box-reflect: below 0) {
  .frame { -webkit-box-reflect: below 3px linear-gradient(transparent 90%, rgba(255, 255, 255, 0.2)); }
}

/* ------------------------------------------------------------ обложка */
.slide--cover { width: min(calc(var(--sw) - var(--pad) * 2), 520px); }
.cover {
  height: var(--fh);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 1rem;
  text-align: center;
}
.cover-title {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, calc(var(--fh) / 5.2), 6rem);
  line-height: 1;
  letter-spacing: -0.015em;
}
.cover-sub {
  font-family: var(--font-script);
  font-style: italic;
  font-size: clamp(1.15rem, 3.2vw, 1.5rem);
  color: var(--fg-2);
}
.cover-hint {
  margin-top: 1.6rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-3);
}
.cover-hint i {
  position: relative;
  width: 44px;
  height: 1px;
  background: currentColor;
  animation: nudge 2.2s ease-in-out infinite;
}
.cover-hint i::after {
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  width: 7px;
  height: 7px;
  border-top: 1px solid currentColor;
  border-right: 1px solid currentColor;
  transform: rotate(45deg);
}
@keyframes nudge { 0%, 100% { transform: translateX(0); opacity: 0.4; } 50% { transform: translateX(10px); opacity: 1; } }

/* ------------------------------------------------------------ табличка месяца */
.slide--plate { width: min(calc(var(--sw) - var(--pad) * 2), 300px); }
.slide--quiet { width: min(calc(var(--sw) - var(--pad) * 2), 230px); }
.plate {
  position: relative;
  width: 100%;
  height: var(--fh);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0.9rem;
  padding: 30px 24px 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(165deg, rgba(34, 29, 43, 0.85), rgba(23, 20, 29, 0.35));
  overflow: hidden;
}
.plate::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 30px;
  width: 28px;
  height: 1px;
  background: var(--gold);
  box-shadow: 0 0 10px var(--gold-glow);
}
.plate .eyebrow { margin-top: auto; }
.plate-title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, calc(var(--fh) / 11), 2.9rem);
  line-height: 1;
  letter-spacing: -0.01em;
}
.plate-title span {
  display: block;
  margin-top: 0.5em;
  font-family: var(--font-body);
  font-size: 0.8rem;
  letter-spacing: 0.24em;
  color: var(--fg-3);
}
.plate-chapter {
  font-family: var(--font-script);
  font-size: 1.2rem;
  line-height: 1.4;
  color: var(--fg-2);
}
.plate-chapter strong { color: var(--fg); font-weight: 500; font-style: italic; }
.slide--quiet .plate { border-style: dashed; background: none; }
.slide--quiet .plate-title { font-size: clamp(1.5rem, calc(var(--fh) / 14), 2.1rem); color: var(--fg-2); }
.plate-quiet { font-size: 0.9rem; color: var(--fg-3); }

/* ------------------------------------------------------------ записка в конце */
.slide--end { width: min(calc(var(--sw) - var(--pad) * 2), 540px); }
.end-card {
  height: var(--fh);
  display: flex;
  flex-direction: column;
  padding: 26px 24px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(165deg, rgba(34, 29, 43, 0.85), rgba(23, 20, 29, 0.35));
  overflow-y: auto;
  overscroll-behavior: contain;
  text-align: center;
  cursor: auto;
  -webkit-user-select: text;
  user-select: text;
  scrollbar-width: thin;
}
.end-card > :first-child { margin-top: auto; }
.end-card > :last-child { margin-bottom: auto; }
.letter { display: grid; gap: 1.1rem; }
.letter-heading { font-family: var(--font-display); font-size: clamp(1.7rem, 5vw, 2.4rem); line-height: 1.15; }
.letter-text {
  font-family: var(--font-script);
  font-size: clamp(1.15rem, 3.4vw, 1.4rem);
  line-height: 1.5;
  color: var(--fg);
  white-space: pre-line;
}
.letter-sign { font-family: var(--font-script); font-style: italic; font-size: 1.4rem; color: var(--gold); }
.end-foot { margin-top: 1.6rem; padding-top: 1.2rem; display: grid; gap: 0.4rem; border-top: 1px solid var(--line); color: var(--fg-3); font-size: 0.9rem; }
.footer-live { font-family: var(--font-script); font-size: 1.3rem; color: var(--fg-2); }
.footer-live strong { color: var(--fg); font-weight: 500; }

/* ------------------------------------------------------------ табличка под кадром */
.info {
  --info-h: 98px;
  height: var(--info-h);
  padding: 0 var(--gutter-r) 0 var(--gutter-l);
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.15rem;
  text-align: center;
  overflow: hidden;
  transition: opacity 0.3s;
}
.info.is-quiet { opacity: 0; }
/* мягкое затемнение под табличкой, чтобы дата читалась поверх окон и забора деревни */
.info { position: relative; }
.info::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(15, 13, 19, 0.58) 28%, rgba(15, 13, 19, 0.58) 72%, transparent);
}
.info-label { font-size: 0.7rem; letter-spacing: 0.2em; text-transform: uppercase; color: var(--fg-3); }
.info-date { font-family: var(--font-display); font-size: 1.35rem; line-height: 1.2; }
.info-meta { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-2); }
.info-cap {
  max-width: 36em;
  font-family: var(--font-script);
  font-style: italic;
  font-size: 1.1rem;
  line-height: 1.3;
  color: var(--fg-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.info-cap:empty { display: none; }
@media (min-width: 700px) {
  .info { --info-h: 110px; }
  .info-date { font-size: 1.6rem; }
  .topbar-title { font-size: 1.3rem; }
}

/* ------------------------------------------------------------ карта года как ползунок времени */
.rail { padding: 2px var(--gutter-r) 12px var(--gutter-l); }
.rail-map {
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 18px;
  touch-action: none;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.yearmap {
  display: grid;
  grid-template-columns: repeat(var(--cols, 53), 1fr);
  gap: 2px;
  width: 100%;
}
@media (min-width: 600px) { .yearmap { gap: 3px; } }
.ym-cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--bg-3);
  border: 0;
  padding: 0;
  margin: 0;
  display: block;
  width: 100%;
  min-width: 0;
  pointer-events: none;
  transition: transform 0.18s, background 0.18s;
}
.ym-cell[data-lvl="1"] { background: color-mix(in srgb, var(--gold) 55%, var(--bg)); }
.ym-cell[data-lvl="2"] { background: color-mix(in srgb, var(--gold) 80%, var(--bg)); }
.ym-cell[data-lvl="3"] { background: var(--gold); box-shadow: 0 0 8px var(--gold-glow); }
.ym-cell.is-today { box-shadow: 0 0 0 2px var(--rose); background: var(--bg); }
.ym-cell.is-anniv { background: var(--rose); box-shadow: 0 0 10px rgba(227, 140, 156, 0.6); }
.ym-cell.is-empty { visibility: hidden; }
.ym-cell.is-current {
  z-index: 2;
  background: var(--fg);
  transform: scale(2.2);
  box-shadow: 0 0 0 1.5px rgba(15, 13, 19, 0.9), 0 0 10px rgba(243, 235, 225, 0.75);
}
.rail-months { position: absolute; left: 0; right: 0; bottom: 0; height: 14px; }
.rail-months span {
  position: absolute;
  top: 0;
  font-size: 0.58rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-3);
  white-space: nowrap;
}
.rail-tip {
  position: absolute;
  bottom: calc(100% + 4px);
  z-index: 5;
  transform: translateX(-50%);
  padding: 0.35em 0.75em;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--bg-3);
  font-size: 0.72rem;
  white-space: nowrap;
  pointer-events: none;
}

/* ------------------------------------------------------------ стрелки (мышь) */
.nav {
  display: none;
  position: absolute;
  top: 50%;
  z-index: 4;
  width: 46px;
  height: 46px;
  margin-top: -23px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(15, 13, 19, 0.55);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--fg);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.2s, border-color 0.2s;
}
.nav:hover:not(:disabled) { border-color: var(--gold); }
.nav:disabled { opacity: 0.25; cursor: default; }
.nav-prev { left: calc(var(--gutter-l) + 8px); }
.nav-next { right: calc(var(--gutter-r) + 8px); }
@media (hover: hover) and (pointer: fine) and (min-width: 700px) { .nav { display: grid; } }

/* телефон на боку: места по высоте мало, оставляем сцену, короткую табличку и тонкую линию прогресса */
@media (max-height: 520px) and (orientation: landscape) {
  .topbar { min-height: 42px; }
  .rail { display: none; }
  .info { --info-h: 62px; }
  .info-label, .info-cap { display: none; }
  .info-date { font-size: 1.15rem; }
  .stage { --fill: 0.9; }
}

@media (prefers-reduced-motion: reduce) {
  .slide { transform: none; }
  .cover-hint i, .music[aria-pressed="true"] .music-icon, .gate-pill, .scenery * { animation: none; }
  .frame img { transition: none; }
}

/* ------------------------------------------------------------ лайтбокс */
.lb {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 8, 13, 0.96);
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) var(--gutter-r) calc(env(safe-area-inset-bottom, 0px) + 12px) var(--gutter-l);
  animation: fade 0.25s ease both;
}
@keyframes fade { from { opacity: 0; } }
.lb-fig {
  margin: 0;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0.8rem;
  align-items: center;
}
.lb-img {
  width: 100%;
  height: 100%;
  max-height: calc(100dvh - 140px);
  object-fit: contain;
  border-radius: 4px;
  justify-self: center;
  background: transparent;
}
.lb-cap { text-align: center; display: grid; gap: 0.25rem; justify-items: center; padding-bottom: 0.4rem; }
.lb-date { font-family: var(--font-display); font-size: 1.1rem; }
.lb-day { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3); }
.lb-text { font-family: var(--font-script); font-style: italic; font-size: 1.2rem; color: var(--fg-2); max-width: 36em; }
.lb-text:empty { display: none; }
.lb-count { font-size: 0.75rem; color: var(--fg-3); font-variant-numeric: tabular-nums; }
.lb-close, .lb-nav {
  position: absolute;
  z-index: 2;
  background: rgba(243, 235, 225, 0.06);
  border: 1px solid var(--line);
  color: var(--fg);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
  transition: background 0.2s;
}
.lb-close:hover, .lb-nav:hover { background: rgba(243, 235, 225, 0.14); }
.lb-close { top: calc(env(safe-area-inset-top, 0px) + 14px); right: calc(var(--gutter-r) + 2px); }
.lb-nav { top: 50%; transform: translateY(-50%); }
.lb-prev { left: calc(var(--gutter-l) + 2px); }
.lb-next { right: calc(var(--gutter-r) + 2px); }
@media (max-width: 599px) { .lb-nav { display: none; } }
