/* Wedding check-in — "ivory stationery" theme.
   Serif (Cormorant Garamond, self-hosted so it works offline) for names and headings,
   system sans with CJK fallback for everything staff scan quickly.
   Side colours are fixed by the brief: CY #366092, Mag #ad2c6c, VIP #bf8f00, arrived #1e7a46. */

@font-face { font-family: "Cormorant"; src: url("fonts/cormorant.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Cormorant"; src: url("fonts/cormorant-italic.woff") format("woff"); font-weight: 500; font-style: italic; font-display: swap; }

:root {
  --cy: #366092; --mag: #ad2c6c; --vip: #bf8f00; --in: #1e7a46; --baby: #e67e22;
  --cy-soft: #e8eef6; --mag-soft: #f7e8ef; --vip-soft: #f7efd9;
  --bg: #fbf7f0;          /* ivory paper */
  --card: #fffdf9;
  --text: #2b2421;        /* warm ink */
  --muted: #74675e;       /* 5.0:1 on --bg */
  --line: #ebe2d4;
  --gold: #a07a2c;        /* ornament + progress; 4.1:1, used for large/decorative only */
  --gold-soft: #f3e9d2;
  --ink-btn: #2b2421; --ink-btn-text: #fbf7f0;
  --in-bg: #e9f4ed; --in-line: #bfdfca;
  --warn: #a8261d; --warn-bg: #fbe9e6;
  --shadow: 0 1px 2px rgb(60 40 20 / .05), 0 6px 18px -8px rgb(60 40 20 / .18);
  --serif: "Cormorant", "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --sans: -apple-system, "Segoe UI", "Noto Sans", "PingFang SC", "Noto Sans CJK SC", Arial, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --cy: #7ea6d8; --mag: #e47aa9; --vip: #e0b84a; --in: #5cc68a;
    --cy-soft: #1d2836; --mag-soft: #33202a; --vip-soft: #2f2816;
    --bg: #17130f; --card: #211b16; --text: #f3ece2; --muted: #b5a899; --line: #382f27;
    --gold: #d4b06a; --gold-soft: #2e2617;
    --ink-btn: #f3ece2; --ink-btn-text: #17130f;
    --in-bg: #16291d; --in-line: #275238;
    --warn: #ff9a8f; --warn-bg: #3a1b17;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 8px 20px -10px rgb(0 0 0 / .6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 var(--sans);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
::selection { background: var(--gold-soft); color: var(--text); }
input { caret-color: var(--gold); }
button, input, select { font: inherit; color: inherit; }
button {
  cursor: pointer; border: 0; border-radius: 12px; background: var(--gold-soft); color: var(--text);
  padding: 10px 16px; min-height: 44px; font-weight: 600;
  transition: transform .15s var(--ease), background-color .2s, color .2s, box-shadow .2s;
}
button:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
button.primary { background: var(--ink-btn); color: var(--ink-btn-text); }
button.danger { background: var(--warn-bg); color: var(--warn); }
input, select {
  border: 1px solid var(--line); border-radius: 12px; background: var(--card);
  padding: 10px 14px; min-height: 48px; width: 100%;
  font-weight: 400; color: var(--text);
}
input::placeholder { color: var(--muted); }
.hidden { display: none !important; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Monogram ---------- */
.mono { font-variant-numeric: lining-nums; display: inline-flex; align-items: baseline; gap: .3em; font-family: var(--serif); font-weight: 600; letter-spacing: .01em; }
.mono .amp { font-style: italic; font-weight: 500; color: var(--gold); }
.xi { font-family: "Songti SC", "STSong", "Noto Serif CJK SC", serif; color: #b3261e; font-weight: 700; }
@media (prefers-color-scheme: dark) { .xi { color: #ff7d6e; } }

/* ---------- Unlock ---------- */
.unlock { min-height: 100vh; display: grid; place-items: center; padding: 32px 20px; }
.unlock form {
  width: min(440px, 100%); background: var(--card); border-radius: 22px; padding: 40px 32px 28px;
  display: grid; gap: 16px; box-shadow: var(--shadow); text-align: center;
  border: 1px solid var(--line); position: relative;
}
.unlock form::before { /* inner hairline frame, like an invitation card */
  content: ""; position: absolute; inset: 8px; border: 1px solid var(--gold-soft); border-radius: 16px; pointer-events: none;
}
.unlock .xi { font-size: 44px; line-height: 1; }
.unlock h1 { margin: 0; font-size: 46px; line-height: 1.05; font-weight: 600; justify-content: center; display: flex; }
.unlock .date { margin: -6px 0 10px; font-family: var(--serif); font-style: italic; font-size: 21px; color: var(--muted); }
.unlock label { display: grid; gap: 6px; text-align: left; font-size: 15px; font-weight: 600; color: var(--muted); }
.unlock button.primary { min-height: 54px; font-size: 18px; margin-top: 4px; }
.err { color: var(--warn); min-height: 1.3em; margin: 0; font-size: 15px; }

/* ---------- Header ---------- */
header {
  position: sticky; top: 0; z-index: 5; padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 0 10px; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 30px; line-height: 1; flex: none; }
.topbar .xi { font-size: 24px; }
.tally { margin-left: auto; display: flex; align-items: baseline; gap: 6px; }
.count { font-family: var(--serif); font-size: 32px; font-weight: 700; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.tally .lbl { font-size: 14px; color: var(--muted); }
.sync {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; background: var(--in-bg); color: var(--in);
}
.sync::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sync.off { background: var(--warn-bg); color: var(--warn); }
.progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), #d9b45d); transition: width .6s var(--ease); }

nav.modes { display: flex; align-items: center; gap: 4px; margin: 12px 0 10px; padding: 4px; background: var(--gold-soft); border-radius: 14px; }
nav.modes button { flex: 1 1 0; min-width: 0; background: transparent; min-height: 46px; font-size: 17px; color: var(--muted); }
nav.modes button[aria-pressed="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.searchrow { position: relative; padding: 0 0 10px; }
.searchrow .ico { position: absolute; left: 16px; top: 15px; color: var(--muted); width: 22px; height: 22px; pointer-events: none; }
.searchrow input { min-height: 54px; padding-left: 50px; font-size: 18px; border-radius: 14px; box-shadow: inset 0 1px 2px rgb(60 40 20 / .04); }
.searchrow input:focus { border-color: var(--gold); }
.searchrow input::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; cursor: pointer; border-radius: 50%;
  background: var(--muted) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fbf7f0' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M8 8l8 8M16 8l-8 8'/%3E%3C/svg%3E") center / 14px no-repeat;
}
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button {
  white-space: nowrap; min-height: 40px; padding: 6px 14px; border-radius: 999px; font-size: 15px;
  background: transparent; border: 1px solid var(--line); color: var(--text);
  display: inline-flex; align-items: center; gap: 7px;
}
.filters button .n { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.filters button .dot { width: 9px; height: 9px; border-radius: 50%; }
.filters button[aria-pressed="true"] { background: var(--ink-btn); border-color: var(--ink-btn); color: var(--ink-btn-text); }
.filters button[aria-pressed="true"] .n { color: inherit; opacity: .75; }

/* ---------- Tables & cards ---------- */
main { padding: 6px 16px 48px; }
.tablegroup { margin: 26px 0 8px; scroll-margin-top: 240px; }
.tablehead { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; padding: 0 2px; font-family: var(--serif); font-weight: 600; font-size: 30px; line-height: 1.1; font-variant-numeric: lining-nums; }
.tablehead::after { content: ""; flex: 1; order: 2; height: 1px; background: linear-gradient(90deg, var(--line), transparent); margin: 0 4px; }
.tablehead .side { order: 1; font-family: var(--sans); font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.tablehead .side.CY { background: var(--cy-soft); color: var(--cy); }
.tablehead .side.Mag { background: var(--mag-soft); color: var(--mag); }
.tablehead .side.VIP { background: var(--vip-soft); color: #7a5b00; }
@media (prefers-color-scheme: dark) { .tablehead .side.VIP { color: var(--vip); } }
.tablehead .baby { order: 1; }
.tablehead .tc { order: 3; font-family: var(--sans); font-size: 15px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.tablehead .tc.full { color: var(--in); }

.cards { display: grid; gap: 12px; }
@media (min-width: 820px) { .cards { grid-template-columns: 1fr 1fr; align-items: start; } }
.card { background: var(--card); border-radius: 18px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
.famhead { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px; border-bottom: 1px solid var(--line); }
.famhead .lbl { flex: 1; min-width: 0; font-size: 15px; color: var(--muted); overflow-wrap: anywhere; }
.famhead .lbl b { color: var(--text); font-weight: 600; }
.famhead button { min-height: 40px; font-size: 15px; padding: 8px 14px; background: transparent; border: 1px solid var(--line); }
.famhead button.allin { background: var(--in-bg); border-color: var(--in-line); color: var(--in); }
.famhead button.armed, .ck.armed { background: var(--warn-bg); border-color: transparent; color: var(--warn); }

.row { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 14px; border-top: 1px solid var(--line); transition: background-color .4s; }
.card > .row:first-child, .famhead + .row { border-top: 0; }
.row.in { background: var(--in-bg); }
.chip {
  flex: none; min-width: 40px; padding: 3px 8px; border-radius: 8px; text-align: center;
  font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: #fff;
}
.chip.CY { background: var(--cy); } .chip.Mag { background: var(--mag); }
.chip.VIP { background: var(--vip); color: #2b2421; } /* dark text: white on #bf8f00 fails contrast */
@media (prefers-color-scheme: dark) { .chip.CY, .chip.Mag { color: #17130f; } }
.who { flex: 1; min-width: 0; }
.who .nm { font-weight: 600; font-size: 19px; line-height: 1.25; display: flex; align-items: center; gap: 7px; overflow-wrap: anywhere; }
.who .sub { font-size: 14px; color: var(--muted); margin-top: 1px; }
.row.in .who .sub { color: var(--in); }
.ck {
  flex: none; min-width: 128px; min-height: 52px; font-size: 17px; border-radius: 14px;
  background: var(--ink-btn); color: var(--ink-btn-text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.row.in .ck { background: transparent; color: var(--in); box-shadow: inset 0 0 0 1.5px var(--in-line); }
.row.in .ck.armed { box-shadow: none; }
.edit { flex: none; min-width: 44px; min-height: 44px; padding: 0; background: transparent; color: var(--muted); display: grid; place-items: center; }
.edit:hover { color: var(--text); }
.baby { width: 22px; height: 22px; flex: none; }

/* The one authored moment: a guest arrives. Gold glow sweeps the row, the tick draws itself. */
.row.just { animation: arrive 1.1s var(--ease); }
.row.just .ck .ico path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw .5s .1s var(--ease) forwards; }
@keyframes arrive {
  0% { background: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold); }
  100% { background: var(--in-bg); box-shadow: inset 0 0 0 0 transparent; }
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.empty { text-align: center; padding: 64px 10px; color: var(--muted); font-family: var(--serif); font-size: 26px; font-style: italic; }
.empty small { display: block; margin-top: 8px; font: 15px/1.4 var(--sans); font-style: normal; }
.foot { text-align: center; font-size: 13px; color: var(--muted); padding: 28px 0 8px; }

/* ---------- Find table ---------- */
.results { display: grid; gap: 8px; }
@media (min-width: 820px) { .results { grid-template-columns: 1fr 1fr; } }
.results button {
  display: flex; align-items: center; gap: 12px; text-align: left; background: var(--card);
  border: 1px solid var(--line); padding: 14px 16px; border-radius: 16px; box-shadow: var(--shadow); min-height: 64px;
}
.results .nm { flex: 1; font-size: 19px; }
.results .where { font-size: 15px; color: var(--muted); font-weight: 500; }
.results .where.in { color: var(--in); }

.found { text-align: center; padding: 16px 0 36px; }
.found .welcome { font-family: var(--serif); font-style: italic; font-size: 26px; color: var(--muted); margin: 6px 0 0; }
.found .gname { font-family: var(--serif); font-size: clamp(40px, 6vw, 60px); font-weight: 600; line-height: 1.1; overflow-wrap: anywhere; margin: 2px 0 18px; text-wrap: balance; }
.found .join { font-size: 15px; font-weight: 600; color: var(--muted); }
.found .bigtable {
  font-family: var(--serif); font-size: clamp(110px, 22vw, 200px); font-weight: 700; line-height: .9;
  margin: 2px 0 6px; font-variant-numeric: lining-nums;
}
.found .bigtable.CY { color: var(--cy); } .found .bigtable.Mag { color: var(--mag); } .found .bigtable.VIP { color: var(--vip); }
.found .sidelbl { color: var(--muted); }
.found .mates { color: var(--muted); margin: 14px auto 0; max-width: 620px; text-wrap: pretty; }
.found .actions { display: flex; gap: 10px; justify-content: center; margin: 22px 0 6px; flex-wrap: wrap; }
.found .actions button { min-width: 170px; min-height: 56px; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.found .actions button.done { background: var(--in-bg); color: var(--in); }
.found .actions button.armed { background: var(--warn-bg); color: var(--warn); }
.plan { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; max-width: 640px; margin: 26px auto 0; padding: 20px; border: 1px solid var(--line); border-radius: 22px; background: var(--card); }
.plan div {
  border: 1.5px solid var(--line); border-radius: 50%; aspect-ratio: 1; display: grid; place-items: center;
  font-weight: 700; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.plan div.hit { border-color: transparent; color: #fff; transform: scale(1.12); box-shadow: 0 0 0 4px var(--card), 0 0 0 6px var(--gold); }
.plan div.hit.CY { background: var(--cy); } .plan div.hit.Mag { background: var(--mag); } .plan div.hit.VIP { background: var(--vip); color: #2b2421; }

/* ---------- Admin ---------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px; margin: 14px 0; display: grid; gap: 12px; box-shadow: var(--shadow); }
.panel h2 { margin: 0; font-family: var(--serif); font-size: 26px; font-weight: 600; }
.panel label { display: grid; gap: 6px; font-size: 15px; font-weight: 600; color: var(--muted); }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.panel label.check { display: flex; align-items: center; gap: 12px; min-height: 48px; color: var(--text); font-weight: 500; font-size: 17px; cursor: pointer; }
.panel label.check input { width: 24px; height: 24px; min-height: 0; margin: 0; flex: none; accent-color: var(--in); }
.panel select { -webkit-appearance: none; appearance: none; padding-right: 40px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2374675e' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 12px center / 18px no-repeat; }
.audit { font-size: 14px; max-height: 360px; overflow: auto; }
.audit div { padding: 8px 0; border-top: 1px solid var(--line); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink-btn); color: var(--ink-btn-text); padding: 8px 8px 8px 18px; border-radius: 16px; z-index: 20;
  max-width: min(560px, 92vw); display: flex; align-items: center; gap: 14px; box-shadow: 0 12px 30px -10px rgb(0 0 0 / .45);
  animation: rise .35s var(--ease);
}
.toast:not(:has(button)) { padding: 12px 20px; }
.toast button { background: color-mix(in srgb, var(--ink-btn-text) 16%, transparent); color: inherit; min-height: 40px; padding: 6px 16px; }
@keyframes rise { from { transform: translate(-50%, 16px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .row.just .ck .ico path { stroke-dashoffset: 0; }
}

/* Phones: keep the header compact so more guests fit. */
@media (max-width: 600px) {
  .topbar h1 { font-size: 24px; }
  .count { font-size: 26px; }
  .tally .lbl { display: none; }
  .tablehead { font-size: 26px; }
  .ck { min-width: 104px; }
}
