/* Khung chung cho cả 5 mẫu: thiệp là một cột dọc kiểu điện thoại,
   trên màn hình rộng thì nằm giữa nền trang trí của từng mẫu. */
:root {
  --bg: #f6efe4;
  --paper: #fffaf2;
  --ink: #2b1714;
  --muted: #7a625c;
  --accent: #9b1c1f;
  --gold: #c39a5a;
  --line: rgba(43, 23, 20, 0.16);
  --on-accent: #fff8ee;
  --backdrop: #e9dfd0;
  --f-display: "Cormorant Garamond", Georgia, serif;
  --f-body: "Be Vietnam Pro", Arial, sans-serif;
  --f-script: "Great Vibes", cursive;
  --radius: 0px;
  --btn-radius: 999px;
  --ph-1: #e9d6c4;
  --ph-2: #d8b9a1;
  --ph-ink: rgba(60, 30, 24, 0.55);
  --column: 480px;
}

* { box-sizing: border-box; }
/* Số kiểu cũ của Cormorant khó đọc ngày giờ; ép số thẳng hàng (font shorthand sẽ reset nếu không có !important). */
*, *::before, *::after { font-variant-numeric: lining-nums !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--backdrop);
  color: var(--ink);
  font: 400 15px/1.7 var(--f-body);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2, h3 { font-weight: 400; text-wrap: balance; }
p, blockquote, address { text-wrap: pretty; }
.invite:focus { outline: none; }

.invite {
  position: relative;
  width: min(var(--column), 100%);
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
}

@media (min-width: 640px) {
  body { padding: 72px 0 96px; }
  .invite { box-shadow: 0 40px 120px rgba(20, 6, 4, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.06); }
}

.kicker {
  margin: 0;
  color: var(--accent);
  font: 600 11px/1.4 var(--f-body);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

/* Khung ảnh: tông màu theo mẫu làm nền khi ảnh chưa tải xong. */
.ph {
  position: relative;
  margin: 0;
  overflow: hidden;
  aspect-ratio: var(--ratio, 4 / 5);
  background:
    radial-gradient(120% 80% at 20% 10%, rgba(255, 255, 255, 0.45), transparent 55%),
    radial-gradient(90% 70% at 85% 95%, rgba(0, 0, 0, 0.12), transparent 60%),
    linear-gradient(160deg, var(--ph-1), var(--ph-2));
}
.ph::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .5 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
  opacity: 0.5;
}
.ph img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Thanh chọn mẫu (chỉ dùng cho bản demo). */
.design-switcher {
  position: fixed;
  z-index: 200;
  top: 12px;
  left: 50%;
  display: flex;
  gap: 2px;
  max-width: calc(100vw - 20px);
  overflow-x: auto;
  padding: 4px;
  border-radius: 999px;
  background: rgba(24, 12, 10, 0.78);
  box-shadow: 0 10px 30px rgba(10, 4, 3, 0.25);
  font-family: "Be Vietnam Pro", Arial, sans-serif;
  scrollbar-width: none;
  backdrop-filter: blur(14px);
  transform: translateX(-50%);
}
.design-switcher::-webkit-scrollbar { display: none; }
.design-switcher a {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 13px;
  border-radius: 999px;
  color: rgba(255, 244, 232, 0.72);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-decoration: none;
  white-space: nowrap;
}
.design-switcher a span { font-size: 9px; opacity: 0.55; }
.design-switcher a.is-active { background: #fff4e8; color: #2a1310; }

.demo-music {
  position: fixed;
  z-index: 180;
  right: calc(16px + env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 12px 30px rgba(20, 6, 4, 0.3);
  color: var(--on-accent);
  cursor: pointer;
}
.demo-music [data-music-label] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.demo-music:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
.demo-music .music-bars { display: flex; align-items: center; gap: 3px; height: 16px; }
.demo-music .music-bars i { display: block; width: 2px; height: 5px; border-radius: 2px; background: currentColor; }
.demo-music.is-playing .music-bars i { animation: demo-music-bar 0.75s ease-in-out infinite alternate; }
.demo-music.is-playing .music-bars i:nth-child(2) { animation-delay: -0.3s; }
.demo-music.is-playing .music-bars i:nth-child(3) { animation-delay: -0.55s; }
@keyframes demo-music-bar { to { height: 16px; } }

[data-reveal] {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.75, 0.25, 1);
}
[data-reveal].is-visible { opacity: 1; transform: none; }

/* Màn mở thiệp. Mỗi mẫu đổi màu và hướng mở trong file theme của mình. */
body.is-invitation-locked { overflow: hidden; }
.invitation-gate {
  --gate-bg: var(--accent);
  --gate-ink: var(--on-accent);
  --gate-gold: var(--gold);
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--gate-ink);
}
.invitation-door {
  position: absolute;
  background: var(--gate-bg);
  transition: transform 1.3s cubic-bezier(0.7, 0, 0.2, 1);
}
.invitation-door-left { top: 0; bottom: 0; left: 0; width: 50.5%; }
.invitation-door-right { top: 0; bottom: 0; right: 0; width: 50.5%; }
.invitation-gate.is-opening .invitation-door-left { transform: translateX(-101%); }
.invitation-gate.is-opening .invitation-door-right { transform: translateX(101%); }

