:root {
  --maroon: #5c0f1f;
  --maroon-2: #7a1528;
  --maroon-deep: #3d0814;
  --gold: #c9a24d;
  --gold-soft: #e8cf8a;
  --ivory: #fbf7f0;
  --paper: #fffdf9;
  --ink: #3a1d22;
  --muted: #7d6a64;
  --script: "Pinyon Script", cursive;
  --app-h: 100dvh;
  --u: calc(var(--app-h) / 100);
  --serif: "Cormorant Garamond", Georgia, serif;
  --caps: "Cinzel", "Cormorant Garamond", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  background: #2a0710;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}

img { display: block; max-width: 100%; }

/* ---------- deck: one full screen per section, snap scrolling ---------- */
.deck {
  height: var(--app-h);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  overscroll-behavior: contain;
  max-width: 480px;
  margin: 0 auto;
  box-shadow: 0 0 60px rgba(0,0,0,.5);
  scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }
.screen {
  position: relative;
  height: var(--app-h);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 24px;
}

/* reveal animation: elements with .rv fade/rise in, staggered by data-d */
.rv { opacity: 0; transform: translateY(16px);
      transition: opacity .7s ease, transform .7s cubic-bezier(.2,.8,.2,1); will-change: opacity, transform; }
.screen.in .rv { opacity: 1; transform: none; }
.screen.in .rv[data-d="1"] { transition-delay: 0.05s; }
.screen.in .rv[data-d="2"] { transition-delay: 0.17s; }
.screen.in .rv[data-d="3"] { transition-delay: 0.29s; }
.screen.in .rv[data-d="4"] { transition-delay: 0.41s; }
.screen.in .rv[data-d="5"] { transition-delay: 0.53s; }
.screen.in .rv[data-d="6"] { transition-delay: 0.65s; }
.screen.in .rv[data-d="7"] { transition-delay: 0.75s; }
.screen.in .rv[data-d="8"] { transition-delay: 0.85s; }
.screen.in .rv[data-d="9"] { transition-delay: 0.95s; }
@media (prefers-reduced-motion: reduce) { .rv { transition: none; opacity: 1; transform: none; } }

/* ---------- envelope ---------- */
.envelope {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(120% 90% at 50% 40%, #fbf6ef 0%, #efe4d8 100%);
  cursor: pointer;
  transition: opacity .9s ease .9s, visibility 0s 1.8s;
}
.env-paper { width: min(86vw, 380px); display: flex; flex-direction: column; align-items: center; }
.env-body {
  position: relative; width: 100%; aspect-ratio: 3 / 4.3;
  background: linear-gradient(160deg, #fffdfa, #f3ebe1);
  border-radius: 6px;
  box-shadow: 0 30px 60px -20px rgba(80,30,30,.45), 0 0 0 1px rgba(160,120,100,.15);
  perspective: 1200px;
  transition: transform 1.1s cubic-bezier(.6,0,.4,1) .7s, opacity .8s ease 1.1s;
}
.env-fold { position: absolute; inset: 0; pointer-events: none; }
.env-fold-l { background: linear-gradient(115deg, rgba(0,0,0,.035) 0 50%, transparent 50%); clip-path: polygon(0 0, 50% 55%, 0 100%); }
.env-fold-r { background: linear-gradient(245deg, rgba(0,0,0,.035) 0 50%, transparent 50%); clip-path: polygon(100% 0, 50% 55%, 100% 100%); }
.env-fold-b { background: linear-gradient(0deg, #f1e8dd, #f8f2ea); clip-path: polygon(0 100%, 50% 52%, 100% 100%); box-shadow: inset 0 0 0 1px rgba(0,0,0,.03); }
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%;
  transform-origin: top center; transform-style: preserve-3d;
  transition: transform .9s cubic-bezier(.5,0,.3,1) .25s;
  z-index: 2;
}
.env-flap-inner {
  width: 100%; height: 100%;
  background: linear-gradient(180deg, #fffcf7, #efe5d9);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 4px 6px rgba(80,40,30,.18));
}
.seal {
  position: absolute; left: 50%; top: 58%; width: 30%; z-index: 3;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 6px 8px rgba(60,5,15,.45));
  transition: transform .45s ease, opacity .4s ease;
}
.seal svg { width: 100%; height: auto; display: block; }
.env-tap {
  margin-top: 26px; font-family: var(--script); font-size: 32px; color: #9d7d6e;
  animation: pulse 2.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.envelope.open .seal { transform: translate(-50%, -50%) scale(1.25); opacity: 0; }
.envelope.open .env-flap { transform: rotateX(178deg); }
.envelope.open .env-body { transform: translateY(16vh) scale(.92); opacity: 0; }
.envelope.open .env-tap { opacity: 0; animation: none; transition: opacity .3s; }
.envelope.open { opacity: 0; visibility: hidden; pointer-events: none; }

/* ---------- music ---------- */
.music-btn {
  position: fixed; left: max(14px, calc(50% - 226px)); bottom: 18px; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid rgba(201,162,77,.7);
  background: rgba(61,8,20,.82); color: var(--gold-soft);
  display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(6px);
}
.music-btn svg { width: 20px; height: 20px; }
.music-btn .ic-off { display: none; }
.music-btn.off .ic-on { display: none; }
.music-btn.off .ic-off { display: block; }
.music-btn:not(.off) .ic-on { animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-2px); } }

/* ---------- hero ---------- */
.hero { padding: 0; justify-content: flex-end; background: #fbf6f0; }
.hero-img { position: absolute; left: 0; top: 0; width: 100%; height: 84%; object-fit: cover; object-position: center top; transform-origin: center 40%; transform: scale(1.12); transition: transform 9s ease-out; }
.hero.in .hero-img { transform: scale(1); }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, transparent 58%, rgba(251,246,240,.75) 72%, #fbf6f0 84%); }
.hero-names { position: relative; padding-bottom: calc(9 * var(--u)); }
.hero-names .name { font-size: clamp(50px, 14.5vw, 66px); line-height: 1.15; color: var(--maroon); }
.hero-names .weds { font-family: var(--serif); font-style: italic; font-size: 20px; color: #8a6a5e; margin: 4px 0 6px; }
.swipe-hint { position: absolute; bottom: 22px; left: 50%; transform: translateX(-50%); font-family: var(--caps); font-size: 10px; letter-spacing: .3em; color: #9b8378; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.swipe-hint span { width: 1px; height: 26px; background: linear-gradient(#9b8378, transparent); animation: drip 1.8s ease-in-out infinite; }
@keyframes drip { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* ---------- arch screens ---------- */
.arch-screen { background: var(--paper); padding: 0; }
.arch-frame { position: absolute; left: 0; top: 0; width: 100%; height: 66%; }
.arch-content { position: relative; z-index: 1; padding: calc(21 * var(--u)) 40px calc(15 * var(--u)); }
.bismillah { font-family: "Amiri", serif; font-size: clamp(26px, 8vw, 34px); color: var(--maroon); line-height: 1.6; }
.small-serif { font-size: 15px; color: var(--muted); line-height: 1.45; margin-top: 4px; }
.caps { font-family: var(--caps); font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: #8d6b4f; margin-top: 16px; }
.caps.tiny { font-size: 9.5px; letter-spacing: .2em; margin-top: 12px; }
.serif-it { font-style: italic; font-size: 18px; line-height: 1.45; color: #5a3d3a; margin-top: 10px; }
.heart { color: #b0273f; font-size: 16px; margin: 10px 0 2px; }
.script { font-family: var(--script); font-weight: 400; }
.script.big { font-size: clamp(33px, 9.6vw, 44px); line-height: 1.25; white-space: nowrap; line-height: 1.05; color: var(--maroon); }
.and { font-family: var(--caps); font-size: 14px; color: var(--gold); margin: 2px 0; letter-spacing: .2em; }
.botanical { position: absolute; bottom: 0; left: 0; width: 100%; height: calc(16 * var(--u)); }
.replay { margin-top: 22px; font-family: var(--caps); font-size: 11px; letter-spacing: .2em; color: var(--maroon); background: none; border: 1px solid rgba(92,15,31,.4); border-radius: 999px; padding: 10px 18px; cursor: pointer; }

/* ---------- dear guests ---------- */
.guests-screen { background: radial-gradient(120% 80% at 50% 0%, #fffdf9, #f6eee6); }
.mini-names { font-family: var(--script); font-size: 30px; line-height: 1.3; color: var(--maroon); }
.mini-names span { font-family: var(--serif); font-size: 15px; color: #b0273f; vertical-align: middle; }
.dear { font-family: var(--serif); font-weight: 500; font-size: 38px; color: var(--ink); margin: 6px 0 22px; }
.torn-wrap { position: relative; width: 100%; max-width: 330px; }
.torn { background: linear-gradient(160deg, #7c1a2d, #5a0e1e); color: #f8e9dd; padding: 46px 34px 44px; font-size: 19px; line-height: 1.55; }
.torn b { font-weight: 600; color: #fff; }
.torn-sub { font-style: italic; font-size: 16px; margin-top: 14px; color: #e9c9b6; }
.rose { position: absolute; width: 104px; z-index: 2; pointer-events: none; }
.rose-tl { left: -40px; top: -50px; }
.rose-br { right: -40px; bottom: -50px; transform: rotate(180deg); }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 30px; max-width: 330px; }
.chips a { font-family: var(--caps); font-size: 11px; letter-spacing: .14em; color: var(--maroon); text-decoration: none; border: 1px solid rgba(92,15,31,.3); background: #fff; border-radius: 6px; padding: 9px 13px; }

/* ---------- function screens ---------- */
.event { background: radial-gradient(110% 70% at 50% 30%, #7d1a2e 0%, var(--maroon) 55%, var(--maroon-deep) 100%); color: #f7e9de; padding: 32px 22px 70px; }
.event::before { content: ""; position: absolute; inset: 12px; border: 1px solid rgba(201,162,77,.45); border-radius: 18px; pointer-events: none; }
.event::after { content: ""; position: absolute; inset: 17px; border: 1px solid rgba(201,162,77,.2); border-radius: 14px; pointer-events: none; }
.ev-figure { position: relative; height: calc(40 * var(--u)); display: flex; justify-content: center; }
.ev-figure::before { content: ""; position: absolute; left: 50%; top: 52%; width: 82%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; background: radial-gradient(circle, rgba(232,190,140,.28), transparent 68%); }
.ev-figure img { position: relative; height: 100%; width: auto; filter: drop-shadow(0 14px 18px rgba(20,0,5,.45)); transform: scale(.94); transition: transform 2.2s cubic-bezier(.2,.8,.2,1); }
.event.in .ev-figure img { transform: scale(1); animation: sway 6s ease-in-out 2.4s infinite; }
@keyframes sway { 50% { transform: translateY(-5px); } }
.ev-title { font-family: var(--script); font-size: clamp(44px, 13vw, 56px); line-height: 1.25; color: #fff3e6; margin-top: 18px; text-shadow: 0 2px 12px rgba(0,0,0,.25); }
.ev-pill { display: inline-block; background: linear-gradient(180deg, #f1d78f, #c99a3d); color: #4a0b17; font-family: var(--caps); font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; padding: 6px 16px; border-radius: 999px; margin-top: 4px; }
.ev-date { font-family: var(--serif); font-weight: 600; font-size: 24px; margin-top: 14px; }
.ev-time { font-size: 18px; color: #f0d9c4; margin-top: 2px; }
.ev-venue { font-size: 17px; line-height: 1.4; color: #e8cdbb; margin-top: 8px; max-width: 290px; }
.ev-venue b { color: #fff3e6; font-weight: 600; }
.ev-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; width: 100%; max-width: 250px; }
.ev-btns a, .ev-btns button {
  font-family: var(--caps); font-size: 11px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--gold-soft); background: rgba(255,255,255,.04); border: 1px solid rgba(232,207,138,.6);
  border-radius: 999px; padding: 12px 10px; text-decoration: none; cursor: pointer;
}
.ev-btns a:active, .ev-btns button:active { background: rgba(232,207,138,.15); }

/* ---------- countdown ---------- */
.count-screen { background: radial-gradient(120% 80% at 50% 0%, #fffdf9, #f4ece4); }
.count-title { font-size: 56px; color: var(--maroon); line-height: 1.25; }
.count-sub { font-style: italic; font-size: 19px; color: var(--muted); margin: 6px 0 30px; }
.count-grid { display: grid; grid-template-columns: repeat(2, 132px); gap: 16px; }
.cbox { height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #f8e9dd; background: linear-gradient(160deg, #7c1a2d, #520c1b); }
.cbox b { font-family: var(--serif); font-size: 40px; font-weight: 600; line-height: 1; }
.cbox span { font-family: var(--caps); font-size: 10px; letter-spacing: .22em; text-transform: uppercase; margin-top: 6px; color: #e9c9b6; }

@media (max-height: 700px) {
  .ev-figure { height: calc(30 * var(--u)); }
  .arch-content { padding-top: calc(17 * var(--u)); padding-bottom: calc(12 * var(--u)); }
  .serif-it { font-size: 16px; }
  .ev-figure { height: calc(33 * var(--u)); }
  .ev-title { font-size: 46px; margin-top: 10px; }
  .ev-btns { flex-direction: row; max-width: 320px; }
  .ev-btns a, .ev-btns button { flex: 1; font-size: 10px; letter-spacing: .14em; }
  .dear { font-size: 32px; margin-bottom: 18px; }
  .torn { padding: 36px 28px; font-size: 17px; }
}

/* ---------- fit: every screen's content is scaled down if taller than the screen ---------- */
.fit { width: 100%; display: flex; flex-direction: column; align-items: center; transform-origin: center center; }
.hero .fit { transform-origin: center bottom; }
.arch-screen .fit, .hero .fit { position: relative; z-index: 1; }
