/* ==========================================================================
   THIỆP CƯỚI — style.css  (giấy xanh lá + nền trắng, chữ mảnh)
   ========================================================================== */
:root {
  --green: #6f9a3a;       /* giấy cửa, dải ảnh, album */
  --green-btn: #628d30;   /* nút: đậm hơn nền một chút để chữ trắng dễ đọc */
  --green-deep: #4c6e26;  /* chữ xanh trên nền trắng */
  --ink: #4f5646;
  --ink-soft: #666d5c;
  --line: #d8dccd;
  --paper: #fff;
  --mist: #e7ebdc;

  --f-serif: "Noto Serif Display", "Times New Roman", serif;
  --f-script: "Ballet", "Segoe Script", cursive;
  --f-hand: "Imperial Script", "Segoe Script", cursive;
  --f-ui: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;

  --ease: cubic-bezier(.22, .8, .24, 1);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--mist); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--f-serif);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.is-locked, body.has-dialog { overflow: hidden; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; background: var(--green-deep); color: #fff; font-size: 1.2rem; z-index: 99; }

/* Lớp hiệu ứng (hoa rơi, chạm bung tim) — nằm trên cùng nhưng không chặn chạm */
.fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 60; pointer-events: none; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 24px;
  border: 0; border-radius: 999px;
  background: var(--green-btn); color: #fff;
  font-family: var(--f-serif); font-size: .92rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  text-decoration: none; cursor: pointer;
  box-shadow: 0 5px 12px rgba(76, 110, 38, .26);
  transition: transform .2s var(--ease), background .2s;
}
.btn:hover { background: var(--green-deep); }
.btn:active { transform: scale(.97); }
.btn:focus-visible, .seal:focus-visible, .tile:focus-visible { outline: 2px solid var(--green-deep); outline-offset: 3px; }
.btn--ghost { background: transparent; color: var(--green-deep); border: 1px solid var(--line); box-shadow: none; }
.btn--ghost:hover { background: rgba(111, 154, 58, .1); }
.btn--block { width: 100%; }
.btn--grow { flex: 1; min-width: 0; padding-inline: 14px; }
.btn--square { flex: none; width: 44px; padding: 0; border-radius: 13px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ==========================================================================
   HAI CÁNH CỬA GIẤY
   ========================================================================== */
.doors { position: fixed; inset: 0; z-index: 50; overflow: hidden; cursor: pointer; }
.door {
  position: absolute; top: 0; bottom: 0; width: 50.2%;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .055) 0 1px, rgba(0, 0, 0, .05) 1px 2px, transparent 2px 3px),
    linear-gradient(var(--dir), #7aa543, var(--green));
  transition: transform 1.75s cubic-bezier(.62, .02, .3, 1);
}
/* Hai cánh đối xứng để hai bên khe giữa cùng một tông màu */
.door--l { --dir: 90deg; left: 0; box-shadow: inset -4px 0 5px -4px rgba(32, 48, 14, .34); }
.door--r { --dir: 270deg; right: 0; z-index: 1; box-shadow: inset 4px 0 5px -4px rgba(32, 48, 14, .34), -1px 0 0 rgba(32, 48, 14, .16); }
.doors.is-leaving { pointer-events: none; }
.doors.is-leaving .door--l { transform: translateX(-102%); }
.doors.is-leaving .door--r { transform: translateX(102%); }

/* Dấu sáp nằm trên mép cánh phải, mở cửa thì trượt đi cùng cánh này */
.seal {
  position: absolute; left: 0; top: 50%;
  width: 112px; height: 112px; margin: -56px 0 0 -56px; padding: 0;
  border: 0; border-radius: 50%; background: none; cursor: pointer;
  filter: drop-shadow(0 2px 3px rgba(26, 38, 10, .3));
  animation: seal-pulse 2.8s ease-in-out infinite;
}
.seal svg { display: block; width: 100%; height: 100%; overflow: visible; }
.doors.is-leaving .seal { animation: none; }
@keyframes seal-pulse { 50% { transform: scale(1.045); } }