.invitation-gate-card {
  position: relative;
  z-index: 3;
  width: min(340px, calc(100vw - 48px));
  padding: 44px 24px 38px;
  text-align: center;
  transition: opacity 0.5s ease, transform 0.7s ease;
}
.invitation-gate.is-opening { pointer-events: none; }
.invitation-gate.is-opening .invitation-gate-card { opacity: 0; transform: scale(0.92); }
.invitation-gate-card > p {
  margin: 0;
  color: var(--gate-gold);
  font: 600 11px/1.5 var(--f-body);
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.invitation-gate-card .gate-title {
  margin: 22px 0 34px;
  font: 400 52px/1.02 var(--f-display);
}
.invitation-gate-card .gate-title i { color: var(--gate-gold); font-style: normal; }
.invitation-gate-card button {
  display: grid;
  gap: 14px;
  place-items: center;
  margin: 0 auto;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: 600 11px/1 var(--f-body);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.invitation-gate-card button span {
  display: grid;
  width: 84px;
  height: 84px;
  place-items: center;
  border-radius: 50%;
  background: var(--gate-gold);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--gate-gold) 18%, transparent);
  color: var(--gate-bg);
  font: 500 26px/1 var(--f-display);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  animation: gate-pulse 2.4s ease-in-out infinite;
}
.invitation-gate-card button:hover span,
.invitation-gate-card button:focus-visible span { transform: scale(1.05); }
.invitation-gate-card button:focus-visible { outline: 0; }
.invitation-gate-card > small {
  display: block;
  margin-top: 24px;
  color: color-mix(in srgb, var(--gate-ink) 60%, transparent);
  font-size: 11px;
  letter-spacing: 0.04em;
}
@keyframes gate-pulse {
  0%, 100% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--gate-gold) 18%, transparent); }
  50% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--gate-gold) 6%, transparent); }
}

.opening-petals { position: absolute; z-index: 4; inset: 0; pointer-events: none; }
.opening-petals i {
  position: absolute;
  top: 45%;
  left: var(--petal-x);
  width: 12px;
  height: 18px;
  border-radius: 80% 15% 70% 25%;
  background: var(--gate-gold);
  opacity: 0;
}
.invitation-gate.is-opening .opening-petals i {
  animation: openingPetal 1.4s var(--petal-delay) cubic-bezier(0.15, 0.65, 0.25, 1) both;
}
@keyframes openingPetal {
  0% { opacity: 0; translate: 0 0; rotate: 0deg; }
  18% { opacity: 0.9; }
  100% { opacity: 0; translate: var(--petal-drift) 50vh; rotate: 280deg; }
}

/* Khép thiệp */
.theme-close {
  padding: 96px 28px 120px;
  text-align: center;
}
.theme-close p { margin: 0; color: var(--accent); font: 600 11px/1.5 var(--f-body); letter-spacing: 0.24em; text-transform: uppercase; }
.theme-close h2 { margin: 18px 0 14px; font: 400 64px/1 var(--f-display); }
.theme-close h2 i { color: var(--accent); }
.theme-close span { color: var(--muted); font-size: 13px; letter-spacing: 0.2em; }
