/* Палитра «Айвори + золото». Другая палитра = поменять только эти переменные. */
:root {
  --bg: #faf6ef;
  --paper: #fffdf8;
  --ink: #3b3226;
  --muted: #6f604c;
  --gold: #b8924a;        /* линии и орнамент */
  --gold-text: #8f6c2e;   /* золотой текст: темнее, чтобы читался */
  --gold-btn: #8a6a2f;
  --line: #e7dcc8;
  --env1: #fffaf0; --env2: #efe5d3;     /* фон вокруг конверта */
  --flap1: #f6eddc; --flap2: #efe2c8;   /* клапан конверта */
  --seal1: #d9b46a; --seal2: #9c7631;   /* печать */
  --on-btn: #fff;                       /* текст на кнопках */
  --picked: #fbf4e6;                    /* выбранный вариант в анкете */
  --shadow: 80, 60, 20;                 /* цвет теней (r, g, b) */
  --glass: rgba(255, 253, 248, .9);     /* фон переключателя языка */
  --error: #a4372a;
  --pattern: none;                      /* узор фона первого экрана */
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Montserrat", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 19px/1.6 var(--serif);
  font-variant-numeric: lining-nums;
  overflow-x: hidden;
}
body.locked { overflow: hidden; }
h1, h2, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }

.orn { display: block; width: 200px; height: 60px; margin: 0 auto; color: var(--gold); }
.orn-small { width: 140px; height: 42px; }
.orn.flip { transform: scaleY(-1); }

/* ---------- Конверт ---------- */
.env {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, var(--env1), var(--env2));
  transition: opacity .8s ease .9s, visibility 0s linear 1.7s;
  padding: 16px;
}
.env-paper {
  position: relative;
  width: min(360px, 100%);
  aspect-ratio: 5 / 7;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 40px 70px -40px rgba(var(--shadow), .45), 0 2px 10px rgba(var(--shadow), .06);
  perspective: 1200px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  padding: 0 24px 28px;
  text-align: center;
}
.env-flap {
  position: absolute; top: 0; left: 0; width: 100%; height: 58%;
  transform-origin: top center;
  transition: transform .9s cubic-bezier(.6, 0, .3, 1), opacity .5s ease .35s;
  filter: drop-shadow(0 6px 8px rgba(var(--shadow), .12));
  z-index: 2;
}
.env-inner { position: relative; z-index: 1; margin-bottom: 8px; transition: transform .9s ease .3s; }
.env-names { font: italic 500 34px/1.15 var(--serif); color: var(--gold-text); margin: 10px 0 6px; }
.env-date { font: 500 12px/1 var(--sans); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.seal {
  position: absolute; top: 52%; left: 50%; z-index: 3;
  width: 78px; height: 78px; margin: -39px 0 0 -39px;
  border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, var(--seal1), var(--seal2) 70%);
  box-shadow: 0 6px 16px rgba(var(--shadow), .45), inset 0 0 0 4px rgba(255, 255, 255, .18);
  color: var(--on-btn); font: italic 500 22px/1 var(--serif);
  transition: transform .4s ease, opacity .4s ease;
  animation: pulse 2.4s ease-in-out infinite;
}
.seal:focus-visible { outline: 2px solid var(--gold-text); outline-offset: 4px; }
.env-hint {
  position: absolute; top: calc(52% + 50px); left: 0; right: 0; z-index: 3;
  font: 500 11px/1 var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--muted);
}
@keyframes pulse { 50% { transform: scale(1.06); } }

.env.open .env-flap { transform: rotateX(180deg); opacity: 0; }
.env.open .seal, .env.open .env-hint { opacity: 0; transform: scale(.6); animation: none; }
.env.open .env-inner { transform: translateY(-40px); }
.env.open { opacity: 0; visibility: hidden; }

