/* In Thiệp — máy in nhiệt trên bàn. Một thế giới đen trắng: mặt bàn xám, giấy in nhiệt, mực nhiệt. */
:root {
  --ink: #1a1a1e;
  --paper: #f6f6f3;
  --table-c: #5d5d5d;
  --muted: #6c6c70;
  --display: 'Archivo', 'Arial Black', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --table: none;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { overflow-x: clip; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: #0b0b0c;
  color: #eee;
  font: 400 15px/1.5 var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, input, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------------------------------------------------------------- màn chờ */
.loader {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-content: center; justify-items: center; gap: 12px;
  background: #0b0b0c; color: #d8d8d8;
  font: 600 12px/1 var(--display); font-stretch: 125%; letter-spacing: .14em; text-transform: uppercase;
  transition: opacity .6s ease .1s, visibility 0s linear .7s;
}
.is-ready .loader { opacity: 0; visibility: hidden; }
.ld-bar { width: 140px; height: 3px; background: #2a2a2c; overflow: hidden; }
.ld-bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: #e8e8e8; transition: width .25s; }
.ld-t, .ld-p { margin: 0; }
.ld-p { font: 500 11px var(--mono); letter-spacing: .06em; color: #8a8a8e; }

/* ---------------------------------------------------------------- cảnh 3D */
.stage {
  position: relative;
  height: 100vh; height: 100svh;
  min-height: 420px;
  overflow: hidden;
  background: #0b0b0c;
  outline: none;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: pan-y; cursor: pointer; }
.fail { position: absolute; inset: 0; display: grid; place-content: center; margin: 0; padding: 24px; text-align: center; color: #bbb; }

.hud {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: calc(14px + var(--safe-t)) calc(16px + var(--safe-r)) 0 calc(16px + var(--safe-l));
  pointer-events: none;
}
.hud > * { pointer-events: auto; }
.brand {
  white-space: nowrap;
  font: 700 11px/1.2 var(--display); font-stretch: 125%; letter-spacing: .12em; text-transform: uppercase;
  color: #e9e9e9; text-decoration: none; padding: 8px 0;
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.brand b { font-weight: 400; opacity: .5; margin: 0 .2em; }
.hud-btns { display: flex; gap: 8px; }
.hb {
  display: inline-flex; align-items: center; gap: 7px;
  min-height: 34px; padding: 0 12px;
  border: 1px solid rgba(255,255,255,.22); border-radius: 999px;
  background: rgba(14,14,15,.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #eee; font: 600 11px/1 var(--mono); letter-spacing: .04em; cursor: pointer; white-space: nowrap;
  transition: background .2s, opacity .2s;
}
.hb:hover { background: rgba(40,40,42,.7); }
.hb:disabled { opacity: .35; cursor: default; }
.hb i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid currentColor; }
.hb[aria-pressed="true"] i { background: currentColor; }
.hb[data-replay] i { border-radius: 0; border: 0; width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-right: 8px solid currentColor; }

.hint {
  position: absolute; left: 50%; bottom: calc(14vh + var(--safe-b)); z-index: 3;
  transform: translateX(-50%); margin: 0; pointer-events: none; white-space: nowrap;
  padding: 6px 10px; border-radius: 999px; background: rgba(12,12,13,.62);
  font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: lowercase;
  color: rgba(255,255,255,.88);
  opacity: 0; transition: opacity .4s;
}
.hint.on { opacity: 1; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .35; } }
.cta {
  position: absolute; left: 50%; bottom: calc(6vh + var(--safe-b)); z-index: 3;
  transform: translate(-50%, 8px);
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 20px;
  background: var(--ink); color: #fff; text-decoration: none;
  border: 1px solid rgba(255,255,255,.25);
  font: 800 12px/1 var(--display); font-stretch: 125%; letter-spacing: .12em; text-transform: uppercase;
  opacity: 0; pointer-events: none;
  transition: opacity .4s, transform .5s cubic-bezier(.2,.9,.3,1.2);
}
.cta.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.cta span { animation: nudge 1.4s ease-in-out infinite; }
@keyframes nudge { 50% { transform: translateY(3px); } }

/* ---------------------------------------------------------------- thiệp chi tiết */
.invite {
  position: relative; z-index: 2;
  padding: clamp(40px, 8vh, 90px) 16px calc(40px + var(--safe-b));
  background:
    radial-gradient(120% 70% at 50% 20%, rgba(0,0,0,0) 0%, rgba(0,0,0,.45) 100%),
    var(--table) 0 0 / 340px 340px,
    var(--table-c);
  box-shadow: 0 -30px 60px rgba(0,0,0,.35);
}
.slip {
  --edge: 9px;
  position: relative;
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 34px clamp(18px, 5vw, 30px) 30px;
  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 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    linear-gradient(90deg, rgba(0,0,0,.035), rgba(0,0,0,0) 8%, rgba(0,0,0,0) 92%, rgba(0,0,0,.035)),
    var(--paper);
  color: var(--ink);
  -webkit-mask:
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(var(--edge) * 2) var(--edge) repeat-x,
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / calc(var(--edge) * 2) var(--edge) repeat-x,
    linear-gradient(#000 0 0) center / 100% calc(100% - var(--edge) * 2 + 1px) no-repeat;
          mask:
    conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / calc(var(--edge) * 2) var(--edge) repeat-x,
    conic-gradient(from 135deg at top, #0000, #000 1deg 89deg, #0000 90deg) top / calc(var(--edge) * 2) var(--edge) repeat-x,
    linear-gradient(#000 0 0) center / 100% calc(100% - var(--edge) * 2 + 1px) no-repeat;
}
.slip-wrap { filter: drop-shadow(0 18px 18px rgba(0,0,0,.35)) drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.mono { font-family: var(--mono); }
.tiny { font-size: 11px; font-weight: 700; letter-spacing: .1em; margin: 0; }
.small { font-size: 13px; line-height: 1.55; }
.center { text-align: center; }
.muted { color: var(--muted); }
.row3 { display: flex; justify-content: space-between; text-transform: uppercase; font-family: var(--display); font-stretch: 125%; font-weight: 800; font-size: 10.5px; letter-spacing: .06em; }
.big {
  margin: 6px 0 2px; text-align: center;
  font: 900 clamp(40px, 13.4vw, 60px)/1.04 var(--display); font-stretch: 125%;
  letter-spacing: -.01em;
}
.names {
  margin: 4px 0 14px; text-align: center;
  font: 800 clamp(13px, 3.6vw, 16px)/1.3 var(--display); font-stretch: 125%; letter-spacing: .08em; text-transform: uppercase;
}
.names i { font-style: normal; font-weight: 600; margin: 0 .3em; }
.meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-weight: 500; letter-spacing: .02em; text-transform: none; }
.meta b { font-weight: 800; }
hr.dots { border: 0; height: 3px; margin: 16px 0; background: radial-gradient(circle at 1.5px 1.5px, var(--ink) 1.2px, transparent 1.4px) 0 0 / 6px 3px repeat-x; }
.doodle { margin: 4px 0 0; }
.doodle img { display: block; width: 100%; height: auto; mix-blend-mode: multiply; image-rendering: auto; }
.lead { margin: 0; text-align: center; font: 600 14px/1.6 var(--mono); }
.lead b { font: 900 1.25em/1.3 var(--display); font-stretch: 125%; text-transform: uppercase; letter-spacing: .02em; display: inline-block; margin: 2px 0; }
.block { display: grid; gap: 10px; }
.date { margin: 4px 0 0; text-align: center; font: 600 13px/1.2 var(--mono); text-transform: uppercase; letter-spacing: .14em; }
.date b { display: block; margin-top: 6px; font: 900 clamp(26px, 8vw, 34px)/1 var(--display); font-stretch: 125%; letter-spacing: .02em; }
.lines { margin: 4px 0 0; display: grid; gap: 4px; }
.lines div { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.lines dt { order: 0; }
.lines dd { order: 2; margin: 0; font-weight: 800; }
.lines div::after { content: ''; order: 1; flex: 1; border-bottom: 2px dotted rgba(26,26,30,.55); transform: translateY(-4px); }
.venue { margin: 0; text-align: center; font: 600 15px/1.35 var(--mono); }
.venue b { display: block; font: 900 26px/1.1 var(--display); font-stretch: 125%; text-transform: uppercase; margin-top: 4px; }
.btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 16px;
  background: var(--ink); color: #fff; border: 1.5px solid var(--ink); border-radius: 0;
  font: 800 11px/1 var(--display); font-stretch: 125%; letter-spacing: .1em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; transition: transform .15s, background .2s, color .2s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); }
.fam { grid-template-columns: 1fr 1fr; gap: 14px; text-align: center; }
.fam h2 { margin-bottom: 6px; }
.fam p { margin: 0; font-size: 13px; line-height: 1.55; font-weight: 500; }
.cd { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; }
.cd p { margin: 0; display: grid; gap: 3px; }
.cd b { font: 900 28px/1 var(--display); font-stretch: 125%; font-variant-numeric: tabular-nums; }
.cd span { font-size: 11px; color: var(--muted); }
.cd-done { display: none; margin: 0; }
[data-countdown].done .cd { display: none; }
[data-countdown].done .cd-done { display: block; }
.bill table { width: 100%; border-collapse: collapse; font-size: 13px; }
.bill th { text-align: left; font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; border-bottom: 2px dashed rgba(26,26,30,.5); padding: 0 0 6px; }
.bill td { padding: 5px 0; vertical-align: top; }
.bill th:last-child, .bill td:last-child { text-align: right; white-space: nowrap; }
.bill th:first-child, .bill td:first-child { width: 2.6em; }
.bill tfoot td { border-top: 2px dashed rgba(26,26,30,.5); padding-top: 8px; font: 900 15px/1.2 var(--display); font-stretch: 125%; text-transform: uppercase; }
.bill p { margin: 2px 0 0; }

/* hồi âm */
.rsvp { display: grid; gap: 12px; margin-top: 4px; }
.rsvp fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.choice { display: grid; gap: 6px; }
.choice label { cursor: pointer; display: block; }
.choice input, .chips input { position: absolute; opacity: 0; pointer-events: none; }
.choice span { display: block; padding: 8px 10px; border: 1.5px solid rgba(26,26,30,.25); font-weight: 700; font-size: 14px; white-space: pre; transition: background .15s, color .15s, border-color .15s; }
.choice input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.choice input:focus-visible + span, .chips input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.field { display: grid; gap: 4px; }
.field > span, .chips legend { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.field small { font-size: 10.5px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--muted); }
.field input, .field textarea {
  width: 100%; min-height: 40px; padding: 6px 2px; border: 0; border-bottom: 2px dotted rgba(26,26,30,.6);
  background: transparent; color: var(--ink); font-size: 16px; border-radius: 0; outline: none; resize: vertical;
}
.field input:focus, .field textarea:focus { border-bottom-style: solid; border-bottom-color: var(--ink); }
.field input::placeholder, .field textarea::placeholder { color: rgba(26,26,30,.35); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips legend { width: 100%; margin-bottom: 6px; padding: 0; }
.chips label { cursor: pointer; }
.chips span { display: inline-block; padding: 7px 10px; border: 1.5px solid rgba(26,26,30,.3); font-size: 13px; font-weight: 600; }
.chips input:checked + span { border-color: var(--ink); background: var(--ink); color: #fff; }
.stepper { display: inline-flex; align-items: center; gap: 0; border: 1.5px solid var(--ink); width: max-content; }
.stepper button { width: 44px; height: 38px; border: 0; background: transparent; cursor: pointer; font-size: 18px; font-weight: 700; color: var(--ink); }
.stepper input { width: 48px; height: 38px; border: 0; border-left: 1.5px solid var(--ink); border-right: 1.5px solid var(--ink); text-align: center; background: transparent; color: var(--ink); font-size: 16px; font-weight: 800; -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.err { margin: 0; padding: 8px 10px; border: 1.5px dashed var(--ink); font-size: 13px; font-weight: 700; }
.send { min-height: 46px; font-size: 12px; }
.demo { margin: 0; color: var(--muted); font-size: 11.5px; }
.demo code { font-size: 1em; }
.thanks { display: grid; gap: 8px; justify-items: center; text-align: center; outline: none; padding: 6px 0; }
.thanks h3 { margin: 6px 0 0; font: 900 24px/1.1 var(--display); font-stretch: 125%; text-transform: uppercase; }
.thanks .row3 { width: 100%; }
.thanks.printing { animation: feed 1.1s steps(9, end) both; }
@keyframes feed { from { clip-path: inset(0 0 100% 0); } to { clip-path: inset(0 0 0 0); } }

.slip-foot { display: grid; gap: 8px; justify-items: center; padding-top: 4px; }
.barcode { display: flex; align-items: stretch; height: 54px; }
.barcode i { display: block; width: calc(var(--w) * 1.6px); margin-right: calc(var(--g) * 1.6px); background: var(--ink); }

.end { width: min(440px, 100%); margin: 34px auto 0; display: grid; gap: 14px; justify-items: center; text-align: center; color: #e2e2e2; }
.end .btn.ghost { color: #f0f0f0; border-color: rgba(255,255,255,.6); }
.credits { margin: 0; font-size: 11.5px; line-height: 1.6; color: rgba(255,255,255,.62); text-shadow: 0 1px 3px rgba(0,0,0,.6); }

/* ---------------------------------------------------------------- chế độ clip / xuất video */
[data-mode="clip"] .invite, [data-mode="clip"] .hint, [data-mode="clip"] .cta, [data-mode="clip"] .brand, [data-mode="clip"] [data-replay] { display: none !important; }
[data-mode="clip"] body { overflow: hidden; }
[data-mode="render"] body { overflow: hidden; background: #000; }
[data-mode="render"] .invite, [data-mode="render"] .hud, [data-mode="render"] .hint, [data-mode="render"] .cta, [data-mode="render"] .loader { display: none !important; }
[data-mode="render"] .stage { height: auto; min-height: 0; }
[data-mode="render"] .stage canvas { position: static; }
.no-3d .stage { height: 50vh; min-height: 300px; }

/* ---------------------------------------------------------------- màn hình nhỏ, cảm ứng */
@media (orientation: portrait) and (max-width: 1100px), (max-width: 560px) {
  .brand { white-space: normal; max-width: 40vw; }
}
@media (orientation: landscape) and (max-height: 520px) {
  .hint { bottom: calc(18vh + var(--safe-b)); }
  .cta { bottom: calc(4vh + var(--safe-b)); }
}
@media (pointer: coarse) {
  .hb { min-height: 44px; padding: 0 14px; }
  .btn { min-height: 44px; }
  .choice span, .chips span { padding-top: 11px; padding-bottom: 11px; }
  .stepper button, .stepper input { height: 44px; }
}
@media (max-width: 380px) {
  .hb span { display: none; }
  .hb { width: 44px; justify-content: center; padding: 0; }
}
