/* ==========================================================================
   THIỆP THÔI NÔI — CSS DÙNG CHUNG (màu theo biến --tn-* khai báo trong index.html)
   Bố cục chi tiết của từng mẫu nằm trong style inline của index.html (bám sát thiết kế).
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
[hidden], [data-off] { display: none !important; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--tn-cover); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--tn-cover);
  color: var(--tn-ink);
  font-family: 'Nunito', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { max-width: 100%; }
button { font: inherit; }
button:disabled { cursor: default; }
button[aria-busy="true"] { opacity: .65; cursor: progress; }
a, button { touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--tn-accent); outline-offset: 2px; }

/* Safari iOS tự phóng to khi focus ô nhập có chữ < 16px → luôn giữ đúng 16px. */
input, select, textarea { font-size: 16px !important; max-width: 100%; }
select { -webkit-appearance: none; appearance: none; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px !important; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--tn-ink) 55%, transparent); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--tn-accent) !important; }

/* ------------------------------- trang thiệp ------------------------------ */
.tn-page { box-shadow: 0 0 40px rgba(0, 0, 0, .06); min-height: 100vh; }
/* Màn hình rộng: khung thiệp tối đa 900px (index.html), nội dung mỗi phần tối đa 560px, nền trải hết khung. */
@media (min-width: 768px) {
  .tn-page { border-inline: 1px solid color-mix(in srgb, var(--tn-ink) 14%, transparent); }
  .tn-page > section {
    padding-left: calc(max(0px, (100% - 560px) / 2) + var(--pl, 0px)) !important;
    padding-right: calc(max(0px, (100% - 560px) / 2) + var(--pr, 0px)) !important;
  }
}
body.is-loading .tn-page, body.has-error .tn-page { visibility: hidden; }
/* Không lộ chữ / khung ảnh mẫu của thiết kế trong lúc chờ dữ liệu. */
body.is-loading .tn-cover [data-t], body.is-loading .tn-cover [data-img] > *, body.is-loading .tn-cover [data-show], body.is-loading .tn-cover [data-hide] { visibility: hidden; }
body.has-cover, body.modal-open { overflow: hidden; }

.tn-slot { position: relative; }
.tn-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; z-index: 0; }
.tn-slot > :not(.tn-img) { z-index: 1; }
[data-gi] { cursor: zoom-in; }

.tn-fullname { margin-top: 4px; font-size: 13px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; text-align: center; opacity: .8; }
.tn-quote { margin: 18px auto 0; max-width: 310px; font-size: 15px; line-height: 1.6; font-style: italic; text-align: center; white-space: pre-line; }
.tn-journey-content { margin-top: 2px; font-size: 14px; line-height: 1.5; opacity: .85; white-space: pre-line; }
.tn-credit { padding: 10px 16px calc(14px + env(safe-area-inset-bottom)); text-align: center; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--tn-ink); opacity: .75; user-select: none; }
.tn-wish-time { margin-top: 4px; font-size: 12px; font-weight: 700; opacity: .6; }
.tn-parents { margin-top: 12px; font-size: 15px; font-weight: 700; text-align: center; line-height: 1.5; }
.tn-outline-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; margin-top: 12px; padding: 0 20px;
  border: 2px solid var(--tn-accent); border-radius: 999px; background: #FFFFFF; color: var(--tn-accent);
  font-family: 'Nunito', sans-serif; font-weight: 800; font-size: 15px; text-decoration: none; cursor: pointer;
}
.tn-map-frame { display: block; width: 100%; height: 100%; border: 0; }

/* Nút nhạc: đang phát → icon quay; tạm dừng → icon mờ và có gạch chéo. */
.tn-music { transition: transform .2s ease; }
.tn-music svg { transition: opacity .2s ease; }
.tn-music:not(.is-playing) svg { opacity: .55; }
.tn-music:not(.is-playing)::after { content: ""; position: absolute; left: 11px; top: 21px; width: 22px; height: 2px; border-radius: 2px; background: currentColor; transform: rotate(-45deg); }
.tn-music.is-playing svg { animation: tn-spin 4s linear infinite; }
@keyframes tn-spin { to { transform: rotate(360deg); } }

/* ---------------------------------- bìa ---------------------------------- */
.tn-cover { position: fixed; inset: 0; z-index: 100; overflow-y: auto; background: var(--tn-cover); transition: opacity 2.4s cubic-bezier(0.4, 0, 0.2, 1), visibility 2.4s cubic-bezier(0.4, 0, 0.2, 1); }
.tn-cover-inner { max-width: 560px; margin: 0 auto; min-height: 100vh !important; min-height: 100dvh !important; padding: 24px 0; }

