:root {
  --cream: #f7f2e7;
  --cream-dim: rgba(247, 242, 231, 0.72);
  --line: rgba(247, 242, 231, 0.42);
  --ink: #1b1d1a;
  --glass: rgba(22, 20, 15, 0.3);
  --sans: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Cormorant Garamond', 'Times New Roman', serif;
  --ease: cubic-bezier(0.2, 0.7, 0.15, 1);
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--sans);
  font-weight: 300;
  -webkit-font-smoothing: antialiased;
}

#gl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

.no-webgl body {
  background: linear-gradient(180deg, #3f5f70 0%, #86a0a6 45%, #ecd0b2 80%, #2f3f2c 100%) fixed;
}

main { position: relative; z-index: 1; }

.chapter { position: relative; height: 230vh; }
.chapter.last { height: 150vh; }
.chapter.long { height: 560vh; } /* chương khám phá bức tranh: cuộn lâu hơn để camera đi chậm */

/* lời thoại của nhân vật trong tranh */
.quote {
  position: absolute;
  bottom: 12vh;
  width: min(440px, calc(100% - 32px));
  margin: 0;
  text-align: left;
}
.q-left { left: max(16px, 6vw); }
.q-right { right: max(16px, 7vw); text-align: right; }
.quote blockquote {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(22px, 2.4vw, 32px);
  line-height: 1.25;
}
.quote .reply { opacity: 0.85; padding-left: 1.2em; }
.q-right .reply { padding-left: 0; padding-right: 1.2em; }
.quote figcaption { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--cream-dim); }
.quote cite { font-style: normal; }

/* thông tin tiệc đặt bên phải để thấy tấm thiệp ở giữa-trái */
.party-info {
  position: absolute;
  right: max(16px, 6vw);
  top: 50%;
  translate: 0 -50%;
  width: min(420px, calc(100% - 32px));
  padding: 26px 24px;
  background: rgba(22, 18, 12, 0.42);
  border: 1px solid var(--line);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.party-info .countdown { margin: 22px 0; }

.sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  padding: 72px 16px;
  text-align: center;
  text-shadow: 0 2px 24px rgba(10, 8, 4, 0.45), 0 1px 2px rgba(10, 8, 4, 0.35);
}

[data-reveal] { opacity: 0; will-change: opacity, transform; }

/* ---------- chữ ---------- */
.eyebrow {
  margin: 0 0 18px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

.names,
h2 {
  margin: 0;
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 0.95;
}

.names { font-size: clamp(44px, 8.4vw, 124px); }
h2 { font-size: clamp(40px, 6.6vw, 96px); margin-bottom: 26px; }

.names em,
h2 em,
.mark em,
.loader-mark em {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.names .amp { display: inline-block; margin: 0 0.12em; font-size: 0.9em; }

.names > span[data-split] { white-space: nowrap; }

.ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.35em) rotate(4deg);
  filter: blur(6px);
  transition: opacity 0.9s var(--ease), transform 1.2s var(--ease), filter 0.9s var(--ease);
  transition-delay: calc(var(--i) * 45ms + var(--d, 0ms));
}

.is-ready .hero .ch,
.in .ch { opacity: 1; transform: none; filter: none; }

.hero {
  position: relative;
  width: min(940px, 100%);
  padding: clamp(28px, 5vw, 64px) clamp(18px, 4vw, 60px);
  border: 1px solid var(--line);
}

.hero::before,
.hero::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--cream);
}
.hero::before { top: -7px; left: -7px; border-right: 0; border-bottom: 0; }
.hero::after { bottom: -7px; right: -7px; border-left: 0; border-top: 0; }

.sub {
  margin: 22px auto 0;
  max-width: 34ch;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(18px, 2vw, 24px);
  color: var(--cream-dim);
}

.date {
  margin: 22px 0 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 14px;
}
.date i { width: 28px; height: 1px; background: var(--cream); display: inline-block; }

.scroll-hint {
  position: absolute;
  bottom: 28px;
  left: 50%;
  translate: -50% 0;
  background: none;
  border: 0;
  color: var(--cream);
  font: 500 11px/1 var(--sans);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  display: grid;
  justify-items: center;
  gap: 12px;
  cursor: pointer;
}
.scroll-hint i {
  width: 1px;
  height: 46px;
  background: linear-gradient(var(--cream), transparent);
  animation: drip 2.2s var(--ease) infinite;
  transform-origin: top;
}
@keyframes drip {
  0% { transform: scaleY(0); opacity: 1; }
  60% { transform: scaleY(1); opacity: 1; }
  100% { transform: scaleY(1); opacity: 0; }
}

.block { width: min(980px, 100%); }
.block.narrow { width: min(640px, 100%); }

