:root {
  --bg: #FAF6F0;
  --paper: #FFFDF9;
  --ink: #2E2622;
  --muted: #7A6D64;
  --accent: #8C3B47;
  --accent-ink: #FFFDF9;
  --accent-soft: #F3E6E2;
  --gold: #A9844F;
  --line: #E7DCCF;
  --radius: 14px;
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --quickbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 300 16px/1.7 var(--sans);
  padding-bottom: calc(var(--quickbar-h) + env(safe-area-inset-bottom));
}
body.locked { overflow: hidden; }
img { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
[hidden] { display: none !important; }

.eyebrow {
  margin: 0 0 .5rem;
  font: 500 .72rem/1.6 var(--sans);
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
}
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.amp { font-family: var(--serif); font-style: italic; color: var(--gold); }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: .7rem 1.4rem;
  border-radius: 999px; border: 1px solid transparent;
  font: 500 .95rem/1 var(--sans); text-decoration: none;
  transition: transform .15s ease, background-color .2s ease, box-shadow .2s ease;
}
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -8px rgba(140, 59, 71, .6); }
.btn--primary:hover { background: #7A313D; }
.btn--ghost { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn--ghost:hover { background: var(--accent-soft); }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .6; pointer-events: none; }

/* ---------- Màn mở thiệp ---------- */
.cover {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 2rem;
  background:
    radial-gradient(120% 80% at 50% 0%, #FFFFFF 0%, transparent 60%),
    var(--bg);
  text-align: center;
  transition: opacity .7s ease, visibility .7s ease;
}
.cover.is-hidden { opacity: 0; visibility: hidden; }
.cover__inner {
  max-width: 420px; width: 100%;
  padding: 3rem 1.5rem;
  border: 1px solid var(--line);
  border-radius: 200px 200px var(--radius) var(--radius);
  background: var(--paper);
}
.cover__names {
  margin: .5rem 0 .25rem;
  font: italic 500 clamp(2.6rem, 11vw, 3.6rem)/1.1 var(--serif);
}
.cover__date { margin: 0 0 1.5rem; letter-spacing: .3em; color: var(--muted); }
.cover__guest { margin: 0 0 1.75rem; color: var(--muted); }
.cover__guest strong { display: block; margin-top: .25rem; font: italic 600 1.6rem/1.3 var(--serif); color: var(--ink); }
.cover__open { min-width: 180px; }

/* ---------- Nhạc ---------- */
.music {
  position: fixed; z-index: 30;
  top: calc(12px + env(safe-area-inset-top)); right: 12px;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: rgba(255, 253, 249, .9);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: grid; place-items: center; color: var(--accent);
  box-shadow: 0 4px 14px -6px rgba(46, 38, 34, .3);
}
.music svg { width: 20px; height: 20px; }
.music__bars { display: none; gap: 3px; align-items: flex-end; height: 16px; }
.music__bars i { width: 3px; background: currentColor; border-radius: 2px; animation: bar 1s ease-in-out infinite; }
.music__bars i:nth-child(2) { animation-delay: .2s; }
.music__bars i:nth-child(3) { animation-delay: .4s; }
.music[aria-pressed="true"] .music__on { display: none; }
.music[aria-pressed="true"] .music__bars { display: flex; }
/* Nút tự cuộn nằm ngay dưới nút nhạc */
.autoscroll { top: calc(64px + env(safe-area-inset-top)); }
.autoscroll__pause { display: none; }
.autoscroll[aria-pressed="true"] .autoscroll__play { display: none; }
.autoscroll[aria-pressed="true"] .autoscroll__pause { display: block; }
@keyframes bar { 0%, 100% { height: 4px; } 50% { height: 16px; } }

/* ---------- Nút chuyển ngôn ngữ (nổi trên cả màn mở thiệp) ---------- */
.lang-switch {
  position: fixed; z-index: 55;
  top: calc(12px + env(safe-area-inset-top)); left: 12px;
  height: 44px; padding: 0 1rem;
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--line); border-radius: 999px;
  background: rgba(255, 253, 249, .9);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px -6px rgba(46, 38, 34, .3);
  font: 500 .85rem/1 var(--sans); color: var(--accent); text-decoration: none;
}
.lang-switch svg { width: 16px; height: 16px; }
/* Cuộn khỏi đầu trang thì ẩn để không che nội dung */
.lang-switch { transition: opacity .3s ease, visibility .3s ease; }
.lang-switch.is-away { opacity: 0; visibility: hidden; }

/* ---------- Bản tiếng Trung ---------- */
:lang(zh) {
  --serif: "Noto Serif TC", "Cormorant Garamond", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
}
/* Chữ Hán không có kiểu nghiêng: dùng chữ đứng, giãn nhẹ */
:lang(zh) :is(.cover__names, .cover__guest strong, .hero__names, .hero__guest, .lede, .section__title,
  .person__name, .event__place, .story__text h3, .story__text em, .footer__thanks, .rsvp__done-title,
  .wishes__title, .countdown-done) { font-style: normal; letter-spacing: .06em; }
:lang(zh) .amp { font-family: "Cormorant Garamond", serif; font-style: italic; letter-spacing: 0; }
:lang(zh) .hero__names { font-size: clamp(2.2rem, 9vw, 3.6rem); line-height: 1.25; font-weight: 600; }
:lang(zh) .section__title { font-weight: 600; font-size: clamp(1.9rem, 7vw, 2.6rem); }
:lang(zh) body { line-height: 1.85; letter-spacing: .02em; }
:lang(zh) .eyebrow { font-size: .82rem; letter-spacing: .3em; }

/* ---------- Mở đầu ---------- */
.hero {
  max-width: 1100px; margin: 0 auto;
  padding: 0 0 3rem;
  display: grid; gap: 2rem;
}
/* Ảnh hiển thị trọn vẹn theo tỉ lệ gốc, không cắt */
.hero__photo { margin: 0; position: relative; }
/* Viền mờ dưới chân ảnh cho liền với nền (chỉ phủ phần váy, không chạm mặt) */
.hero__photo::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 18%;
  background: linear-gradient(to bottom, rgba(250, 246, 240, 0), var(--bg));
  pointer-events: none;
}
.hero__photo img { width: 100%; }
.hero__text { padding: 0 1.5rem; text-align: center; }
.hero__names {
  margin: .25rem 0 1rem;
  font: italic 500 clamp(2.6rem, 10vw, 4.2rem)/1.05 var(--serif);
  display: flex; flex-direction: column; align-items: center;
}
.hero__names .amp { font-size: .7em; margin: .1em 0; }
.hero__guest { margin: 0 0 1rem; font: italic 500 1.25rem/1.4 var(--serif); color: var(--accent); }
.hero__lead { margin: 0 0 1.5rem; color: var(--muted); }

