/* Приглашение Рустама и Эзозы. Две темы на одном движке:
   d — «Лепнина»: гипс, тёплый серый, золото волосяной линией;
   g — «Гризайль»: серебро и жемчуг, цветная только бордовая печать.
   Один светлый мир (как зал), поэтому тёмной темы нет — цвета заданы явно. */
:root {
  --script: "Great Vibes", "Segoe Script", cursive;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --caps: "Forum", "Cormorant Garamond", serif;
  --vh: 100vh;
  color-scheme: light;
}
@supports (height: 100svh) { :root { --vh: 100svh } }

[data-v="d"] {
  --paper: #f3f1ec; --panel: #e9e5dd; --ink: #34302c; --mute: #7a736b; --line: #d2cbbf;
  --accent: #a8874f; --seal: #7a2030; --foil-a: #d9d2c6; --foil-b: #f7f4ee; --foil-c: #c4bba9;
}
[data-v="g"] {
  --paper: #eceae6; --panel: #dfdcd6; --ink: #2b2a29; --mute: #6c6965; --line: #bdb9b2;
  --accent: #8e8a84; --seal: #7a1f2e; --foil-a: #c9c6c0; --foil-b: #f2f1ee; --foil-c: #a9a5a0;
}

* { box-sizing: border-box }
[hidden] { display: none !important }
html, body { background: #ebe8e3 }
body { margin: 0; color: var(--ink); font: 400 19px/1.55 var(--serif); -webkit-font-smoothing: antialiased }
#root { background: var(--paper); color: var(--ink); min-height: var(--vh) }
html.locked, html.locked body { overflow: hidden; height: 100% }
h2 { font: 400 clamp(40px, 11vw, 54px)/1.1 var(--script); margin: 0; font-weight: 400; text-wrap: balance }
p { margin: 0 }
.k { font: 400 12px/1.5 var(--caps); letter-spacing: .3em; text-transform: uppercase }
:focus-visible { outline: 2px solid var(--seal); outline-offset: 3px }

/* язык */
.lang { position: fixed; z-index: 60; top: calc(12px + env(safe-area-inset-top, 0px)); right: calc(12px + env(safe-area-inset-right, 0px)); display: flex; border: 1px solid var(--line); background: rgba(250, 249, 246, .82); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px) }
.lang button { font: 400 12px/1 var(--caps); letter-spacing: .16em; padding: 9px 11px; background: none; color: var(--ink); border: 0; cursor: pointer }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--paper) }

/* кадр 9:16: на телефоне занимает весь экран (лишнее по бокам обрезано), на широком экране — колонка по центру */
.viewport { position: relative; width: 100%; height: var(--vh); overflow: hidden; background: var(--panel) }
.viewport .bg { position: absolute; inset: -40px; background-size: cover; background-position: center; filter: blur(28px) saturate(.8); opacity: .75 }
.frame { position: absolute; top: 0; left: 50%; height: 100%; aspect-ratio: 9 / 16; transform: translateX(-50%); max-width: none }
.frame img, .frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; max-width: none }
.frame canvas { opacity: 0 }
.frame canvas.on { opacity: 1 }
.ov { position: absolute; inset: 0; margin: 0 auto; width: min(100%, calc(var(--vh) * 9 / 16)); pointer-events: none }
.ov a, .ov button { pointer-events: auto }

/* конверт-вход */
#gate { position: fixed; inset: 0; z-index: 50; transition: opacity .8s ease .4s }
#gate::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(25,22,20,.55), rgba(25,22,20,0) 32%, rgba(25,22,20,0) 70%, rgba(25,22,20,.55)); pointer-events: none }
.gate-ov { z-index: 2; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; text-align: center; color: #fff; padding: calc(64px + env(safe-area-inset-top, 0px)) 20px calc(34px + env(safe-area-inset-bottom, 0px)); text-shadow: 0 2px 16px rgba(0,0,0,.55) }
.gate-top { display: grid; gap: 8px }
.greet { font: 400 clamp(34px, 10vw, 46px)/1.1 var(--script) }
.tap { grid-row: 3; font: 400 12px/1.4 var(--caps); letter-spacing: .3em; text-transform: uppercase }
.seal { position: absolute; z-index: 3; width: 82px; height: 82px; margin: -41px 0 0 -41px; border-radius: 50%; border: 0; background: transparent; cursor: pointer }
.seal::before, .seal::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 0 12px rgba(0,0,0,.3); animation: ring 2.2s ease-out infinite }
.seal::after { animation-delay: 1.1s }
@keyframes ring { from { transform: scale(.75); opacity: .95 } to { transform: scale(1.9); opacity: 0 } }
[data-v="d"] .seal { left: 49%; top: 39% }
[data-v="g"] .seal { left: 32%; top: 72% }
#gate.opening .seal::before, #gate.opening .seal::after { animation: burst 1s ease-out forwards }
@keyframes burst { from { transform: scale(1); opacity: 1; box-shadow: 0 0 40px 20px rgba(255,255,255,.85) } to { transform: scale(9); opacity: 0 } }
#gate.opening { opacity: 0; pointer-events: none }
#gate.gone { display: none }