/* ---------- Переключатель языка и музыка ---------- */
.lang {
  position: fixed; top: 12px; right: 12px; z-index: 60;
  display: flex; background: var(--glass); border: 1px solid var(--line); border-radius: 20px; padding: 3px;
}
.lang button {
  border: 0; background: none; cursor: pointer; padding: 6px 12px; border-radius: 16px;
  font: 500 12px/1 var(--sans); letter-spacing: .08em; color: var(--muted);
}
.lang button[aria-pressed="true"] { background: var(--gold-btn); color: var(--on-btn); }
.music {
  position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 40;
  width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--paper); color: var(--gold-text); font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(var(--shadow), .15);
}
.music[aria-pressed="true"] .music-icon { display: inline-block; animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Контент ---------- */
.hero {
  min-height: 100svh; display: grid; place-items: center; text-align: center;
  padding: 72px 16px 48px;
  background-size: cover; background-position: center;
  background-image: var(--pattern);
}
.hero.has-photo { color: #fff; }
.hero.has-photo .orn { color: #f1dcae; }
.hero.has-photo .kicker, .hero.has-photo .hero-date { color: #f6ecd8; }
.hero.has-photo .names { color: #fff; }
.kicker { font: 500 12px/1 var(--sans); letter-spacing: .3em; text-transform: uppercase; color: var(--muted); margin-top: 24px; }
.names { font: italic 500 clamp(48px, 13vw, 88px)/1.05 var(--serif); color: var(--gold-text); margin: 18px 0; }
.hero-date { font: 500 14px/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; margin-bottom: 24px; }

.sec { position: relative; max-width: 560px; margin: 0 auto; padding: 56px 16px; text-align: center; }
.sec::before { content: ""; position: absolute; top: 0; left: 50%; width: 64px; height: 1.5px; margin-left: -32px; border-radius: 2px; background: var(--gold); opacity: .6; }
h2 { font: 500 30px/1.2 var(--serif); color: var(--gold-text); margin-bottom: 22px; }
.greeting { font: italic 500 26px/1.3 var(--serif); margin-bottom: 14px; }
.lead { font-size: 21px; }

.timer { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.timer div { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 14px 4px; }
.timer b { display: block; font: 500 clamp(28px, 9vw, 40px)/1 var(--serif); color: var(--gold-text); font-variant-numeric: tabular-nums; }
.timer span { font: 500 10px/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.started { font: italic 500 28px/1.2 var(--serif); color: var(--gold-text); }

.program { list-style: none; margin: 0 auto; padding: 0; max-width: 360px; text-align: left; position: relative; }
.program::before { content: ""; position: absolute; left: 68px; top: 8px; bottom: 8px; width: 1px; background: var(--gold); opacity: .5; }
.program li { display: grid; grid-template-columns: 56px 1fr; gap: 26px; padding: 10px 0; position: relative; }
.program li::after { content: ""; position: absolute; left: 64px; top: 20px; width: 9px; height: 9px; transform: rotate(45deg); background: var(--gold); }
.program time { font: 500 14px/1.9 var(--sans); color: var(--gold-text); text-align: right; }

.place-name { font-size: 24px; font-weight: 500; }
.maps { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }
.btn, .maps a {
  display: inline-block; border: 1px solid var(--gold-btn); border-radius: 30px;
  padding: 12px 22px; font: 500 13px/1 var(--sans); letter-spacing: .08em; text-decoration: none;
  color: var(--gold-btn); background: transparent; cursor: pointer;
}
.maps a:hover { background: var(--gold-btn); color: var(--on-btn); }
.btn { background: var(--gold-btn); color: var(--on-btn); width: 100%; padding: 17px; font-size: 14px; }
.btn:disabled { opacity: .6; cursor: wait; }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.gallery img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 16px; display: block; }
.gallery img:first-child:nth-last-child(odd) { grid-column: span 2; aspect-ratio: 3 / 2; }

.swatches { display: flex; justify-content: center; gap: 10px; margin-top: 18px; }
.swatches i { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); }

.rsvp { display: grid; gap: 16px; text-align: left; margin-top: 24px; }
.rsvp label { display: grid; gap: 6px; font: 500 13px/1.3 var(--sans); color: var(--muted); }
.rsvp input:not([type=radio]), .rsvp select, .rsvp textarea {
  font: 400 18px/1.3 var(--serif); color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 13px 16px; width: 100%;
}
.rsvp input:focus, .rsvp select:focus, .rsvp textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.choice { display: grid; gap: 8px; }
.choice label {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 13px 16px;
  font: 400 18px/1.2 var(--serif); color: var(--ink);
}
.choice input { accent-color: var(--gold-btn); width: 18px; height: 18px; }
.choice label:has(input:checked) { border-color: var(--gold); background: var(--picked); }
.form-msg { text-align: center; min-height: 1.4em; font-size: 18px; }
.form-msg.ok { color: var(--gold-text); font-style: italic; font-size: 22px; }
.form-msg.err { color: var(--error); }

.foot { text-align: center; padding: 48px 16px calc(80px + env(safe-area-inset-bottom)); font-style: italic; font-size: 22px; }
.foot .orn { margin-bottom: 14px; }

/* ---------- Появление при прокрутке ---------- */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .9s ease, transform .9s ease; }
.js .reveal.on { opacity: 1; transform: none; }

/* ---------- Движок: календарь ---------- */
.cal-head { display: flex; justify-content: space-between; align-items: baseline; max-width: 340px; margin: 0 auto 14px; padding-bottom: 10px; border-bottom: 1px solid var(--gold); font: 500 26px/1 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--gold-text); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px 0; max-width: 340px; margin: 0 auto; }
.cal-dn { font: 500 12px/2 var(--sans); color: var(--muted); }
.cal-day { position: relative; font: 400 19px/2.1 var(--sans); font-variant-numeric: tabular-nums; }
.cal-day.on { color: var(--gold-text); font-weight: 600; }
.cal-day svg { position: absolute; left: 50%; top: 50%; width: 46px; height: 44px; transform: translate(-50%, -48%); fill: none; stroke: var(--gold-text); stroke-width: 1.4; }
.js .reveal.on .cal-day.on svg { animation: beat 1.8s ease-in-out .6s 2; }
@keyframes beat { 30% { transform: translate(-50%, -48%) scale(1.12); } 60% { transform: translate(-50%, -48%) scale(1); } }
.cal-time { margin: 18px 0 18px; font: 500 15px/1 var(--sans); letter-spacing: .06em; color: var(--muted); }
.cal-add, .con-btns { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.cal-btn { display: inline-block; border: 1px solid var(--gold-btn); border-radius: 30px; padding: 11px 18px; font: 500 12px/1 var(--sans); letter-spacing: .06em; color: var(--gold-btn); text-decoration: none; }
.cal-btn:hover { background: var(--gold-btn); color: var(--on-btn); }
.con-list { display: grid; gap: 14px; }
.con-row { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.con-name { font-size: 20px; }

/* ---------- Движок: подсказки ---------- */
.hint-scroll, .hint-music { position: fixed; z-index: 45; font: 500 12px/1 var(--sans); letter-spacing: .1em; color: var(--muted); background: var(--glass); border: 1px solid var(--line); border-radius: 20px; padding: 9px 14px; opacity: 0; transition: opacity .6s ease, transform .6s ease; pointer-events: none; }
.hint-scroll { white-space: nowrap; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 8px); text-transform: uppercase; }
.hint-scroll.show { opacity: 1; transform: translate(-50%, 0); animation: nudge 2.4s ease-in-out 1s infinite; }
@keyframes nudge { 50% { transform: translate(-50%, 5px); } }
.hint-music { right: 70px; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(6px); }
.hint-music.show { opacity: 1; transform: none; }

/* ---------- Движок: эффекты ---------- */
.fx { position: fixed; inset: 0; pointer-events: none; z-index: 35; overflow: hidden; opacity: 0; transition: opacity 2s ease; }
.fx.on { opacity: 1; }
.fx i { position: absolute; top: -20px; display: block; animation: fall linear infinite; }
.fx-lepestki i { background: var(--seal1); opacity: .35; border-radius: 80% 0 80% 0; }
.fx-blestki i { background: var(--gold); border-radius: 50%; box-shadow: 0 0 6px var(--gold); opacity: .55; }
@keyframes fall { 0% { transform: translate3d(0, -5vh, 0) rotate(0); } 50% { transform: translate3d(24px, 50vh, 0) rotate(180deg); } 100% { transform: translate3d(-12px, 108vh, 0) rotate(360deg); } }

/* ---------- Движок: материалы темы ---------- */
.names-script .names, .names-script .env-names { font-family: "Bad Script", var(--serif); font-style: normal; font-weight: 400; }
.env.env-img .env-paper { background: var(--konvert) center / cover no-repeat; border: 0; }
.env.env-img .env-flap, .env.env-img .env-inner .orn { display: none; }
.seal.seal-img { background: var(--pechat) center / contain no-repeat; box-shadow: none; width: 110px; height: 110px; margin: -55px 0 0 -55px; }
.seal.seal-img .seal-mono { opacity: 0; }
.hero.has-fon { background-image: var(--fon); background-size: cover; background-position: center; }
.intro-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .4s ease; z-index: 5; pointer-events: none; }
.env.playing .intro-video { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