.datebar {
  display: inline-grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
  padding: .75rem 0; margin-bottom: .25rem;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-size: .9rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.datebar strong { font: 600 1.9rem/1 var(--serif); letter-spacing: .02em; color: var(--ink); font-variant-numeric: lining-nums; }

.countdown {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
  max-width: 360px; margin: 1.75rem auto 0;
}
.countdown div {
  padding: .75rem 0 .6rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
.countdown b { display: block; font: 600 1.9rem/1 var(--serif); color: var(--accent); font-variant-numeric: lining-nums tabular-nums; }
.countdown span { font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.countdown-done { margin: 1.5rem 0 0; font: italic 500 1.4rem/1.4 var(--serif); color: var(--accent); }

/* ---------- Khung section ---------- */
.section {
  max-width: 1000px; margin: 0 auto;
  padding: 4rem 1.5rem;
  text-align: center;
}
.section__title {
  margin: 0 0 2rem;
  font: italic 500 clamp(2.2rem, 8vw, 3rem)/1.1 var(--serif);
}
.lede {
  max-width: 34ch; margin: -.75rem auto 2rem;
  font: italic 400 1.25rem/1.5 var(--serif); color: var(--muted);
}
.section__title::after {
  content: ""; display: block; width: 48px; height: 1px; margin: 1rem auto 0;
  background: var(--gold);
}

/* ---------- Cặp đôi ---------- */
.couple__grid { display: grid; gap: 1.25rem; }
.person {
  padding: 2rem 1.5rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
}
.person__role { margin: 0; font-size: .75rem; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.person__name { margin: .25rem 0 .75rem; font: italic 600 2rem/1.2 var(--serif); }
.person p:last-child { margin: 0; color: var(--muted); }
.couple__heart { font-size: 1.4rem; color: var(--accent); }

/* ---------- Lễ cưới ---------- */
.event__card {
  display: grid;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; text-align: left;
}
.event__date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.75rem 1rem;
  background: var(--accent); color: var(--accent-ink); text-align: center;
}
.event__weekday { font-size: .78rem; letter-spacing: .22em; text-transform: uppercase; opacity: .85; }
.event__day { font: 600 4.5rem/1 var(--serif); font-variant-numeric: lining-nums; }
.event__month { font-size: .95rem; letter-spacing: .08em; }
.event__lunar { margin-top: .35rem; font-size: .8rem; opacity: .8; }
.event__body { padding: 1.75rem 1.5rem; }
.event__place { margin: 0; font: italic 600 1.8rem/1.2 var(--serif); }
.event__address { margin: .25rem 0 1.25rem; color: var(--muted); }

.timeline { list-style: none; margin: 0 0 1.5rem; padding: 0; border-left: 1px solid var(--line); }
.timeline li { position: relative; display: flex; gap: 1rem; padding: .55rem 0 .55rem 1.25rem; }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 1.05rem;
  width: 9px; height: 9px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--gold);
}
.timeline li.is-main::before { background: var(--accent); border-color: var(--accent); }
.timeline time { min-width: 3.2rem; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.timeline li.is-main span { font-weight: 500; }

.event__actions { display: flex; flex-wrap: wrap; gap: .75rem; }
.event__actions .btn { flex: 1 1 160px; }

.map {
  margin-top: 1.25rem; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--paper);
  aspect-ratio: 4 / 3;
}
.map iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- Câu chuyện ---------- */
.story__item { display: grid; gap: 1.25rem; margin-bottom: 3rem; align-items: center; text-align: left; }
.story__item:last-child { margin-bottom: 0; }
.story__photo { margin: 0; }
.story__photo img { width: 100%; border-radius: var(--radius); }
.story__text h3 { margin: 0 0 .5rem; font: italic 600 1.7rem/1.2 var(--serif); }
.story__text p { margin: 0 0 .75rem; color: var(--muted); }
.story__text em { font-family: var(--serif); font-size: 1.15rem; color: var(--ink); }

/* ---------- Album: hai cột cố định, giữ nguyên tỉ lệ ảnh ---------- */
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; align-items: start; margin-top: 1.5rem; }
.gallery__col { display: flex; flex-direction: column; gap: .75rem; }
.gallery__item {
  display: block; width: 100%; margin: 0; padding: 0;
  border: 0; background: none; border-radius: 10px; overflow: hidden;
}
.gallery__item img { width: 100%; transition: transform .4s ease; }
.gallery__item:hover img { transform: scale(1.03); }

