/* =========================================================
   Шаблон «Сиреневый сад»: арка в горах, водопад, сирень и цветник.
   Тёплые коричневые чернила (как на образце заказчика), подписи цвета пыльной розы и золото. Одна сцена 9:16 из слоёв-картинок
   (положения слоёв — как на макете заказчика, в процентах сцены).
   До касания — закрытый конверт с восковой печатью; по касанию вокруг печати золотой линией
   замыкается кольцо, створки раздвигаются, а за ними — крупный план дворца, и камера отъезжает: снизу вырастают цветы, с боков входят деревья, надвигаются арка и сирень,
   по колоннам поднимаются ветки с ягодами. Затем проявляются имена, а кнопкой «Далее»
   сменяются страницы. Всё время по саду гуляет ветер. Размеры — в долях сцены (cqw/cqh).
   ========================================================= */

:root {
  --ivory: #FCF8F6;
  /* тёплые коричневые чернила — как на образце; второй цвет — пыльная роза:
     дружит и с коричневым, и с розово-сиреневыми цветами сцены */
  --ink: #6B4C3D;
  --ink-2: rgba(107, 76, 61, .9);
  --ink-script: #765545;
  --gold: #A3824F;
  --gold-2: #BE9E6A;
  --rose: #A06E6E;
  --gold-line: rgba(170, 128, 118, .42);
  --gold-text: linear-gradient(100deg, #8F6F3F 0%, #C9A86C 30%, #A3824F 55%, #DEC59A 75%, #8F6F3F 100%);
  --glass: rgba(255, 252, 250, .74);

  --serif: "Cormorant Garamond", Georgia, serif;
  --display: "Playfair Display", Georgia, serif;
  --script: "Great Vibes", cursive;
  --sans: "Montserrat", system-ui, sans-serif;
  --ease: cubic-bezier(.19, 1, .22, 1);
  /* слои сада выходят с лёгкой пружинкой в конце */
  --grow: cubic-bezier(.3, 1.35, .55, 1);
  --soft: cubic-bezier(.55, 0, .15, 1);
  /* светлое свечение вокруг букв: текст читается на любом участке картинки */
  --glow: 0 0 14px rgba(255, 251, 249, .95), 0 0 3px rgba(255, 251, 249, .9);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  display: grid;
  place-items: center;
  margin: 0;
  overflow: hidden;
  background: #EEE6EC;
  color: var(--ink);
  font-family: var(--serif);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* вокруг сцены — та же картинка, сильно размытая и высветленная: края сцены не видны */
.backdrop {
  position: fixed;
  inset: -10%;
  z-index: -1;
  background: url("images/bg.webp") center / cover;
  filter: blur(40px) brightness(1.06) saturate(.85);
  opacity: .9;
}

img, svg { display: block; }
h1, h2, p { margin: 0; font-weight: 400; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }

/* ---------- Сцена 9:16 ---------- */

.stage {
  position: relative;
  width: min(100vw, 56.25vh);
  width: min(100vw, 56.25svh);
  height: min(100vh, 177.78vw);
  height: min(100svh, 177.78vw);
  overflow: hidden;
  container-type: size;
  box-shadow: 0 30px 80px -30px rgba(107, 76, 61, .45);
  user-select: none;
  -webkit-user-select: none;
}

.scene { position: absolute; inset: 0; pointer-events: none; }
/* положение и ширина каждого слоя — в style у картинки (проценты сцены, как на макете) */
.scene img { position: absolute; max-width: none; height: auto; -webkit-user-drag: none; }
.scene__bg {
  inset: 0;
  width: 100%;
  height: 100% !important;
  object-fit: cover;
}
/* «камера»: до касания — крупный план дворца с водопадом, по касанию она отъезжает.
   Ближние слои движутся сильнее дальних: фон уменьшается меньше всех, деревья — сильнее,
   арка с сиренью — сильнее всех, поэтому сцена кажется объёмной (как на видео-референсе) */
.scene__bg, .cam { transform-origin: 50% 96%; }
.scene__bg { scale: 1.6; }
.cam { position: absolute; inset: 0; }
.cam--grove { scale: 2.2; }
.cam--arch { scale: 2.9; }
/* цветник поднимается снизу, и каждый цветок вырастает из земли со своей задержкой (--fd) */
.bed { position: absolute; inset: 0; transform-origin: 50% 100%; scale: 1.3; translate: 0 6cqh; }
.flower { opacity: 0; translate: 0 18cqh; scale: .5; transform-origin: 50% 100%; }
/* ветки с ягодами поднимаются вдоль колонн снизу вверх */
.berry { clip-path: inset(100% 0 0 0); }
.fly { opacity: 0; translate: 30cqw -40cqh; rotate: 25deg; scale: .7; transform-origin: 50% 80%; }
/* светлая дымка в проёме арки — под текстом, появляется вместе с именами */
.scene__haze {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: radial-gradient(66% 27% at 50% 47%, rgba(255, 251, 250, .86), rgba(253, 248, 250, .5) 58%, rgba(253, 248, 250, 0) 90%);
}

/* --- касание: камера отъезжает, сад собирается --- */
.is-blooming .scene__bg { scale: 1; transition: scale 3.6s var(--soft) .25s; }
.is-blooming .cam--grove { scale: 1; transition: scale 3.4s var(--soft) .35s; }
.is-blooming .cam--arch { scale: 1; transition: scale 3.5s var(--soft) .3s; }
.is-blooming .bed { scale: 1; translate: 0 0; transition: scale 3.2s var(--soft) .3s, translate 3.2s var(--soft) .3s; }
.is-blooming .flower { opacity: 1; translate: 0 0; scale: 1; transition: opacity .7s ease var(--fd), translate 1.6s var(--grow) var(--fd), scale 1.6s var(--grow) var(--fd); }
.is-blooming .berry { clip-path: inset(0 0 0 0); transition: clip-path 2.2s var(--soft) 1.9s; }
/* бабочка прилетает сверху справа и садится у воды */
.is-blooming .fly { opacity: 1; translate: 0 0; rotate: 0deg; scale: 1; transition: opacity .8s ease 3s, translate 2.6s cubic-bezier(.3, .6, .35, 1) 3s, rotate 2.6s ease 3s, scale 2.6s ease 3s; }
.is-blooming .scene__haze { opacity: 1; transition: opacity 2s ease 2.8s; }
/* в кабинете сад сразу собран */
.is-instant .scene * { transition: none !important; }

/* --- «Далее»: камера мягко наезжает на дворец с водопадом и отъезжает обратно ---
   Наезд неглубокий: дальний фон приближается сильнее всего на глаз, а деревья, арка
   и цветы лишь чуть раздвигаются — всё остаётся в кадре. Плавный разгон и торможение */
/* камера целится в дворец — в середину кадра, а не к низу, как в начале (при масштабе 1 смена точки незаметна) */
.is-open .scene__bg, .is-open .cam { transform-origin: 50% 58%; }
.is-open .scene__bg, .is-open .cam, .is-open .bed { transition: scale 1.8s cubic-bezier(.45, 0, .25, 1); }
.is-open.is-zooming .scene__bg, .is-open.is-zooming .cam, .is-open.is-zooming .bed { transition-duration: 1.5s; }
.is-open.is-zooming .scene__bg { scale: 1.22; }
.is-open.is-zooming .cam--grove { scale: 1.08; }
.is-open.is-zooming .cam--arch { scale: 1.1; }
.is-open.is-zooming .bed { scale: 1.05; }
.is-open .scene__haze { transition: opacity .9s ease; }
.is-open.is-zooming .scene__haze { opacity: 0; transition-duration: .5s; }
.is-zooming .nav { pointer-events: none; }

/* --- ветер: раскачка волной проходит по саду слева направо ---
   Движение складывается из плавных встречных качаний (каждое — туда-обратно с мягким
   разгоном и торможением), поэтому без рывков. Растения качаются в одном ритме (--wind),
   но каждое — со сдвигом по своему месту в кадре (--wd): видно, как ветер бежит по саду.
   --a — сила (высокие цветы гнутся сильнее), --fl — ритм колыхания стебля у каждого свой.
   Ветер начинается с касания печати и дальше не стихает — и пока камера отъезжает, и после.
   Деревья и сирень рисует WebGL (main.js): ствол стоит, крона раскачивается, ветки шевелятся.
   Здесь — запасной вариант для них же, если WebGL нет: плавный изгиб от основания ствола */
:root { --wind: 2.06s; }
.sway { position: absolute; transform-origin: var(--ox, 50%) var(--oy, 100%); }
.scene .sway > img { position: relative; display: block; width: 100%; }
.wind-canvas { position: absolute; inset: 0; width: 100%; height: 100%; visibility: hidden; }
.gl-wind .wind-canvas { visibility: visible; }
.gl-ready .sway { animation: none !important; }
.gl-wind .sway { visibility: hidden; }
.is-open .scene__bg { animation: breathe 26s ease-in-out infinite alternate; }
.is-gate-open .flower { animation: sway-f calc(var(--wind) / 2) ease-in-out var(--wd, 0s) infinite alternate, stem calc(var(--fl, 1s) * .97) ease-in-out var(--wd, 0s) infinite alternate; }
.is-gate-open .sway { animation: bend calc(var(--wind) / 2) ease-in-out var(--wd, 0s) infinite alternate; }
@keyframes breathe { to { transform: scale(1.03); } }
/* цветок раскачивается от земли туда и обратно, чуть сильнее — по ветру */
@keyframes sway-f {
  from { rotate: calc(var(--a, 1) * -6deg); }
  to { rotate: calc(var(--a, 1) * 8deg); }
}
/* стебель изгибается, головка цветка отстаёт и догоняет */
@keyframes stem {
  from { transform: skewX(calc(var(--a, 1) * 1deg)); }
  to { transform: skewX(calc(var(--a, 1) * -1.4deg)); }
}
/* запасная раскачка дерева от ствола: верхушка ходит туда и обратно */
@keyframes bend {
  from { transform: skewX(calc(var(--a, 1) * 2deg)) rotate(calc(var(--a, 1) * -.5deg)); }
  to { transform: skewX(calc(var(--a, 1) * -2.6deg)) rotate(calc(var(--a, 1) * .65deg)); }
}

/* бабочка сидит у воды: изредка складывает и раскрывает крылья, чуть покачивается */
/* после прилёта: покачивание идёт по translate, поэтому ждёт, пока бабочка сядет */
.is-open .fly { animation: wings 3.2s ease-in-out 3s infinite, perch 1.8s ease-in-out 2.6s infinite alternate; }
.is-instant .fly { animation-delay: 0s, 0s; }
@keyframes wings {
  0%, 70%, 100% { transform: scaleX(1); }
  76% { transform: scaleX(.4); }
  82% { transform: scaleX(1); }
  88% { transform: scaleX(.5); }
  94% { transform: scaleX(1); }
}
@keyframes perch { to { translate: 0 -.4cqh; } }

/* блеск воды: по водопадам бегут светлые струи */
.fall {
  position: absolute;
  top: 75.5%;
  height: 9%;
  opacity: 0;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0) 0 1.2cqh, rgba(255, 255, 255, .85) 1.6cqh, rgba(255, 255, 255, 0) 2.2cqh) 0 0 / 100% 4.4cqh;
  mix-blend-mode: soft-light;
  -webkit-mask: linear-gradient(180deg, transparent, #000 25%, #000 75%, transparent);
          mask: linear-gradient(180deg, transparent, #000 25%, #000 75%, transparent);
}
.fall--l { left: 43.5%; width: 9%; }
.fall--r { left: 56.5%; width: 7.2%; }
.is-open .fall { opacity: .9; transition: opacity 2s ease; animation: water 1.6s linear infinite; }
.is-open .fall--r { animation-duration: 1.35s; }
@keyframes water { to { background-position: 0 4.4cqh; } }

/* --- лепестки сирени срывает и несёт ветром слева направо (создаёт main.js) --- */
.petals { position: absolute; inset: 0; }
.petal {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--s);
  height: calc(var(--s) * .7);
  border-radius: 80% 0 80% 0;
  background: radial-gradient(ellipse at 30% 30%, #FBF4FD, #DCC4EA 55%, #C2A1D8);
  opacity: 0;
}
.is-open .petal { animation: petal-fall var(--dur) linear var(--delay) infinite; }
@keyframes petal-fall {
  0%   { opacity: 0; transform: translate(0, 0) rotate(0deg); }
  8%   { opacity: .9; }
  35%  { transform: translate(calc(var(--dx) * .45), calc(var(--dy) * .25)) rotate(calc(var(--rot) * .4)) rotateY(140deg); }
  70%  { transform: translate(calc(var(--dx) * .8), calc(var(--dy) * .7)) rotate(calc(var(--rot) * .75)) rotateY(260deg); }
  90%  { opacity: .8; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) rotateY(360deg); }
}

/* вихрь лепестков из печати, когда замкнулось золотое кольцо */
.burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--s);
  height: calc(var(--s) * .7);
  border-radius: 80% 0 80% 0;
  background: radial-gradient(ellipse at 30% 30%, #FFFFFF, #E2CDEE 55%, #BE9AD5);
  animation: burst var(--dur) cubic-bezier(.15, .7, .3, 1) var(--delay) both;
}
@keyframes burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.3); }
  12% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--rot)) scale(1); }
}

