/* ==========================================================================
   css/base.css — Reset, design tokens, layout khung điện thoại, typography,
   button, form, toast, lightbox. Dùng chung cho Thiệp và Dashboard.

   Mục tiêu chống tràn (quan trọng nhất):
     • html, body { overflow-x: hidden }
     • * { box-sizing: border-box; min-width: 0 }
     • Chữ dài: overflow-wrap: anywhere + text-wrap: balance
     • Ảnh / iframe: max-width: 100%
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
  min-width: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: var(--font-body);
  font-size: clamp(14px, 1.05vw + 12px, 16px);
  line-height: 1.6;
  color: var(--ink);
  background: var(--page-bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 500;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

p, li, dd, dt, span, a, strong, em, label, legend, button, input, textarea, select, td, th {
  overflow-wrap: anywhere;
}

img, svg, video, canvas, iframe {
  max-width: 100%;
  display: block;
}

img {
  height: auto;
}

/* Quy tắc `display: block` ở trên vô tình ghi đè [hidden] của trình duyệt
   ⇒ phải khôi phục để thuộc tính hidden luôn có tác dụng. */
[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ------------------------------ Design tokens ---------------------------- */

:root {
  --font-display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --font-script: 'Great Vibes', 'Alex Brush', cursive;
  --font-body: 'Be Vietnam Pro', 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;

  --gold: #b28a5d;
  --gold-deep: #8f6b42;
  --gold-soft: #dfc8a5;
  --ink: #3f3a33;
  --ink-soft: #6f6659;
  --line: rgba(111, 102, 89, 0.24);
  --paper: #fdfbf6;
  --paper-deep: #f4efe4;
  --page-bg: radial-gradient(120% 80% at 50% 0%, #f6f1e7 0%, #e8e2d6 45%, #ded7c8 100%);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 26px;
  --shadow-soft: 0 10px 28px rgba(63, 58, 51, 0.1);
  --shadow-card: 0 26px 70px rgba(48, 42, 34, 0.24), 0 8px 20px rgba(48, 42, 34, 0.12);
  --touch: 44px;
  --ease-out: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ------------------------------- Tiện ích -------------------------------- */

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: ui-monospace, 'SF Mono', 'Roboto Mono', Menlo, monospace;
  letter-spacing: 0.04em;
}

body.is-locked {
  overflow: hidden;
}

/* --------------------------------- Nút ----------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--touch);
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out),
    background-color 0.25s var(--ease-out), color 0.25s var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

.btn--solid {
  background: linear-gradient(135deg, var(--t-gold, var(--gold)) 0%, var(--gold-deep) 100%);
  color: #fff;
  box-shadow: 0 10px 22px rgba(143, 107, 66, 0.28);
}

.btn--solid:hover,
.btn--solid:focus-visible {
  box-shadow: 0 14px 30px rgba(143, 107, 66, 0.36);
  filter: brightness(1.05);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.72);
  border-color: var(--t-line, var(--line));
  color: var(--t-ink, var(--ink));
}

.btn--ghost:hover,
.btn--ghost:focus-visible {
  background: #fff;
  border-color: var(--t-gold, var(--gold));
}

.btn--block {
  width: 100%;
}

.btn--tiny {
  min-height: 32px;
  padding: 0 12px;
  font-size: 11px;
  border-radius: 999px;
  border-color: var(--t-line, var(--line));
  background: rgba(255, 255, 255, 0.6);
}

.btn:focus-visible,
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--t-gold, var(--gold));
  outline-offset: 2px;
}

/* --------------------------------- Form ---------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  border: 0;
  padding: 0;
}

.field > label,
.field > legend {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--t-ink-soft, var(--ink-soft));
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: var(--touch);
  padding: 10px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--t-ink, var(--ink));
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--t-line, var(--line));
  border-radius: var(--radius-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field textarea {
  min-height: 74px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--t-gold, var(--gold));
  box-shadow: 0 0 0 3px rgba(178, 138, 93, 0.14);
  outline: none;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field--choice {
  gap: 8px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--touch);
  padding: 8px 12px;
  border: 1px solid var(--t-line, var(--line));
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
  font-size: 13.5px;
  cursor: pointer;
}

.choice input {
  width: 18px;
  height: 18px;
  min-height: 0;
  accent-color: var(--t-gold, var(--gold));
  flex: 0 0 auto;
}

.choice:has(input:checked) {
  border-color: var(--t-gold, var(--gold));
  background: rgba(178, 138, 93, 0.1);
}

.form-status {
  min-height: 18px;
  margin: 8px 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--t-ink-soft, var(--ink-soft));
}

.form-status[data-type='error'] {
  color: #b3261e;
}

.form-status[data-type='ok'] {
  color: #2f6b3f;
}

/* --------------------------------- Toast --------------------------------- */

.wd-toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  z-index: 4000;
  max-width: min(92vw, 420px);
  padding: 12px 20px;
  font-size: 13.5px;
  color: #fff;
  background: rgba(45, 39, 32, 0.94);
  border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, 16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s var(--ease-out);
  text-align: center;
}

.wd-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.wd-toast[data-type='error'] {
  background: rgba(150, 30, 24, 0.95);
}

/* -------------------------------- Lightbox ------------------------------- */

.wd-lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  background: rgba(14, 11, 8, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.wd-lightbox.is-open {
  display: flex;
}

.wd-lightbox__stage {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  touch-action: pan-y;
}

.wd-lightbox__img {
  max-width: min(96%, 920px);
  max-height: 72vh;
  width: auto;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  object-fit: contain;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.wd-lightbox__close,
.wd-image-overlay__close {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: var(--touch);
  height: var(--touch);
  display: grid;
  place-items: center;
  font-size: 26px;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  z-index: 15;
  cursor: pointer;
}

.wd-lightbox__nav {
  position: absolute;
  top: 46%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 32px;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 50%;
  z-index: 15;
  cursor: pointer;
}

.wd-lightbox__nav.prev { left: 14px; }
.wd-lightbox__nav.next { right: 14px; }

.wd-lightbox__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 500px;
  z-index: 10;
}

.wd-lightbox__counter {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
}

.wd-lightbox__thumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding: 4px;
  scrollbar-width: none;
}

.wd-lightbox__thumbs::-webkit-scrollbar {
  display: none;
}

.wd-lightbox__thumb {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  opacity: 0.55;
  cursor: pointer;
  padding: 0;
  background: transparent;
  transition: all 0.2s ease;
}

.wd-lightbox__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wd-lightbox__thumb.is-active {
  border-color: #b28a5d;
  opacity: 1;
  transform: scale(1.12);
  box-shadow: 0 0 10px rgba(178, 138, 93, 0.6);
}

/* Overlay phóng to ảnh QR mừng cưới */
.wd-image-overlay {
  position: fixed;
  inset: 0;
  z-index: 3600;
  display: none;
  align-items: center;
  justify-content: center;
  padding:
    calc(env(safe-area-inset-top, 0px) + 24px) 14px
    calc(env(safe-area-inset-bottom, 0px) + 24px);
  background: rgba(14, 11, 8, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: zoom-out;
}

.wd-image-overlay.is-open {
  display: flex;
  animation: wd-fade-in 0.25s ease both;
}

.wd-image-overlay img {
  max-width: min(100%, 460px);
  max-height: 80dvh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  cursor: default;
}

.wd-image-overlay__cap {
  position: absolute;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  color: #fff;
  font-size: 13px;
  letter-spacing: 0.08em;
}

/* ------------------------- Màn hình chờ tải trang ------------------------ */

#wd-boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  gap: 14px;
  text-align: center;
  padding: 24px;
  background: var(--page-bg);
}

#wd-boot .boot-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 2px solid rgba(143, 107, 66, 0.25);
  border-top-color: var(--gold-deep);
  animation: wd-spin 0.9s linear infinite;
}

#wd-boot p {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-deep);
}

.boot-error {
  color: #b3261e;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0;
  text-transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