.doors__invite, .doors__hint {
  position: absolute; z-index: 2; left: 50%; transform: translateX(-50%);
  width: min(86vw, 420px); text-align: center; color: #fdfbe6;
  pointer-events: none;
  text-shadow: 0 1px 8px rgba(32, 48, 14, .5);
  transition: opacity .4s ease;
}
.doors__invite { bottom: calc(50% + 70px); font-size: 1rem; letter-spacing: .1em; text-transform: uppercase; }
.doors__invite strong { display: block; margin-top: 2px; font-family: var(--f-hand); font-weight: 400; font-size: 2.5rem; line-height: 1.2; letter-spacing: 0; text-transform: none; }
.doors__hint { top: calc(50% + 70px); font-size: .86rem; letter-spacing: .14em; text-transform: uppercase; }
.doors.is-leaving .doors__invite, .doors.is-leaving .doors__hint { opacity: 0; }

/* ==========================================================================
   THIỆP
   ========================================================================== */
.invite {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  overflow: hidden;
  background: var(--paper);
  box-shadow: 0 0 60px rgba(70, 95, 35, .18);
}

/* ---------- Ảnh bìa ---------- */
.hero { position: relative; aspect-ratio: 2 / 3; overflow: hidden; background: var(--mist); }
.hero__photo { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 56%;
  background: linear-gradient(to top, rgba(62, 92, 28, .94), rgba(70, 102, 32, .7) 46%, rgba(78, 112, 36, 0));
  pointer-events: none;
}
.hero__text { position: absolute; z-index: 1; left: 0; right: 0; bottom: 22px; text-align: center; color: #fff; }
.hero__script {
  font-family: var(--f-script);
  font-size: clamp(4.3rem, 23vw, 6.2rem); line-height: 1.05;
  clip-path: inset(-30% 100% -30% -5%);
}
.hero__names {
  margin: .3em 0 0;
  font-weight: 300; font-size: clamp(1.75rem, 8.4vw, 2.3rem); line-height: 1.22; letter-spacing: .01em;
  text-transform: uppercase;
  opacity: 0;
}
.hero__names span { display: block; }
.hero__names .sr-only { position: absolute; }
.hero__date { margin-top: 6px; font-size: 1rem; letter-spacing: .06em; opacity: 0; }
body.is-open .hero__script { animation: write-on 1.9s cubic-bezier(.45, .05, .4, 1) 1.5s forwards; }
body.is-open .hero__names { animation: rise-in 1.1s var(--ease) 2.5s forwards; }
body.is-open .hero__date { animation: rise-in 1.1s var(--ease) 2.9s forwards; }
@keyframes write-on { to { clip-path: inset(-30% -5% -30% -5%); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ---------- Lời dẫn, gia đình, cô dâu chú rể ---------- */
.intro { padding: 36px 14px 30px; text-align: center; }
.quote { font-family: var(--f-hand); font-size: 1.62rem; line-height: 1.45; color: var(--ink); }
.parents { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 26px; }
.family__label { font-size: .96rem; font-weight: 500; text-transform: uppercase; color: var(--ink); }
.family__names { margin-top: 3px; font-size: clamp(.7rem, 3.15vw, .84rem); line-height: 1.6; text-transform: uppercase; color: var(--ink); }
.family__addr { margin-top: 3px; font-size: .84rem; line-height: 1.4; color: var(--ink-soft); text-wrap: balance; }
.heart { display: block; width: 76px; height: 76px; margin: 16px auto 10px; overflow: visible; }
.heart path {
  fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 1;
}
.heart.is-in path { animation: draw 2.2s ease-in-out .25s forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.couple { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.couple__role { font-size: .9rem; text-transform: uppercase; color: var(--ink); }
.couple__name { font-family: var(--f-hand); font-size: 2.2rem; line-height: 1.25; color: var(--green-deep); }

/* ---------- Hai ảnh trên dải xanh ---------- */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px; background: var(--green); }
.duo figure, .trio figure, .tile { margin: 0; overflow: hidden; background: var(--mist); }
.duo figure { aspect-ratio: 3 / 4; }
.duo img, .trio img, .tile img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 26%; }
.duo figure:nth-child(1) { --x: -26px; --y: 0px; }
.duo figure:nth-child(2) { --x: 26px; --y: 0px; }

/* ---------- Lời mời + ba ảnh so le ---------- */
.invitation { padding: 34px 18px 34px; text-align: center; }
.invitation__text { font-size: 1.08rem; line-height: 1.45; text-transform: uppercase; color: var(--ink); }
.invitation__guest { display: block; margin: 6px 0 4px; font-family: var(--f-hand); font-weight: 400; font-size: 2.4rem; line-height: 1.2; text-transform: none; color: var(--green-deep); }
.trio { display: grid; grid-template-columns: 1fr 1.24fr 1fr; align-items: center; gap: 10px; margin-top: 24px; }
.trio figure { aspect-ratio: 2 / 3; box-shadow: 0 8px 18px rgba(50, 65, 30, .16); }
.trio figure:nth-child(1) { --r: -3deg; }
.trio figure:nth-child(2) { --r: 1.5deg; transition-delay: .12s; }
.trio figure:nth-child(3) { --r: 3deg; transition-delay: .24s; }

/* ---------- Tiệc + lễ ---------- */
.events { padding: 6px 20px 40px; text-align: center; }
.event__title { margin: 0; font-size: 1.2rem; font-weight: 500; letter-spacing: .01em; text-transform: uppercase; color: var(--ink); }
.event__when { font-size: .9rem; text-transform: uppercase; color: var(--ink-soft); }
.event__date { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 14px; max-width: 320px; margin: 10px auto 8px; }
.event__date span { padding: 3px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: .92rem; text-transform: uppercase; color: var(--ink-soft); }
.event__date b { font-size: 3.5rem; font-weight: 300; line-height: 1; font-variant-numeric: lining-nums; color: var(--green-deep); }
.event__lunar { font-size: .92rem; font-style: italic; color: var(--ink-soft); }
.event__place { margin-top: 8px; font-size: 1rem; font-weight: 500; text-transform: uppercase; color: var(--ink); }
.event__addr { font-size: .92rem; color: var(--ink-soft); text-wrap: balance; }
.rings { display: block; width: 58px; height: 46px; margin: 28px auto 22px; color: var(--ink-soft); }

/* ---------- Album ghép ---------- */
.story { padding: 34px 12px 14px; background: var(--green); color: #fff; }
.story__title { margin: 0; padding: 0 6px; font-size: clamp(1.5rem, 7.2vw, 1.95rem); font-weight: 400; line-height: 1.2; text-transform: uppercase; }
.story__title em { padding: 0 .08em; font-family: var(--f-hand); font-style: normal; font-size: 1.3em; line-height: 1; text-transform: none; }
.story__text { margin-top: 10px; padding: 0 6px; font-size: .98rem; font-weight: 500; line-height: 1.5; text-align: justify; }
.mosaic { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-top: 18px; }
.tile { display: block; padding: 0; border: 0; cursor: zoom-in; }
.tile--w { grid-column: span 6; aspect-ratio: 4 / 3; }
.tile--b { grid-column: span 4; grid-row: span 2; }
.tile--s { grid-column: span 2; aspect-ratio: 4 / 5.2; }
.tile--h { grid-column: span 3; aspect-ratio: 4 / 5.2; }

/* ---------- Xác nhận tham dự ---------- */
.rsvp { padding: 32px 20px 24px; }
.rsvp__lead { text-align: center; font-size: 1rem; line-height: 1.5; color: var(--ink-soft); }
.rsvp__form { display: grid; gap: 10px; margin-top: 18px; }
.input {
  display: block; width: 100%; min-height: 44px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--ink);
  font-family: var(--f-serif); font-size: 16px; line-height: 1.4;
  resize: vertical;
}
.input::placeholder { color: var(--ink-soft); opacity: 1; }
.input:focus { outline: 2px solid var(--green); outline-offset: 0; border-color: transparent; }
select.input {
  padding-right: 34px;
  -webkit-appearance: none; appearance: none;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%23767d6c' d='M0 0h10L5 6z'/%3E%3C/svg%3E") no-repeat right 14px center;
}
select.input:invalid { color: var(--ink-soft); }
.rsvp__extra { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rsvp__extra select:only-of-type { grid-column: 1 / -1; }
.rsvp__actions { display: flex; gap: 10px; }
.form-error { font-family: var(--f-ui); font-size: .88rem; color: #b3261e; }
.form-error:empty { display: none; }
#btnGift { margin-top: 12px; }
.rsvp-done { margin-top: 18px; text-align: center; }
.rsvp-done__text { margin-bottom: 14px; font-size: 1.08rem; line-height: 1.5; color: var(--green-deep); }
.rsvp-done__fallback { margin-bottom: 10px; }

/* ---------- Đếm ngược ---------- */
.timer { padding: 22px 20px 34px; text-align: center; }
.timer__title { margin: 0; font-family: var(--f-script); font-size: 3.5rem; font-weight: 400; line-height: 1.2; color: var(--ink); }
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); max-width: 320px; margin: 6px auto 0; }
.countdown b { display: block; font-size: 2.1rem; font-weight: 300; line-height: 1.15; font-variant-numeric: lining-nums tabular-nums; color: var(--ink-soft); }
.countdown span { font-size: .78rem; color: var(--ink-soft); }
.countdown__done { font-size: 1.05rem; font-style: italic; color: var(--ink-soft); }

/* ---------- Lời cảm ơn trên ảnh ---------- */
.closing { position: relative; aspect-ratio: 2 / 3; overflow: hidden; background: var(--mist); }
.closing__photo { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.closing::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 62%;
  background: linear-gradient(to top, rgba(62, 92, 28, .96), rgba(70, 102, 32, .76) 52%, rgba(78, 112, 36, 0));
  pointer-events: none;
}
.closing__text { position: absolute; z-index: 1; left: 0; right: 0; bottom: 0; padding: 0 20px calc(26px + env(safe-area-inset-bottom)); text-align: center; color: #fff; }
.closing__script { font-family: var(--f-script); font-size: 3.7rem; line-height: 1.2; }
.closing__lines { font-size: 1rem; font-weight: 500; line-height: 1.5; }

/* ---------- Hiện dần khi cuộn ---------- */
.reveal {
  --x: 0px; --y: 26px; --r: 0deg;
  opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r));
  transition: opacity 1s ease, transform 1s var(--ease);
}
.reveal.is-in { opacity: 1; transform: rotate(var(--r)); }

/* ==========================================================================
   NÚT NHẠC NỔI
   ========================================================================== */
.music-fab {
  position: fixed; z-index: 40;
  right: max(12px, calc(50% - 240px + 12px)); top: calc(12px + env(safe-area-inset-top));
  display: inline-flex; align-items: center; justify-content: center; gap: 2.5px;
  width: 42px; height: 26px; padding: 0;
  border: 0; border-radius: 999px;
  background: rgba(70, 76, 62, .46);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}
.music-fab::before { content: ""; position: absolute; inset: -9px -3px; } /* vùng chạm đủ rộng */
.music-fab i { width: 2.5px; height: 4px; border-radius: 2px; background: #fff; opacity: .75; transform-origin: 50% 50%; }
.music-fab.is-playing i { opacity: 1; animation: bars 1s ease-in-out infinite; }
.music-fab.is-playing i:nth-child(2) { animation-delay: -.35s; }
.music-fab.is-playing i:nth-child(3) { animation-delay: -.7s; }
.music-fab.is-playing i:nth-child(4) { animation-delay: -.15s; }
@keyframes bars { 50% { transform: scaleY(2.8); } }
.music-fab.is-waiting::after {
  content: attr(data-hint);
  position: absolute; right: 50px; top: 50%; transform: translateY(-50%);
  white-space: nowrap; padding: 6px 12px; border-radius: 999px;
  font-family: var(--f-ui); font-size: .8rem;
  color: var(--green-deep); background: #fff;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .18);
  animation: nudge 1.6s ease-in-out infinite;
}
@keyframes nudge { 50% { transform: translate(-4px, -50%); } }

/* ==========================================================================
   HỘP THOẠI (thêm vào lịch, quà mừng)
   ========================================================================== */
dialog { color: inherit; }
.sheet {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  padding: 30px 20px 22px;
  border: 0; border-radius: 18px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(20, 30, 8, .4);
  overscroll-behavior: contain;
}
.sheet[open] { animation: sheet-in .45s var(--ease); }
.sheet::backdrop { background: rgba(26, 36, 12, .58); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px) scale(.98); } }
.sheet__close {
  position: absolute; top: 10px; right: 10px;
  width: 38px; height: 38px; border: 0; border-radius: 50%;
  background: rgba(76, 110, 38, .1); color: var(--green-deep); font-size: 1rem; cursor: pointer;
}
.sheet__title { margin: 0; text-align: center; font-size: 1.3rem; font-weight: 500; text-transform: uppercase; color: var(--green-deep); }
.sheet__sub { margin: 6px 0 18px; text-align: center; font-size: .98rem; color: var(--ink-soft); }
.sheet__foot { margin-top: 16px; text-align: center; font-size: .92rem; font-style: italic; color: var(--ink-soft); }
.cal-links { display: grid; gap: 10px; margin-top: 16px; }

/* Quà mừng: thẻ ngân hàng */
.tabs { display: flex; justify-content: center; gap: 8px; margin: 14px 0 4px; }
.tabs:empty { display: none; }
.tab { min-height: 40px; padding: 6px 18px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--ink); font-family: var(--f-ui); font-size: .9rem; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--green-btn); border-color: var(--green-btn); color: #fff; }
.bank { margin-top: 14px; text-align: center; }
.bank__who { font-weight: 600; font-size: 1.08rem; color: var(--green-deep); }
.bank__who:empty { display: none; }
.bank__qr { width: min(230px, 70vw); margin: 12px auto; padding: 10px; border-radius: 14px; background: #fff; box-shadow: 0 8px 22px rgba(50, 65, 30, .15); }
.bank__qr canvas, .bank__qr img { display: block; width: 100%; height: auto; }
.bank__empty { margin: 14px auto; padding: 28px 12px; max-width: 260px; border: 1.5px dashed var(--line); border-radius: 14px; color: var(--ink-soft); font-style: italic; }
.bank__name { font-family: var(--f-ui); font-size: .9rem; color: var(--ink-soft); }
.bank__acc { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 2px; font-family: var(--f-ui); font-size: 1.2rem; font-weight: 600; letter-spacing: .03em; color: var(--ink); overflow-wrap: anywhere; }
.bank__acc:has(span:empty) { display: none; }
.copy-btn { flex: none; width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(76, 110, 38, .1); color: var(--green-deep); cursor: pointer; }
.bank__owner { margin: 2px 0 16px; font-family: var(--f-ui); font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.bank__status { min-height: 1.4em; margin-top: 8px; font-family: var(--f-ui); font-size: .86rem; color: var(--green-deep); }

/* ---------- Xem ảnh to ---------- */
.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: rgba(10, 14, 5, .96); color: #fff;
  overscroll-behavior: contain;
}
.lightbox[open] { display: grid; place-items: center; animation: fade-in .3s ease; }
.lightbox::backdrop { background: transparent; }
@keyframes fade-in { from { opacity: 0; } }
.lightbox__img { max-width: 100%; max-height: 84dvh; object-fit: contain; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.lightbox__count { position: absolute; top: calc(16px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; font-family: var(--f-ui); font-size: .9rem; opacity: .8; }
.lightbox__close, .lightbox__nav { position: absolute; display: grid; place-items: center; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .12); color: #fff; cursor: pointer; }
.lightbox__close { top: calc(10px + env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; font-size: 1.1rem; }
.lightbox__nav { top: 50%; width: 46px; height: 46px; margin-top: -23px; font-size: 1.8rem; }
.lightbox__nav--prev { left: 10px; }
.lightbox__nav--next { right: 10px; }

/* ---------- Giảm chuyển động ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  .reveal { opacity: 1; transform: rotate(var(--r)); }
  .hero__script { clip-path: none; }
  .hero__names, .hero__date { opacity: 1; }
  .heart path { stroke-dashoffset: 0; }
}