/* Mở thiệp (giống thiệp cưới): bìa mờ dần 2,4s; khung phong bì trượt lên + thu nhẹ, chữ/nút trượt lên và nhoè đi. */
body.is-opening .tn-cover { opacity: 0; visibility: hidden; pointer-events: none; }
body.is-opening .tn-cover-inner > * {
  opacity: 0; translate: 0 -45px; filter: blur(6px);
  transition: filter 1.9s ease, opacity 1.8s ease, translate 2s cubic-bezier(0.2, 0.8, 0.25, 1);
}
body.is-opening .tn-cover-inner > .tn-cover-stage {
  translate: 0 -85px; scale: .97; filter: blur(8px);
  transition: filter 2.3s ease, opacity 2.1s cubic-bezier(0.4, 0, 0.2, 1), translate 2.4s cubic-bezier(0.2, 0.8, 0.25, 1), scale 2.4s cubic-bezier(0.2, 0.8, 0.25, 1);
}
/* Thân thiệp trượt từ dưới lên trong lúc bìa mờ đi. */
.tn-page { transition: opacity 2.2s ease, translate 2.4s cubic-bezier(0.16, 1, 0.3, 1); }
body.has-cover:not(.is-opening) .tn-page { opacity: 0; translate: 0 110px; pointer-events: none; }
.tn-cover [data-act="open"]:disabled { opacity: .7; }
.tn-loading { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: color-mix(in srgb, var(--tn-cover) 70%, transparent); z-index: 5; }
body.is-loading .tn-loading { display: flex; }
.tn-loading span { width: 44px; height: 44px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .7); border-top-color: var(--tn-accent); animation: tn-spin .9s linear infinite; }

/* ---------------------------------- modal --------------------------------- */
.tn-modal [data-backdrop] { align-items: flex-start !important; overflow-y: auto; overscroll-behavior: contain; }
.tn-modal [role="dialog"] { margin: auto 0; }
.tn-modal [data-act="att-yes"], .tn-modal [data-act="att-no"] { transition: background .15s ease, border-color .15s ease; }

.tn-lightbox { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; background: rgba(15, 10, 20, .92); padding: 56px 12px; }
.tn-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 12px; user-select: none; }
.tn-lightbox__close, .tn-lightbox__nav { position: absolute; width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); color: var(--tn-accent); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 30px; line-height: 1; }
.tn-lightbox__close { top: 12px; right: 12px; }
.tn-lightbox__nav--prev { left: 10px; top: 50%; margin-top: -24px; }
.tn-lightbox__nav--next { right: 10px; top: 50%; margin-top: -24px; }
.tn-lightbox__count { position: absolute; bottom: 14px; left: 0; right: 0; margin: 0; text-align: center; color: #FFFFFF; font-weight: 700; font-size: 14px; }

.tn-error { position: fixed; inset: 0; z-index: 150; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--tn-cover); }
.tn-error__card { width: 100%; max-width: 360px; padding: 32px 24px; border-radius: 24px; background: #FFFFFF; text-align: center; box-shadow: 0 8px 0 color-mix(in srgb, var(--tn-accent) 18%, transparent); }
.tn-error__card h2 { margin: 0 0 10px; font-family: 'Baloo 2', sans-serif; font-size: 24px; color: var(--tn-accent); }
.tn-error__card p { margin: 0 0 8px; font-size: 15px; line-height: 1.6; }

.tn-toast { position: fixed; left: 50%; bottom: 24px; z-index: 300; max-width: calc(100% - 32px); padding: 12px 20px; border-radius: 18px; background: var(--tn-ink); color: #FFFFFF; font-weight: 700; font-size: 15px; text-align: center; box-shadow: 0 8px 20px rgba(0, 0, 0, .18); opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: opacity .25s ease, transform .25s ease; }
.tn-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.tn-toast.is-error { background: #B3261E; }

/* --------------------------------- hiệu ứng ------------------------------- */
/* Hiện dần khi cuộn — cùng thông số với thiệp cưới (5s, cubic-bezier(0.16, 1, 0.3, 1)).
   Dùng translate/scale riêng để giữ nguyên transform xoay/nghiêng có sẵn trong thiết kế. */
:root { --reveal-duration: 5s; --reveal-ease: cubic-bezier(0.16, 1, 0.3, 1); --slide-distance-medium: 70px; }
html, body { overflow-x: hidden; overflow-x: clip; }
.rv {
  opacity: 0; translate: 0 40px;
  transition: opacity var(--reveal-duration) var(--reveal-ease) var(--rv-delay, 0s),
              translate var(--reveal-duration) var(--reveal-ease) var(--rv-delay, 0s),
              scale var(--reveal-duration) var(--reveal-ease) var(--rv-delay, 0s);
  will-change: opacity, translate;
}
.rv.rv-left { translate: calc(var(--slide-distance-medium) * -1) 0; }
.rv.rv-right { translate: var(--slide-distance-medium) 0; }
.rv.rv-pop { translate: 0 45px; scale: .95; }
.rv.visible { opacity: 1; translate: none; scale: none; }
.rv.reveal-done { will-change: auto; }

