:root {
  --paper: #fbf7f0;
  --paper-2: #f5ede0;
  --card: #fffdf9;
  --ink: #3a2e22;
  --muted: #7d6c58;
  --gold: #b38b3f;
  --gold-deep: #8a6726;
  --gold-soft: #e9dbbb;
  --gold-grad: linear-gradient(135deg, #8a6726 0%, #c9a259 45%, #e6cc8a 55%, #a7802f 100%);
  --rose: #d68c95;
  --line: #e9dcc5;
  --shadow: 0 10px 30px -12px rgba(110, 80, 30, .28);
  --radius: 18px;
  --f-body: "Kantumruy Pro", system-ui, sans-serif;
  --f-display: "Moul", "Kantumruy Pro", serif;
  --f-en: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.7 var(--f-body);
  overflow-x: hidden;
}
body.locked { overflow: hidden; height: 100svh; }
html[lang="en"] body { font-size: 17px; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }

.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* ---------- headings ---------- */
.eyebrow {
  margin: 0;
  font-family: var(--f-display);
  font-size: 1.05rem;
  letter-spacing: .02em;
  color: var(--gold-deep);
}
html[lang="en"] .eyebrow { font-family: var(--f-en); font-style: italic; font-size: 1.35rem; font-weight: 500; }

.gold-text, .title-km, .h .main, .monogram, .cover-couple .n {
  background: var(--gold-grad);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}

.h { margin: 0 0 1.6rem; text-align: center; line-height: 1.5; }
.h .main { display: block; font-family: var(--f-display); font-weight: 400; font-size: clamp(1.6rem, 6vw, 2.1rem); }
.h .sub { display: block; font-family: var(--f-en); font-size: 1.25rem; font-weight: 500; color: var(--ink); }
html[lang="en"] .h .main { font-family: var(--f-en); font-weight: 600; font-size: clamp(2rem, 8vw, 2.6rem); line-height: 1.15; }
html[lang="en"] .h .sub { font-family: var(--f-display); font-size: .95rem; color: var(--muted); margin-top: .3rem; }

/* ---------- ornaments ---------- */
.divider { display: block; width: 210px; height: 42px; margin: 0 auto; color: var(--gold); }
.divider.flip { transform: scaleY(-1); }
.divider.big { width: min(300px, 80vw); height: 60px; margin: 2.5rem auto 0; }

/* ---------- petals ---------- */
.petals { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
.petal {
  position: absolute; top: -20px;
  width: 12px; height: 10px;
  background: radial-gradient(circle at 30% 30%, #f6c9cf, var(--rose));
  border-radius: 70% 0 70% 0;
  opacity: .75;
  animation: fall linear infinite;
}
@keyframes fall {
  0%   { transform: translate3d(0, -5vh, 0) rotate(0deg); }
  50%  { transform: translate3d(30px, 50vh, 0) rotate(200deg); }
  100% { transform: translate3d(-20px, 105vh, 0) rotate(420deg); }
}

/* ---------- toolbar ---------- */
.toolbar {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: 12px; z-index: 30;
  display: flex; gap: 8px;
}
.pill {
  min-width: 44px; height: 38px; padding: 0 14px;
  border: 1px solid var(--gold-soft); border-radius: 999px;
  background: rgba(255, 253, 249, .88); backdrop-filter: blur(6px);
  color: var(--gold-deep); font-weight: 600; font-size: .9rem;
  box-shadow: var(--shadow);
}
.pill.round { padding: 0; width: 38px; min-width: 38px; display: grid; place-items: center; }
.pill.playing { background: var(--gold); color: #fff; }
.pill.playing .ic { animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- cover ---------- */
.cover {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center; padding: 24px 16px;
  background:
    radial-gradient(ellipse at 50% 0%, #fff 0%, transparent 60%),
    radial-gradient(ellipse at 50% 120%, var(--gold-soft) 0%, transparent 55%),
    var(--paper);
  transition: opacity .9s ease, visibility .9s;
}
.cover.gone { opacity: 0; visibility: hidden; }
.cover-frame {
  position: relative;
  width: min(420px, 100%);
  padding: 34px 22px;
  text-align: center;
  border: 1px solid var(--gold-soft);
  outline: 1px solid var(--gold-soft); outline-offset: 6px;
  border-radius: 6px;
  background: rgba(255, 253, 249, .7);
}
.cover-name {
  margin: 1rem 0 .4rem;
  font-family: var(--f-en); font-weight: 600; font-size: clamp(1.7rem, 7vw, 2.3rem); line-height: 1.25;
  color: var(--ink);
  overflow-wrap: anywhere;
}
html[lang="km"] .cover-name { font-family: var(--f-body); font-weight: 600; font-size: clamp(1.45rem, 6vw, 1.9rem); }
.cover-couple { margin: 1.2rem 0 .2rem; display: flex; align-items: center; justify-content: center; gap: 10px; }
.cover-couple .n { font-family: var(--f-display); font-size: 1.5rem; }
html[lang="en"] .cover-couple .n { font-family: var(--f-en); font-weight: 600; font-size: 2rem; }
.cover-couple .ic { color: var(--rose); width: 18px; height: 18px; }
.cover-date { margin: 0 0 1.6rem; color: var(--muted); font-size: .95rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 46px; padding: .6em 1.4em;
  border-radius: 999px; border: 1px solid transparent;
  font-weight: 500; text-decoration: none;
  transition: transform .15s ease, box-shadow .2s ease, background .2s;
}
.btn:active { transform: scale(.97); }
.btn-gold { background: var(--gold-grad); background-size: 140% 140%; color: #fff; box-shadow: 0 8px 20px -8px rgba(138, 103, 38, .7); }
.btn-gold:hover { background-position: 100% 0; }
.btn-ghost { background: var(--card); border-color: var(--gold-soft); color: var(--gold-deep); }
.btn.wide { width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }
.btn:focus-visible, .pill:focus-visible, .choice-btn:focus-visible, .stepper button:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold); outline-offset: 3px;
}
#open-btn { animation: breathe 2.6s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 8px 28px -4px rgba(179, 139, 63, .75); } }

/* ---------- main ---------- */
main { opacity: 0; transition: opacity 1s ease .2s; }
main.shown { opacity: 1; }

.hero { position: relative; padding: 72px 16px 24px; text-align: center; overflow: hidden; }
.hero-bg {
  position: absolute; inset: 0; z-index: -1;
  background:
    radial-gradient(ellipse at 50% -10%, #fff 0%, transparent 55%),
    radial-gradient(circle at 0% 40%, rgba(233, 219, 187, .55), transparent 40%),
    radial-gradient(circle at 100% 70%, rgba(233, 219, 187, .55), transparent 40%),
    var(--paper);
}
.hero-bg.photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(251, 247, 240, .78) 0%, rgba(251, 247, 240, .9) 60%, var(--paper) 100%);
}
.hero-bg.photo { background-size: cover; background-position: center top; }
.hero-inner { max-width: 560px; margin: 0 auto; }

.name-box {
  display: inline-block; margin: 14px auto 10px;
  min-width: min(260px, 90%); max-width: 100%;
  padding: 10px 26px;
  border: 1px solid var(--gold);
  outline: 1px solid var(--gold-soft); outline-offset: 4px;
  font-family: var(--f-en); font-weight: 600; font-size: 1.6rem; line-height: 1.3;
  overflow-wrap: anywhere;
}
html[lang="km"] .name-box { font-family: var(--f-body); font-size: 1.3rem; padding: 12px 26px; }

.title { margin: 1.2rem 0 1.6rem; line-height: 1.5; }
.title-km { display: block; font-family: var(--f-display); font-weight: 400; font-size: clamp(2rem, 9vw, 2.8rem); }
.title-en { display: block; font-family: var(--f-en); font-weight: 500; font-size: 1.5rem; }

.couple { display: flex; align-items: flex-start; justify-content: center; gap: clamp(8px, 4vw, 28px); }
.person { margin: 0; flex: 1 1 0; max-width: 200px; }
.monogram {
  width: clamp(92px, 28vw, 128px); aspect-ratio: 1; margin: 0 auto 10px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 3px solid transparent;
  background-image: linear-gradient(var(--card), var(--card)), var(--gold-grad);
  background-origin: border-box; background-clip: padding-box, border-box;
  box-shadow: inset 0 0 0 5px var(--card), inset 0 0 0 6px var(--gold-soft), var(--shadow);
  font-family: var(--f-display); font-size: clamp(2.2rem, 10vw, 3rem); line-height: 1;
  color: var(--gold);
}
html[lang="en"] .monogram { font-family: var(--f-en); font-weight: 600; font-size: clamp(2.6rem, 12vw, 3.6rem); }
.person figcaption { font-family: var(--f-display); font-size: 1.3rem; color: var(--gold-deep); }
html[lang="en"] .person figcaption { font-family: var(--f-en); font-weight: 600; font-size: 1.7rem; }
.parents { margin: .3rem 0 0; font-size: .8rem; line-height: 1.55; color: var(--muted); white-space: pre-line; }
.heart { margin-top: clamp(36px, 11vw, 52px); color: var(--rose); width: 26px; height: 26px; animation: beat 1.8s ease-in-out infinite; }
@keyframes beat { 15% { transform: scale(1.18); } 30% { transform: scale(1); } }

.info-card {
  list-style: none; margin: 28px auto 0; padding: 8px 20px;
  max-width: 420px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.info-card li { display: flex; gap: 14px; padding: 12px 0; align-items: flex-start; }
.info-card li + li { border-top: 1px dashed var(--line); }
.info-card .ic { color: var(--gold); margin-top: 4px; }
.info-card strong { display: block; font-weight: 600; }
.info-card span { display: block; font-size: .85rem; color: var(--muted); }

/* ---------- sections ---------- */
.section { padding: 64px 16px; max-width: 640px; margin: 0 auto; }
.section.alt { max-width: none; background: var(--paper-2); }
.section.alt > * { max-width: 608px; margin-left: auto; margin-right: auto; }
.section.alt > .h { margin-bottom: 1.6rem; }

.count { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 420px; margin: 0 auto; }
.count div {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 4px 10px; text-align: center; box-shadow: var(--shadow);
}
.count b { display: block; font-family: var(--f-en); font-size: clamp(1.8rem, 8vw, 2.4rem); font-weight: 600; line-height: 1.1; color: var(--gold-deep); font-variant-numeric: tabular-nums; }
html[lang="km"] .count b { font-family: var(--f-body); font-size: clamp(1.5rem, 7vw, 2rem); }
.count span { font-size: .8rem; color: var(--muted); }
.count-note { text-align: center; font-family: var(--f-en); font-size: 1.5rem; color: var(--gold-deep); margin: 0; }
html[lang="km"] .count-note { font-family: var(--f-body); font-size: 1.2rem; }

.timeline { list-style: none; margin: 0 auto; padding: 0; position: relative; max-width: 440px; }
.timeline::before { content: ""; position: absolute; left: 21px; top: 10px; bottom: 10px; width: 1px; background: linear-gradient(var(--gold-soft), var(--gold), var(--gold-soft)); }
.timeline li { position: relative; display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.timeline .dot {
  position: relative; z-index: 1; flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--gold-soft); color: var(--gold);
}
.timeline .item {
  flex: 1; padding: 12px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
}
.timeline time { display: block; font-size: .8rem; color: var(--gold-deep); font-weight: 600; letter-spacing: .02em; }
.timeline .what { font-weight: 500; }

.dress { display: flex; gap: 10px; justify-content: center; align-items: center; margin: 1.8rem auto 0; color: var(--muted); font-size: .92rem; text-align: center; }
.dress .ic { color: var(--gold); }

.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gallery img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 14px; box-shadow: var(--shadow); background: var(--paper-2); }
.gallery img:first-child { grid-column: span 2; aspect-ratio: 4 / 3; }
@media (min-width: 560px) { .gallery { grid-template-columns: repeat(3, 1fr); } .gallery img:first-child { grid-column: span 3; aspect-ratio: 16 / 9; } }

.venue-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.map-wrap { aspect-ratio: 16 / 10; background: var(--paper-2); }
.map-wrap iframe { width: 100%; height: 100%; border: 0; display: block; filter: sepia(.15) saturate(.9); }
.venue-body { padding: 20px; }
.venue-title { display: flex; gap: 12px; align-items: center; }
.venue-title h3 { margin: 0; font-size: 1.2rem; font-weight: 600; line-height: 1.4; }
.gold-sub { margin: 0; color: var(--gold-deep); font-family: var(--f-en); font-size: 1.1rem; }
.ic-circle { display: grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 50%; background: var(--paper-2); color: var(--gold); }
.ic-circle.big { width: 64px; height: 64px; margin: 0 auto 8px; background: var(--gold); color: #fff; }
.ic-circle.big .ic { width: 30px; height: 30px; }
.venue-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 10px 0 16px; font-size: .9rem; color: var(--muted); }
.venue-meta .ic { color: var(--gold); margin-right: 4px; }
.plain { text-decoration: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row .btn { flex: 1 1 180px; }
.link { display: inline-block; margin-top: 12px; color: var(--gold-deep); }

.gift-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px 20px; text-align: center; box-shadow: var(--shadow);
}
.gift-card > p { margin-top: 0; }
.qr-frame {
  position: relative; z-index: 6; /* above the falling petals so the QR stays scannable */
  width: min(260px, 80%); margin: 18px auto; padding: 12px;
  background: #fff; border-radius: 16px;
  border: 1px solid var(--gold-soft); outline: 1px solid var(--gold-soft); outline-offset: 5px;
}
.qr-frame img { width: 100%; height: auto; image-rendering: pixelated; }
.account { margin: 22px auto 18px; max-width: 340px; text-align: left; }
.account div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.account dt { color: var(--muted); font-size: .88rem; }
.account dd { margin: 0; font-weight: 600; text-align: right; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--gold-soft); background: var(--paper); color: var(--gold-deep); border-radius: 999px; padding: 2px 10px; font-size: .8rem; font-weight: 500; }

.big-ic { display: block; margin: 0 auto 10px; width: 38px; height: 38px; color: var(--gold); }
#rsvp .h { margin-bottom: .6rem; }
.rsvp-card {
  margin-top: 20px; padding: 22px 20px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.rsvp-card.done { text-align: center; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-btn {
  min-height: 52px; padding: 8px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--gold-soft); background: var(--paper); color: var(--ink); font-weight: 500;
  transition: background .2s, color .2s, border-color .2s;
}
.choice-btn .ic { color: var(--rose); }
.choice-btn[aria-checked="true"][data-status="yes"] { background: var(--gold-grad); color: #fff; border-color: transparent; }
.choice-btn[aria-checked="true"][data-status="yes"] .ic { color: #fff; }
.choice-btn[aria-checked="true"][data-status="no"] { background: #6f6253; color: #fff; border-color: transparent; }
.field { position: relative; margin-top: 18px; }
.field label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 6px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--gold-soft); border-radius: 999px; overflow: hidden; background: var(--paper); }
.stepper button { width: 46px; height: 44px; border: 0; background: transparent; font-size: 1.3rem; color: var(--gold-deep); }
.stepper output { min-width: 44px; text-align: center; font-weight: 600; font-size: 1.1rem; }
textarea {
  width: 100%; resize: vertical; min-height: 96px;
  padding: 12px 14px; border-radius: 14px; border: 1px solid var(--gold-soft); background: var(--paper);
  font: inherit; color: var(--ink);
}
.counter { position: absolute; right: 12px; bottom: 8px; font-size: .75rem; color: var(--muted); }
#rsvp-submit { margin-top: 18px; }
.form-msg { min-height: 1.4em; margin: 10px 0 0; text-align: center; font-size: .9rem; color: #a2453b; }

.thanks { text-align: center; padding: 56px 20px calc(48px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; }
.thanks .divider { margin-bottom: 1.4rem; }
.thanks p { color: var(--muted); }
.sign { font-family: var(--f-display); font-size: 1.3rem; margin-top: 1.2rem; }
.sign { background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
html[lang="en"] .sign { font-family: var(--f-en); font-weight: 600; font-size: 1.8rem; }
.contacts { list-style: none; padding: 0; margin: 1.6rem 0 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.contacts a { display: inline-flex; gap: 6px; align-items: center; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--gold-soft); text-decoration: none; font-size: .85rem; color: var(--gold-deep); background: var(--card); }

/* ---------- notice / toast ---------- */
.notice {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 40; max-width: calc(100% - 32px);
  padding: 10px 18px; border-radius: 999px;
  background: var(--ink); color: #fff; font-size: .9rem; text-align: center;
  box-shadow: var(--shadow);
}
.error-screen { min-height: 100svh; display: grid; place-items: center; padding: 24px; text-align: center; }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity .8s ease, transform .8s ease; }
.reveal.in { opacity: 1; transform: none; }

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