/* ============================================================
   «После моря» — оформление. Мобильный приоритет.
   Палитра: вода → песок → соляная корка (сюжет высыхания).
   ============================================================ */

:root{
  --ink: #e9e4d8;
  --ink-dim: rgba(233,228,216,.62);
  --card: rgba(10, 22, 28, .46);
  --line: rgba(233,228,216,.22);
  --accent: #7fd4c7;
  --serif: "Iowan Old Style","Palatino Linotype",Palatino,Georgia,"Times New Roman",serif;
  --sans: system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --fade: 1.4s;
}

*{ box-sizing:border-box; margin:0; padding:0; }
html,body{ height:100%; }
body{
  font-family:var(--sans);
  color:var(--ink);
  background:#0b3a4a;
  overflow:hidden;
  -webkit-font-smoothing:antialiased;
  overscroll-behavior:none;
}

/* ---------- сцена (фоны по таймкодам) ---------- */
#stage{ position:fixed; inset:0; z-index:0; }
.layer{
  position:absolute; inset:0;
  opacity:0; transition:opacity var(--fade) ease;
  background-size:cover; background-position:center;
}
.layer.on{ opacity:1; }
.layer img, .layer video{
  width:100%; height:100%; object-fit:cover; display:block;
}
.layer img.contain, .layer video.contain{ object-fit:contain; }
/* поля contain-медиа наследуют фон слоя (градиент), а не черноту */

/* Дефолтные фоны-градиенты: подобраны по тону фото каждой главы
   (видны при кросс-фейдах и по бокам от contain-медиа).
   Свои фото/видео задаются в js/cues.js (media) — они лягут поверх. */
