:root {
  --bg: #faf6f0;
  --paper: #fffdf9;
  --ink: #3b2b2b;
  --mute: #8a7a72;
  --wine: #8c2f39;
  --wine-dark: #6b1f29;
  --gold: #b8925a;
  --gold-soft: #e7d6b8;
  --rose: #f3e3dc;
  --line: #eadfce;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Be Vietnam Pro", system-ui, sans-serif;
  --script: "Dancing Script", cursive;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-weight: 300;
  color: var(--ink);
  background: #e9dfd3 radial-gradient(circle at 50% 0, #f3ebe1, #e2d5c6);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
img { display: block; max-width: 100%; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }

.script { font-family: var(--script); font-weight: 700; }
.eyebrow {
  display: inline-block;
  font-size: 11px;
  letter-spacing: .32em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 500;
  margin-bottom: 6px;
}
.eyebrow.light { color: var(--gold-soft); }
.muted { color: var(--mute); font-size: 14px; max-width: 340px; margin: 0 auto 18px; }

/* ===== Envelope screen ===== */
.envelope-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px;
  background: radial-gradient(circle at 50% 30%, #a23a45, var(--wine-dark) 70%);
  color: #fff; text-align: center; padding: 24px;
  transition: opacity 1s ease, visibility 1s;
}
/* Ảnh cưới làm nền phong bì */
.envelope-screen.has-photo { justify-content: flex-end; gap: 26px; padding-bottom: max(40px, 7vh); overflow: hidden; background: var(--wine-dark); }
.envelope-screen.has-photo::before {
  content: ""; position: absolute; inset: 0;
  background: var(--env-photo) center 22% / cover no-repeat;
  animation: kenburns 16s ease-out both;
}
.envelope-screen.has-photo::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(60,15,22,.1), rgba(60,15,22,.2) 30%, rgba(95,24,34,.85) 58%, #5e1822 80%);
}
.envelope-screen.has-photo > * { position: relative; z-index: 1; }
.envelope-screen.has-photo .envelope { margin-top: 30px; width: min(290px, 78vw); }
.envelope-screen.has-photo .env-guest-name { text-shadow: 0 2px 12px rgba(0,0,0,.35); }
@media (min-aspect-ratio: 3/4) {
  .envelope-screen.has-photo::before {
    left: 50%; width: calc(100vh * 2 / 3); margin-left: calc(100vh / -3);
    -webkit-mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent);
    mask-image: linear-gradient(to right, transparent, #000 18%, #000 82%, transparent);
  }
}
@keyframes kenburns { from { transform: scale(1.12); } to { transform: scale(1); } }
.envelope-screen.gone { opacity: 0; visibility: hidden; }
.env-guest-name { font-family: var(--serif); font-size: 26px; font-style: italic; }
.env-hint { font-size: 13px; opacity: .75; letter-spacing: .05em; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.envelope {
  position: relative; width: min(320px, 84vw); aspect-ratio: 3 / 2;
  perspective: 1200px; margin-top: 90px;
}
.envelope > span { position: absolute; left: 0; right: 0; }
.env-back { inset: 0; background: #e9d9c3; border-radius: 6px; z-index: 1; box-shadow: 0 30px 60px rgba(0,0,0,.35); }
.env-card {
  left: 6% !important; right: 6% !important; top: 8%; height: 84%;
  background: var(--paper); border-radius: 4px; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--wine); border: 1px solid var(--gold-soft);
  transition: transform 1.1s cubic-bezier(.6,.05,.3,1) .5s;
}
.env-card .script { font-size: clamp(22px, 7vw, 30px); }
.env-card-date { font-family: var(--serif); font-size: 13px; letter-spacing: .2em; color: var(--gold); }
.env-front {
  inset: 0; z-index: 3; border-radius: 6px;
  background: linear-gradient(160deg, #f4e8d7, #e8d5bb);
  clip-path: polygon(0 0, 50% 55%, 100% 0, 100% 100%, 0 100%);
}
.env-flap {
  top: 0; height: 60%; z-index: 4;
  background: linear-gradient(#e4d1b6, #ead9c1);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top; transition: transform .7s ease, z-index 0s .35s;
}
.envelope .seal {
  position: absolute; left: 50%; right: auto; top: 60%; z-index: 5;
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #c24a55, var(--wine) 60%, var(--wine-dark));
  color: var(--gold-soft); font-size: 30px; font-weight: 700;
  box-shadow: 0 6px 14px rgba(0,0,0,.35), inset 0 0 0 3px rgba(255,255,255,.12);
  transition: transform .5s ease, opacity .4s ease;
  animation: beat 1.6s ease-in-out infinite;
}
@keyframes beat { 50% { transform: scale(1.08); } }
.envelope.open .seal { animation: none; transform: scale(0); opacity: 0; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-card { transform: translateY(-58%) scale(1.04); }
.envelope-screen.opening .env-guest, .envelope-screen.opening .env-hint { opacity: 0; transition: opacity .5s; }
.envelope-screen.opening .env-hint { animation: none; }

/* --- Hiệu ứng màn phong bì --- */
.env-guest .eyebrow { animation: fadeDown .9s ease .3s both; }
.env-guest-name { animation: blurIn 1.3s ease .6s both; }
.envelope { animation: rise 1.1s cubic-bezier(.2,.8,.2,1) 1s both, float 3.6s ease-in-out 2.1s infinite; }
.envelope.open { animation-play-state: paused; }
.env-hint { animation: fadeIn 1s ease 1.8s both, pulse 2s ease-in-out 2.8s infinite; }
.env-front::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,.6) 50%, transparent 62%);
  transform: translateX(-100%); animation: shimmer 4.5s ease-in-out 2.4s infinite;
}
.envelope .seal::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid rgba(246,223,174,.8); animation: ring 2s ease-out 2.2s infinite both;
}
@keyframes fadeDown { from { opacity: 0; transform: translateY(-14px); } }
@keyframes blurIn { from { opacity: 0; filter: blur(10px); letter-spacing: .2em; } }
@keyframes rise { from { opacity: 0; transform: translateY(70px) scale(.92); } }
@keyframes float { 50% { transform: translateY(-8px); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes shimmer { 0% { transform: translateX(-100%); } 45%, 100% { transform: translateX(100%); } }
@keyframes ring { from { transform: scale(1); opacity: .9; } to { transform: scale(1.7); opacity: 0; } }

/* ===== Petals ===== */
#petals { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 55; }

/* ===== Music ===== */
.music-btn {
  position: fixed; right: 16px; bottom: 16px; z-index: 45;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--wine); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 18px rgba(140,47,57,.4);
}
.music-btn[hidden] { display: none; }
.music-btn .ic-off, .music-btn.playing .ic-on { display: block; }
.music-btn .ic-on, .music-btn.playing .ic-off { display: none; }
.music-btn:not(.playing) { background: #8a7a72; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.music-btn.playing::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--wine); animation: ring 2.2s ease-out infinite;
}
.music-tip {
  position: absolute; right: 0; bottom: 56px; transform: translateY(8px);
  white-space: nowrap; font-size: 13px; background: var(--ink); color: #fff;
  padding: 6px 12px; border-radius: 999px; opacity: 0; pointer-events: none; transition: .4s;
}
.music-tip::after { content: ""; position: absolute; right: 18px; bottom: -5px; border: 5px solid transparent; border-bottom: 0; border-top-color: var(--ink); }
.music-btn.tip .music-tip { opacity: 1; transform: none; }

/* ===== Card layout ===== */
.card {
  max-width: 480px; margin: 0 auto; background: var(--bg);
  box-shadow: 0 0 60px rgba(80,40,30,.15); min-height: 100vh; overflow: hidden;
}
.sec { padding: 64px 24px; text-align: center; position: relative; }
.sec + .sec::before {
  content: "❦"; position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  color: var(--gold); font-size: 20px; background: var(--bg); padding: 0 10px;
}
h2 { font-family: var(--serif); font-weight: 500; font-size: 30px; color: var(--wine); margin-bottom: 18px; line-height: 1.25; }
h3 { font-family: var(--serif); font-weight: 500; }

/* Cover */
.cover { position: relative; height: 100vh; height: 100svh; min-height: 560px; color: #fff; display: flex; align-items: flex-end; text-align: center; }
.cover-photo { position: absolute; inset: 0; background: #6b4a44 center / cover no-repeat; transform: scale(1.15); transition: transform 6s ease-out; }
.card.shown .cover-photo { transform: scale(1); }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(40,15,18,.85), rgba(40,15,18,.15) 55%, rgba(40,15,18,.35)); }
.cover-inner { position: relative; z-index: 1; width: 100%; padding: 0 20px 110px; }
/* Bìa: chữ hiện dần sau khi mở thiệp */
.cover-inner .eyebrow, .cover-names > *, .cover-date { opacity: 0; transform: translateY(24px); transition: opacity 1.1s ease, transform 1.1s ease; }
.card.shown .cover-inner .eyebrow, .card.shown .cover-names > *, .card.shown .cover-date { opacity: 1; transform: none; }
.card.shown .cover-inner .eyebrow { transition-delay: .4s; }
.card.shown .cover-names > :nth-child(1) { transition-delay: .8s; }
.card.shown .cover-names > :nth-child(2) { transition-delay: 1.2s; }
.card.shown .cover-names > :nth-child(3) { transition-delay: 1.5s; }
.card.shown .cover-date { transition-delay: 1.9s; }
.cover-names { display: flex; flex-direction: column; align-items: center; line-height: 1.05; margin: 8px 0 16px; font-weight: 400; }
.cover-names .script { font-size: clamp(46px, 14vw, 64px); }
.cover-names .amp { font-family: var(--serif); font-style: italic; font-size: 26px; color: var(--gold-soft); margin: 2px 0; }
.cover-date { font-family: var(--serif); letter-spacing: .35em; font-size: 15px; display: inline-flex; gap: 14px; align-items: center; }
.cover-date::before, .cover-date::after { content: ""; width: 36px; height: 1px; background: var(--gold-soft); }
.scroll-cue {
  position: absolute; bottom: 18px; left: 50%; z-index: 2; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px; color: #fff;
  opacity: 0; transition: opacity 1s ease 2.6s;
}
.card.shown .scroll-cue { opacity: 1; }
.scroll-cue span {
  font-size: 12.5px; letter-spacing: .12em; white-space: nowrap;
  padding: 7px 16px; border-radius: 999px;
  background: rgba(60,15,22,.38); border: 1px solid rgba(255,255,255,.5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  animation: glow 2.4s ease-in-out infinite;
}
.scroll-cue svg { width: 26px; height: 26px; animation: bounce 1.4s ease-in-out infinite; filter: drop-shadow(0 2px 4px rgba(0,0,0,.35)); }
@keyframes bounce { 0%, 100% { transform: translateY(0); opacity: .6; } 50% { transform: translateY(7px); opacity: 1; } }
@keyframes glow { 50% { background: rgba(140,47,57,.6); } }

/* Families */
.families { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: start; margin: 14px 0 30px; }
.family h3 { font-size: 18px; color: var(--wine); margin-bottom: 6px; }
.family p { font-size: 13.5px; }
.family .parent { display: block; line-height: 1.5; margin-bottom: 2px; }
.family .parent small { font-size: 12px; color: var(--mute); font-weight: 500; }
.family .addr { color: var(--mute); font-size: 12px; margin-top: 6px; }
.xi { color: var(--wine); font-size: 34px; font-weight: 700; padding-top: 18px; }
.lead { font-family: var(--serif); font-style: italic; color: var(--mute); margin-bottom: 26px; }
.couple { display: flex; justify-content: center; align-items: flex-start; gap: 6px; }
.couple-amp { font-size: 40px; color: var(--gold); align-self: center; margin-top: -40px; }
.person { width: 42%; }
.portrait { aspect-ratio: 3 / 4; border-radius: 999px 999px 12px 12px; overflow: hidden; border: 4px solid var(--paper); box-shadow: 0 0 0 1px var(--gold-soft), 0 12px 30px rgba(80,40,30,.15); background: var(--rose); }
.portrait img { width: 100%; height: 100%; object-fit: cover; object-position: top; }
.person figcaption { margin-top: 12px; }
.person small { display: block; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.person strong { font-family: var(--serif); font-weight: 500; font-size: 17px; color: var(--wine); }

/* Invitation */
.invite { background: var(--rose); }
.invite::before, .invite + .sec::before, .thanks::before { display: none; }
.frame { background: var(--paper); padding: 36px 22px; border: 1px solid var(--gold-soft); outline: 1px solid var(--gold-soft); outline-offset: -8px; }
.invite-to { font-family: var(--serif); font-size: 15px; color: var(--mute); }
.invite-guest { font-size: 34px; color: var(--wine); margin: 4px 0 12px; line-height: 1.2; }
.invite-text { font-size: 14px; margin-bottom: 24px; }
.big-date { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; color: var(--wine); }
.bd-side { font-family: var(--serif); font-size: 14px; letter-spacing: .12em; text-transform: uppercase; border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); padding: 6px 0; }
.bd-main { display: flex; flex-direction: column; padding: 0 18px; font-family: var(--serif); }
.bd-main strong { font-size: 58px; font-weight: 500; line-height: 1; }
.bd-main span { font-size: 13px; letter-spacing: .15em; text-transform: uppercase; }
.lunar { margin-top: 16px; font-style: italic; color: var(--mute); font-size: 13.5px; }

/* Calendar */
.calendar { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; max-width: 340px; margin: 0 auto 30px; font-size: 14px; }
.calendar .dow { font-size: 11px; color: var(--gold); font-weight: 500; padding-bottom: 6px; }
.calendar .d { aspect-ratio: 1; display: grid; place-items: center; position: relative; }
.calendar .d.hl { color: #fff; font-weight: 600; }
.calendar .d.hl::before {
  content: "❤"; position: absolute; inset: 0; display: grid; place-items: center; z-index: -1;
  color: var(--wine); font-size: 40px; line-height: 1; animation: beat 1.4s infinite;
}
.calendar .d.hl { z-index: 0; }
.countdown { display: flex; justify-content: center; gap: 10px; }
.countdown div { width: 70px; padding: 12px 0; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; }
.countdown b { display: block; font-family: var(--serif); font-size: 26px; font-weight: 500; color: var(--wine); line-height: 1.2; }
.countdown span { font-size: 11px; color: var(--mute); letter-spacing: .1em; text-transform: uppercase; }

/* Events */
.events { display: grid; gap: 18px; }
.event { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 26px 20px; }
.event h3 { font-size: 22px; color: var(--wine); }
.event .side { font-size: 12px; letter-spacing: .15em; text-transform: uppercase; color: var(--gold); }
.event .when { margin: 12px 0 4px; font-family: var(--serif); font-size: 17px; }
.event .place { font-weight: 500; }
.event .addr { font-size: 13.5px; color: var(--mute); }
.event .map { margin-top: 14px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.event .map iframe { display: block; width: 100%; height: 220px; border: 0; }
.event .actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--wine); color: var(--wine); text-decoration: none; transition: .2s; }
.chip:hover { background: var(--wine); color: #fff; }

/* Timeline */
.timeline { list-style: none; max-width: 340px; margin: 0 auto; text-align: left; position: relative; }
.timeline::before { content: ""; position: absolute; left: 66px; top: 6px; bottom: 6px; width: 1px; background: var(--gold-soft); }
.timeline li { display: grid; grid-template-columns: 54px 1fr; gap: 26px; padding: 10px 0; position: relative; }
.timeline li::before { content: ""; position: absolute; left: 62px; top: 18px; width: 9px; height: 9px; border-radius: 50%; background: var(--wine); box-shadow: 0 0 0 4px var(--bg); }
.timeline time { font-family: var(--serif); color: var(--wine); font-size: 17px; text-align: right; }

/* Gallery */
.gallery { display: grid; grid-template-columns: 1fr 1fr; grid-auto-flow: dense; gap: 8px; }
.gallery button { overflow: hidden; border-radius: 10px; aspect-ratio: 2 / 3; background: var(--rose); }
.gallery button.wide { grid-column: span 2; aspect-ratio: 3 / 2; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.gallery button:hover img { transform: scale(1.06); }

.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(20,8,10,.94); display: flex; align-items: center; justify-content: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 92vw; max-height: 86vh; border-radius: 6px; }
.lb-close { position: absolute; top: 10px; right: 16px; color: #fff; font-size: 38px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); color: #fff; font-size: 44px; padding: 10px 14px; }
.lb-nav.prev { left: 4px; } .lb-nav.next { right: 4px; }

/* Dress code */
.swatches { display: flex; justify-content: center; gap: 12px; }
.swatches span { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--line), 0 6px 12px rgba(0,0,0,.08); }

/* Forms */
.form { display: grid; gap: 10px; max-width: 380px; margin: 0 auto; text-align: left; }
.form input:not([type=radio]), .form select, .form textarea {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); outline: none;
}
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--gold); }
.form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice input { position: absolute; opacity: 0; }
.choice span { display: block; text-align: center; padding: 11px 6px; font-size: 13.5px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); cursor: pointer; transition: .2s; }
.choice input:checked + span { border-color: var(--wine); background: var(--wine); color: #fff; }
.btn { background: var(--wine); color: #fff; padding: 13px; border-radius: 10px; font-weight: 500; letter-spacing: .05em; transition: .2s; }
.btn:hover { background: var(--wine-dark); }
.btn:disabled { opacity: .6; }
.form-msg { text-align: center; font-size: 14px; color: var(--wine); min-height: 1.4em; }

/* Gift */
.gift-tabs { display: inline-flex; background: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 4px; margin-bottom: 16px; }
.gift-tabs button { padding: 8px 16px; border-radius: 999px; font-size: 13px; }
.gift-tabs button.on { background: var(--wine); color: #fff; }
.gift-card { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 22px; max-width: 320px; margin: 0 auto; }
.gift-card img { width: 220px; height: auto; max-height: 260px; margin: 0 auto 14px; object-fit: contain; border-radius: 12px; }
.gift-card p { font-size: 14px; }
.gift-card .acc { font-family: var(--serif); font-size: 22px; color: var(--wine); letter-spacing: .05em; }
.gift-card .chip { margin-top: 12px; }

/* Wishes */
.wishes { margin-top: 24px; display: grid; gap: 10px; max-height: 420px; overflow-y: auto; text-align: left; padding: 2px; }
.wish { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; animation: fadeUp .5s ease both; }
.wish-empty { text-align: center; color: var(--mute); font-size: 14px; font-style: italic; }
.wish b { font-weight: 600; color: var(--wine); font-size: 14px; }
.wish p { font-size: 14px; margin-top: 2px; white-space: pre-line; }

/* Thanks */
.thanks { padding-top: 0; }
.thanks-photo { height: 340px; margin: 0 -24px 30px; background: var(--rose) center 30% / cover no-repeat; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.big { font-size: 54px; font-weight: 700; }
.thanks p { font-size: 14.5px; max-width: 340px; margin: 0 auto; }
.thanks .sign { font-size: 30px; color: var(--wine); margin-top: 18px !important; }
.foot { text-align: center; font-size: 12px; color: var(--mute); padding: 20px 0 80px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 80px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; font-size: 14px; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .3s; z-index: 70; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Reveal */
.reveal { opacity: 0; transform: translateY(36px); transition: opacity .9s ease, transform .9s ease; }
.reveal.in { opacity: 1; transform: none; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } }

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