/* =========================================================
   Шаблон «Изумрудная бабочка». Всё приглашение — одна сцена 9:16:
   видео с конвертом и бабочкой идёт всё время, поверх него кнопкой «Далее»
   сменяются страницы. Буквы проявляются из размытия, ветки вырастают.
   Видео не растягивается: сцена всегда 9:16 и целиком помещается в экран,
   а всё вокруг неё — CSS-бархат в цветах кадра.
   Размеры заданы в долях сцены (cqw/cqh) — на любом экране сцена выглядит одинаково.
   ========================================================= */

:root {
  --em-0: #06140F;
  --em-1: #0C211A;
  --em-2: #173A2E;
  --ivory: #EFE7D6;
  --ivory-2: rgba(239, 231, 214, .8);
  --gold: #C9A866;
  --gold-2: #E7D3A0;
  --gold-dim: #9C824F;
  --gold-line: rgba(201, 168, 102, .45);
  --gold-text: linear-gradient(100deg, #A9884F 0%, #E9D29C 30%, #C29E5E 55%, #F1E0B4 75%, #B08E52 100%);

  --serif: "Cormorant Garamond", Georgia, serif;
  --script: "Great Vibes", cursive;
  --sans: "Montserrat", system-ui, sans-serif;
  --ease: cubic-bezier(.19, 1, .22, 1);

  --grain: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .85  0 0 0 0 .95  0 0 0 0 .88  0 0 0 .11 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

*, *::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:
    var(--grain),
    radial-gradient(48% 78% at 50% 44%, rgba(29, 60, 44, .9), rgba(20, 44, 32, .45) 55%, transparent 82%),
    radial-gradient(35% 28% at 18% 78%, rgba(23, 49, 35, .55), transparent 70%),
    radial-gradient(38% 30% at 84% 22%, rgba(23, 49, 35, .5), transparent 70%),
    radial-gradient(30% 22% at 78% 88%, rgba(16, 38, 27, .6), transparent 70%),
    #06120D;
  background-size: 220px, cover, cover, cover, cover;
  color: var(--ivory);
  font-family: var(--serif);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
/* тёмная виньетка по краям экрана */
body::after { content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(130% 100% at 50% 45%, transparent 35%, rgba(0, 0, 0, .7)); }

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 ---------- */

/* сцена 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: visible; /* ветки могут свисать за край видео в бархат */
  container-type: size;
  user-select: none;
  -webkit-user-select: none;
}
.stage__media, .stage__media video { position: absolute; inset: 0; width: 100%; height: 100%; }
/* сцена и видео одних пропорций, поэтому кадр показан целиком, без увеличения */
.stage__media video { object-fit: contain; }
.stage__open.is-done { visibility: hidden; }
/* под видео — первый кадр раскрытия: пока ролик стартует, вместо пустого фона виден тот же кадр */
.stage__media { background: url("images/open-poster.jpg") center / 100% 100% no-repeat; }
/* бесконечная сцена спрятана до своей очереди, иначе её кадр мелькает, пока раскрытие стартует */
.stage__loop { visibility: hidden; }
.stage__loop.is-on { visibility: visible; }

/* ---------- Сказочный свет при открытии конверта ----------
   Время подогнано под видео: 0–1,2 с печать вспыхивает, 1,2–2,2 с клапаны расходятся
   и изнутри поднимается тёплый свет с лучами, затем он мягко гаснет. Центр печати в кадре — 47,6% / 49,1%. */

.magic { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.magic span {
  position: absolute;
  left: 47.6%;
  top: 49.1%;
  translate: -50% -50%;
  border-radius: 50%;
  mix-blend-mode: screen;
  opacity: 0;
}
/* печать загорается золотом, от неё расходятся два светящихся кольца */
.magic__seal {
  width: 46cqw;
  aspect-ratio: 1;
  /* ореол вокруг печати: сама печать лишь чуть теплеет, золотое свечение — по её краю и дальше */
  background: radial-gradient(circle, rgba(255, 200, 110, .1) 0 26%, rgba(255, 200, 110, .34) 34%, rgba(240, 175, 80, .18) 46%, rgba(220, 150, 60, .06) 58%, transparent 70%);
  filter: blur(6px);
}
.magic__seal::before,
.magic__seal::after {
  content: "";
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  box-shadow: 0 0 20px 5px rgba(240, 180, 90, .32), inset 0 0 16px 4px rgba(240, 185, 100, .26);
  filter: blur(2px);
  opacity: 0;
}
.is-opening .magic__seal { animation: seal-bloom 2.2s ease-in-out forwards; }
.is-opening .magic__seal::before { animation: seal-ring 2s cubic-bezier(.25, .6, .3, 1) .15s forwards; }
.is-opening .magic__seal::after { animation: seal-ring 2s cubic-bezier(.25, .6, .3, 1) .7s forwards; }
@keyframes seal-bloom {
  0% { opacity: 0; scale: .85; }
  35% { opacity: 1; scale: 1; }
  70% { opacity: .7; scale: 1.04; }
  100% { opacity: 0; scale: 1.1; }
}
@keyframes seal-ring {
  0% { opacity: 0; scale: .9; }
  25% { opacity: .8; }
  100% { opacity: 0; scale: 1.7; }
}

/* тёплый свет изнутри: вспыхивает, пока расходятся клапаны, и медленно гаснет */
.magic__light {
  width: 200cqw;
  height: 150cqh;
  background: radial-gradient(closest-side, rgba(255, 238, 200, .7), rgba(255, 214, 145, .4) 32%, rgba(226, 168, 78, .14) 62%, transparent 100%);
}
.is-opening .magic__light { animation: inner-light 4.4s ease-in-out 1.1s forwards; }
@keyframes inner-light {
  0% { opacity: 0; scale: .2; }
  30% { opacity: .75; scale: .65; }
  55% { opacity: .55; scale: .85; }
  100% { opacity: 0; scale: 1.05; }
}

/* лучи из конверта — тонкие, медленно поворачиваются и растворяются к краям */
.magic__rays {
  width: 150cqw;
  aspect-ratio: 1;
  background: repeating-conic-gradient(from 4deg, rgba(255, 228, 165, 0) 0deg 9deg, rgba(255, 228, 165, .22) 14deg, rgba(255, 228, 165, 0) 19deg 30deg);
  filter: blur(5px); /* лучи мягкие, как свет в дымке, а не тонкие линии */
  -webkit-mask-image: radial-gradient(circle, rgba(0, 0, 0, .8) 0 6%, rgba(0, 0, 0, .35) 24%, transparent 48%);
          mask-image: radial-gradient(circle, rgba(0, 0, 0, .8) 0 6%, rgba(0, 0, 0, .35) 24%, transparent 48%);
}
.is-opening .magic__rays { animation: rays 4.4s ease-in-out 1.3s forwards; }
@keyframes rays {
  0% { opacity: 0; scale: .5; rotate: 0deg; }
  35% { opacity: .7; scale: .9; }
  100% { opacity: 0; scale: 1.15; rotate: 18deg; }
}

/* золотая пыль поднимается из конверта (рисует main.js) */
.magic__dust { position: absolute; inset: 0; width: 100%; height: 100%; mix-blend-mode: screen; }

/* нажатие на печать */
.tap { position: absolute; inset: 0; z-index: 6; padding: 0; border: 0; background: none; cursor: pointer; }
.is-playing .tap { display: none; }
.tap__hint {
  position: absolute;
  left: 0;
  right: 0;
  top: 66%;
  font-family: var(--sans);
  font-size: max(10px, 2.8cqw);
  letter-spacing: .32em;
  padding-left: .32em;
  text-transform: uppercase;
  color: var(--gold-2);
  text-shadow: 0 1px 8px rgba(0, 0, 0, .9);
  animation: hint 2.6s ease-in-out infinite;
}
@keyframes hint { 50% { opacity: .45; } }

/* ---------- Ветки: вырастают из нижних углов один раз ---------- */

.branch {
  position: absolute;
  bottom: -2cqh;
  z-index: 1;
  width: 25cqw;
  height: auto;
  pointer-events: none;
  /* ветки не спорят с видео: приглушённый цвет, тёплый оттенок под золото кадра,
     полупрозрачность и мягкая тень */
  opacity: .8;
  filter: saturate(.75) brightness(.85) sepia(.13) drop-shadow(0 4px 8px rgba(0, 0, 0, .32));
}
.branch--l {
  left: -1.5cqw;
  transform-origin: 0 100%;
  rotate: -14deg;
  clip-path: circle(0% at 0% 100%);
  -webkit-mask-image: radial-gradient(circle at 0% 100%, #000 45%, rgba(0, 0, 0, .5) 88%, transparent 110%);
          mask-image: radial-gradient(circle at 0% 100%, #000 45%, rgba(0, 0, 0, .5) 88%, transparent 110%);
}
.branch--r {
  right: -1.5cqw;
  transform-origin: 100% 100%;
  rotate: 14deg;
  clip-path: circle(0% at 100% 100%);
  -webkit-mask-image: radial-gradient(circle at 100% 100%, #000 45%, rgba(0, 0, 0, .5) 88%, transparent 110%);
          mask-image: radial-gradient(circle at 100% 100%, #000 45%, rgba(0, 0, 0, .5) 88%, transparent 110%);
}
.is-open .branch--l { animation: grow-l 2.8s cubic-bezier(.3, .1, .2, 1) 3.2s forwards; }
.is-open .branch--r { animation: grow-r 2.8s cubic-bezier(.3, .1, .2, 1) 3.45s forwards; }
@keyframes grow-l { to { clip-path: circle(150% at 0% 100%); } }
@keyframes grow-r { to { clip-path: circle(150% at 100% 100%); } }

/* ---------- Страницы ---------- */

/* область текста: под бабочкой и над ветками — ничего не пересекается */
.slides { position: absolute; top: 36cqh; bottom: 17cqh; 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 8cqw;
  overflow-y: auto;
  scrollbar-width: none;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateY(2cqh);
  filter: blur(6px);
  transition: opacity .45s ease, transform .5s ease, filter .45s ease, visibility 0s linear .5s;
}
.slide::-webkit-scrollbar { display: none; }
.slide--cover { justify-content: flex-start; }
.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(9px); transform: translateY(.12em); }
.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.1s var(--ease) forwards; animation-delay: calc(var(--d, .35s) + var(--i, 0) * 50ms); }
/* при правках в кабинете текст появляется сразу */
.ch-now .ch { animation: none !important; opacity: 1; filter: none; transform: none; }
@keyframes ch-in { to { opacity: 1; filter: blur(0); transform: none; } }

/* остальные элементы страницы появляются следом друг за другом (--r ставит скрипт) */
.reveal { opacity: 0; filter: blur(6px); transform: translateY(1.6cqh); }
.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: 30cqw; height: 2.6cqw; margin: 1cqh auto; color: var(--gold); stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; flex: none; }
.flourish--sm { width: 20cqw; }
/* завиток не размывается и не сдвигается, как прочие элементы, — он рисуется линией */
.flourish.reveal { filter: none; transform: none; }
.is-in .flourish { animation: draw 1.6s ease-out forwards; animation-delay: calc(.5s + var(--r, 0) * .16s); }
@keyframes draw { from { opacity: 1; } to { stroke-dashoffset: 0; opacity: 1; } }
@keyframes fade-in { to { opacity: 1; } }

/* ---------- Типографика ---------- */

.std { line-height: 1; }
.std__big { display: block; font-weight: 300; font-size: min(12cqw, 6.2cqh); letter-spacing: .32em; padding-left: .32em; color: var(--ivory); }
.std__the { display: block; margin: -.05em 0 .02em; font-family: var(--script); font-size: min(8cqw, 4.2cqh); color: var(--gold); }
.cap {
  font-family: var(--sans);
  font-size: max(9.5px, 2.7cqw);
  letter-spacing: .3em;
  padding-left: .3em;
  text-transform: uppercase;
  color: var(--gold);
}
.slide--cover .cap { margin-top: 1.4cqh; }
.cap--city { margin-top: 0 !important; color: var(--gold-2); }
.names { font-size: min(7.6cqw, 4.2cqh); letter-spacing: .1em; text-transform: uppercase; color: var(--ivory); line-height: 1.15; }
.amp { font-family: var(--script); font-size: 1.05em; text-transform: none; letter-spacing: 0; color: var(--gold); opacity: 0; }
.is-in .amp { animation: fade-in 1s ease 2.6s forwards; }
.date { font-size: min(5.2cqw, 2.8cqh); letter-spacing: .22em; padding-left: .22em; color: var(--ivory); }
.title { font-weight: 300; font-size: min(7.6cqw, 4.1cqh); letter-spacing: .2em; padding-left: .2em; text-transform: uppercase; color: var(--ivory); line-height: 1.15; }
.text { max-width: 100%; font-size: min(5cqw, 2.7cqh); line-height: 1.55; color: var(--ivory-2); }
.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-2); }
.pen { font-family: var(--script); font-size: min(9cqw, 4.8cqh); color: var(--gold-2); line-height: 1.2; }
.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%); } }