/* --- при листании страниц разлетается золотая пыль --- */
.dust {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF6EA, #D7BC88 60%, transparent 72%);
  box-shadow: 0 0 6px 1px rgba(214, 190, 150, .7);
  animation: dust-fly var(--dur) cubic-bezier(.2, .7, .3, 1) var(--delay) both;
}
@keyframes dust-fly {
  0% { opacity: 0; transform: translate(0, 0) scale(.4); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1); }
}

/* ---------- Конверт: две створки и восковая печать на шве ----------
   До касания конверт закрывает сцену целиком. По касанию печати вокруг неё из одной точки
   по кругу пробегает золотая линия и замыкается в кольцо (за кончиком бежит искра), кольцо
   вспыхивает, печать тает, а створки раздвигаются влево и вправо — за ними уже камера
   отъезжает от дворца. Правая створка — та же картинка, отражённая зеркально. */

.gate { position: absolute; inset: 0; z-index: 5; pointer-events: none; }
.gate__door {
  position: absolute;
  top: 0;
  width: 50.2%;
  height: 100%;
  object-fit: cover;
}
/* цветы створки — вдоль шва посередине; тень на шве разделяет створки */
.gate__door--l { left: 0; object-position: 100% 50%; filter: drop-shadow(3px 0 6px rgba(107, 76, 61, .28)); }
.gate__door--r { right: 0; object-position: 100% 50%; scale: -1 1; }
.seal {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40cqw;
  aspect-ratio: 1;
  translate: -50% -50%;
}
.seal__img {
  position: absolute;
  inset: 15%;
  width: 70%;
  height: 70%;
  object-fit: contain;
  filter: drop-shadow(0 .8cqh 1.4cqh rgba(107, 76, 61, .45));
  animation: seal-breathe 2.8s ease-in-out infinite;
}
/* до касания печать мягко «дышит» золотым отблеском — подсказывает, куда нажать */
@keyframes seal-breathe {
  0%, 100% { scale: 1; filter: drop-shadow(0 .8cqh 1.4cqh rgba(107, 76, 61, .45)) drop-shadow(0 0 0 rgba(240, 210, 150, 0)); }
  50% { scale: 1.035; filter: drop-shadow(0 .8cqh 1.4cqh rgba(107, 76, 61, .45)) drop-shadow(0 0 2.2cqw rgba(240, 210, 150, .8)); }
}
/* золотое кольцо: линия рисуется от верхней точки по часовой стрелке и замыкается */
.seal__ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  rotate: -90deg;
  /* тёплое свечение вокруг золотой линии */
  filter: drop-shadow(0 0 .5cqw rgba(255, 228, 165, .95)) drop-shadow(0 0 1.6cqw rgba(226, 182, 100, .7));
}
.seal__ring circle {
  fill: none;
  stroke: url(#ring-gold);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
/* искра на кончике линии — бежит по кругу вместе с ней */
.seal__spark {
  position: absolute;
  inset: 0;
  opacity: 0;
}
.seal__spark::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 5%;
  width: 6.4cqw;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: radial-gradient(circle, #FFFBEF 0 14%, #F3D99A 30%, rgba(236, 196, 120, .5) 46%, transparent 68%);
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
  border-radius: 50%;
}
.seal__spark::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 5%;
  width: 4.2cqw;
  aspect-ratio: 1;
  translate: -50% -50%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 214, .95), rgba(240, 206, 140, .4) 45%, transparent 70%);
}

