/* =========================================================
   Шаблон «Восточная сказка», тема «Тысяча и одна ночь»: приглашение — книга сказок,
   страницы — главы. Коричневые чернила и розовое золото. Одна сцена 9:16 из слоёв-картинок.
   До касания виден крупный план дворца с водопадом; по касанию камера отъезжает:
   фон уменьшается, арка, сакура и цветы съезжаются к краям кадра — ближние слои
   движутся сильнее дальних, поэтому кажется, что сцена объёмная. Затем проявляются имена,
   а кнопкой «Далее» сменяются страницы. Размеры — в долях сцены (cqw/cqh).
   ========================================================= */

:root {
  --ivory: #FBF6EF;
  /* тёплые коричневые чернила и розовое золото — цвет лепестков сакуры на золоте арки */
  --ink: #5E4636;
  --ink-2: rgba(94, 70, 54, .84);
  --gold: #A9765F;
  --gold-2: #C79583;
  --rose: #A86A78;
  --gold-line: rgba(176, 120, 104, .4);
  --gold-text: linear-gradient(100deg, #9A6452 0%, #D2A18E 30%, #AE7663 55%, #E2B9A8 75%, #9A6452 100%);
  --glass: rgba(255, 252, 247, .74);

  --serif: "Cormorant Garamond", Georgia, serif;
  --script: "Great Vibes", cursive;
  --sans: "Montserrat", system-ui, sans-serif;
  --ease: cubic-bezier(.19, 1, .22, 1);
  /* «камера» — плавный разгон и долгое мягкое торможение */
  --cam: cubic-bezier(.55, 0, .15, 1);
  /* светлое свечение вокруг букв: текст читается на любом участке картинки */
  --glow: 0 0 14px rgba(255, 251, 245, .95), 0 0 3px rgba(255, 251, 245, .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: #EFE6DD;
  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(94, 70, 54, .45);
  user-select: none;
  -webkit-user-select: none;
}

.scene { position: absolute; inset: 0; pointer-events: none; }
.scene img { position: absolute; max-width: none; -webkit-user-drag: none; }

/* стартовые положения слоёв — «камера» близко к дворцу; .is-playing возвращает всё на место */
.scene__bg {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: 50% 66%;
  scale: 2.1;
}
/* светлая дымка в центре арки — под текстом, появляется после отъезда */
.scene__haze {
  position: absolute;
  inset: 0;
  opacity: 0;
  /* чуть розоватая дымка, как отсвет сакуры */
  background: radial-gradient(74% 36% at 50% 46%, rgba(255, 249, 247, .84), rgba(255, 246, 244, .46) 58%, rgba(255, 246, 244, 0) 88%);
}
/* арка и всё, что на ней растёт, — один слой: при отъезде камеры он уменьшается сильнее фона */
.scene__archset { position: absolute; inset: 0; transform-origin: 50% 60%; scale: 2.8; }
.scene__arch {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* гирлянда из пионов и роз за аркой: свисает в проём сверху, края спрятаны под камнем;
   две зеркальные половины встречаются в центре */
.scene__garland { top: 8.5cqh; width: 37cqw; }
.scene__garland--l { left: 14.5cqw; transform-origin: 0 0; }
.scene__garland--r { right: 14.5cqw; transform-origin: 100% 0; }
.scene__garland--c { left: 50%; top: 5.5cqh; width: 46cqw; translate: -50% 0; }
/* цветущие кусты сакуры растут вверх у основания колонн */
.scene__vine { bottom: 17cqh; width: 19cqw; transform-origin: 50% 100%; }
.scene__vine--l { left: -6.5cqw; }
.scene__vine--r { right: -6.5cqw; }
/* цветущие кисти сакуры свисают вдоль колонн */
.scene__hang { top: 33cqh; width: 21cqw; transform-origin: 50% 0; }
.scene__hang--l { left: -8cqw; translate: -120% 0; }
.scene__hang--r { right: -8cqw; top: 37cqh; translate: 120% 0; }
/* кроны в верхних углах */
.scene__tree { top: -11cqh; width: 47cqw; }
.scene__tree--l { left: -13cqw; transform-origin: 0 0; translate: -80% -75%; scale: 1.4; }
.scene__tree--r { right: -13cqw; transform-origin: 100% 0; translate: 80% -75%; scale: 1.4; }
/* полоса цветов по низу */
.scene__flowers { left: 0; bottom: -2cqh; width: 100cqw; height: auto; transform-origin: 50% 100%; translate: 0 105%; scale: 1.35; }

/* --- отъезд камеры --- */
.is-playing .scene__bg { scale: 1; transition: scale 3.4s var(--cam); }
.is-playing .scene__archset { scale: 1; transition: scale 3.4s var(--cam); }
.is-playing .scene__tree { translate: 0 0; scale: 1; transition: translate 3s var(--cam) .45s, scale 3s var(--cam) .45s; }
.is-playing .scene__hang { translate: 0 0; transition: translate 2.6s var(--cam) .9s; }
.is-playing .scene__flowers { translate: 0 0; scale: 1; transition: translate 2.8s var(--cam) .55s, scale 2.8s var(--cam) .55s; }
.is-playing .scene__haze { opacity: 1; transition: opacity 2s ease 2.2s; }
/* в кабинете сцена сразу собрана, без отъезда */
.is-instant .scene * { transition: none !important; }

/* --- после отъезда сцена живёт: фон медленно «дышит», ветки покачиваются --- */
.is-open .scene__bg { animation: breathe 24s ease-in-out infinite alternate; }
.is-open .scene__tree--l { animation: sway-l 7s ease-in-out infinite alternate; }
.is-open .scene__tree--r { animation: sway-r 8s ease-in-out -2s infinite alternate; }
.is-open .scene__hang--l { animation: swing 5.5s ease-in-out infinite alternate; }
.is-open .scene__hang--r { animation: swing 6.2s ease-in-out -3s infinite alternate-reverse; }
.is-open .scene__garland--l { animation: sway-l 9s ease-in-out -1s infinite alternate; }
.is-open .scene__garland--r { animation: sway-r 9.5s ease-in-out -4s infinite alternate; }
.is-open .scene__vine--l { animation: swing 6.8s ease-in-out infinite alternate; }
.is-open .scene__vine--r { animation: swing 7.4s ease-in-out -3s infinite alternate-reverse; }
@keyframes breathe { to { transform: scale(1.035); } }
@keyframes sway-l { to { transform: rotate(1.6deg); } }
@keyframes sway-r { to { transform: rotate(-1.6deg); } }
@keyframes swing { from { transform: rotate(-2.2deg); } to { transform: rotate(2.2deg); } }

/* цветы внизу пульсируют: чуть увеличиваются от земли и теплеют, задний и передний слои — в разном ритме */
.is-open .scene__flowers--back { animation: bloom 4.4s ease-in-out infinite alternate; }
.is-open .scene__flowers--front { animation: bloom-front 3.4s ease-in-out -1.7s infinite alternate; }
@keyframes bloom { to { transform: scale(1.03); filter: brightness(1.04) saturate(1.06); } }
@keyframes bloom-front { to { transform: scale(1.045); filter: brightness(1.06) saturate(1.1); } }

/* --- бабочки сидят: две на цветах по бокам, одна на кисти сакуры у колонны.
       Время от времени складывают и раскрывают крылья и чуть покачиваются --- */
/* места посадки подобраны по картинкам: «лапки» (80% высоты бабочки) — на верхушке цветка или кисти */
.fly { opacity: 0; transform-origin: 50% 80%; }
.fly--1 { left: 2.75cqw; top: 74cqh; width: 6.5cqw; rotate: -12deg; }
.fly--2 { left: 89.25cqw; top: 74.6cqh; width: 7.5cqw; rotate: 10deg; }
.fly--3 { left: 8cqw; top: 47.4cqh; width: 5cqw; rotate: 8deg; }
.is-open .fly { animation: fly-in 1.6s ease 1s forwards, wings 5.2s ease-in-out 2s infinite, perch 3.6s ease-in-out infinite alternate; }
.is-open .fly--2 { animation-delay: 1.4s, 3.7s, -1.2s; animation-duration: 1.6s, 6.4s, 4.1s; }
.is-open .fly--3 { animation-delay: 1.8s, 2.9s, -2.3s; animation-duration: 1.6s, 5.8s, 3.3s; }
/* крылья почти всё время раскрыты, иногда дважды неспешно складываются — как у сидящей бабочки */
@keyframes wings {
  0%, 70%, 100% { scale: 1 1; }
  76% { scale: .4 1; }
  82% { scale: 1 1; }
  88% { scale: .5 1; }
  94% { scale: 1 1; }
}
/* лёгкое покачивание вместе с цветком */
@keyframes perch { to { transform: translateY(-.4cqh) rotate(3deg); } }
@keyframes fly-in { to { opacity: 1; } }

/* --- лепестки сакуры медленно падают (создаёт main.js) --- */
.petals { position: absolute; inset: 0; }
.petal {
  position: absolute;
  top: -4cqh;
  left: var(--x);
  width: var(--s);
  height: calc(var(--s) * .72);
  border-radius: 80% 0 80% 0;
  background: radial-gradient(ellipse at 30% 30%, #FFF0F3, #F5C3D0 55%, #E9A6B9);
  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: .85; }
  50%  { transform: translate(calc(var(--dx) * .5), 55cqh) rotate(calc(var(--rot) * .5)) rotateY(160deg); }
  90%  { opacity: .75; }
  100% { opacity: 0; transform: translate(var(--dx), 110cqh) rotate(var(--rot)) rotateY(360deg); }
}

/* --- золотые звёзды мерцают в небе над дворцом (создаёт main.js) --- */
.stars { position: absolute; inset: 0; opacity: 0; }
.is-open .stars { animation: fade-in 2s ease .4s forwards; }
.star {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  aspect-ratio: 1;
  background: radial-gradient(circle, #FFF6DE 0 12%, #E9CC8E 24%, transparent 60%);
  clip-path: polygon(50% 0, 58% 42%, 100% 50%, 58% 58%, 50% 100%, 42% 58%, 0 50%, 42% 42%);
  animation: twinkle var(--dur) ease-in-out var(--delay) infinite;
}
@keyframes twinkle {
  0%, 100% { opacity: .15; scale: .55; rotate: 0deg; }
  50% { opacity: 1; scale: 1; rotate: 45deg; }
}

/* --- при листании страниц разлетается золотая пыль --- */
.dust {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #FFF4D6, #D9B56E 60%, transparent 72%);
  box-shadow: 0 0 6px 1px rgba(230, 196, 120, .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; perspective: 1400px; pointer-events: none; }
.gate__door {
  position: absolute;
  top: 0;
  width: 50.2%;
  height: 100%;
  object-fit: cover;
  backface-visibility: hidden;
}
/* петли — на внешних краях, шов — по центру */
.gate__door--l { left: 0; object-position: 100% 50%; transform-origin: 0 50%; box-shadow: inset -6px 0 10px -6px rgba(60, 30, 70, .35); }
.gate__door--r { right: 0; object-position: 0 50%; transform-origin: 100% 50%; box-shadow: inset 6px 0 10px -6px rgba(60, 30, 70, .35); }
.gate__seal {
  position: absolute;
  left: 50%;
  top: 50.1%;
  width: 22.7cqw;
  translate: -50% -50%;
  filter: drop-shadow(0 6px 10px rgba(50, 20, 60, .45));
  animation: seal-pulse 2.6s ease-in-out infinite;
}
/* печать до касания мягко «дышит» золотым отблеском — подсказывает, куда нажать */
@keyframes seal-pulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 6px 10px rgba(50, 20, 60, .45)) drop-shadow(0 0 0 rgba(236, 200, 140, 0)); }
  50% { transform: scale(1.04); filter: drop-shadow(0 6px 10px rgba(50, 20, 60, .45)) drop-shadow(0 0 14px rgba(236, 200, 140, .75)); }
}

/* касание: печать подпрыгивает, отрывается от шва и падает вниз, кувыркаясь */
.is-gate-open .gate__seal { animation: seal-fall 1.05s cubic-bezier(.55, 0, .8, .4) forwards; }
@keyframes seal-fall {
  0%   { transform: none; }
  18%  { transform: translateY(-3cqh) rotate(-8deg) scale(1.06); }
  100% { transform: translateY(85cqh) rotate(70deg) scale(.92); opacity: .9; }
}
/* створки раздвигаются влево и вправо, как раздвижные двери, и уходят за края экрана */
.is-gate-open .gate__door--l { animation: door-l 1.9s cubic-bezier(.65, 0, .25, 1) .5s forwards; }
.is-gate-open .gate__door--r { animation: door-r 1.9s cubic-bezier(.65, 0, .25, 1) .5s forwards; }
@keyframes door-l { to { transform: translateX(-102%); } }
@keyframes door-r { to { transform: translateX(102%); } }
.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 { display: none; }
/* подсказка в духе сказки: золотая линия с полумесяцем, надпись каллиграфией с бегущим бликом
   и мелкая подпись — без рамки, прямо на бумаге конверта */
.tap__hint {
  position: absolute;
  left: 50%;
  top: 57cqh;
  translate: -50% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  white-space: nowrap;
  filter: drop-shadow(0 0 8px rgba(255, 251, 246, .95));
  animation: hint 3.2s ease-in-out infinite;
}
.tap__orn { width: 34cqw; height: 3.8cqw; color: var(--gold); }
.tap__text {
  margin-top: .4cqh;
  font-family: var(--script);
  font-size: min(8.8cqw, 4.9cqh);
  line-height: 1.15;
  padding: 0 .15em;
  /* розовое золото с бликом, который медленно пробегает по буквам */
  background: linear-gradient(100deg, #9A6452 0%, #B97F6C 35%, #F3D9C9 48%, #B97F6C 60%, #9A6452 100%) 0 0 / 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: hint-shine 3.6s ease-in-out infinite;
}
.tap__sub {
  margin-top: .2cqh;
  font-family: var(--sans);
  font-size: max(8.5px, 2.3cqw);
  letter-spacing: .32em;
  padding-left: .32em;
  text-transform: uppercase;
  color: #9C7A73;
}
@keyframes hint { 50% { opacity: .78; scale: 1.02; } }
@keyframes hint-shine { from { background-position: 100% 0; } to { background-position: -50% 0; } }

/* ---------- Страницы ---------- */

/* текст — в проёме арки, над цветами */
.slides { position: absolute; top: 22cqh; bottom: 27cqh; 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 16cqw;
  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-weight: 400; font-size: min(5.4cqw, 3cqh); letter-spacing: .1em; padding-left: .1em; white-space: nowrap; text-transform: uppercase; color: var(--ink); line-height: 1.15; 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: #6B4E3B;
  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: -.2em 0 -.1em; font-family: var(--script); font-size: min(9cqw, 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; 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::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, 247, .84); /* плотнее: подложка без размытия */
  box-shadow: 0 10px 22px -14px rgba(94, 70, 54, .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(176, 120, 104, .22);
}
.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: #8E5E50; 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, #A46B5C, #DDB1A0 50%, #A06859); border-color: transparent; color: #FFFDFB; font-weight: 500; box-shadow: 0 10px 22px -12px rgba(140, 80, 66, .7); }
.btn-line--solid:hover { background: linear-gradient(120deg, #AE7464, #E6BEAE 50%, #AA7262); }

/* ---------- Для гостей ---------- */

.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: #6B4E3B; text-shadow: var(--glow); --d: 1.8s; }

/* ---------- Навигация ---------- */

.nav {
  position: absolute;
  left: 0;
  right: 0;
  /* над цветами — в понижении цветника, над водой */
  bottom: 19.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 4.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(168, 106, 120, .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(94, 70, 54, .6);
}
.dialog::backdrop { background: rgba(94, 70, 54, .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%, #FFFDF9, #F6EEE4); }
.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: 28px; 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; }

/* ---------- Вытянутые телефоны ----------
   Экран уже, чем 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)); }
  /* бабочки сидят на цветах у самого края — пересаживаем их внутрь видимой части */
  .fly--1 { left: calc(2.75cqw + var(--cx, 0px)); }
  .fly--2 { left: calc(89.25cqw - var(--cx, 0px)); }
  .fly--3 { left: calc(8cqw + 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='%23A9765F' 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, #F6EEE6;
    font: 500 12px/1.5 "Montserrat", system-ui, sans-serif;
    letter-spacing: .24em;
    text-transform: uppercase;
    text-align: center;
    color: #A9765F;
  }
}

@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; }
  .fly, .petals, .stars { display: none; }
  .gate__seal { animation: none; }
}
