/* Thiệp cưới online — giao diện khách xem
   Mỗi mẫu là một bộ biến màu/font đặt theo data-mau trên <body>; danh sách mẫu ở thiep.js. */
:root {
  --bg: #f4ebe1; --bg2: #faf5ee; --ink: #2a1a1a; --muted: #6a5650;
  --accent: #6b1525; --on-accent: #fff; --soft: #b08968; --line: rgba(42, 26, 26, 0.14);
  --display: "Cormorant Garamond", "Times New Roman", serif;
  --script: "Cormorant Garamond", serif; --script-style: italic;
  --body: "Be Vietnam Pro", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 0.8, 0.2, 1);
}
body[data-mau="toi-gian"] { --bg: #f4f3f0; --bg2: #ffffff; --ink: #151515; --muted: #5d5d5d; --accent: #151515; --soft: #9a9a9a; --line: rgba(0, 0, 0, 0.12); }
body[data-mau="hoa-la"] { --bg: #eef0e4; --bg2: #fbfaf4; --ink: #22291f; --muted: #5a6355; --accent: #4f6a45; --soft: #a7b29a; --line: rgba(34, 41, 31, 0.14); --script: "Dancing Script", cursive; --script-style: normal; }
body[data-mau="song-hy"] { --bg: #8e1220; --bg2: #a3182a; --ink: #fdf0d5; --muted: #f1d9ae; --accent: #f0c869; --on-accent: #5c0d17; --soft: #e2b659; --line: rgba(240, 200, 105, 0.32); --display: "Playfair Display", serif; --script: "Playfair Display", serif; }
body[data-mau="dem-sao"] { --bg: #0d1530; --bg2: #121c3d; --ink: #f3ecdc; --muted: #b9bfd3; --accent: #e3c98b; --on-accent: #121c3d; --soft: #9c8a5b; --line: rgba(227, 201, 139, 0.24); --script: "Dancing Script", cursive; --script-style: normal; }
body[data-mau="hong-phan"] { --bg: #fbeaea; --bg2: #fff7f6; --ink: #4a2a31; --muted: #86636a; --accent: #c2607a; --soft: #e3a9b5; --line: rgba(74, 42, 49, 0.13); --script: "Dancing Script", cursive; --script-style: normal; }
body[data-mau="bien-xanh"] { --bg: #e4eef1; --bg2: #f7fbfc; --ink: #14323d; --muted: #4d6a74; --accent: #1f6f86; --soft: #8fb7c2; --line: rgba(20, 50, 61, 0.14); --display: "Playfair Display", serif; --script: "Playfair Display", serif; }
body[data-mau="thanh-duong"] { --bg: #f3ecdd; --bg2: #fffcf5; --ink: #2e2618; --muted: #6d6250; --accent: #9a7428; --soft: #c9ad6c; --line: rgba(46, 38, 24, 0.15); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-weight: 300; font-size: 16px; line-height: 1.7; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
body.is-locked { overflow: hidden; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.inv { max-width: 560px; margin: 0 auto; background: var(--bg2); min-height: 100svh; box-shadow: 0 0 80px rgba(0, 0, 0, 0.1); position: relative; overflow: hidden; }
.sec { padding: 76px 28px; text-align: center; position: relative; }
.sec + .sec { border-top: 1px solid var(--line); }
.label { font-size: 11px; font-weight: 500; letter-spacing: 0.32em; text-transform: uppercase; color: var(--soft); }
.title { font-family: var(--display); font-weight: 400; font-size: 38px; line-height: 1.25; margin: 14px 0 22px; }
.title em { color: var(--accent); }
.text { color: var(--muted); max-width: 30em; margin: 0 auto; }
.text p + p { margin-top: 0.9em; }
.text b { color: var(--ink); font-weight: 500; }
.orn { color: var(--soft); margin: 26px auto; width: 150px; }
.orn svg { width: 100%; height: auto; display: block; }
.orn path, .orn line { stroke-dasharray: 220; stroke-dashoffset: 220; transition: stroke-dashoffset 1.8s var(--ease) 0.2s; }
.orn.is-in path, .orn.is-in line { stroke-dashoffset: 0; }

/* ---------- Phong bì mở thiệp ---------- */
.open { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: grid; place-items: center; padding: 24px; text-align: center; transition: opacity 0.9s var(--ease) 1.25s, visibility 0s linear 2.2s; }
.open.is-gone { opacity: 0; visibility: hidden; }
.open__to { font-size: 12px; letter-spacing: 0.3em; text-transform: uppercase; color: var(--soft); }
.open__guest { font-family: var(--display); font-size: 34px; line-height: 1.2; margin: 6px 0 34px; min-height: 1.2em; }
.env { width: min(320px, 78vw); aspect-ratio: 3 / 2.1; margin: 0 auto 40px; position: relative; perspective: 900px; filter: drop-shadow(0 24px 30px rgba(0, 0, 0, 0.22)); animation: bob 3.2s ease-in-out infinite; }
.env__back { position: absolute; inset: 0; background: var(--accent); filter: brightness(0.82); border-radius: 4px; }
.env__card { position: absolute; left: 7%; right: 7%; top: 8%; bottom: 8%; background: #fffdf8; color: #2a1a1a; display: grid; place-items: center; font-family: var(--display); font-size: 22px; line-height: 1.25; transition: transform 1.1s var(--ease) 0.45s; border-radius: 2px; }
.env__card small { display: block; font-family: var(--body); font-size: 9px; letter-spacing: 0.3em; text-transform: uppercase; color: #8a7a6a; margin-bottom: 4px; }
.env__front { position: absolute; inset: 0; background: var(--accent); clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%); border-radius: 4px; }
.env__front::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.16)); }
.env__flap { position: absolute; left: 0; right: 0; top: 0; height: 62%; background: var(--accent); filter: brightness(1.12); clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: top; transition: transform 0.8s var(--ease); z-index: 2; backface-visibility: visible; }
.env__seal { position: absolute; left: 50%; top: 56%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; background: var(--soft); color: #fff; display: grid; place-items: center; font-family: var(--display); font-size: 21px; z-index: 3; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28), inset 0 0 0 3px rgba(255, 255, 255, 0.25); transition: transform 0.5s var(--ease), opacity 0.5s; }
.open.is-open .env { animation: none; }
.open.is-open .env__flap { transform: rotateX(180deg); z-index: 0; }
.open.is-open .env__seal { transform: scale(0); opacity: 0; }
.open.is-open .env__card { transform: translateY(-62%); }
.open__btn { display: inline-flex; align-items: center; justify-content: center; min-height: 54px; padding: 0 38px; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase; animation: pulse 2.2s ease-in-out infinite; }
.open.is-open .open__btn, .open.is-open .open__to, .open.is-open .open__guest { opacity: 0; transition: opacity 0.4s; }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 60% { box-shadow: 0 0 0 16px transparent; } }

/* ---------- Bìa ---------- */
.cover { padding: 0; min-height: 100svh; display: flex; flex-direction: column; justify-content: flex-end; overflow: hidden; }
.cover__names { font-family: var(--script); font-style: var(--script-style); font-weight: 400; font-size: clamp(48px, 14vw, 68px); line-height: 1.12; margin: 16px 0 10px; }
.cover__names i { font-style: inherit; display: inline-block; opacity: 0; transform: translateY(0.5em) rotate(6deg); transition: opacity 0.7s var(--ease), transform 0.9s var(--ease); transition-delay: calc(var(--i) * 55ms + 0.5s); }
.is-opened .cover__names i { opacity: 1; transform: none; }
.cover__amp { display: block; font-family: var(--display); font-style: italic; font-size: 0.48em; color: var(--soft); margin: 2px 0; animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%, 100% { transform: scale(1); } 18% { transform: scale(1.28); } 36% { transform: scale(1); } 52% { transform: scale(1.16); } }
.cover__date { font-family: var(--display); font-size: 22px; letter-spacing: 0.1em; }
.cover__guest { margin-top: 26px; padding-top: 20px; border-top: 1px solid currentColor; border-color: color-mix(in srgb, currentColor 35%, transparent); font-size: 14px; }
.cover__guest b { display: block; font-family: var(--display); font-weight: 400; font-size: 28px; margin-top: 2px; }
.cover__in { position: relative; padding: 48px 28px 64px; width: 100%; }
.cover__scroll { position: absolute; left: 50%; bottom: 18px; width: 1px; height: 34px; background: currentColor; opacity: 0.6; transform-origin: top; animation: drip 2s ease-in-out infinite; }
@keyframes drip { 0% { transform: scaleY(0); } 50% { transform: scaleY(1); } 100% { transform: scaleY(1) translateY(34px); opacity: 0; } }

/* kiểu "ảnh": chữ nằm trên ảnh phủ kín, ảnh tự phóng chậm */
.cover--anh { color: #fff; }
.cover--anh .cover__img { position: absolute; inset: 0; overflow: hidden; }
.cover--anh .cover__img img { width: 100%; height: 100%; object-fit: cover; animation: kenburns 22s ease-in-out infinite alternate; }
.cover--anh .cover__img::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(0, 0, 0, 0.08) 25%, rgba(0, 0, 0, 0.66)); }
.cover--anh .label, .cover--anh .cover__amp { color: rgba(255, 255, 255, 0.88); }
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.16) translateY(-2%); } }

/* kiểu "vòm": ảnh trong khung vòm, chữ bên dưới */
.cover--vom { justify-content: center; padding-top: 56px; }
.cover--vom .cover__img { width: 66%; max-width: 300px; margin: 0 auto; aspect-ratio: 3 / 4; border-radius: 999px 999px 0 0; overflow: hidden; position: relative; box-shadow: 0 0 0 8px var(--bg2), 0 0 0 9px var(--soft); }
.cover--vom .cover__img img { width: 100%; height: 100%; object-fit: cover; animation: kenburns 22s ease-in-out infinite alternate; }
.cover--vom .cover__in { padding-top: 34px; }

/* kiểu "khung": không ảnh, viền đôi và hoạ tiết */
.cover--khung { justify-content: center; }
.cover--khung::before, .cover--khung::after { content: ""; position: absolute; inset: 16px; border: 1px solid var(--soft); pointer-events: none; }
.cover--khung::after { inset: 22px; opacity: 0.5; }
.cover__mark { font-family: var(--display); font-size: 84px; line-height: 1; color: var(--accent); margin-bottom: 8px; animation: glow 3s ease-in-out infinite; }
.cover__mark svg { width: 74px; height: 74px; margin: 0 auto; display: block; }
@keyframes glow { 50% { opacity: 0.72; transform: scale(1.04); } }

/* ---------- Lễ và tiệc ---------- */
.events { display: grid; gap: 16px; margin-top: 8px; }
.event { background: var(--bg); border: 1px solid var(--line); padding: 28px 22px; }
.event h3 { font-family: var(--display); font-weight: 500; font-size: 26px; color: var(--accent); }
.event time { display: block; font-family: var(--display); font-size: 21px; margin: 8px 0 4px; }
.event p { color: var(--muted); font-size: 15px; }
.event a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 12px; padding: 0 20px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); text-decoration: none; font-size: 13px; letter-spacing: 0.06em; transition: background 0.3s, color 0.3s; }
.event a:hover { background: var(--accent); color: var(--on-accent); }