/* касание: печать чуть вдавливается, линия бежит по кругу, кольцо вспыхивает */
.is-gate-open .seal__img { animation: seal-press .5s ease-out forwards; }
.is-gate-open .seal__ring circle { animation: ring-draw 1s cubic-bezier(.45, .05, .35, 1) .1s forwards, ring-flash .6s ease-out 1.1s forwards; }
/* кольцо замкнулось — печать вместе с ним вспыхивает и тает */
.is-gate-open .seal { animation: seal-out .7s ease-in 1.2s forwards; }
.is-gate-open .seal__spark { animation: spark-run 1s cubic-bezier(.45, .05, .35, 1) .1s forwards; }
@keyframes seal-press { 40% { scale: .95; } 100% { scale: 1; } }
@keyframes ring-draw { to { stroke-dashoffset: 0; } }
@keyframes ring-flash {
  40% { stroke-width: 3.4; }
  100% { stroke-dashoffset: 0; stroke-width: 2.2; }
}
@keyframes spark-run {
  0% { opacity: 0; rotate: 0deg; }
  8% { opacity: 1; }
  88% { opacity: 1; }
  100% { opacity: 0; rotate: 360deg; }
}
@keyframes seal-out { to { opacity: 0; scale: 1.18; filter: blur(4px) brightness(1.3); } }

