/* Door scanner. Designed for one-handed use outdoors: huge verdicts, high
   contrast, no colour-only signals, and controls parked at the bottom of the
   screen where a thumb can reach them.

   The palette is fixed dark: the door is usually a dim room or a night street,
   and a surface that changes with the phone's theme is one more thing to think
   about at 1am. */
:root {
  --bg: #0b0d12;
  --surface: #151922;
  --surface-2: #1c2029;
  --fg: #f4f6fa;
  --muted: #a4adbe;
  --line: #2a2f3b;
  --accent: #4d7dff;
  --accent-hover: #628dff;
  --ok: #0d7a34;
  --ok-strong: #12a247;
  --danger: #b3121f;
  --warn: #a35a00;
  --radius: .875rem;
  --radius-lg: 1.25rem;
  --tap: 3rem;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* The screens below set their own `display`, which would otherwise win over the
   `hidden` attribute and leave two screens stacked on top of each other. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(60rem 30rem at 50% -10rem, #1b2333 0%, transparent 70%),
    var(--bg);
  color: var(--fg);
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
.screen {
  width: 100%; max-width: 34rem; margin-inline: auto;
  padding: calc(1rem + var(--safe-top)) 1rem calc(1rem + var(--safe-bottom));
}
h1 { font-size: 1.6rem; letter-spacing: -.02em; margin: 0 0 .35rem; }
h2 { margin: 0; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.error { color: #ff9a9a; font-size: .95rem; }

/* ------------------------------------------------------------- controls */
label {
  display: block; margin: 1rem 0 0;
  color: var(--muted); font-size: .8rem; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
}
input {
  width: 100%; padding: .85rem .9rem; margin-top: .4rem;
  font: inherit; font-size: 1.1rem;
  background: var(--surface-2); color: var(--fg);
  border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: #6d7688; }
input:focus-visible {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}
#join-code {
  text-transform: uppercase; letter-spacing: .35em; text-align: center;
  font-size: 1.75rem; font-weight: 700; padding-block: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
button {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font: inherit; font-weight: 600;
  padding: .85rem 1.1rem; min-height: var(--tap);
  border-radius: var(--radius); border: 1px solid transparent;
  background: var(--accent); color: #fff; cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .08s ease;
}
button:active { transform: scale(.98); }
button.ghost { background: var(--surface-2); border-color: var(--line); color: var(--fg); }
button.ghost:hover { background: #232833; }
button.danger { background: transparent; border-color: color-mix(in srgb, var(--danger) 60%, var(--line)); color: #ff9a9a; }
button.block { width: 100%; }
button.icon { padding: 0; width: var(--tap); height: var(--tap); }
button[disabled] { opacity: .5; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* -------------------------------------------------------------- pairing */
.pair {
  display: flex; flex-direction: column; justify-content: center;
  min-height: 100dvh;
}
.pair-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 1.5rem;
  box-shadow: 0 24px 60px -30px rgb(0 0 0 / .9);
}
.logo {
  display: grid; place-items: center;
  width: 2.75rem; height: 2.75rem; margin-bottom: 1rem;
  border-radius: .85rem;
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
  color: #fff; font-weight: 800; font-size: 1.25rem;
}
#pair-form button { margin-top: 1.5rem; }
#pair-error { margin-top: 1rem; }

/* ------------------------------------------------------------- scanning */
#scan {
  display: flex; flex-direction: column; gap: .75rem;
  height: 100dvh;
  padding-bottom: calc(.75rem + var(--safe-bottom));
}
.bar {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  flex: none;
}
.bar-title { min-width: 0; }
.bar-title strong { display: block; font-size: 1rem; }
.bar-title #gate-name { font-size: .8rem; }
#event-name, #gate-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-right { display: flex; align-items: center; gap: .4rem; flex: none; }
.pill {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: .75rem; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px;
  padding: .25rem .65rem; color: var(--muted); background: var(--surface);
}
.pill::before {
  content: ""; width: .4rem; height: .4rem; border-radius: 50%;
  background: var(--ok-strong);
}
.pill.offline { border-color: var(--warn); color: #ffc078; }
.pill.offline::before { background: #ffc078; }
#queued::before { background: var(--accent); }

#camera-wrap {
  position: relative; flex: 1 1 auto; min-height: 0;
  border-radius: var(--radius-lg); overflow: hidden; background: #000;
  border: 1px solid var(--line);
}
#video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Corner brackets rather than a full box: they frame the code without hiding it. */
/* A square frame: the thing being framed is a square QR code. */
#reticle {
  position: absolute; top: 45%; left: 50%; transform: translate(-50%, -50%);
  width: min(78%, 18rem); aspect-ratio: 1; pointer-events: none;
}
#reticle span {
  position: absolute; width: 2.25rem; height: 2.25rem;
  border: 3px solid rgb(255 255 255 / .9);
  border-radius: .35rem;
}
#reticle span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; }
#reticle span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; }
#reticle span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; }
#reticle span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; }
#reticle::after {
  content: ""; position: absolute; left: .25rem; right: .25rem; top: 0; height: 2px;
  background: linear-gradient(90deg, transparent, rgb(120 160 255 / .9), transparent);
  animation: sweep 2.4s ease-in-out infinite;
}
@keyframes sweep {
  0%, 100% { top: 0; opacity: .3; }
  50% { top: calc(100% - 2px); opacity: 1; }
}
.cam-status {
  position: absolute; top: .6rem; right: .6rem; left: .6rem;
  display: flex; justify-content: flex-end; gap: .4rem; flex-wrap: wrap;
}
.cam-status .pill {
  background: rgb(10 12 18 / .7);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: #e8ecf5;
}
.hint {
  position: absolute; bottom: 0; left: 0; right: 0; margin: 0;
  padding: 2.5rem .75rem .9rem;
  background: linear-gradient(to top, rgb(0 0 0 / .75), transparent);
  color: #fff; text-align: center; font-size: .9rem;
}

/* The menu is a bottom sheet: the door is one-handed, so actions live in reach. */
.menu {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 34rem); z-index: 20;
  display: grid; gap: .5rem;
  padding: .75rem 1rem calc(1rem + var(--safe-bottom));
  background: var(--surface);
  border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -20px 50px -20px rgb(0 0 0 / .95);
  animation: sheet-up .18s ease-out;
}
.sheet-grip {
  width: 2.5rem; height: .25rem; border-radius: 999px;
  background: var(--line); margin: 0 auto .25rem;
}
@keyframes sheet-up { from { transform: translate(-50%, 100%); } }

.test-banner {
  flex: none;
  background: var(--warn); color: #000; font-weight: 800; letter-spacing: .02em;
  text-align: center; padding: .45rem .5rem; border-radius: .5rem;
}

/* --------------------------------------------------------------- verdict */
/* Colour + icon + text + sound + haptics together, never colour alone. */
.verdict {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: center; gap: 1rem;
  animation: verdict-in .18s ease-out;
}
@keyframes verdict-in { from { opacity: 0; transform: scale(.985); } }
.verdict-body {
  flex: 1 1 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
}
.verdict.valid { background: var(--ok); }
.verdict.already_used { background: var(--warn); }
.verdict.invalid, .verdict.voided, .verdict.wrong_event, .verdict.wrong_gate,
.verdict.outside_window, .verdict.superseded, .verdict.unknown_ticket, .verdict.event_cancelled { background: var(--danger); }
.verdict-icon {
  display: grid; place-items: center;
  width: 7rem; height: 7rem; margin-bottom: .5rem;
  border-radius: 50%;
  background: rgb(255 255 255 / .16);
  border: 3px solid rgb(255 255 255 / .5);
  font-size: 3.75rem; line-height: 1;
}
.verdict h2 { font-size: clamp(2rem, 1.4rem + 3.5vw, 2.75rem); letter-spacing: -.02em; margin: 0; }
.verdict-name { font-size: 1.5rem; font-weight: 700; margin: .25rem 0 0; }
.verdict-detail { font-size: 1.05rem; margin: 0; opacity: .95; }
.verdict-meta { font-size: .85rem; opacity: .85; margin: .5rem 0 0; }
.verdict-actions {
  flex: none;
  display: grid; gap: .55rem; width: min(24rem, 100%); margin: 0 auto;
}
.verdict-actions button { min-height: 3.25rem; font-size: 1.05rem; }
.verdict button.primary {
  background: rgb(255 255 255 / .95); color: #10131a; border-color: transparent;
}
.verdict button.primary:hover { background: #fff; }
.verdict button.ghost {
  background: rgb(0 0 0 / .28); border-color: rgb(255 255 255 / .5); color: #fff;
}
.verdict button.ghost:hover { background: rgb(0 0 0 / .4); }
.verdict button.danger { color: #fff; }

/* ---------------------------------------------------------------- lookup */
#lookup, #summary { display: flex; flex-direction: column; min-height: 100dvh; }
#lookup .bar, #summary .bar { margin-bottom: .75rem; }
.search-field { position: relative; flex: none; }
.search-field svg {
  position: absolute; left: .85rem; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.search-field input { padding-left: 2.6rem; margin-top: 0; }
.results { list-style: none; padding: 0; margin: .75rem 0 0; overflow-y: auto; min-height: 0; }
.results li {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .8rem .9rem; margin-bottom: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.results li.muted { display: block; background: transparent; border-style: dashed; text-align: center; }
.results .who { text-align: left; min-width: 0; }
.results .who strong { display: block; }
.results .sub { color: var(--muted); font-size: .8rem; }
.results button { flex: none; }

#summary-body ul { list-style: none; padding: 0; margin: 0; }
#summary-body li {
  padding: .8rem .9rem; margin-bottom: .5rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  font-size: .95rem;
}

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