/* Powwow Hub: design tokens and components.

   Every colour is a token. Text tokens are measured against the surfaces they
   sit on (WCAG AA, 4.5:1) by tests/test_contrast.py, which reads this file. */

:root {
  --bg: #faf6ef;
  --surface: #ffffff;
  --surface-2: #f4ecdf;
  --ink: #241c16;
  --ink-2: #5a4b40;
  --line: #e4d9c8;
  --brand: #9a2b1c;
  --brand-ink: #ffffff;
  --accent: #0e6a6a;
  --ok: #1d6b3d;
  --ok-bg: #e2f2e6;
  --warn: #7a5200;
  --warn-bg: #fff1d1;
  --danger: #a4262c;
  --danger-bg: #fbe6e7;
  --info: #135f73;
  --info-bg: #e1f0f4;
  --tab-ink: #5a4b40;
  --tab-bg: #ffffff;
  /* QR codes stay pure black on white in every theme so scanners read them. */
  --qr-paper: #ffffff;
  --shadow: 0 1px 2px rgb(36 28 22 / 0.06), 0 4px 16px rgb(36 28 22 / 0.06);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17130f;
    --surface: #221c18;
    --surface-2: #2e2621;
    --ink: #f4ece3;
    --ink-2: #c8bbae;
    --line: #443932;
    --brand: #f0836d;
    --brand-ink: #2a0d08;
    --accent: #6fcfcf;
    --ok: #7fd9a4;
    --ok-bg: #173326;
    --warn: #f6c85a;
    --warn-bg: #3a2d10;
    --danger: #ff9a9e;
    --danger-bg: #44201f;
    --info: #8fd3e3;
    --info-bg: #15313a;
    --tab-ink: #c8bbae;
    --tab-bg: #221c18;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.3);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; font-weight: 700; }
h1 { font-size: 1.625rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75em; }
a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

[hidden] { display: none !important; }

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 100;
}
.skip:focus { left: 8px; }

