/* Queue Board — mobile-first (320px) styles.
   Colours: only tokens from design/palette.json (light + dark). */

:root {
  --text: #1a1714;
  --text-dim: #4a443c;
  --canvas: #f4efe4;
  --surface: #fffdf8;
  --raised: #ffffff;
  --brand: #9e1f1a;
  --brand-ink: #ffffff;
  --brand-wash: #f8e4df;
  --ok: #1b5a28;
  --ok-wash: #e2f0e3;
  --warn: #6e4300;
  --warn-wash: #faecd2;
  --bad: #951b1b;
  --bad-wash: #fae2df;
  --line-strong: #6b6359;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-number: "DIN Alternate", "Bahnschrift", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --gap: 1rem;
  --tap: 3rem; /* 48px minimum touch target */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --text: #f5efe4;
    --text-dim: #c9bfae;
    --canvas: #14120f;
    --surface: #1e1b17;
    --raised: #29251f;
    --brand: #ff9584;
    --brand-ink: #1a0a07;
    --brand-wash: #3a1c17;
    --ok: #93d89e;
    --ok-wash: #15301a;
    --warn: #f2c66f;
    --warn-wash: #3a2c10;
    --bad: #ffa097;
    --bad-wash: #3d1714;
    --line-strong: #8f8578;
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--canvas);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1.125rem;
  line-height: 1.5;
  overflow-x: clip; /* sideways backstop; never on <html> */
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5rem; overflow-wrap: anywhere; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.25rem; }
p { margin: 0 0 0.75rem; }

a { color: var(--brand); text-underline-offset: 0.15em; }

:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -10rem;
  background: var(--raised);
  color: var(--text);
  padding: 0.75rem 1rem;
  border: 2px solid var(--line-strong);
  z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* ---- page frame ---- */
.site-header {
  padding: max(0.75rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.75rem max(1rem, env(safe-area-inset-left));
  border-bottom: 2px solid var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.wordmark {
  font-family: var(--font-number);
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 1rem;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
}
.wordmark-mark {
  display: inline-block;
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
}
.wordmark { min-width: 0; max-width: 100%; }
.wordmark-name { min-width: 0; overflow-wrap: anywhere; }
.tenant-logo { width: 2rem; height: 2rem; object-fit: contain; flex: none; }
.header-nav { display: flex; gap: 0.5rem; flex-wrap: wrap; min-width: 0; }

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 40rem;
  margin: 0 auto;
  padding: 1.25rem max(1rem, env(safe-area-inset-right)) 2rem max(1rem, env(safe-area-inset-left));
}
.site-footer {
  padding: 1rem max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  color: var(--text-dim);
  font-size: 0.95rem;
  border-top: 1px solid var(--line-strong);
}
.site-footer p { margin: 0; max-width: 40rem; margin-inline: auto; }
/* Standalone links in prose (footer, empty states) are thumb targets too:
   each gets the full 48px tap height without depending on line-height. */
.site-footer a, .empty a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  max-width: 100%;
  overflow-wrap: anywhere;
  touch-action: manipulation;
}

.lede { color: var(--text-dim); }