/* ---------- Тиснение: текст будто вдавлен в бархат конверта ----------
   У вдавленной буквы верхний край уходит в тень, а нижний ловит свет —
   поэтому тёмная тень смещена вверх, светлая кромка вниз. Цвет чуть приглушён,
   как у тиснения фольгой по ткани. */

.slides {
  --press-dark: rgba(0, 0, 0, .62);
  --press-light: rgba(255, 236, 196, .2);
  /* глубина тиснения растёт с размером букв, но не меньше 1px — у крупных надписей она заметнее */
  --press: 0 min(-1px, -.035em) 0 var(--press-dark), 0 max(1px, .035em) 0 var(--press-light), 0 0 1px rgba(0, 0, 0, .35);
}
.std__big, .names, .date, .title, .text, .address, .cap, .bismillah, .timer b, .timer span, .plan p, .timer-hint, .venue {
  text-shadow: var(--press);
}
/* крупные надписи — чуть плотнее, чтобы тиснение читалось на тонких штрихах */
.std__big, .title { font-weight: 400; color: #E4D8BF; }
.names, .date { color: #E4D8BF; }
/* рукописное золото: тень и блик мягче, буквы тоньше */
.std__the, .amp, .pen, .pen-text { text-shadow: 0 -1px 0 rgba(0, 0, 0, .5), 0 1px 0 rgba(255, 228, 175, .22); }
/* время в программе — золото с переливом, тень ему даёт filter, а не text-shadow */
.plan time { filter: drop-shadow(0 -1px 0 rgba(0, 0, 0, .55)) drop-shadow(0 1px 0 rgba(255, 232, 185, .2)); }

/* очередь на первой странице: «SAVE the DATE», затем имена, дата, город */
.slide--cover .std__big:first-child { --d: .1s; }
.slide--cover .std__the { --d: .7s; }
.slide--cover .std__big:last-child { --d: .9s; }
.slide--cover > .cap:not(.cap--city) { --d: 1.7s; }
.slide--cover .names { --d: 2.2s; }
.slide--cover .date { --d: 3.2s; }
.slide--cover .cap--city { --d: 4s; }
.slide--cover .flourish:nth-of-type(1) { --r: 11; }
.slide--cover .flourish:nth-of-type(2) { --r: 17; }
.slide--cover .flourish:nth-of-type(3) { --r: 22; }

/* ---------- Таймер ---------- */

/* страница таймера не обрезает золотые хлопья, летящие из-под наклеек */
.slide.countdown { overflow: visible; }
.timer { position: relative; display: flex; justify-content: center; gap: 2.6cqw; margin-top: .6cqh; }
/* ячейка — тёмная бархатная карточка с золотой рамкой, на ней наклейка */
.timer__cell {
  position: relative;
  width: 18.5cqw;
  padding: 1.8cqh 0 1.4cqh;
  border: 1px solid var(--gold-line);
  border-radius: 2.4cqw;
  background: rgba(6, 20, 15, .62); /* плотнее: подложка без размытия */
  box-shadow: inset 0 0 0 3px rgba(6, 20, 15, .35), 0 10px 20px -12px rgba(0, 0, 0, .7);
}
.timer b { display: block; font-weight: 300; font-size: min(10.5cqw, 5.6cqh); line-height: 1; color: var(--ivory); font-variant-numeric: lining-nums tabular-nums; }
.timer span { display: block; margin-top: 1cqh; font-family: var(--sans); font-size: max(8.5px, 2.3cqw); letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.countdown > .cap { margin-top: 1.6cqh; color: var(--gold-2); }

/* золотая стираемая наклейка (рисуется в main.js на canvas) */
.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(0, 0, 0, .45)) 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-2); outline-offset: 3px; }
/* слой рассыпается: остаток фольги улетает хлопьями, холст гаснет со вспышкой */
.scratch.is-gone { opacity: 0; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 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(231, 211, 160, .7), 0 0 26px 4px rgba(201, 168, 102, .55); }
  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.6cqh; font-family: var(--sans); font-size: max(9px, 2.4cqw); letter-spacing: .14em; color: var(--ivory-2); }