/* ---------- chrome ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brandname {
  font-weight: 700;
  color: var(--brand);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.topbar .offline { color: var(--danger); font-weight: 700; }

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
}

.page-loading { padding: 48px 0; text-align: center; color: var(--ink-2); }

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--tab-bg);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  color: var(--tab-ink);
  text-decoration: none;
  text-align: center;
  padding: 8px 2px 10px;
  font-size: 0.8125rem;
  font-weight: 700;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tabbar a[aria-current="page"] { color: var(--brand); box-shadow: inset 0 3px 0 0 var(--brand); }

.staffnav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin: 0 0 16px;
  padding-bottom: 4px;
  scrollbar-width: none;
}
.staffnav::-webkit-scrollbar { display: none; }
.staffnav a {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.staffnav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn[aria-busy="true"] { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: var(--brand-ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--brand-ink); }
.btn-primary:hover, .btn-ok:hover, .btn-danger:hover { background: var(--brand); filter: brightness(1.1); }
.btn-ok:hover { background: var(--ok); }
.btn-danger:hover { background: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-sm { min-height: 40px; padding: 6px 12px; font-size: 0.9375rem; border-radius: 10px; }
.btn-block { width: 100%; }

.linklike {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- chips, alerts, cards ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 700;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--ink-2);
}
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-brand { background: var(--brand); color: var(--brand-ink); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-info { background: var(--info-bg); color: var(--info); }

.alert {
  padding: 12px 14px;
  border-radius: 12px;
  margin: 0 0 12px;
  border-left: 5px solid;
}
.alert p:last-child { margin-bottom: 0; }
.alert a { color: inherit; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.alert-info { background: var(--info-bg); color: var(--info); border-color: var(--info); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }

.hero { border-left: 6px solid var(--brand); }
.eyebrow {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-2);
  margin: 0 0 4px;
}
.lead { color: var(--ink-2); font-size: 1.0625rem; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.08em; }
.footnote { font-size: 0.875rem; color: var(--ink-2); }

/* ---------- layout helpers ---------- */

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
/* The list itself is the card: rows carry the side padding (no negative margins). */
.list.card { padding: 4px 0; }
.list.card > li { padding: 12px 16px; margin: 0; }
.list a { color: inherit; text-decoration: none; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row > div:first-child { flex: 1; min-width: 0; }
.row.actions { margin-top: 14px; flex-wrap: wrap; }
.row.actions .btn { flex: 1 1 auto; }
.col { display: flex; flex-direction: column; gap: 4px; }
.right { text-align: right; flex: none; }
.time { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 420px) {
  .grid2 { grid-template-columns: 1fr; }
}

.quick { margin: 0 0 16px; }
.quick .btn { width: 100%; }

.day {
  margin: 16px 0 4px;
  font-size: 0.9375rem;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.day:first-of-type { margin-top: 0; }

.next { border-left: 6px solid var(--accent); }
.next.is-open { border-left-color: var(--ok); }
.next.is-live { border-left-color: var(--brand); }
.next-when { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.next-time { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.countdown { font-size: 1.125rem; font-weight: 700; color: var(--brand); margin: 4px 0; }

/* ---------- forms ---------- */

.form > * + * { margin-top: 14px; }
.form h2 { margin-bottom: 0; }
.field { display: block; }
.field-label { display: block; font-weight: 600; margin: 0 0 4px; }
.hint { display: block; font-size: 0.875rem; color: var(--ink-2); margin-top: 4px; }
/* A one-line subtitle that belongs to the heading right above it. */
.under-heading { margin-top: -10px; }

input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--ink-2);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 48px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }
input::placeholder, textarea::placeholder { color: var(--ink-2); opacity: 1; }
textarea { min-height: 80px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 24px; height: 24px; min-height: 0; margin: 0; flex: none; }
.form-error { margin-bottom: 14px; }

.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.filters > :first-child { grid-column: 1 / -1; }

.facts { display: grid; gap: 0; margin: 0 0 12px; }
.facts div { display: flex; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 6px 0; }
.facts dt { color: var(--ink-2); font-weight: 600; }
.facts dd { margin: 0; text-align: right; }

/* ---------- pass, QR, stats ---------- */

.pass { border-top: 5px solid var(--brand); }
/* Label and number sit beside the code; the name and details get the whole
   width underneath, so a long name never runs under the QR. */
.pass-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "top qr" "id id";
  column-gap: 16px;
  row-gap: 4px;
  align-items: start;
}
.pass-top { grid-area: top; min-width: 0; }
.pass-id { grid-area: id; min-width: 0; }
.pass-id h1, .pass-id h2 { overflow-wrap: anywhere; }
/* A six-character code must stay on one line beside the code box on a phone. */
.pass .big-number.mono { font-size: 1.75rem; white-space: nowrap; }
.camp-status { margin-top: 12px; margin-bottom: 8px; }
.big-number {
  font-size: 2.75rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.qr {
  flex: none;
  background: var(--qr-paper);
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  line-height: 0;
}
.qr svg { display: block; }

.stats { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.stat { text-align: center; }
.stat b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.8125rem; color: var(--ink-2); }

.ledger li { display: flex; justify-content: space-between; gap: 12px; }
.pts { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pts.neg { color: var(--danger); }
.pts.pos { color: var(--ok); }
.struck { text-decoration: line-through; color: var(--ink-2); }
.ledger .struck > div { text-decoration: line-through; }
.ledger .btn { text-decoration: none; }

/* ---------- tables, details ---------- */

.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th, .table td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--line); }
/* Headers never wrap: on a phone the name column gives way instead. */
.table th { font-size: 0.8125rem; text-transform: uppercase; letter-spacing: 0.02em; color: var(--ink-2); white-space: nowrap; padding-left: 4px; padding-right: 4px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

details.card summary {
  cursor: pointer;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  list-style: none;
}
/* The trailing count stays on one line; the title is what wraps. */
details.card summary > span:last-child { flex: none; white-space: nowrap; font-weight: 400; }
/* Title left; the count sits beside the +/- toggle on the right. */
details.card summary > span:nth-child(2) { margin-left: auto; }
details.card summary::-webkit-details-marker { display: none; }
details.card summary::after { content: "+"; font-size: 1.25rem; color: var(--ink-2); }
details.card[open] summary::after { content: "\2212"; }
details.card[open] summary { margin-bottom: 12px; }

/* ---------- check-in desk ---------- */

.scan-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.result { border-radius: var(--radius); padding: 20px 16px; text-align: center; margin: 0 0 16px; }
.result h2 { color: inherit; }
.result p:last-child { margin-bottom: 0; }
.result-ok { background: var(--ok-bg); color: var(--ok); }
.result-warn { background: var(--warn-bg); color: var(--warn); }
.result-danger { background: var(--danger-bg); color: var(--danger); }
.result-icon { font-size: 3rem; line-height: 1; }
.dancer-card .alert { margin-bottom: 8px; }

.scanner { margin: 0 0 16px; }
.scanner video { width: 100%; border-radius: var(--radius); background: var(--qr-paper); display: block; aspect-ratio: 4 / 3; }

.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--ink-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  margin: 0 0 16px;
  background: var(--surface);
}

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 12px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 44px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
/* The count on a selected tab must follow the filled tab's ink, not --ink-2. */
.tabs button[aria-selected="true"] .muted { color: inherit; }

.audit { padding-left: 20px; margin: 0; }
.audit li { padding: 6px 0; border-bottom: 1px solid var(--line); }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(88px + env(safe-area-inset-bottom));
  background: var(--ink);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 50;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { opacity: 1; }
.toast.kind-danger { background: var(--danger); color: var(--brand-ink); }
.toast.kind-ok { background: var(--ok); color: var(--brand-ink); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