/* ---------- Xem ảnh lớn ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: #16110F;
  touch-action: pan-y pinch-zoom;
}
.lightbox__img {
  max-width: 94vw; max-height: 86vh; width: auto; height: auto;
  object-fit: contain; border-radius: 6px;
  user-select: none; -webkit-user-drag: none;
}
.lightbox button {
  position: absolute; border: 0; background: rgba(255, 255, 255, .12); color: #fff;
  width: 48px; height: 48px; border-radius: 50%; font-size: 1.8rem; line-height: 1;
  display: grid; place-items: center;
}
.lightbox button:hover { background: rgba(255, 255, 255, .22); }
.lightbox__close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lightbox__prev { left: 10px; top: 50%; transform: translateY(-50%); }
.lightbox__next { right: 10px; top: 50%; transform: translateY(-50%); }
.lightbox__count {
  position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; right: 0;
  margin: 0; text-align: center; color: rgba(255, 255, 255, .8); font-size: .9rem; letter-spacing: .1em;
}

/* ---------- Xác nhận tham dự ---------- */
.rsvp__form, .rsvp__done {
  max-width: 520px; margin: 0 auto; padding: 1.75rem 1.5rem;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  text-align: left;
}
.field { margin: 0 0 1.25rem; padding: 0; border: 0; min-width: 0; }
.field > label, .field > legend { display: block; margin-bottom: .4rem; padding: 0; font-weight: 500; font-size: .92rem; }
.field input[type="text"], .field input[type="number"], .field textarea {
  width: 100%; padding: .8rem 1rem;
  font: 400 1rem/1.5 var(--sans); color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field [aria-invalid="true"] { border-color: #B3261E; }
.field__error { margin: .35rem 0 0; font-size: .85rem; color: #B3261E; }
.field textarea { resize: vertical; min-height: 110px; }

.choice { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.choice label { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: .5rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); font-size: .92rem;
  transition: all .2s ease;
}
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 500; }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--bg); }
.stepper button { width: 48px; height: 48px; border: 0; background: transparent; font-size: 1.3rem; color: var(--accent); }
.stepper input[type="number"] {
  width: 56px; padding: 0; border: 0; border-radius: 0; background: transparent;
  text-align: center; font-weight: 600; -moz-appearance: textfield; appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { box-shadow: none; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.chip {
  padding: .4rem .8rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg);
  font-size: .82rem; color: var(--muted); text-align: left;
}
.chip:hover { border-color: var(--gold); color: var(--ink); }

.form__status { margin: .75rem 0 0; min-height: 1.4em; font-size: .9rem; text-align: center; color: var(--muted); }
.form__status.is-error { color: #B3261E; }

.rsvp__done { text-align: center; }
.rsvp__done-title { margin: 0 0 .25rem; font: italic 600 2rem/1.2 var(--serif); color: var(--accent); }

.wishes { max-width: 520px; margin: 2.5rem auto 0; text-align: left; }
.wishes__title { margin: 0 0 1rem; text-align: center; font: italic 600 1.6rem/1.2 var(--serif); }
.wishes__list { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; max-height: 480px; overflow-y: auto; }
.wishes__list li { padding: 1rem 1.1rem; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; }
.wishes__list strong { display: block; font-weight: 600; margin-bottom: .2rem; }
.wishes__list p { margin: 0; color: var(--muted); }

/* ---------- Chân trang ---------- */
.footer { max-width: 560px; margin: 0 auto; padding: 3rem 1.5rem 4rem; text-align: center; color: var(--muted); }
.footer__photo { width: 180px; margin: 0 auto 1.5rem; border-radius: var(--radius); }
.footer__thanks { margin: 0; font: italic 500 2.6rem/1.1 var(--serif); color: var(--ink); }
.footer__names { margin-top: 1.5rem; letter-spacing: .2em; text-transform: uppercase; font-size: .78rem; color: var(--gold); }

/* ---------- Thanh điều hướng nhanh ---------- */
.quickbar {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around;
  height: calc(var(--quickbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 253, 249, .94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.quickbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .72rem; font-weight: 500; color: var(--muted); text-decoration: none;
}
.quickbar a:hover, .quickbar a:active { color: var(--accent); }
.quickbar svg { width: 22px; height: 22px; }

/* ---------- Hiệu ứng xuất hiện ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .8s ease, transform .8s ease; }
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .music__bars i { animation: none; height: 10px; }
  .cover { transition: none; }
}

/* ---------- Màn hình lớn ---------- */
@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .quickbar { display: none; }

  .hero {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center; gap: 4rem;
    min-height: 100vh; padding: 3rem 2rem;
  }
  .hero__photo img { max-height: calc(100vh - 6rem); width: auto; margin-left: auto; border-radius: var(--radius); }
  .hero__photo::after { display: none; }

  .couple__grid { grid-template-columns: 1fr auto 1fr; align-items: center; }

  .event__card { grid-template-columns: 220px 1fr; }
  .event__body { padding: 2rem 2.25rem; }
  .map { aspect-ratio: 21 / 9; }

  .story__item { grid-template-columns: 1fr 1fr; gap: 3rem; }
  .story__item--flip .story__photo { order: 2; }

  .gallery { max-width: 760px; margin-left: auto; margin-right: auto; gap: 1rem; }
  .gallery__col { gap: 1rem; }

  .lightbox__prev { left: 24px; }
  .lightbox__next { right: 24px; }
}