/* ---------- Đếm ngược ---------- */
.count { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 380px; margin: 0 auto; }
.count div { border: 1px solid var(--line); padding: 14px 4px; background: var(--bg); }
.count b { display: block; font-family: var(--display); font-weight: 400; font-size: 36px; line-height: 1.1; color: var(--accent); }
.count b.pop { animation: pop 0.45s var(--ease); }
@keyframes pop { 0% { transform: translateY(-40%); opacity: 0; } 100% { transform: none; opacity: 1; } }
.count span { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted); }

/* ---------- Album trượt ngang ---------- */
.album { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; margin: 6px -28px 0; padding: 6px 28px 14px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.album::-webkit-scrollbar { display: none; }
.album button { flex: 0 0 76%; padding: 0; border: 0; background: var(--line); aspect-ratio: 4 / 5; overflow: hidden; cursor: zoom-in; scroll-snap-align: center; box-shadow: 0 14px 26px -16px rgba(0, 0, 0, 0.5); }
.album img { width: 100%; height: 100%; object-fit: cover; }
.dots { display: flex; gap: 6px; justify-content: center; margin-top: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--soft); opacity: 0.35; transition: opacity 0.3s, transform 0.3s; }
.dots i.is-on { opacity: 1; transform: scale(1.4); }
.viewer { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, 0.92); display: none; place-items: center; padding: 20px; }
.viewer.is-open { display: grid; }
.viewer img { max-height: 88svh; object-fit: contain; }
.viewer button { position: absolute; top: 12px; right: 12px; width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.4); background: none; color: #fff; font-size: 22px; }

