/* Shared foundation for both themes: tokens (overridden per theme), type roles, the mobile
   column, controls, cover, floating controls, lightbox and motion. Section layouts live in
   invitation-sections.css; palettes and ornament treatment in theme-*.css. */

:root {
  --font-script: "Ephesis", "Great Vibes", cursive;
  --font-serif: "Cormorant Garamond", "Noto Serif", Georgia, serif;
  --font-sans: "Be Vietnam Pro", "Segoe UI", system-ui, sans-serif;
  --paper: #f6f1e7;
  --ink: #3d4637;
  --muted: #7b8471;
  --accent: #6f8157;
  --accent-ink: #fbf8f1;
  --rule: rgba(79, 95, 59, 0.22);
  --backdrop: #e6ddcb;
  --surface: var(--paper);
  --text: var(--ink);
  --field-bg: rgba(255, 255, 255, 0.55);
  --radius: 14px;
  --column: 480px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--backdrop);
  color: var(--text);
  font: 400 18px/1.6 var(--font-serif);
  -webkit-font-smoothing: antialiased;
}
body.is-sealed { overflow: hidden; }
img { max-width: 100%; display: block; }
p, h1, h2, h3, ol, ul, figure { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* The invitation is a phone-width column; on larger screens it floats on the backdrop. */
.page {
  max-width: var(--column);
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 60px rgba(40, 30, 20, 0.12);
  overflow: hidden;
}
.page > section {
  position: relative;
  background: var(--surface);
  color: var(--text);
  padding: 64px 24px;
  text-align: center;
}

/* ---- type roles ---- */
.eyebrow {
  font: 500 11px/1.5 var(--font-sans);
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--muted);
}
.center { text-align: center; }
.script { font-family: var(--font-script); font-weight: 400; line-height: 1.15; }
.section-title {
  margin-top: 6px;
  font: italic 500 34px/1.2 var(--font-serif);
  text-wrap: balance;
}
.section-note { margin: 10px auto 0; max-width: 34ch; font-style: italic; color: var(--muted); }
.lunar { font-style: italic; font-size: 16px; color: var(--muted); }
.amp { display: block; font-size: 0.6em; color: var(--accent); margin: 0.1em 0; }

/* ---- ornaments ---- */
.orn { position: absolute; pointer-events: none; user-select: none; -webkit-user-drag: none; }
.orn.divider { position: relative; width: 78%; margin: 22px auto 0; }