/* ---- messages (status never by colour alone: each has a text label) ---- */
.messages { list-style: none; margin: 0 0 1rem; padding: 0; display: grid; gap: 0.5rem; }
.msg {
  padding: 0.75rem 1rem;
  border-left: 6px solid currentColor;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.msg-label { font-weight: 700; margin-right: 0.25rem; }
.msg-success { color: var(--ok); background: var(--ok-wash); }
.msg-info { color: var(--text); background: var(--surface); border-left-color: var(--line-strong); }
.msg-warning { color: var(--warn); background: var(--warn-wash); }
.msg-error { color: var(--bad); background: var(--bad-wash); }

/* ---- forms ---- */
.field { margin-bottom: 1.25rem; }
.field label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.field .hint { display: block; color: var(--text-dim); font-size: 0.95rem; margin-bottom: 0.35rem; }
.field input {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 1.125rem; /* >=16px avoids iOS zoom */
  color: var(--text);
  background: var(--raised);
  border: 2px solid var(--line-strong);
  border-radius: 4px;
}
.field input[aria-invalid="true"] { border-color: var(--bad); border-width: 3px; }
.field-error {
  display: block;
  color: var(--bad);
  font-weight: 700;
  margin-top: 0.35rem;
}
.form-error {
  padding: 0.75rem 1rem;
  border-left: 6px solid var(--bad);
  background: var(--bad-wash);
  color: var(--bad);
  margin-bottom: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border-radius: 4px;
  border: 2px solid var(--text);
  background: var(--raised);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-block { display: flex; width: 100%; }
.btn-huge {
  min-height: 5.5rem;
  font-size: 1.6rem;
  font-family: var(--font-number);
  letter-spacing: 0.02em;
}
.btn-quiet { border-color: var(--line-strong); font-weight: 600; }
.btn-danger { color: var(--bad); border-color: var(--bad); }
.btn[disabled] { cursor: not-allowed; border-style: dashed; color: var(--text-dim); background: var(--surface); border-color: var(--line-strong); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.btn-row > * { flex: 1 1 8rem; min-width: 0; }
form.inline { margin: 0; }

/* ---- the ticket stub: the product's signature element ---- */
.stub {
  background: var(--surface);
  border: 2px solid var(--text);
  border-radius: 6px;
  margin: 0 0 1.25rem;
  position: relative;
}
.stub-top {
  padding: 1rem 1rem 1.25rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.stub-label {
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-dim);
}
.stub-number {
  display: block;
  font-family: var(--font-number);
  font-weight: 800;
  font-size: 4.5rem;
  line-height: 1;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}
.stub-name { min-width: 0; text-align: right; overflow-wrap: anywhere; font-weight: 700; flex: 1 1 8rem; }
.stub-perf {
  border: 0;
  border-top: 3px dashed var(--line-strong);
  margin: 0 0.5rem;
}
.stub-body { padding: 1.25rem 1rem 1rem; }
.stub-body h1 { font-size: 2rem; }
.position-big {
  font-family: var(--font-number);
  font-variant-numeric: tabular-nums;
}
.stub-called { background: var(--brand-wash); border-color: var(--brand); border-width: 4px; }
.stub-called h1 { font-size: 2.4rem; color: var(--text); }
.state-tag {
  display: inline-block;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  padding: 0.15rem 0.5rem;
  border: 2px solid currentColor;
  border-radius: 3px;
  margin-bottom: 0.5rem;
}
.state-waiting { color: var(--text-dim); }
.state-called { color: var(--brand); }
.state-served { color: var(--ok); }
.state-no_show, .state-left { color: var(--text-dim); }
.updated { color: var(--text-dim); font-size: 0.95rem; margin: 0; }
.refresh-error { color: var(--bad); font-weight: 700; font-size: 0.95rem; margin: 0.5rem 0 0; }
.refresh-error:empty { display: none; }

.ticket-actions { display: grid; gap: 0.75rem; margin-top: 1rem; }

/* ---- staff ---- */
.summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  border: 2px solid var(--text);
  border-radius: 6px;
  margin: 0 0 1.25rem;
  background: var(--surface);
}
.summary div { padding: 0.6rem 0.75rem; min-width: 0; border-bottom: 1px solid var(--line-strong); }
.summary div:nth-child(odd) { border-right: 1px solid var(--line-strong); }
.summary div:nth-last-child(-n+2) { border-bottom: 0; }
.summary dt { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); font-weight: 700; }
.summary dd { margin: 0; font-family: var(--font-number); font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.section { margin: 0 0 1.5rem; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; flex-wrap: wrap; }

.called-card {
  border: 4px solid var(--brand);
  background: var(--brand-wash);
  border-radius: 6px;
  padding: 0.9rem;
  margin-bottom: 0.75rem;
}
.called-card .who { display: flex; gap: 0.75rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.5rem; }
.called-card .num { font-family: var(--font-number); font-weight: 800; font-size: 2.25rem; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.called-card .name { font-weight: 700; font-size: 1.25rem; min-width: 0; overflow-wrap: anywhere; flex: 1 1 8rem; }
.meta { color: var(--text-dim); font-size: 0.95rem; overflow-wrap: anywhere; }
.meta a { display: inline-flex; align-items: center; min-height: var(--tap); }

.queue-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--text); }
.queue-list li {
  display: grid;
  grid-template-columns: 3.25rem minmax(0, 1fr);
  gap: 0.25rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line-strong);
}
.queue-list .num { font-family: var(--font-number); font-weight: 800; font-size: 1.75rem; line-height: 1.1; font-variant-numeric: tabular-nums; grid-row: span 2; }
.queue-list .name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.queue-list .meta { min-width: 0; }
.tag-demo {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  padding: 0 0.35rem;
  border-radius: 3px;
  vertical-align: middle;
}
.empty {
  border: 2px dashed var(--line-strong);
  border-radius: 6px;
  padding: 1rem;
  color: var(--text-dim);
}
.call-form { margin: 0 0 1.5rem; }
.call-next-who { display: block; font-size: 1rem; font-family: var(--font-body); font-weight: 600; overflow-wrap: anywhere; }
.preview-banner { padding: 0.75rem 1rem; background: var(--warn-wash); color: var(--warn); border-left: 6px solid var(--warn); margin-bottom: 1rem; }

/* ---- business notices: paused queue, demo plan ---- */
.notice {
  padding: 0.75rem 1rem;
  border-left: 6px solid var(--warn);
  background: var(--warn-wash);
  color: var(--text);
  margin: 0 0 1rem;
  overflow-wrap: anywhere;
}
.plan-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  padding: 0.5rem 0 0.75rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--line-strong);
}
.plan-bar p { margin: 0; min-width: 0; }
.steps { padding-left: 1.5rem; }
.steps li { margin-bottom: 0.4rem; }
.plain-list { padding-left: 1.25rem; }
.plain-list li { margin-bottom: 0.6rem; }
.field-check { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.25rem 0.75rem; align-items: center; }
.field-check input {
  width: 2.75rem; /* 44px target; the label beside it also toggles it */
  height: 2.75rem;
  min-height: 0;
  margin: 0;
  accent-color: var(--brand);
}
.field-check label { margin: 0; min-height: var(--tap); display: flex; align-items: center; }
.field-check .field-error { grid-column: 1 / -1; }
.field-check .terms-link { grid-column: 2; min-height: var(--tap); display: inline-flex; align-items: center; justify-self: start; }

.poster { text-align: center; }
.poster svg { width: 100%; max-width: 20rem; height: auto; background: var(--raised); }
.poster .url { overflow-wrap: anywhere; font-weight: 700; }

@media (min-width: 40rem) {
  h1 { font-size: 2.25rem; }
  .summary { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .summary div { border-bottom: 0; border-right: 1px solid var(--line-strong); }
  .summary div:last-child { border-right: 0; }
  .stub-number { font-size: 6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .site-header, .site-footer, .no-print { display: none; }
  body { background: var(--raised); }
}