.timer-hint.is-done { opacity: 0 !important; transition: opacity .6s; }

/* ---------- Программа ---------- */

.plan { width: 100%; margin: .4cqh 0 0; padding: 0; list-style: none; }
.plan li {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 4cqw;
  align-items: baseline;
  padding: .75cqh 0;
  border-bottom: 1px solid rgba(201, 168, 102, .16);
}
.plan li:last-child { border-bottom: 0; }
.plan time { text-align: right; font-size: min(6.2cqw, 3.3cqh); 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(9.5px, 2.7cqw); letter-spacing: .14em; text-transform: uppercase; color: var(--ivory-2); }

/* ---------- Место ---------- */

.location .cap { margin-top: .4cqh; }
.venue { margin-top: .6cqh; font-style: italic; font-size: min(8.4cqw, 4.5cqh); line-height: 1.15; color: #D9BC82; }
.address { margin-top: 1cqh; font-size: min(4.8cqw, 2.6cqh); color: var(--ivory-2); }

.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: rgba(6, 20, 15, .35);
  font-family: var(--sans);
  font-size: max(10px, 2.6cqw);
  letter-spacing: .22em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--gold-2);
  cursor: pointer;
  transition: background .5s var(--ease), border-color .5s;
}
.btn-line:hover { background: rgba(201, 168, 102, .16); border-color: var(--gold); }
.btn-line--solid { background: linear-gradient(120deg, #A9884F, #E3CB92 50%, #B08E52); border-color: transparent; color: #10241C; font-weight: 500; }
.btn-line--solid:hover { background: linear-gradient(120deg, #B6945A, #EDD8A4 50%, #BC9A5D); }

/* ---------- Для гостей ---------- */

.wish { margin-top: 1.6cqh; }
.wish__icon { width: 7.5cqw; height: 7.5cqw; margin: 0 auto .6cqh; fill: none; stroke: var(--gold); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.wish .text { margin-top: .6cqh; font-size: min(4.6cqw, 2.5cqh); }

/* ---------- Финал ---------- */

.photo { width: 28cqw; margin: 0 auto 1.4cqh; padding: 1.4cqw; border: 1px solid var(--gold-line); border-radius: 50% / 42%; 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-size: min(7cqw, 3.8cqh); --d: 1.8s; }

/* ---------- Навигация ---------- */

.nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4cqh;
  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 5.2s 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: rgba(6, 20, 15, .45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--gold-2);
  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(201, 168, 102, .16); border-color: var(--gold); }
.nav__back:disabled { opacity: 0; pointer-events: none; }
.nav__dots { display: flex; gap: 5px; }
.nav__dots i { width: 5px; height: 5px; border-radius: 3px; background: rgba(231, 211, 160, .35); transition: width .5s var(--ease), background .5s; }
.nav__dots i.is-on { width: 16px; background: var(--gold); }

/* ---------- Музыка ---------- */

.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: rgba(6, 20, 15, .55);
  -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(--gold); 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(--em-1);
  color: var(--ivory);
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .8);
}
.dialog::backdrop { background: rgba(3, 10, 7, .6); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.form { position: relative; padding: 38px 26px 28px; text-align: center; background: var(--grain), radial-gradient(120% 90% at 50% 0%, var(--em-2), var(--em-1)); background-size: 220px, cover; }
.form::before { content: ""; position: absolute; inset: 8px; border: 1px solid var(--gold-line); border-radius: 12px; pointer-events: none; }
.form .cap { font-size: 10px; }
.form .title { margin-top: 4px; font-size: 30px; }
.dialog__close { position: absolute; top: 14px; right: 16px; z-index: 1; width: 36px; height: 36px; border: 0; background: none; font-size: 26px; color: var(--gold); 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(--gold); }
.field input[type="text"], .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--gold-line);
  border-radius: 10px;
  background: rgba(6, 20, 15, .5);
  font-family: var(--sans);
  font-size: 15px;
  color: var(--ivory);
}
.field select option { color: #10241C; }
.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(--gold); 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(--ivory-2); }
.pen-text { display: block; font-family: var(--script); font-size: 46px; color: var(--gold-2); line-height: 1.2; }
.form.is-sent .field, .form.is-sent .btn-line { display: none; }

/* ---------- Вытянутые телефоны ----------
   Экран уже, чем 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)); }
  .slide { padding-left: max(8cqw, var(--cx, 0px) + 3cqw); padding-right: max(8cqw, var(--cx, 0px) + 3cqw); }
  /* четыре ячейки таймера помещаются в видимую часть с отступом от краёв */
  .timer__cell { width: min(18.5cqw, (100cqw - 2 * var(--cx, 0px) - 14cqw) / 4); }
}

/* ---------- Без сдвига вбок ----------
   Ветки, свет и холсты эффектов могут выходить за край сцены — страница от этого
   не должна сдвигаться пальцем вбок и «оттягиваться» на 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='%23C9A866' 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, #0C211A;
    font: 500 12px/1.5 "Montserrat", system-ui, sans-serif;
    letter-spacing: .24em;
    text-transform: uppercase;
    text-align: center;
    color: #E7D3A0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .001s !important; transition-delay: 0s !important; }
  .ch, .reveal, .amp, .nav { opacity: 1 !important; filter: none !important; transform: none !important; }
  .slide.is-active { filter: none; transform: none; }
  .flourish { stroke-dashoffset: 0 !important; opacity: 1 !important; }
  .pen span, .branch { clip-path: none !important; }
  .magic { display: none; }
}
