/* 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);
}

/* Full-screen scan result.
   A brief tint over the video feed was easy to miss on a phone at arm's length
   under hall lighting -- reps could not tell whether a scan had registered.
   This covers the frame and states the outcome in words. */
.confirm {
  position: absolute; inset: 0; z-index: 15;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px; text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 110ms ease;
}
.confirm.show { opacity: 1; }
.confirm-icon { font-size: 5rem; line-height: 1; font-weight: 700; }
.confirm-heading { font-size: 1.65rem; font-weight: 700; letter-spacing: 0.01em; }
.confirm-detail { font-size: 1rem; max-width: 20rem; opacity: 0.95; }
.confirm-count { font-size: 0.9rem; opacity: 0.85; margin-top: 10px; }

/* Colour is reinforcement, never the only signal: each state also differs by
   icon, wording and sound, so it reads correctly in glare or colour-blind. */
.confirm.captured  { background: #12692f; color: #fff; }
.confirm.unmatched { background: #8a5a00; color: #fff; }
.confirm.duplicate { background: #1e3a5f; color: #fff; }
.confirm.rejected  { background: #7f1d1d; color: #fff; }

.sound {
  flex: none; min-height: 40px; padding: 8px 10px; font-size: 1.1rem;
  background: transparent; border-color: var(--line); line-height: 1;
}
.sound.muted { opacity: 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; }

/* Interest tags: set per event by staff, tapped by the rep. Wrapping chips
   rather than a select, because a select is two taps and a scroll on a phone. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { padding: 9px 14px; font-size: 0.92rem; border-radius: 999px; margin: 0; }
.chip.selected { background: var(--accent); border-color: var(--accent); font-weight: 600; }

.declined {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; font-size: 0.9rem;
  background: rgba(251, 191, 36, 0.12); border: 1px solid var(--warn); color: var(--text);
}

/* The undo. Plain text, below the real actions: reachable in the moment the
   wrong name registers, not something to hit by accident. */
.undo {
  display: block; width: 100%; margin: 14px 0 0; padding: 10px;
  background: none; border: 0; color: var(--muted); font-size: 0.9rem; text-decoration: underline;
}

.confirm-who { font-size: 2.2rem; font-weight: 800; line-height: 1.1; min-height: 0; }
.confirm-who:empty { display: none; }

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);
}

/* Data handling notice ------------------------------------------------------
   Shown once per device. The screen scrolls rather than centring, because the
   obligations list overflows a small phone in landscape. */
.screen:has(.notice) { align-items: flex-start; overflow-y: auto; }
.panel.notice { max-width: 26rem; text-align: left; }
.panel.notice h1 { text-align: center; font-size: 1.3rem; }
.notice-intro { font-size: 0.95rem; color: var(--text); }
.notice-lead { font-size: 0.95rem; font-weight: 600; margin-bottom: 6px; }
.panel.notice ul { margin: 0 0 16px; padding-left: 20px; }
.panel.notice li { font-size: 0.92rem; color: var(--muted); margin-bottom: 8px; }
.notice-closing {
  font-size: 0.92rem; background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 13px; margin-bottom: 18px;
}
.panel.notice button { width: 100%; font-size: 1.02rem; }
.notice-once { text-align: center; margin: 12px 0 0; }

/* Hourly cap reached. Distinct from every other outcome by colour, icon,
   wording and dwell time -- it is the one state that asks the rep to stop. */
.confirm.cooldown { background: #3b2f63; color: #fff; }

/* Enrolment PIN ------------------------------------------------------------ */
.pin-label {
  display: block; text-align: left; font-size: 0.85rem; font-weight: 600;
  color: var(--muted); margin-bottom: 6px;
}
#pin {
  width: 100%; font: inherit; font-size: 1.6rem; letter-spacing: 0.35em;
  text-align: center; padding: 14px 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.pin-help { text-align: left; margin: 8px 0 14px; font-size: 0.88rem; }
.pin-error {
  background: #4a1214; border: 1px solid #7f1d1d; color: #fecaca;
  border-radius: 10px; padding: 10px 12px; font-size: 0.9rem; margin: 0 0 14px;
}

/* Brand mark over the camera feed.
   Sits above the video but BELOW the scan confirmation (z-15) and the notes
   sheet (z-20), so it never covers an outcome the rep needs to read. On a light
   chip because the mark is red and the video behind it is arbitrary. */
.brandmark {
  position: absolute; top: 12px; left: 12px; z-index: 5;
  height: 24px; width: auto; padding: 6px;
  background: rgba(255, 255, 255, 0.92); border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

/* Sponsor guide ------------------------------------------------------------ */
body.help { height: auto; padding: 0 0 40px; }
.help-head {
  display: flex; align-items: center; gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) 20px 16px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.help-logo { height: 26px; width: auto; background: #fff; padding: 5px; border-radius: 7px; }
.help-head h1 { margin: 0; font-size: 1.2rem; }
.help-head p { margin: 2px 0 0; }
.help-body { padding: 4px 20px; max-width: 40rem; margin: 0 auto; }
.help-body section { padding: 20px 0; border-bottom: 1px solid var(--line); }
.help-body h2 { font-size: 1.05rem; margin: 0 0 10px; }
.help-body p, .help-body li, .help-body dd { font-size: 0.95rem; line-height: 1.55; }
.help-body ol, .help-body ul { padding-left: 22px; margin: 0 0 12px; }
.help-body li { margin-bottom: 7px; }
.help-body a { color: #8ab4ff; }

.tip {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--muted);
  border-radius: 8px; padding: 11px 13px; margin: 12px 0;
}
.tip.warn { border-left-color: var(--warn); }

.help-states { list-style: none; padding: 0; }
.help-states li { padding: 7px 0; border-bottom: 1px solid var(--line); }
.help-states b { display: inline-block; min-width: 9.5rem; }
.help-states .ok { color: var(--ok); }
.help-states .warn { color: var(--warn); }
.help-states .dupe { color: #93b4e8; }
.help-states .bad { color: #f87171; }

.help-dl dt { font-weight: 650; margin-top: 14px; }
.help-dl dd { margin: 4px 0 0; color: var(--muted); }
.help-foot { text-align: center; padding: 24px 20px 0; }
.help-foot a { color: #8ab4ff; }

.help-link {
  display: inline-flex; align-items: center; justify-content: center;
  text-decoration: none; font-weight: 700; color: var(--text);
}

.delivery { max-width: 760px; margin: 3rem auto; padding: 1.5rem; }
.delivery pre { white-space: pre-wrap; font: inherit; line-height: 1.6; }
.delivery label { display: flex; align-items: start; gap: .7rem; }
.delivery input { width: auto; }
.delivery button { margin: .5rem .5rem .5rem 0; padding: .8rem 1rem; }
