/* Booth-floor UI: dark to cut glare under trade-show lighting, large touch
   targets, and nothing that needs a second look while talking to someone. */

:root {
  --bg: #0b1220;
  --panel: #131c2e;
  --line: #24304a;
  --text: #f2f6fd;
  /* Secondary text sits at ~9:1 rather than the usual ~4.5. Booth lighting is
     harsh, phones are held at arm's length, and reps are reading while talking
     to someone -- the AA floor is not enough here. */
  --muted: #b8c4da;
  --ok: #4ade80;
  --warn: #fbbf24;
  --accent: #d3222a;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* The app shows exactly one panel at a time by toggling the `hidden` attribute.
   `[hidden]` is a user-agent rule, so any class selector setting `display`
   (.screen, main, .sheet below) silently beats it and every panel renders at
   once. This must stay above those rules and keep !important. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}

.screen {
  display: grid; place-items: center; min-height: 100dvh; padding: 24px;
}
.panel {
  max-width: 22rem; text-align: center;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 24px;
}
.panel h1 { margin: 0 0 12px; font-size: 1.4rem; }
.muted { color: var(--muted); font-size: 0.95rem; }

main { display: flex; flex-direction: column; min-height: 100dvh; }

header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  border-bottom: 1px solid var(--line); background: var(--panel);
}
.sponsor { font-weight: 650; font-size: 1.1rem; line-height: 1.2; }
.sub { color: var(--muted); font-size: 0.875rem; margin-top: 3px; }
.tally { text-align: right; flex: none; }
.count { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.pending { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.pending.warn { color: var(--warn); font-weight: 600; }

.viewport {
  position: relative; flex: 1; min-height: 0;
  display: grid; place-items: center; overflow: hidden; background: #000;
}
video { width: 100%; height: 100%; object-fit: cover; }

/* Framing guide. Purely visual - decoding uses the whole frame, so a badge
   slightly outside the box still scans. */
.reticle {
  position: absolute; width: min(62vw, 260px); aspect-ratio: 1;
  border: 3px solid rgba(255, 255, 255, 0.95); border-radius: 20px;
  /* Dim the surround hard. This is what keeps the status bar and reticle
     legible when the camera is pointed at a white badge under a spotlight. */
  box-shadow: 0 0 0 100vmax rgba(3, 7, 18, 0.62);
}

.flash {
  position: absolute; inset: 0; opacity: 0; pointer-events: none;
  transition: opacity 140ms ease;
}
.flash.show { opacity: 1; }
.flash.ok { background: rgba(34, 197, 94, 0.55); }
.flash.warn { background: rgba(245, 158, 11, 0.55); }

/* Sits over live video, so its background must not be translucent: the frame
   behind it changes every time the rep moves, and a see-through bar drifts in
   and out of legibility. Solid panel colour, fixed contrast. */
.status {
  position: absolute; bottom: 16px; left: 16px; right: 16px;
  text-align: center; font-size: 0.95rem; font-weight: 500; color: var(--text);
  background: rgba(11, 18, 32, 0.94); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; margin: 0;
}

button {
  font: inherit; border-radius: 12px; border: 1px solid var(--line);
  padding: 14px 18px; background: var(--panel); color: var(--text);
  cursor: pointer; min-height: 48px;
}
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
/* Secondary buttons keep full-strength label text. Muted grey on a button
   reads as "disabled" even when the contrast ratio is fine. */
button.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.ghost { margin: 12px 16px max(12px, env(safe-area-inset-bottom)); }
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 3px solid #7aa2f7; outline-offset: 2px;
}

.manual { display: flex; gap: 8px; padding: 0 16px 16px; }
.manual input {
  flex: 1; font: inherit; padding: 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
}

/* Notes sheet -------------------------------------------------------------- */

.sheet {
  position: fixed; inset: 0; background: rgba(3, 7, 18, 0.72);
  display: flex; align-items: flex-end; z-index: 20;
}
.sheet-inner {
  width: 100%; background: var(--panel);
  border-radius: 20px 20px 0 0; border-top: 1px solid var(--line);
  padding: 22px 18px max(18px, env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 4px; font-size: 1.2rem; }
.sheet .muted { margin: 0 0 16px; }

.ratings { display: flex; gap: 8px; margin-bottom: 14px; }
.rating { flex: 1; padding: 12px 6px; }
.rating.selected { background: var(--accent); border-color: var(--accent); font-weight: 600; }

textarea {
  width: 100%; font: inherit; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  resize: vertical;
}

.actions { display: flex; gap: 10px; margin-top: 14px; }
.actions button { flex: 1; margin: 0; }

/* Toast -------------------------------------------------------------------- */

.toast {
  position: fixed; left: 50%; bottom: 92px; transform: translate(-50%, 12px);
  background: #1e293b; border: 1px solid var(--line); color: var(--text);
  padding: 12px 18px; border-radius: 999px; font-size: 0.95rem; font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity 160ms, transform 160ms;
  z-index: 30; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: var(--ok); }
.toast.warn { border-color: var(--warn); }

/* Enrolment page ----------------------------------------------------------- */

.enrol { max-width: 24rem; }
.enrol .sponsor-lg { font-size: 1.6rem; font-weight: 700; margin: 6px 0 2px; }
.enrol .booth-lg { font-size: 1.1rem; color: var(--muted); margin-bottom: 22px; }
.enrol button { width: 100%; font-size: 1.05rem; }
.enrol .eyebrow {
  text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 0.8rem; font-weight: 600; color: var(--muted);
}