.lead {
  margin: 0 auto;
  max-width: 46ch;
  font-size: clamp(16px, 1.5vw, 19px);
  line-height: 1.75;
}

.sign {
  margin-top: 22px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  color: var(--cream-dim);
}

.cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 8px;
}
.card {
  padding: 28px 22px 26px;
  border: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.card h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cream-dim);
}
.card .time {
  margin: 10px 0 6px;
  font-family: var(--serif);
  font-size: 54px;
  font-weight: 500;
  line-height: 1;
}
.card p { margin: 4px 0; }
.muted { color: var(--cream-dim); font-size: 14px; line-height: 1.6; }

.countdown {
  display: flex;
  justify-content: center;
  gap: clamp(18px, 4vw, 44px);
  margin: 30px 0;
}
.countdown div { display: grid; gap: 4px; }
.countdown b {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(44px, 6vw, 72px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.countdown span {
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cream-dim);
}

.btn {
  display: inline-block;
  padding: 14px 30px;
  border: 1px solid var(--cream);
  border-radius: 999px;
  background: transparent;
  color: var(--cream);
  font: 500 12px/1 var(--sans);
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}
.btn:hover { background: var(--cream); color: var(--ink); text-shadow: none; }

/* ---------- hồi âm ---------- */
.rsvp {
  margin: 0 auto;
  padding: 26px;
  border: 1px solid var(--line);
  background: rgba(22, 20, 15, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-align: left;
  text-shadow: none;
}
.rsvp .fields { display: grid; gap: 14px; }
.rsvp .row { display: grid; grid-template-columns: 1fr 110px; gap: 14px; }
.rsvp label {
  display: grid;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--cream-dim);
}
.rsvp input,
.rsvp select,
.rsvp textarea {
  width: 100%;
  padding: 11px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--cream);
  font: 400 16px/1.4 var(--sans);
  letter-spacing: 0;
  text-transform: none;
  outline: none;
  resize: none;
}
.rsvp select option { color: var(--ink); }
.rsvp input:focus,
.rsvp select:focus,
.rsvp textarea:focus { border-bottom-color: var(--cream); }
.rsvp input::placeholder,
.rsvp textarea::placeholder { color: rgba(247, 242, 231, 0.4); }
.rsvp .btn { justify-self: center; margin-top: 6px; }
.rsvp .thanks {
  display: none;
  margin: 0;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 24px;
}
.rsvp.sent .fields { display: none; }
.rsvp.sent .thanks { display: block; }

.credits {
  margin: 14px auto 0;
  max-width: 640px;
  padding: 8px 14px;
  font-size: 10px;
  letter-spacing: 0.08em;
  line-height: 1.6;
  color: rgba(247, 242, 231, 0.82);
  background: rgba(22, 18, 12, 0.55);
  border-radius: 6px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  text-shadow: none;
}

.foot {
  margin-top: 22px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 20px;
  color: var(--cream);
  text-shadow: 0 1px 14px rgba(10, 8, 4, 0.7), 0 0 2px rgba(10, 8, 4, 0.5);
}

/* ---------- khung trang ---------- */
.topbar {
  position: fixed;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px clamp(16px, 3vw, 36px);
  pointer-events: none;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35);
}
.topbar > * { pointer-events: auto; }
.mark { color: var(--cream); text-decoration: none; font-weight: 500; font-size: 18px; letter-spacing: -0.02em; }
.mark em { font-size: 1.1em; }
.topdate { font-size: 11px; font-weight: 500; letter-spacing: 0.3em; }

.chapters {
  position: fixed;
  z-index: 3;
  right: clamp(12px, 2.4vw, 32px);
  top: 50%;
  translate: 0 -50%;
  display: grid;
  gap: 14px;
}
.chapters a {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  color: var(--cream);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}
.chapters a span { opacity: 0; transform: translateX(6px); transition: 0.5s var(--ease); }
.chapters a::after {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1px solid var(--cream);
  transition: 0.5s var(--ease);
}
.chapters a.active::after { background: var(--cream); width: 8px; height: 8px; }
.chapters:hover a span,
.chapters a.active span { opacity: 1; transform: none; }