/* фильм под прокрутку */
#film { height: calc(var(--vh) * 4.2) }
.sticky { position: sticky; top: 0 }
.sticky::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(25,22,20,.38), rgba(25,22,20,0) 26%, rgba(25,22,20,0) 66%, rgba(25,22,20,.45)); pointer-events: none }
.beat { position: absolute; left: 18px; right: 18px; z-index: 2; display: grid; gap: 8px; justify-items: center; text-align: center; opacity: 0; will-change: opacity, transform }
.b1 { bottom: calc(40px + env(safe-area-inset-bottom, 0px)); color: #fff; text-shadow: 0 2px 18px rgba(0,0,0,.55) }
.b2, .b3 { top: 50%; transform: translateY(-50%) }
.b4 { bottom: calc(30px + env(safe-area-inset-bottom, 0px)); color: #fff; text-shadow: 0 1px 10px rgba(0,0,0,.6) }
.names { font: 400 clamp(52px, 15vw, 70px)/1 var(--script) }
.hint { font: 400 11px/1 var(--caps); letter-spacing: .3em; text-transform: uppercase; margin-top: 10px; animation: bob 1.8s ease-in-out infinite }
@keyframes bob { 50% { transform: translateY(6px) } }
.card { background: rgba(247, 245, 241, .86); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--line); padding: 22px 18px; color: var(--ink) }
.card .greet { font-size: clamp(34px, 9vw, 42px) }
.card p { font-size: 18px; line-height: 1.45; max-width: 30ch }
.card .k { color: var(--seal) }
.count { display: flex; gap: 14px; justify-content: center; font-variant-numeric: tabular-nums }
.count div { display: grid; gap: 2px; justify-items: center; min-width: 54px }
.count b { font: 400 34px/1 var(--caps); font-weight: 400 }
.count span { font: 400 10px/1.3 var(--caps); letter-spacing: .2em; text-transform: uppercase; color: var(--mute) }

/* статичная часть */
.content { max-width: 520px; margin: 0 auto; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px) }
.block { padding-block: 56px 40px; display: grid; gap: 14px; justify-items: center; text-align: center }
.block > .k { color: var(--seal) }
.medal { width: 168px; height: 168px; object-fit: cover; border-radius: 50%; border: 1px solid var(--line); box-shadow: 0 0 0 6px var(--paper), 0 0 0 7px var(--line) }
[data-v="g"] .medal { width: 150px; height: 190px; border-radius: 50% / 50% }
.divider { display: flex; align-items: center; gap: 12px; color: var(--line) }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line) }
.divider i { width: 7px; height: 7px; transform: rotate(45deg); border: 1px solid var(--accent) }

.scratch { position: relative; width: min(340px, 100%); aspect-ratio: 340 / 190; background: var(--paper); border: 1px solid var(--line); display: grid; place-items: center; touch-action: none; margin-top: 6px }
.scratch .under { display: grid; gap: 6px }
.scratch .under .s { font: 400 48px/1 var(--script) }
.scratch .under .k { color: var(--seal) }
.scratch canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; transition: opacity .7s }
.scratch.done canvas { opacity: 0; pointer-events: none }
.link-btn { font: italic 400 16px/1.4 var(--serif); background: none; border: 0; color: var(--mute); text-decoration: underline; cursor: pointer; padding: 4px }
.count.big { margin-top: 8px }
.count.big b { font-size: 38px }
.cal { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px }
.cal-k { margin-top: 14px; color: var(--mute) }
.btn { display: inline-block; font: 400 12px/1 var(--caps); letter-spacing: .22em; text-transform: uppercase; text-decoration: none; padding: 14px 18px; background: var(--ink); color: var(--paper); border: 1px solid var(--ink); cursor: pointer }
.btn.ghost { background: none; color: var(--ink) }

.hall { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border: 1px solid var(--line); margin-block: 8px }
[data-v="g"] .hall { filter: grayscale(1) contrast(.92) brightness(1.05) }
.lead { font-size: 22px }
.note { font-style: italic; color: var(--mute); font-size: 17px; max-width: 34ch }

form { width: 100%; display: grid; gap: 10px; text-align: left; margin-top: 6px }
form > label, legend { font: 400 12px/1.4 var(--caps); letter-spacing: .2em; text-transform: uppercase; color: var(--mute) }
input:not([type]), input[type="text"], textarea { font: 400 19px/1.3 var(--serif); color: var(--ink); background: #fbfaf8; border: 1px solid var(--line); border-radius: 0; padding: 11px 12px; width: 100%; -webkit-appearance: none; appearance: none }
.name-row { display: grid; gap: 10px }
.answers { display: grid; gap: 10px; margin-top: 8px }
.answers .btn { width: 100%; padding: 17px 18px; font-size: 13px }
.answers .btn[disabled] { opacity: .55 }
.err { color: var(--seal); font-size: 16px; text-align: center }
.thanks { display: grid; gap: 8px; justify-items: center; padding: 20px 18px; border: 1px solid var(--line); width: 100% }
.thanks > span { font: 400 32px/1.2 var(--script); color: var(--ink) }
.thanks p { font-size: 19px }

footer { display: grid; gap: 8px; justify-items: center; text-align: center; padding-block: 30px 70px }
footer .end { width: 100%; aspect-ratio: 9 / 11; object-fit: cover; margin-bottom: 14px; -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 75%, transparent); mask-image: linear-gradient(180deg, transparent, #000 18%, #000 75%, transparent) }
footer > .k:first-of-type { color: var(--seal) }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important }
}
