/* The ticket scanner, in the house colours of the back office. Made for a
   phone held in one hand at the door: big targets, big answers. */
:root {
  color-scheme: light;
  --room: #f5f1f3;
  --surface: #ffffff;
  --ink: #2a1720;
  --ink-2: #5c4a53;
  --ink-3: #7f6e76;
  --rule: #e2d8dc;
  --velvet: #973961;
  --on-velvet: #ffffff;
  --good: #1f7a4d;
  --again: #b8660f;
  --bad: #b3261e;
  --wait: #3d4a5c;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --room: #1a1216;
    --surface: #251a1f;
    --ink: #f4edf0;
    --ink-2: #cdbec5;
    --ink-3: #9d8b93;
    --rule: #40303a;
    --velvet: #ba4979;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--room); color: var(--ink); font: 400 17px/1.5 var(--body); -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2 { font-family: var(--display); font-weight: 600; line-height: 1.1; margin: 0 0 8px; }
h1 { font-size: clamp(34px, 9vw, 48px); }
h2 { font-size: 24px; margin-top: 28px; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--velvet); outline-offset: 3px; }

.view { max-width: 560px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.brandbar { display: flex; align-items: center; min-height: 48px; margin-bottom: 24px; }
.brandbar img { height: 36px; width: auto; display: block; }
.kicker { margin: 0; font-weight: 600; color: var(--velvet); text-transform: uppercase; letter-spacing: .06em; font-size: 14px; }
.lead { color: var(--ink-2); margin: 0 0 20px; }
.note { color: var(--ink-3); font-size: 15px; }
.error { color: var(--bad); font-weight: 500; }

button { cursor: pointer; border: 1px solid var(--rule); background: var(--surface); border-radius: 10px; padding: 10px 16px; min-height: 44px; }
button.primary { background: var(--velvet); border-color: var(--velvet); color: var(--on-velvet); font-weight: 600; }
button.big { width: 100%; min-height: 64px; font-size: 21px; border-radius: 14px; }
button.linkish { border: 0; background: none; padding: 8px 0; min-height: 0; text-decoration: underline; text-underline-offset: 3px; }
input[type=text], input[type=search] { width: 100%; padding: 12px 14px; border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); min-height: 48px; }
.inline { margin-top: 24px; }
.inline label { display: block; color: var(--ink-2); margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

.card { display: block; text-decoration: none; background: var(--surface); border: 1px solid var(--rule); border-left: 5px solid var(--velvet); border-radius: 10px; padding: 14px 16px; }
.card strong { display: block; font-size: 19px; }
.card span { color: var(--ink-2); }

.tally { margin: 8px 0 6px; display: flex; align-items: baseline; gap: 8px; color: var(--ink-2); }
.tally strong { font-family: var(--display); font-size: 44px; color: var(--ink); line-height: 1; }
.bar { height: 8px; background: var(--rule); border-radius: 4px; overflow: hidden; margin-bottom: 24px; }
.bar .fill { display: block; height: 100%; width: 0; background: var(--velvet); transition: width .4s; }
.links { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-top: 12px; }
.links a { padding: 8px 0; text-underline-offset: 3px; }

/* Scanning: the camera fills the screen. */
body[data-view=scan] { background: #000; overflow: hidden; }
.scanning { position: fixed; inset: 0; max-width: none; padding: 0; color: #fff; }
#video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* The frame matches the part of the picture that is read: 86% wide and
   70% of the short side high, around the middle. */
.frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.frame span { width: 86vw; max-width: 86vh; aspect-ratio: 86 / 70; max-height: 60vh; border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); border: 3px solid rgba(255,255,255,.9); }
.config .frame span { border-color: #f0b6cf; }
.scanbar { position: absolute; top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 12px; padding: max(12px, env(safe-area-inset-top)) 12px 12px; background: linear-gradient(rgba(0,0,0,.7), transparent); }
.scanbar .what { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.scanbar strong { font-family: var(--display); font-size: 22px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scanbar b { font-size: 18px; }
.config .scanbar .what span { display: none; }
.round { width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; display: grid; place-items: center; flex: none; }
svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hint { position: absolute; left: 16px; right: 16px; bottom: calc(112px + env(safe-area-inset-bottom)); margin: 0; text-align: center; font-weight: 500; text-shadow: 0 1px 4px rgba(0,0,0,.8); }
.hint.warn { color: #ffd2a6; }
.tools { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; gap: 6px; padding: 12px 8px max(14px, env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(0,0,0,.75)); }
.config .tools [data-act=type-code], .config .tools [data-act=search] { display: none; }
.tool { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 72px; padding: 8px 6px; border: 0; border-radius: 14px; background: rgba(255,255,255,.14); color: #fff; font-size: 13px; }
.tool.on { background: #fff; color: #000; }
.camera-error { position: absolute; left: 16px; right: 16px; top: 35%; margin: 0; padding: 16px; border-radius: 12px; background: var(--surface); color: var(--ink); }
.camera-error button { margin-top: 12px; width: 100%; }

/* The answer: the whole screen in one colour, readable from a step away. */
.result { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; color: #fff; background: var(--wait); }
.result.ok { background: var(--good); }
.result.again { background: var(--again); }
.result.no { background: var(--bad); }
.result .sign svg { display: none; width: 120px; height: 120px; stroke-width: 2.4; }
.result.ok .ok, .result.again .again, .result.no .no, .result.wait .wait { display: block; }
.result.wait .wait { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.result .title { font-family: var(--display); font-size: clamp(44px, 13vw, 72px); font-weight: 600; line-height: 1; margin: 16px 0 12px; }
.result .detail { font-size: 21px; max-width: 30ch; margin: 0 0 12px; }
.result .code { font-family: ui-monospace, Menlo, monospace; opacity: .8; margin: 0; }
.result .retry { margin-top: 16px; background: #fff; color: var(--wait); border: 0; font-weight: 600; min-height: 52px; padding: 0 28px; }
.result .tap { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); margin: 0; opacity: .75; font-size: 15px; }
.result.wait .tap { display: none; }
@media (prefers-reduced-motion: reduce) { .result.wait .wait { animation: none; } }

/* Overview. */
.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 12px; }
.figures p { margin: 0; background: var(--surface); border: 1px solid var(--rule); border-radius: 10px; padding: 10px 12px; }
.figures strong { display: block; font-family: var(--display); font-size: 36px; line-height: 1; }
.figures span { color: var(--ink-2); font-size: 15px; }
.back { text-underline-offset: 3px; }
.people { list-style: none; margin: 12px 0 0; padding: 0; }
.people li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.people li > div { flex: 1; min-width: 0; }
.people strong { display: block; }
.people span { display: block; color: var(--ink-2); font-size: 15px; overflow-wrap: anywhere; }
.people li.empty { color: var(--ink-3); border: 0; }
.people button { flex: none; }

/* Dialogs. */
dialog { width: min(520px, calc(100vw - 32px)); border: 0; border-radius: 16px; padding: 20px; background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.55); }
dialog h2 { margin-top: 0; }
dialog.tall { height: min(720px, calc(100dvh - 32px)); }
dialog.tall form { display: flex; flex-direction: column; height: 100%; }
dialog.tall .people { flex: 1; overflow-y: auto; }
.buttons { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
#type-input { font-family: ui-monospace, Menlo, monospace; font-size: 24px; letter-spacing: .08em; text-align: center; }
.qr { background: #fff; border-radius: 12px; padding: 8px; width: min(280px, 100%); margin: 0 auto; }
.qr svg { width: 100%; height: auto; display: block; stroke: none; }