/* створки раздвигаются влево и вправо и уходят за края экрана */
.is-gate-open .gate__door--l { animation: door-l 1.8s cubic-bezier(.65, 0, .25, 1) 1.35s forwards; }
.is-gate-open .gate__door--r { animation: door-r 1.8s cubic-bezier(.65, 0, .25, 1) 1.35s forwards; }
@keyframes door-l { to { translate: -102% 0; } }
@keyframes door-r { to { translate: 102% 0; } }
.is-gate-gone .gate, .is-instant .gate { display: none; }

/* подсказка под печатью */
.tap { position: absolute; inset: 0; z-index: 6; padding: 0; border: 0; background: none; cursor: pointer; }
.is-gate-open .tap, .is-instant .tap { pointer-events: none; }
.tap__hint {
  position: absolute;
  left: 50%;
  top: 61cqh;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  white-space: nowrap;
  /* светлая матовая плашка: подсказка лежит на цветах шва и без подложки не читается */
  padding: 1.3cqh 6cqw 1.5cqh;
  border: 1px solid rgba(190, 158, 106, .55);
  border-radius: 999px;
  background: rgba(253, 249, 244, .8);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 1cqh 3cqh -1.5cqh rgba(107, 76, 61, .45);
  animation: hint 3.2s ease-in-out infinite;
}
.tap__text { font-family: var(--display); font-style: italic; font-size: min(6.2cqw, 3.4cqh); color: var(--ink); }
.tap__sub { margin-top: .4cqh; font-family: var(--sans); font-size: max(8.5px, 2.3cqw); letter-spacing: .32em; padding-left: .32em; text-transform: uppercase; color: var(--rose); }
@keyframes hint { 50% { opacity: .86; } }
.is-gate-open .tap__hint { animation: fade-out .5s ease forwards; }
@keyframes fade-out { to { opacity: 0; } }
.is-instant .tap__hint { display: none; }
/* конверт открыт — подсказка и кнопка больше не нужны */
.is-gate-gone .tap { display: none; }

/* ---------- Страницы ---------- */