/* ---- controls ---- */
.btn-solid, .btn-line, .btn-open {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 26px; border-radius: 999px; cursor: pointer;
  font: 500 13px/1 var(--font-sans); letter-spacing: 0.14em; text-transform: uppercase; text-decoration: none;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
.btn-solid { border: 0; background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -10px var(--accent); }
.btn-line { border: 1px solid var(--rule); background: transparent; color: var(--text); min-height: 40px; padding: 0 16px; font-size: 11px; }
.btn-line.subtle { opacity: 0.7; }
.btn-solid:active, .btn-line:active, .btn-open:active { transform: scale(0.97); }

.form { display: grid; gap: 16px; max-width: 360px; margin: 28px auto 0; text-align: left; }
.field { display: grid; gap: 6px; }
.field > span { font: 500 11px/1.4 var(--font-sans); letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px;
  background: var(--field-bg); font-size: 18px;
}
.field textarea { resize: vertical; }
.choice { display: grid; gap: 8px; border: 0; padding: 0; margin: 0; }
.choice label { display: block; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice span {
  display: block; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 999px; text-align: center;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.choice input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 3px; }
.form .btn-solid { justify-self: center; margin-top: 4px; }
.form-status { min-height: 1.6em; text-align: center; font-style: italic; }
.form-status.error { color: #a4332b; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* ---- cover (sealed card shown before the invitation opens) ---- */
.cover {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 24px 16px;
  background: var(--cover-bg, var(--backdrop));
  transition: opacity 0.9s ease 0.35s, visibility 0s linear 1.25s;
}
.cover-card {
  position: relative; width: min(360px, 100%); padding: 56px 28px 44px;
  background: var(--cover-card-bg, var(--paper)); color: var(--cover-text, var(--ink));
  border-radius: 6px; box-shadow: 0 30px 70px -20px rgba(30, 20, 10, 0.45);
  text-align: center; overflow: hidden;
  transition: transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), opacity 0.7s ease;
  animation: card-in 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}
.cover-inner { position: relative; z-index: 2; display: grid; justify-items: center; gap: 6px; }
.cover-names { font-size: 50px; margin-top: 8px; }
.cover-date { margin-top: 10px; font: 500 15px/1 var(--font-sans); letter-spacing: 0.3em; }
.cover-date span { opacity: 0.5; }
.cover-invite { margin-top: 22px; font: 500 11px/1.4 var(--font-sans); letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.8; }
.cover-guest { font-size: clamp(30px, 9vw, 38px); white-space: nowrap; }
.btn-open { margin-top: 18px; border: 0; background: var(--accent); color: var(--accent-ink); animation: breathe 2.6s ease-in-out infinite; }
body.is-open .cover { opacity: 0; visibility: hidden; }
body.is-open .cover-card { transform: translateY(-30px) scale(0.94); opacity: 0; }

/* ---- floating controls ---- */
.dock {
  position: fixed; left: 50%; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); z-index: 30;
  display: flex; gap: 2px; padding: 4px; border-radius: 999px; transform: translateX(-50%);
  background: color-mix(in srgb, var(--paper) 82%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.35); border: 1px solid var(--rule);
  transition: opacity 0.4s, transform 0.4s;
}
.dock a { padding: 9px 12px; border-radius: 999px; font: 500 11px/1 var(--font-sans); letter-spacing: 0.06em; text-decoration: none; color: var(--ink); white-space: nowrap; }
.dock a:active { background: var(--rule); }
body.is-sealed .dock, body.is-sealed .music { opacity: 0; pointer-events: none; }
.music {
  position: fixed; right: 14px; bottom: calc(70px + env(safe-area-inset-bottom, 0px)); z-index: 31;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--rule); cursor: pointer;
  background: color-mix(in srgb, var(--paper) 85%, transparent); color: var(--ink); font-size: 18px;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.music[aria-pressed="true"] span { display: inline-block; animation: spin 4s linear infinite; }
.sample-ribbon {
  position: fixed; top: 14px; right: -34px; z-index: 60; transform: rotate(45deg);
  padding: 4px 40px; background: rgba(0, 0, 0, 0.55); color: #fff;
  font: 500 10px/1.4 var(--font-sans); letter-spacing: 0.2em; text-transform: uppercase; pointer-events: none;
}

/* ---- lightbox ---- */
.lightbox { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(12, 10, 8, 0.94); }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 94vw; max-height: 86vh; object-fit: contain; border-radius: 4px; }
.lightbox button { position: absolute; border: 0; background: none; color: #fff; font-size: 40px; line-height: 1; padding: 14px; cursor: pointer; }
.lb-close { top: 8px; right: 8px; }
.lb-prev { left: 4px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 4px; top: 50%; transform: translateY(-50%); }

/* ---- falling petals / 囍 (JS adds a few; kept light for the Zalo webview) ---- */
.fall-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.fall { position: absolute; top: -30px; animation: fall linear infinite; will-change: transform; }

/* Sections animate in from a visible resting state: only once JS has marked them waiting. */
.js-reveal .reveal.waiting { opacity: 0; transform: translateY(18px); }
.reveal { transition: opacity 0.9s ease, transform 0.9s ease; }

@keyframes card-in { from { opacity: 0; transform: translateY(26px) scale(0.97); } }
@keyframes breathe { 50% { transform: scale(1.045); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fall { to { transform: translate3d(var(--drift, 30px), 110vh, 0) rotate(var(--turn, 420deg)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .fall-layer { display: none; }
}

/* petal shapes per theme (set here so the JS stays theme-agnostic) */
.fall-petal { width: 12px; height: 15px; border-radius: 80% 0 80% 0; background: var(--petal, linear-gradient(135deg, #ffffff, #e9dccb)); opacity: 0.85; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.fall-hy { font: 700 16px/1 "Noto Serif TC", serif; color: var(--gold, #d9b064); opacity: 0.6; }
[data-theme-id="red"] { --petal: linear-gradient(135deg, #ff9ea4, #c93a44); }
