/* Font cục bộ (đã cắt bớt ký tự, chỉ giữ Latin + tiếng Việt) */
@font-face { font-family: 'Lora'; src: url(/assets/fonts/lora-regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Lora'; src: url(/assets/fonts/lora-semibold.woff2) format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'UVN Hoa Tay'; src: url(/assets/fonts/uvnhoatay.woff2) format('woff2'); font-display: swap; }

:root {
  --gold: #928362;
  --gold-dark: #6f6248;
  --ink: #2b2620;
  --muted: #8a8174;
  --paper: #f7f7f7; /* màu trung bình của nền giấy */
  --paper-texture: url(/assets/deco/nen.webp);
  --line: #e7e0d2;
  --white: #fff;
  --serif: 'Lora', Georgia, serif;                       /* chữ có chân: ngày giờ, tên bố mẹ, sự kiện */
  --elegant: 'Cormorant Garamond', Georgia, serif;       /* chữ mảnh: lời trích, tiêu đề in hoa */
  --script: 'UVN Hoa Tay', cursive;                      /* viết tay tiếng Việt: tiêu đề, tên khách */
  /* Chữ cách điệu ưu tiên dễ đọc: dùng chung UVN Hoa Tay */
  --names: var(--script);    /* tên cô dâu chú rể */
  --display: var(--script);  /* chữ trang trí tiếng Anh */
  --sans: 'Be Vietnam Pro', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans);
  font-weight: 300;
  color: var(--ink);
  background: var(--paper) var(--paper-texture) center top / 750px auto repeat; /* nền giấy cả hai bên ngoài thiệp */
  line-height: 1.6;
}
body.locked { overflow: hidden; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* Ảnh chưa có: hiện ô màu thay thế */
img.placeholder {
  background: linear-gradient(135deg, #d9cfbd, #b9ab90);
  min-height: 160px;
}

.card {
  max-width: 480px;
  margin: 0 auto;
  background: var(--paper) var(--paper-texture) center top / 100% auto repeat-y;
  box-shadow: 0 0 40px rgba(0, 0, 0, .08);
  overflow: hidden;
}

.section { padding: 56px 28px; }
.center { text-align: center; }
.muted { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.small-caps { font-size: 12px; letter-spacing: .25em; text-transform: uppercase; color: var(--gold); font-weight: 500; }
.small-caps.light, .light { color: rgba(255, 255, 255, .92); }
.script { font-family: var(--script); font-weight: 400; color: var(--gold); }
.script-en { font-family: var(--display); font-weight: 400; color: var(--gold); }
h2.script-en { font-size: 40px; line-height: 1.3; margin-bottom: 20px; }
/* Tiêu đề tiếng Việt (Xác nhận tham dự, Sổ lưu bút, Hộp mừng cưới): chữ có chân cho rõ */
h2.script { font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1.35; letter-spacing: .02em; color: var(--gold-dark); margin-bottom: 18px; }
.guest-name { font-family: var(--script); font-size: 30px; font-weight: 400; color: var(--gold-dark); margin: 6px 0; }
.quote { font-family: var(--elegant); font-style: italic; font-size: 19px; text-align: center; color: var(--ink); margin: 24px 0; }

/* Bìa */
.hero { position: relative; min-height: 100svh; max-height: 860px; }
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  gap: 12px; padding: 40px 24px 56px; text-align: center;
  background: linear-gradient(to top, rgba(20, 16, 10, .7), rgba(20, 16, 10, 0) 60%);
}
.names { font-size: 56px; line-height: 1.1; color: #fff; display: flex; flex-direction: column; }
h1.names { font-family: var(--names); font-size: 54px; line-height: 1.2; text-shadow: 0 2px 10px rgba(0, 0, 0, .35); }
.names .amp { font-family: var(--display); font-size: 36px; }
.thanks { min-height: 70svh; }
.thanks .hero-overlay p { max-width: 340px; font-size: 15px; }

.countdown { display: flex; gap: 10px; margin-top: 6px; }
.countdown div {
  width: 64px; padding: 8px 0; border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 8px; color: #fff; backdrop-filter: blur(4px);
}
.countdown b { display: block; font-family: var(--serif); font-size: 28px; font-weight: 600; line-height: 1; }
.countdown small { font-size: 11px; opacity: .85; }

.big-date { font-family: var(--elegant); font-size: 52px; font-weight: 600; letter-spacing: .05em; color: var(--ink); margin: 8px 0; }
.sub { font-size: 32px; }

/* Hai họ */
.families { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; text-align: center; }
.family p:not(.small-caps) { font-family: var(--serif); font-size: 17px; }
.invite-to { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 28px; margin-top: 8px; }

/* Cô dâu chú rể */
.couple { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.couple figure { position: relative; border-radius: 120px 120px 8px 8px; overflow: hidden; aspect-ratio: 3 / 4.2; }
.couple img { width: 100%; height: 100%; object-fit: cover; }
.couple figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 8px 12px; text-align: center; color: #fff;
  background: linear-gradient(to top, rgba(0, 0, 0, .6), transparent);
  font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
}
.couple figcaption small { display: block; font-family: var(--sans); font-size: 11px; font-weight: 400; text-transform: none; letter-spacing: .1em; opacity: .9; }
.couple .quote { grid-column: 1 / -1; }

/* Timeline */
.timeline { list-style: none; display: flex; justify-content: space-between; position: relative; }
.timeline::before { content: ''; position: absolute; top: 18px; left: 15%; right: 15%; height: 1px; background: var(--gold); }
.timeline li { flex: 1; position: relative; }
.timeline .dot { width: 36px; height: 36px; margin: 0 auto 10px; border-radius: 50%; background: var(--paper); border: 1px solid var(--gold); display: grid; place-items: center; color: var(--gold); font-size: 14px; }
.timeline b { display: block; font-family: var(--serif); font-size: 22px; font-weight: 600; }
.timeline span { font-size: 13px; color: var(--muted); }

/* Lịch */
.calendar { max-width: 330px; margin: 0 auto; }
.calendar .month { font-family: var(--serif); font-size: 24px; font-weight: 600; margin-bottom: 12px; }
.calendar .grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 14px; }
.calendar .dow { font-size: 11px; color: var(--muted); font-weight: 500; }
.calendar .day { aspect-ratio: 1; display: grid; place-items: center; }
.calendar .day.hit { position: relative; color: #fff; font-weight: 600; }
.calendar .day.hit::before { content: '♥'; position: absolute; font-size: 40px; color: var(--gold); line-height: 1; z-index: 0; }
.calendar .day.hit span { position: relative; z-index: 1; }

/* Sự kiện */
.events { display: grid; gap: 18px; }
.event { border: 1px solid var(--line); border-radius: 14px; padding: 26px 20px; text-align: center; background: var(--white); }
.event h3 { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--gold-dark); text-transform: uppercase; letter-spacing: .06em; }
.event .when { display: flex; justify-content: center; align-items: center; gap: 14px; margin: 14px 0; font-family: var(--serif); }
.event .when .d { font-size: 46px; font-weight: 600; line-height: 1; padding: 0 14px; border-left: 1px solid var(--gold); border-right: 1px solid var(--gold); }
.event .when small { display: block; font-family: var(--sans); font-size: 11px; color: var(--muted); letter-spacing: .15em; text-transform: uppercase; }
.event .when .side { font-size: 20px; }
.event .lunar { font-size: 13px; color: var(--muted); font-style: italic; }
.event .place { margin-top: 12px; font-weight: 500; }
.event .addr { font-size: 14px; color: var(--muted); margin-bottom: 14px; }

/* Album */
.album { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.album img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 6px; cursor: zoom-in; min-height: 0; }
.album img:first-child { grid-column: span 2; grid-row: span 2; aspect-ratio: auto; height: 100%; }

/* Form */
.form { display: grid; gap: 12px; }
.form input:not([type]), .form input[name="name"], .form select, .form textarea {
  width: 100%; padding: 12px 14px; font: inherit; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: var(--white);
}
.form textarea { resize: vertical; }
.form :focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.radios { display: grid; gap: 6px; font-size: 15px; }
.radios label { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.radios input { accent-color: var(--gold); }

.btn { font: inherit; font-weight: 500; border-radius: 999px; padding: 12px 26px; cursor: pointer; border: 1px solid var(--gold); transition: transform .15s, background .15s; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover { background: var(--gold-dark); }
.btn-primary:disabled { opacity: .6; cursor: wait; }
.btn-ghost { background: transparent; color: var(--gold-dark); display: block; margin: 16px auto 0; }
.btn.sm { display: inline-block; margin: 0 0 0 8px; padding: 4px 12px; font-size: 13px; }

/* Lời chúc */
.wishes { list-style: none; margin-top: 24px; display: grid; gap: 12px; }
.wishes li { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.wishes b { font-weight: 600; color: var(--gold-dark); }
.wishes p { margin-top: 4px; font-size: 15px; white-space: pre-wrap; word-break: break-word; }
.wishes time { font-size: 12px; color: var(--muted); }

.qr { width: 200px; margin: 0 auto 14px; border-radius: 12px; }
.acct { font-family: var(--serif); font-size: 20px; }

/* Màn mở thiệp */
.opening {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 36px;
  background: var(--paper) var(--paper-texture) center / cover no-repeat;
  transition: opacity .7s ease .9s, visibility 0s linear 1.6s;
}
.opening.done { opacity: 0; visibility: hidden; }
/* Phong bì ghép từ các lớp ảnh. Vị trí các lớp theo % kích thước phong bì,
   đo từ thiệp mẫu; hoa và chuỗi ngọc tràn ra ngoài nên chừa lề dưới */
.envelope {
  --env-w: min(340px, 66vw);
  position: relative; width: var(--env-w); aspect-ratio: 782 / 550; cursor: pointer;
  margin-bottom: calc(var(--env-w) * .62);
  -webkit-tap-highlight-color: transparent; outline: none;
}
.env-layer { position: absolute; display: block; max-width: none; pointer-events: none; user-select: none; transition: opacity .5s ease, transform .7s ease; }
.env-paper { inset: 0; width: 100%; height: 100%; filter: drop-shadow(0 14px 24px rgba(60, 45, 20, .18)); }
.env-pearls { left: 19%; top: 97%; width: 66%; }
.env-flower-left { left: -14%; top: -18%; width: 34%; }
.env-flower-right { left: 74%; top: 66%; width: 37%; }
.env-seal { left: 40.5%; top: 52.5%; width: 19%; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .25)); }
.env-hand {
  left: 49%; top: 64%; width: 21%; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .35));
  animation: hand-tap 1.6s ease-in-out infinite; transform-origin: 30% 20%;
}
@keyframes hand-tap { 0%, 100% { transform: translate(6%, 10%); } 45%, 55% { transform: translate(0, 0) scale(.94); } }
.envelope:focus-visible .env-seal { outline: 2px solid var(--gold); outline-offset: 4px; border-radius: 50%; }
.envelope.open .env-hand, .envelope.open .env-seal { opacity: 0; }
.envelope.open .env-paper { transform: scale(1.04); }

/* Tên khách phía trên phong bì */
.invite-head { text-align: center; padding: 0 24px; max-width: 100%; }
.invite-head-title {
  font-family: var(--elegant); font-size: 22px; font-weight: 400; letter-spacing: .18em;
  text-transform: uppercase; color: var(--gold);
}
.invite-head-name {
  display: inline-block; margin-top: 10px; padding: 0 14px 4px; max-width: 100%;
  font-family: var(--script); font-size: 32px; color: var(--gold-dark);
  border-bottom: 1.5px dashed var(--gold);
}

/* Nút nhạc */
.music-btn {
  position: fixed; right: 16px; bottom: 16px; z-index: 50; width: 46px; height: 46px; border-radius: 50%;
  border: none; background: var(--gold); color: #fff; font-size: 20px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}
.music-btn.playing { animation: spin 4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Lightbox */
.lightbox { position: fixed; inset: 0; z-index: 200; background: rgba(0, 0, 0, .92); display: flex; align-items: center; justify-content: center; }
.lightbox img { max-width: 94vw; max-height: 86vh; object-fit: contain; }
.lightbox button { position: absolute; background: none; border: none; color: #fff; font-size: 42px; cursor: pointer; padding: 10px 16px; }
.lb-close { top: 8px; right: 8px; }
.lb-prev { left: 4px; }
.lb-next { right: 4px; }

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translate(-50%, 20px); z-index: 300;
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .3s; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #b4433a; }

/* Hiệu ứng hiện dần khi cuộn */
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .9s ease, transform .9s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .env-hand, .music-btn.playing { animation: none; }
}

/* Hoa rơi: lớp cố định rộng bằng thiệp, không chặn bấm */
.petals {
  position: fixed; top: 0; bottom: 0; left: 50%; z-index: 39;
  width: min(480px, 100%); transform: translateX(-50%); pointer-events: none; overflow: hidden;
}
.petal { position: absolute; top: -40px; animation: petal-fall linear infinite; opacity: .85; }
.petal svg { display: block; width: 100%; height: 100%; animation: petal-sway 3s ease-in-out infinite alternate; }
@keyframes petal-fall { to { transform: translateY(calc(100vh + 80px)); } }
@keyframes petal-sway { from { transform: translateX(-18px) rotate(0deg); } to { transform: translateX(18px) rotate(240deg); } }
@media (prefers-reduced-motion: reduce) { .petals { display: none; } }