/* ---------- màn chờ ---------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: var(--ink);
  transition: opacity 1.2s var(--ease) 0.2s, visibility 0s linear 1.4s;
}
.is-ready .loader { opacity: 0; visibility: hidden; }
.loader-inner { display: grid; justify-items: center; gap: 18px; }
.loader-mark { font-size: 42px; font-weight: 500; letter-spacing: -0.03em; }
.loader-text { font-size: 11px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--cream-dim); }
.loader-bar { width: 160px; height: 1px; background: rgba(247, 242, 231, 0.18); overflow: hidden; }
.loader-bar i {
  display: block;
  height: 100%;
  background: var(--cream);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.4s var(--ease);
}

/* ---------- di động ---------- */
@media (max-width: 720px) {
  .chapter { height: 210vh; }
  .chapter.long { height: 520vh; }
  .party-info { top: auto; bottom: 4vh; translate: none; left: 16px; right: 16px; width: auto; }
  .quote { bottom: 6vh; }
  .chapters { display: none; }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .card { padding: 18px; }
  .card .time { font-size: 40px; }
  .rsvp { padding: 20px 18px; }
  .sticky { padding: 64px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .ch { transition: opacity 0.4s linear; transform: none; filter: none; }
  .scroll-hint i { animation: none; }
}

/* ---------- mở đầu trên nền giấy (trước khi hai tay chạm nhau) ---------- */
#mo-dau .sticky { place-items: end center; padding-bottom: max(14vh, 112px); }
body { transition: color 0.8s var(--ease); }
@media (max-width: 720px) {
  #mo-dau .sticky { padding-bottom: 104px; }
  #mo-dau .hero { padding: 22px 16px; }
}
#mo-dau .hero { width: min(760px, 100%); padding: clamp(18px, 3vw, 34px) clamp(18px, 4vw, 48px); }
#mo-dau .names { font-size: clamp(40px, 6.4vw, 86px); }
#mo-dau .sub { margin-top: 12px; font-size: clamp(16px, 1.6vw, 20px); }
#mo-dau .date { margin-top: 14px; }
#mo-dau .eyebrow { margin-bottom: 10px; }

/* ---------- nút phụ ---------- */
.btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 6px; }
.party-info .btns { justify-content: flex-start; }
.btn.ghost { border-color: var(--line); }
.hint { margin: 12px 0 0; font: italic 15px/1.4 var(--serif); color: var(--cream-dim); }
.party-info { pointer-events: auto; }

/* ---------- thiệp chi tiết (mở khi bấm vào tấm thiệp trên bàn) ---------- */
.invite {
  --cream: #2b2119;
  --cream-dim: rgba(43, 33, 25, 0.72);
  --line: rgba(43, 33, 25, 0.3);
  width: min(640px, calc(100vw - 32px));
  max-height: calc(100svh - 32px);
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--cream);
  background: linear-gradient(160deg, #fbf6ea, #f1e6cf);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  text-align: center;
  text-shadow: none;
  overflow: auto;
}
.invite::backdrop { background: rgba(14, 12, 9, 0.62); backdrop-filter: blur(4px); }
.invite[open] { animation: invite-in 0.6s var(--ease); }
@keyframes invite-in { from { opacity: 0; transform: translateY(24px) scale(0.97); } }
.invite-card {
  margin: 14px;
  padding: clamp(26px, 5vw, 48px) clamp(18px, 4vw, 40px);
  border: 1px solid #b8913f;
  outline: 1px solid rgba(184, 145, 63, 0.5);
  outline-offset: -8px;
}
.invite .eyebrow { color: #8a6a2c; }
.invite-lead { margin: 0; font: italic 20px/1.4 var(--serif); color: var(--cream-dim); }
.invite h2 { margin: 10px 0 22px; font-size: clamp(34px, 6vw, 54px); }
.invite h2 em { color: #9a6b2f; }
.invite-families { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.invite-families h3 { margin: 0 0 6px; font: 500 11px/1 var(--sans); letter-spacing: 0.28em; text-transform: uppercase; color: #8a6a2c; }
.invite-families p { margin: 0 0 4px; font-size: 15px; }
.invite .muted { color: var(--cream-dim); font-size: 14px; }
.invite-times { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 18px; padding: 16px 0; list-style: none; border-block: 1px solid var(--line); }
.invite-times b { display: block; font: 500 28px/1.1 var(--serif); }
.invite-times span { display: block; margin-top: 4px; font-size: 13px; font-weight: 500; }
.invite-times small { color: var(--cream-dim); font-size: 12px; }
.invite-date { margin: 0 0 6px; font: 500 13px/1 var(--sans); letter-spacing: 0.28em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 12px; }
.invite-date i { width: 26px; height: 1px; background: currentColor; display: inline-block; }
.invite .btns { margin-top: 20px; }
.invite .btn:hover { background: #2b2119; color: #fbf6ea; }
.invite-close {
  position: absolute; top: 10px; right: 12px; width: 40px; height: 40px;
  border: 0; background: none; color: #6b5232; font-size: 30px; line-height: 1; cursor: pointer;
}
@media (max-width: 520px) {
  .invite-families { grid-template-columns: 1fr; }
  .invite-times b { font-size: 22px; }
}
.block.party-info { width: min(400px, calc(100% - 32px)); max-width: none; }
@media (min-width: 900px) { .block.party-info { right: max(16px, 5vw); left: auto; } }