.bg-greeting  { background:linear-gradient(180deg,#141518 0%,#26282b 45%,#4a4d50 78%,#6e7276 100%); }
.bg-first-hall{ background:linear-gradient(180deg,#9aa0a5 0%,#c6cacd 55%,#e4e6e8 100%); }
.bg-khorezm   { background:linear-gradient(180deg,#3a2015 0%,#7a4224 55%,#b06a3c 85%,#d29a6a 100%); }
.bg-pialki    { background:linear-gradient(180deg,#221509 0%,#5c3a20 55%,#966840 85%,#c2946a 100%); }
.bg-amber     { background:linear-gradient(180deg,#8a857c 0%,#c2bcb0 55%,#e2ddd2 100%); }
.bg-no-sea    { background:linear-gradient(180deg,#0a3a5c 0%,#146a9e 55%,#2798c8 85%,#4ab8dc 100%); }
.bg-foam      { background:linear-gradient(180deg,#7e7e7a 0%,#b6b6b0 55%,#e6e6e0 100%); }
.bg-breeze    { background:linear-gradient(180deg,#0c3247 0%,#155e7e 55%,#2389a8 100%); }
.bg-showcase  { background:linear-gradient(180deg,#191b1d 0%,#3a3d40 55%,#8f8d86 100%); }
.bg-lenin     { background:linear-gradient(180deg,#6e7a82 0%,#9fb0b8 55%,#d5dade 100%); }
.bg-outro     { background:linear-gradient(180deg,#0c0d0e 0%,#202224 55%,#3c3e40 100%); }

/* Контраст текста по тону ЗОНЫ (замер по каждому кропу):
   шапка (~10–30% высоты) и подпись (~35–65%) могут краситься раздельно.
   Светлые зоны — тёмный текст с белой обводкой-свечением;
   пёстрые/тёмные — светлый текст с плотной тенью. */
#stage[data-cue="first-hall"] ~ .content .caption,
#stage[data-cue="amber"]      ~ .content .caption,
#stage[data-cue="foam"]       ~ .content .caption,
#stage[data-cue="lenin"]      ~ .content .caption{
  color:#12232b;
  text-shadow:0 1px 14px rgba(255,255,255,.55), 0 0 3px rgba(255,255,255,.5);
}
#stage[data-cue="amber"]  ~ .content :is(.masthead h1, .eyebrow, .masthead .sub),
#stage[data-cue="foam"]   ~ .content :is(.masthead h1, .eyebrow, .masthead .sub),
#stage[data-cue="lenin"]  ~ .content :is(.masthead h1, .eyebrow, .masthead .sub),
#stage[data-cue="breeze"] ~ .content :is(.masthead h1, .eyebrow, .masthead .sub){
  color:#12232b;
  text-shadow:0 1px 14px rgba(255,255,255,.55), 0 0 3px rgba(255,255,255,.5);
}
#stage[data-cue="greeting"] ~ .content .caption,
#stage[data-cue="khorezm"]  ~ .content .caption,
#stage[data-cue="no-sea"]   ~ .content .caption,
#stage[data-cue="pialki"]   ~ .content .caption{
  text-shadow:0 1px 3px rgba(0,0,0,.7), 0 2px 24px rgba(0,0,0,.6);
}
#stage[data-cue="first-hall"] ~ .content :is(.masthead h1, .eyebrow, .masthead .sub),
#stage[data-cue="pialki"]     ~ .content :is(.masthead h1, .eyebrow, .masthead .sub),
#stage[data-cue="no-sea"]     ~ .content :is(.masthead h1, .eyebrow, .masthead .sub),
#stage[data-cue="khorezm"]    ~ .content :is(.masthead h1, .eyebrow, .masthead .sub){
  text-shadow:0 1px 4px rgba(0,0,0,.75), 0 3px 26px rgba(0,0,0,.55);
}
/* Финал: постер пёстрый (белая рыба на чёрном) — подпись на мягкой плашке */
#stage[data-cue="outro"] ~ .content .caption{
  background:rgba(12,13,14,.42); padding:.45em .8em; border-radius:14px;
  -webkit-backdrop-filter:blur(6px); backdrop-filter:blur(6px);
  text-shadow:0 1px 3px rgba(0,0,0,.6);
}

.grain{
  position:absolute; inset:0; opacity:.5; mix-blend-mode:overlay;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
.vignette{
  position:absolute; inset:0;
  background:radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(0,0,0,.42) 100%);
}

/* ---------- компоновка ---------- */
.content{
  position:relative; z-index:1;
  height:100dvh;
  display:flex; flex-direction:column;
  padding:max(20px, env(safe-area-inset-top)) 20px max(14px, env(safe-area-inset-bottom));
  max-width:640px; margin:0 auto;
}

.masthead{ text-align:center; margin-top:min(8dvh,64px);
  transition:opacity 1.2s ease, transform 1.2s ease; }
/* на аутро сценой становится постер выставки — убираем our заголовок,
   чтобы текст постера читался сам */
#stage[data-cue="outro"] ~ .content .masthead{ opacity:0; transform:translateY(-12px); }
.eyebrow{
  font-size:.72rem; letter-spacing:.32em; text-transform:uppercase;
  color:var(--ink-dim); margin-bottom:.7rem;
  text-shadow:0 1px 3px rgba(0,0,0,.6);
}
.masthead h1{
  font-family:var(--serif); font-weight:500;
  font-size:clamp(2.1rem,8vw,3.4rem); letter-spacing:.02em;
  text-shadow:0 1px 4px rgba(0,0,0,.6), 0 3px 26px rgba(0,0,0,.5);
}
.masthead .sub{
  margin-top:.6rem; font-size:.85rem; color:var(--ink-dim);
  letter-spacing:.14em; text-transform:uppercase;
  text-wrap:balance;
  text-shadow:0 1px 3px rgba(0,0,0,.6);
}
@media (max-width:360px){
  .masthead .sub{ font-size:.74rem; letter-spacing:.10em; }
}

.caption-area{ flex:1; display:flex; align-items:center; justify-content:center;
  padding:24px 8px 12dvh; }
.caption{
  font-family:var(--serif); font-style:italic;
  font-size:clamp(1.1rem,4.5vw,1.5rem); line-height:1.5; text-align:center;
  max-width:34ch; text-shadow:0 1px 18px rgba(0,0,0,.55);
  opacity:0; transform:translateY(8px);
  transition:opacity .9s ease, transform .9s ease;
}
.caption.show{ opacity:1; transform:none; }

/* ---------- плеер ---------- */
.player{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:20px;
  padding:12px 16px 10px;
  backdrop-filter:blur(14px); -webkit-backdrop-filter:blur(14px);
  box-shadow:0 14px 44px rgba(0,0,0,.35);
  position:relative;
}
.track-info{
  display:flex; justify-content:space-between; align-items:baseline;
  font-size:.78rem; color:var(--ink-dim); margin-bottom:6px;
}
.track-title{ color:var(--ink); font-size:.86rem; letter-spacing:.04em; }
.time{ font-variant-numeric:tabular-nums; }

/*scrub */
.scrub{ position:relative; height:26px; touch-action:none; cursor:pointer; outline:none; }
.rail{ position:absolute; left:0; right:0; top:50%; height:4px; transform:translateY(-50%);
  background:rgba(233,228,216,.18); border-radius:2px; overflow:hidden; }
.fill{ height:100%; width:0; background:var(--accent); border-radius:2px; }
.thumb{
  position:absolute; top:50%; left:0; width:16px; height:16px; border-radius:50%;
  background:var(--ink); transform:translate(-50%,-50%);
  box-shadow:0 2px 10px rgba(0,0,0,.5); transition:transform .15s;
}
.scrub:active .thumb{ transform:translate(-50%,-50%) scale(1.25); }
.ticks{ position:absolute; inset:0; }
.tick{
  position:absolute; top:50%; width:2px; height:14px; transform:translate(-50%,-50%);
  background:var(--ink-dim); border-radius:1px;
}
.tick.passed{ background:var(--accent); }

/* play */
.controls{ display:flex; justify-content:center; margin:2px 0 8px; position:relative; }
.play{
  width:66px; height:66px; border-radius:50%;
  border:1px solid var(--line); background:rgba(233,228,216,.08);
  color:var(--ink); cursor:pointer;
  display:grid; place-items:center;
  transition:background .2s, transform .1s;
}
.play:active{ transform:scale(.94); background:rgba(233,228,216,.16); }
.play svg{ width:30px; height:30px; fill:currentColor; display:none; }
.play .i-play.on, .play .i-pause.on, .play .i-replay.on{ display:block; }

/* субтитры: маленький круглый CC справа от play; полоса текста над карточкой */
.cc-btn{
  position:absolute; left:calc(50% + 56px); top:50%; transform:translateY(-50%);
  width:40px; height:40px; border-radius:50%;
  border:1px solid var(--line); background:rgba(233,228,216,.08);
  color:var(--ink-dim); font:inherit; font-weight:600; font-size:.62rem;
  letter-spacing:.05em; cursor:pointer; transition:background .2s, color .2s;
}
.cc-btn:active{ transform:translateY(-50%) scale(.94); }
.cc-btn.on{
  color:#062b38; background:var(--accent); border-color:var(--accent);
}
.subs{
  position:absolute; left:0; right:0; bottom:calc(100% + 10px);
  display:none; justify-content:center; pointer-events:none;
}
.subs.on{ display:flex; }
.subs span{
  background:rgba(9,14,18,.66); color:#f3f0e7;
  border:1px solid rgba(243,240,231,.14); border-radius:14px;
  padding:.4em .8em; font-size:clamp(.88rem,3.8vw,1rem); line-height:1.45;
  text-align:center; max-width:38ch;
  text-shadow:0 1px 2px rgba(0,0,0,.5);
  backdrop-filter:blur(8px); -webkit-backdrop-filter:blur(8px);
}

/* chapters */
.chapters{ display:grid; grid-template-columns:repeat(4,1fr); gap:5px; }
.chapters button{
  font:inherit; font-size:.7rem; color:var(--ink-dim);
  background:transparent; border:1px solid transparent; border-radius:12px;
  padding:6px 3px; cursor:pointer; text-align:center; line-height:1.2;
}
.chapters button small{ display:block; font-size:.64rem; opacity:.7; font-variant-numeric:tabular-nums; }
.chapters button:hover{ color:var(--ink); }
.chapters button.active{
  color:var(--ink); border-color:var(--line); background:rgba(233,228,216,.08);
}

@media (min-width:640px){
  .player{ padding:20px 24px 18px; }
}
@media (prefers-reduced-motion:reduce){
  .layer,.caption{ transition-duration:.01s; }
}