/* ---------- Xác nhận tham dự ---------- */
.rsvp { text-align: left; max-width: 400px; margin: 0 auto; }
.field { margin-bottom: 18px; }
.field label, .field legend { display: block; font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; min-height: 50px; padding: 10px 14px; font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 0; }
.field select option { color: #222; }
.field textarea { min-height: 96px; resize: vertical; }
.field fieldset { border: 0; padding: 0; margin: 0; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice label { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 50px; padding: 4px 8px; border: 1px solid var(--line); text-transform: none; letter-spacing: 0; font-size: 15px; font-weight: 400; margin: 0; cursor: pointer; background: var(--bg); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice input:checked + span { color: var(--accent); font-weight: 500; }
.choice label:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; min-height: 54px; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; }
.rsvp__done { display: none; text-align: center; }
.rsvp.is-done form { display: none; }
.rsvp.is-done .rsvp__done { display: block; animation: pop 0.6s var(--ease); }
.err { color: #c0392b; font-size: 14px; margin-top: 6px; display: none; }
.field.is-bad .err { display: block; }

/* ---------- Mừng cưới ---------- */
.gifts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 6px; }
.gift { background: var(--bg); border: 1px solid var(--line); padding: 22px; }
.gift img { width: 180px; height: 180px; object-fit: contain; margin: 10px auto; background: #fff; }
.gift p { font-size: 14px; color: var(--muted); }
.gift b { display: block; font-family: var(--display); font-weight: 500; font-size: 22px; color: var(--ink); }

.wishes { display: grid; gap: 12px; text-align: left; max-height: 460px; overflow-y: auto; padding: 2px; }
.wish { background: var(--bg); border: 1px solid var(--line); padding: 16px 18px; }
.wish p { font-family: var(--display); font-size: 19px; line-height: 1.45; }
.wish b { display: block; margin-top: 8px; font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--soft); }
.thanks .title { font-family: var(--script); font-style: var(--script-style); font-size: 50px; }
.foot { padding: 30px 28px 90px; text-align: center; font-family: var(--display); font-style: italic; font-size: 19px; color: var(--muted); border-top: 1px solid var(--line); }
.foot a { color: var(--accent); text-decoration: none; border-bottom: 1px solid currentColor; }

/* ---------- Nhạc nền, hiệu ứng rơi ---------- */
.music { position: fixed; right: 16px; bottom: 16px; z-index: 40; width: 52px; height: 52px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.6); background: var(--accent); color: var(--on-accent); display: grid; place-items: center; box-shadow: 0 10px 24px -8px rgba(0, 0, 0, 0.45); }
.music svg { width: 22px; height: 22px; }
.music.is-on svg { animation: spin 6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.fx { position: fixed; inset: 0; z-index: 30; pointer-events: none; }

/* ---------- Hiện dần khi cuộn: mỗi loại phần tử một kiểu ---------- */
.rv { opacity: 0; transition: opacity 0.9s var(--ease), transform 1s var(--ease); transition-delay: var(--d, 0s); transform: translateY(26px); }
.rv[data-rv="left"] { transform: translateX(-34px); }
.rv[data-rv="right"] { transform: translateX(34px); }
.rv[data-rv="zoom"] { transform: scale(0.88); }
.rv.is-in { opacity: 1; transform: none; }

/* Máy bật "giảm chuyển động": bỏ hiệu ứng lặp và trượt, vẫn giữ mờ dần và mở phong bì */
.reduce .rv { transform: none; }
.reduce .env, .reduce .open__btn, .reduce .cover__amp, .reduce .cover__mark, .reduce .cover__scroll,
.reduce .cover__img img, .reduce .music.is-on svg, .reduce .count b.pop { animation: none; }
.reduce .cover__names i { transform: none; }

/* ---------- Thanh chọn mẫu (chỉ ở bản xem thử) ---------- */
.demo { position: fixed; left: 0; right: 0; top: 0; z-index: 45; display: flex; gap: 4px; padding: 8px 10px; overflow-x: auto; background: rgba(255, 255, 255, 0.94); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14); font-size: 12px; scrollbar-width: none; justify-content: safe center; }
.demo::-webkit-scrollbar { display: none; }
.demo a { padding: 8px 13px; min-height: 36px; border-radius: 999px; text-decoration: none; color: #333; white-space: nowrap; border: 1px solid rgba(0, 0, 0, 0.12); }
.demo a[aria-current="true"] { background: #2a1a1a; border-color: #2a1a1a; color: #fff; }

.wait { padding: 40svh 28px 0; text-align: center; color: var(--muted); font-family: var(--display); font-size: 22px; }
.rsvp__err { color: #c0392b; font-size: 14px; margin-top: 10px; text-align: center; }