/* текст — в проёме арки над дворцом: сверху сирень, снизу водопад */
.slides { position: absolute; top: 21.5cqh; bottom: 28.5cqh; left: 0; right: 0; z-index: 2; }
.slide {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 17cqw;
  overflow-y: auto;
  scrollbar-width: none;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2cqh) scale(.98);
  filter: blur(6px);
  transition: opacity .45s ease, transform .5s ease, filter .45s ease, visibility 0s linear .5s;
}
.slide::-webkit-scrollbar { display: none; }
.slide.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  filter: none;
  transition: opacity .9s var(--ease) .3s, transform 1.1s var(--ease) .3s, filter .9s ease .3s, visibility 0s;
}

/* буквы: каждая проявляется из размытия, по очереди (--i — номер буквы, --d — задержка строки) */
.ch { display: inline-block; opacity: 0; filter: blur(6px); transform: translateY(.3em) scale(.9); }
.w { display: inline-block; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.is-in .ch { animation: ch-in 1.3s var(--ease) forwards; animation-delay: calc(var(--d, .35s) + var(--i, 0) * 45ms); }
.ch-now .ch { animation: none !important; opacity: 1; filter: none; transform: none; }
@keyframes ch-in {
  0% { text-shadow: 0 0 10px rgba(226, 190, 120, 1), 0 0 22px rgba(226, 190, 120, .9); }
  45% { opacity: 1; filter: blur(0); transform: none; text-shadow: 0 0 8px rgba(226, 190, 120, .95), 0 0 18px rgba(226, 190, 120, .6); }
  100% { opacity: 1; filter: blur(0); transform: none; }
}

.reveal { opacity: 0; filter: blur(6px); transform: translateY(1.4cqh); }
.is-in .reveal { animation: rise 1.1s var(--ease) forwards; animation-delay: calc(.5s + var(--r, 0) * .16s); }
@keyframes rise { to { opacity: 1; filter: none; transform: none; } }

.flourish { width: 32cqw; height: 3.2cqw; margin: 1.2cqh auto; color: var(--gold-2); stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; flex: none; }
.flourish.reveal { filter: none; transform: none; }
.is-in .flourish { animation: draw 1.6s ease-out forwards, bud 1.4s var(--ease) both; animation-delay: calc(.5s + var(--r, 0) * .16s); }
@keyframes bud { from { scale: .6; rotate: 30deg; } to { scale: 1; rotate: 0deg; } }
@keyframes draw { from { opacity: 1; } to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes fade-in { to { opacity: 1; } }

/* ---------- Типографика ---------- */

.cap {
  font-family: var(--sans);
  font-size: max(9.5px, 2.7cqw);
  letter-spacing: .3em;
  padding-left: .3em;
  text-transform: uppercase;
  color: var(--rose);
  text-shadow: var(--glow);
}
.title { font-family: var(--display); font-style: italic; font-weight: 400; font-size: min(6.6cqw, 3.6cqh); white-space: nowrap; color: var(--ink); line-height: 1.2; text-shadow: var(--glow); }
.text { max-width: 100%; font-size: min(5cqw, 2.7cqh); line-height: 1.55; color: var(--ink-2); text-shadow: var(--glow); }
.welcome .text { font-style: italic; font-size: min(5.4cqw, 2.9cqh); }
.bismillah { font-family: "Amiri", serif; font-size: min(6.6cqw, 3.6cqh); color: var(--gold); text-shadow: var(--glow); }
.date { font-size: min(5.4cqw, 2.9cqh); letter-spacing: .22em; padding-left: .22em; color: var(--ink); text-shadow: var(--glow); }

/* имена — каллиграфией, как на референсе. Связная пропись не разбивается на буквы:
   строка проявляется из дымки слева направо, будто её пишут */
.couple { margin: 1.4cqh 0 0; font-weight: 400; line-height: 1; }
.script {
  display: block;
  padding: 0 .18em .06em;
  font-family: var(--script);
  /* длинное имя уменьшается, чтобы не выйти за проём арки (--len — длина длинного имени, ставит main.js) */
  font-size: min(13.5cqw, 7.6cqh, calc(118cqw / var(--len, 6)));
  white-space: nowrap;
  line-height: 1.12;
  color: var(--ink-script);
  text-shadow: var(--glow);
  opacity: 0;
  -webkit-mask: linear-gradient(90deg, #000 45%, transparent 55%) 100% 0 / 260% 100% no-repeat;
          mask: linear-gradient(90deg, #000 45%, transparent 55%) 100% 0 / 260% 100% no-repeat;
  filter: blur(6px);
}
.is-in .script { animation: ink-in 2s cubic-bezier(.45, .1, .35, 1) forwards; }
.is-in .script--1 { animation-delay: .5s; }
.is-in .script--2 { animation-delay: 1.9s; }
@keyframes ink-in {
  0%   { opacity: 1; -webkit-mask-position: 100% 0; mask-position: 100% 0; filter: blur(6px); }
  100% { opacity: 1; -webkit-mask-position: 0 0; mask-position: 0 0; filter: blur(0); }
}
.ch-now .script, .ch-now.script { animation: none !important; opacity: 1; -webkit-mask: none; mask: none; filter: none; }
.couple__amp { display: block; margin: -.25em 0 -.15em; font-family: var(--script); font-size: min(10cqw, 5.5cqh); color: var(--gold-2); text-shadow: var(--glow); opacity: 0; }
.is-in .couple__amp { animation: fade-in 1.2s ease 1.5s forwards; }

.invite { margin-top: .8cqh; max-width: 62cqw; font-style: italic; font-size: min(4.8cqw, 2.6cqh); color: var(--ink-2); text-shadow: var(--glow); }

.chapter {
  display: flex;
  align-items: center;
  gap: 2.4cqw;
  margin-bottom: 1cqh;
  font-family: var(--sans);
  font-size: max(9px, 2.4cqw);
  letter-spacing: .3em;
  padding-left: .3em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: var(--glow);
}
.chapter { color: var(--rose); }
.chapter::before, .chapter::after { content: ""; width: 7cqw; height: 1px; background: linear-gradient(90deg, transparent, var(--gold-2), transparent); }

/* очередь на первой странице */
.slide--cover > .cap:first-child { --d: .1s; }
.slide--cover .flourish { --r: 20; }
.slide--cover .invite { --d: 3s; }
.slide--cover .date { margin-top: .2cqh; --d: 3.8s; }
.slide--cover .cap--city { margin-top: 1cqh; --d: 4.4s; color: var(--gold); }

.pen { font-family: var(--script); font-size: min(7.4cqw, 4cqh); color: var(--rose); line-height: 1.2; text-shadow: var(--glow); }
.pen span { display: inline-block; padding: 0 .1em; clip-path: inset(0 100% 0 0); }
.is-in .pen span { animation: write 2.2s cubic-bezier(.45, .1, .4, 1) .9s forwards; }
@keyframes write { to { clip-path: inset(0 -6% 0 -6%); } }

/* ---------- Таймер ---------- */

.slide.countdown { overflow: visible; }
.timer { position: relative; display: flex; justify-content: center; gap: 1.8cqw; margin-top: .6cqh; }
/* ячейка — светлое матовое стекло с золотой рамкой, на ней золотая наклейка */
.timer__cell {
  position: relative;
  width: 14.6cqw;
  padding: 1.6cqh 0 1.3cqh;
  overflow: hidden;
  border: 1px solid var(--gold-line);
  border-radius: 2.4cqw;
  /* без размытия подложки: вместе с хлопьями фольги на телефонах оно оставляло полосы */
  background: rgba(255, 252, 248, .84);
  box-shadow: 0 10px 22px -14px rgba(107, 76, 61, .5);
}
/* три цифры дней должны целиком помещаться под наклейкой */
.timer b { display: block; font-weight: 400; font-size: min(8cqw, 4.4cqh); line-height: 1; color: var(--ink); font-variant-numeric: lining-nums tabular-nums; }
.timer span { display: block; margin-top: 1cqh; font-family: var(--sans); font-size: max(7.5px, 1.9cqw); letter-spacing: .1em; text-transform: uppercase; color: var(--rose); }
.countdown > .cap { margin-top: 1cqh; }
.countdown .chapter { margin-bottom: .4cqh; }
.countdown .title { margin-bottom: 1.2cqh; }
.schedule > .cap, .welcome > .cap { margin-top: .4cqh; }

.scratch {
  position: absolute;
  inset: 3px;
  z-index: 2;
  width: calc(100% - 6px);
  height: calc(100% - 6px);
  border-radius: 1.8cqw;
  cursor: grab;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  filter: drop-shadow(0 3px 5px rgba(94, 70, 54, .35)) brightness(1) blur(0);
  transition: opacity .45s var(--ease), filter .45s var(--ease);
}
.scratch:active { cursor: grabbing; }
.scratch:focus-visible { outline: 1px solid var(--gold); outline-offset: 3px; }
.scratch.is-gone { opacity: 0; filter: drop-shadow(0 3px 5px rgba(94, 70, 54, 0)) brightness(1.5) blur(2px); pointer-events: none; }
.timer__cell.is-revealed { animation: cell-pop 1.1s var(--ease); }
@keyframes cell-pop {
  0% { transform: scale(.95); }
  35% { transform: scale(1.06); box-shadow: 0 0 0 1px rgba(196, 160, 106, .7), 0 0 26px 4px rgba(201, 168, 102, .45); }
  100% { transform: none; }
}
.timer__cell.has-foil:not(.is-touched)::after {
  content: "";
  position: absolute;
  inset: 3px;
  z-index: 3;
  border-radius: 1.8cqw;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255, 246, 220, .75) 50%, transparent 62%) -150% 0 / 250% 100% no-repeat;
  mix-blend-mode: soft-light;
  animation: foil-shine 4.2s ease-in-out infinite;
}
.timer__cell:nth-child(2)::after { animation-delay: .25s; }
.timer__cell:nth-child(3)::after { animation-delay: .5s; }
.timer__cell:nth-child(4)::after { animation-delay: .75s; }
@keyframes foil-shine {
  0%, 55% { background-position: -150% 0; }
  85%, 100% { background-position: 250% 0; }
}
/* свой слой отрисовки: браузер перерисовывает его целиком и не оставляет следов хлопьев */
.scratch-fx { position: absolute; z-index: 5; pointer-events: none; will-change: transform; }
.timer-hint { margin-top: 1.2cqh; font-family: var(--sans); font-size: max(9px, 2.4cqw); letter-spacing: .12em; color: var(--ink-2); text-shadow: var(--glow); }
.timer-hint.is-done { opacity: 0 !important; transition: opacity .6s; }

/* ---------- Программа ---------- */

.plan { width: 100%; margin: .4cqh 0 0; padding: 1cqh 4cqw; list-style: none; border-radius: 3cqw; background: rgba(255, 252, 247, .55); }
.plan li {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 4cqw;
  align-items: baseline;
  padding: .7cqh 0;
  border-bottom: 1px solid rgba(160, 110, 110, .25);
}
.plan li:last-child { border-bottom: 0; }
.plan time { text-align: right; font-size: min(6cqw, 3.2cqh); letter-spacing: .04em; background: var(--gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.plan p { text-align: left; font-family: var(--sans); font-size: max(9px, 2.5cqw); letter-spacing: .12em; text-transform: uppercase; color: var(--ink); }

/* ---------- Место ---------- */

.location .cap { margin-top: .4cqh; }
.venue { margin-top: .6cqh; font-style: italic; font-size: min(8cqw, 4.3cqh); line-height: 1.15; color: #8A5A50; text-shadow: var(--glow); }
.address { margin-top: 1cqh; font-size: min(4.8cqw, 2.6cqh); color: var(--ink-2); text-shadow: var(--glow); }

.btn-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 2.2cqh;
  padding: 0 7cqw;
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  background: var(--glass);
  font-family: var(--sans);
  font-size: max(10px, 2.6cqw);
  letter-spacing: .2em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  transition: background .5s var(--ease), border-color .5s;
}
.btn-line:hover { background: rgba(255, 252, 247, .95); border-color: var(--gold); }
.btn-line--solid { background: linear-gradient(120deg, #93625C, #D9B1A6 50%, #8A5952); border-color: transparent; color: #FFFDFB; font-weight: 500; box-shadow: 0 10px 22px -12px rgba(120, 76, 66, .7); }
.btn-line--solid:hover { background: linear-gradient(120deg, #9D6C66, #E2BCB1 50%, #94635C); }

/* ---------- Для гостей ---------- */

.wish { margin-top: 1.6cqh; }
.wish__icon { width: 7.5cqw; height: 7.5cqw; margin: 0 auto .6cqh; fill: none; stroke: var(--gold-2); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.wish .text { margin-top: .6cqh; font-size: min(4.6cqw, 2.5cqh); }

/* ---------- Финал ---------- */

.photo { width: 30cqw; margin: 0 auto 1.4cqh; padding: 1.4cqw; border: 1px solid var(--gold-line); border-radius: 50% / 42%; background: rgba(255, 252, 247, .6); flex: none; }
.photo img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 38%; border-radius: 50% / 42%; }
.names--final { margin-top: .6cqh; font-family: var(--script); font-size: min(10cqw, 5.4cqh); line-height: 1.1; color: var(--ink-script); text-shadow: var(--glow); --d: 1.8s; }

/* ---------- Навигация ---------- */

.nav {
  position: absolute;
  left: 0;
  right: 0;
  /* над водопадом, выше цветника */
  bottom: 21.5cqh;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2cqw;
  opacity: 0;
  pointer-events: none;
}
.is-open .nav { animation: fade-in 1s ease 2.6s forwards; pointer-events: auto; }
.is-preview .nav { animation-delay: 0s; }
.nav__back, .nav__next {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--ink);
  cursor: pointer;
  transition: background .4s, border-color .4s, opacity .4s;
}
.nav__back { width: 38px; }
.nav__back svg { width: 20px; height: 20px; transform: scaleX(-1); }
.nav__next { gap: 5px; padding: 0 12px 0 15px; font-family: var(--sans); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; }
.nav__next svg { width: 18px; height: 18px; }
.nav__back:hover, .nav__next:hover { background: rgba(255, 252, 247, .95); border-color: var(--gold); }
.nav__back:disabled { opacity: 0; pointer-events: none; }
.nav__dots { display: flex; gap: 5px; padding: 6px 8px; border-radius: 999px; background: rgba(255, 252, 247, .6); }
.nav__dots i { width: 5px; height: 5px; border-radius: 3px; background: rgba(160, 110, 110, .35); transition: width .5s var(--ease), background .5s; }
.nav__dots i.is-on { width: 16px; background: var(--rose); }

/* ---------- Музыка ---------- */

.music {
  position: absolute;
  top: 2.4cqh;
  right: 4cqw;
  z-index: 7;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--gold-line);
  border-radius: 50%;
  background: var(--glass);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.music__bars { display: flex; align-items: flex-end; gap: 3px; height: 15px; }
.music__bars i { width: 2px; height: 100%; background: var(--rose); transform-origin: bottom; animation: bars 1.1s ease-in-out infinite; }
.music__bars i:nth-child(2) { animation-delay: -.3s; }
.music__bars i:nth-child(3) { animation-delay: -.6s; }
.music__bars i:nth-child(4) { animation-delay: -.15s; }
@keyframes bars { 50% { transform: scaleY(.3); } }
.music[aria-pressed="false"] .music__bars i { animation: none; transform: scaleY(.25); }

/* ---------- Окно ответа ---------- */

.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  background: var(--ivory);
  color: var(--ink);
  box-shadow: 0 40px 80px -30px rgba(107, 76, 61, .6);
}
.dialog::backdrop { background: rgba(107, 76, 61, .3); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.form { position: relative; padding: 38px 26px 28px; text-align: center; background: radial-gradient(120% 90% at 50% 0%, #FFFDFB, #F6EEEA); }
.form::before { content: ""; position: absolute; inset: 8px; border: 1px solid var(--gold-line); border-radius: 12px; pointer-events: none; }
.form .cap { font-size: 10px; text-shadow: none; }
.form .title { margin-top: 4px; font-size: 30px; white-space: normal; text-shadow: none; }
.dialog__close { position: absolute; top: 14px; right: 16px; z-index: 1; width: 36px; height: 36px; border: 0; background: none; font-size: 26px; color: var(--rose); cursor: pointer; }
.field { display: block; margin-top: 16px; padding: 0; border: 0; text-align: left; }
.field > span, .field legend { display: block; margin-bottom: 6px; padding: 0; font-family: var(--sans); font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--rose); }
.field input[type="text"], .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--gold-line);
  border-radius: 10px;
  background: #fff;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 1px solid var(--gold); outline-offset: 1px; }
.choice label { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 18px; cursor: pointer; }
.choice input { accent-color: var(--rose); width: 18px; height: 18px; }
.form .btn-line { width: 100%; margin-top: 22px; font-size: 11px; }
.form__thanks { margin-top: 14px; font-size: 19px; color: var(--ink-2); }
.pen-text { display: block; font-family: var(--script); font-size: 46px; color: var(--rose); line-height: 1.2; }
.form.is-sent .field, .form.is-sent .btn-line { display: none; }

/* ---------- Плотнее там, где много строк ---------- */
.schedule .flourish { margin: .6cqh auto; }
.plan li { padding: .5cqh 0; }
.wishes .wish { margin-top: 1cqh; }
.wish__icon { width: 6.5cqw; height: 6.5cqw; }

/* ---------- Вытянутые телефоны ----------
   Экран уже, чем 9:16 (почти все современные телефоны): сцена заполняет экран по высоте,
   а края кадра немного уходят за бока — как вертикальное видео в сторис. Срезается не больше
   12% ширины с каждой стороны; --cx — ширина среза, на неё кнопки у края сдвигаются внутрь */
@media (max-aspect-ratio: 9/16) {
  .stage {
    --cx: max(0px, (min(56.25vh, 131.6vw) - 100vw) / 2);
    --cx: max(0px, (min(56.25svh, 131.6vw) - 100vw) / 2);
    width: min(56.25vh, 131.6vw);
    width: min(56.25svh, 131.6vw);
    height: min(100vh, 233.9vw);
    height: min(100svh, 233.9vw);
    margin: 0 calc(-1 * var(--cx, 0px));
  }
  .music { right: calc(4cqw + var(--cx, 0px)); }
}

/* ---------- Без сдвига вбок ----------
   Ветки, свет и холсты эффектов могут выходить за край сцены — страница от этого
   не должна сдвигаться пальцем вбок и «оттягиваться» на iPhone */
html, body { overflow: hidden; overscroll-behavior: none; }

/* ---------- Телефон боком ----------
   Приглашение — вертикальная открытка 9:16; на телефоне, повёрнутом боком, она превращается
   в узкую полоску, поэтому просим повернуть телефон (на компьютере подсказки нет) */
@media (orientation: landscape) and (max-height: 500px) and (pointer: coarse) {
  body::before {
    content: "Поверните телефон вертикально";
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 70px 24px 0;
    background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48' fill='none' stroke='%23A06E6E' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><rect x='16' y='6' width='16' height='28' rx='3'/><path d='M22 30h4'/><path d='M38 26a14 14 0 0 1-12 14'/><path d='M29 37l-3 3 3 3'/></svg>") center calc(50% - 26px) / 46px no-repeat, #F6EFEB;
    font: 500 12px/1.5 "Montserrat", system-ui, sans-serif;
    letter-spacing: .24em;
    text-transform: uppercase;
    text-align: center;
    color: #A06E6E;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .001s !important; transition-delay: 0s !important; }
  .ch, .reveal, .couple__amp, .nav { opacity: 1 !important; filter: none !important; transform: none !important; }
  .script { opacity: 1 !important; -webkit-mask: none !important; mask: none !important; filter: none !important; }
  .slide.is-active { filter: none; transform: none; }
  .flourish { stroke-dashoffset: 0 !important; opacity: 1 !important; }
  .pen span { clip-path: none !important; }
  .petals, .fall { display: none; }
  .seal__img { animation: none; }
}
