/* Ajaltoun Festivals — door scanner.
 *
 * One dark theme throughout. The camera view has to be dark and a door is
 * worked at night, so the brand is brought ONTO the dark ground — the header
 * uses the knocked-out lockup (coral mark, white wordmark) rather than the app
 * carrying a white slab at the top.
 *
 * Colour is meaning: coral marks brand and admin affordances, navy is the
 * primary action, and green / amber / red are reserved for verdicts so they
 * never compete with the interface. */

:root {
  --navy: #22407a;          /* Ajaltoun wordmark navy */
  --navy-lift: #2f57a7;     /* the navy raised to sit on a dark ground */
  --coral: #dc6d59;
  --coral-soft: #e89179;

  --bg: #0e131b;            /* page: near-black, cooled towards the navy */
  --surface: #161d29;       /* cards */
  --surface-2: #0b1017;     /* inputs and wells */
  --line: #26314a;
  --line-soft: #1c2434;

  --text: #eef2f8;
  --muted: #93a1b8;
  --faint: #6b7890;

  --ok: #12a150;
  --ok-soft: #56d98c;
  --warn: #d98200;
  --warn-soft: #f0ad42;
  --bad: #d13438;
  --bad-soft: #ff8b8f;

  --r-sm: 9px;
  --r-md: 12px;
  --r-lg: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

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;
  -webkit-tap-highlight-color: transparent;
}

.view { display: none; height: 100%; }
.view.active { display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- bars */

.bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.bar h1 { font-size: 18px; margin: 0; flex: 1; }

/* The brand band: still dark, lifted just enough to read as a header. */
.bar.brand {
  gap: 12px;
  background: linear-gradient(180deg, #1a2438 0%, #121926 100%);
  border-bottom: 1px solid #27324b;
}
.lockup { display: block; height: 52px; width: auto; flex: 0 0 auto; }
.bar.brand .spacer { flex: 1; }
/* The header's own actions stay quiet — coral is for the brand and for the
   one place that adds data, not for a sign-out link. */
.bar.brand .link { color: var(--muted); }
.bar.brand .link:active { color: var(--coral); }

.bar.overlay {
  position: fixed;
  top: 0; left: 0; right: 0;
  border: 0;
  background: linear-gradient(#000c, #0000);
  z-index: 3;
}
.bar.overlay.bottom {
  top: auto;
  bottom: 0;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: linear-gradient(#0000, #000c);
  justify-content: space-between;
}

.pill {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-weight: 600;
  font-size: 15px;
  text-shadow: 0 1px 3px #000;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  padding: 4px 9px;
  border-radius: 999px;
  background: #ffffff0f;
  border: 1px solid #ffffff1f;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.offline { background: #3a2a12; border-color: #6b4a1d; color: var(--warn-soft); }
.badge.online { background: #14301f; border-color: #23543a; color: #7ee2a2; }

/* ---------------------------------------------------------------- layout */

.pane { padding: 18px 14px 48px; max-width: 620px; margin: 0 auto; }

/* Nothing may push the page sideways on a narrow screen. */
body { overflow-x: hidden; }
.pane, .cards, .guests, .scan-rows { min-width: 0; }
code { overflow-wrap: anywhere; }

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 26px 0 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--faint);
}
.section-title:first-child { margin-top: 2px; }
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

/* ---------------------------------------------------------------- controls */

button { font: inherit; cursor: pointer; }

input:not([type=file]):not([type=checkbox]), select, textarea {
  width: 100%;
  padding: 13px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  -webkit-appearance: none;
  appearance: none;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px #dc6d5933;
}
input::placeholder, textarea::placeholder { color: #5d6a80; }
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; resize: vertical; }
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 18px center, right 13px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
/* The native file control is unstyleable and looks like debris on a phone;
   the label is the button, the input itself is hidden inside it. */
.file-button {
  display: block;
  margin-top: 16px;
  padding: 13px;
  border: 1px dashed var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
  cursor: pointer;
}
.file-button:active { border-color: var(--coral); color: var(--text); }
.file-button input[type=file] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

label { display: block; margin: 16px 0 0; font-size: 12.5px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 7px; }

label.check {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  font-size: 15px;
}
label.check input { width: 21px; height: 21px; accent-color: var(--coral); }

.primary {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: var(--navy-lift);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}
.primary:active { background: var(--navy); }
.primary:disabled { opacity: .55; }

.ghost {
  background: #ffffff0d;
  border: 1px solid #ffffff21;
  border-radius: var(--r-sm);
  color: var(--text);
  min-height: 40px;
  padding: 9px 13px;
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(6px);
}

.link {
  background: none;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--coral);
  font-size: 14px;
  font-weight: 600;
  min-height: 40px;          /* a thumb-sized target, even as bare text */
  padding: 8px 6px;
}

.wide {
  display: block;
  width: 100%;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font-weight: 600;
}
.wide:active { background: #1c2534; }

.msg { min-height: 20px; font-size: 13px; margin: 12px 0 0; }
.msg.err { color: var(--bad-soft); }
.msg.ok { color: var(--ok-soft); }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---------------------------------------------------------------- list picker */

.cards { display: grid; gap: 10px; }

/* One row per list: [handle] [ name + metadata ] [Edit].
   The name gets a line of its own — several artists here run to 25 characters
   and a phone is 360-390px wide, so squeezing chips beside the name is what
   made it wrap into three lines. */
.card {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.card:active { background: #1c2534; }
.card .name {
  display: block;
  font-weight: 650;
  font-size: 16.5px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  flex-wrap: wrap;
}
.card .meta { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* Not `.ticket` — that class belongs to the scanner's full-screen card,
   which is display:none until a code is decoded. */
.card .kind {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  padding: 4px 8px;
  border-radius: 999px;
}
.card .kind-guest { color: var(--coral-soft); background: #dc6d5922; }
.card .kind-ticket { color: #9db4e8; background: #2f57a72e; }

/* ---------------------------------------------------------------- admin */

details {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 15px 16px;
}
details[open] { padding-bottom: 18px; }
summary {
  cursor: pointer;
  font-weight: 650;
  color: var(--coral);
  list-style: none;
}
summary::-webkit-details-marker { display: none; }
summary::before { content: '+ '; font-weight: 700; }
details[open] summary::before { content: '− '; }

/* Sign-in gets a modal: it is a mode change, not another block on the page. */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #04070cd6;
  backdrop-filter: blur(4px);
}
.modal-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: 0 24px 60px #000000a8;
}
.modal-card h3 { margin: 0; font-size: 18px; }
.modal-card .sub { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions button { flex: 1; margin: 0; padding: 14px; }

/* ---------------------------------------------------------------- search */

.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input { flex: 1; }
.search .ghost { flex: 0 0 auto; }

/* ---------------------------------------------------------------- guests */

.guests { display: grid; gap: 10px; padding-bottom: 30px; }
.guest {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.guest.done { background: var(--surface-2); border-color: var(--line-soft); }
.guest-who { flex: 1; min-width: 0; }
.guest-name { display: block; font-weight: 650; font-size: 17px; }
.guest.done .guest-name { color: var(--muted); font-weight: 600; }
.guest-seat { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.guest-action {
  flex: 0 0 auto;
  min-height: 44px;          /* a thumb-sized target */
  padding: 12px 14px;
  border: 1px solid var(--ok);
  border-radius: var(--r-sm);
  background: #12a1501f;
  color: var(--ok-soft);
  font-weight: 700;
}
.guest-action:active { background: var(--ok); color: #fff; }
.guest-action.is-done {
  background: transparent;
  border-color: var(--line-soft);
  color: var(--faint);
  font-weight: 600;
  font-size: 12.5px;
}

/* ---------------------------------------------------------------- report */

.overlay-view {
  position: fixed;
  inset: 0;
  z-index: 6;
  background: var(--bg);
  overflow-y: auto;
}
.overlay-view.active { display: block; }

/* A phone can't hold a six-column table without cutting the action off the
   right edge, so each check-in is a row instead. */
.scan-rows { display: grid; gap: 10px; padding-bottom: 40px; }
.scan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
}
.scan-main { flex: 1; min-width: 0; }
.scan-id {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  font-size: 15px;
}
.scan-sub { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.undo {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid #6b2f31;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--bad-soft);
  font-size: 12.5px;
  font-weight: 600;
}
.undo:active { background: #d1343820; }
.undo:disabled { opacity: .5; }

/* ---------------------------------------------------------------- scanner */

#view-scan { position: relative; overflow: hidden; background: #000; }
#video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#reticle {
  position: absolute;
  top: 50%; left: 50%;
  width: min(68vw, 300px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 2px solid #ffffff5c;
  outline: 3px solid #dc6d5933;
  outline-offset: -3px;
  border-radius: 22px;
  box-shadow: 0 0 0 100vmax #00000059;
  z-index: 1;
}

/* The verdict layer must feel instant: it paints on the same frame the code is
   decoded, before any network call. */
.verdict {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .08s linear;
  text-align: center;
  padding: 20px;
}
.verdict.show { opacity: 1; }
.verdict.approved { background: #12a150ee; }
.verdict.expired  { background: #d98200ee; color: #1a1200; }
.verdict.invalid  { background: #d13438ee; }
#verdict-word {
  font-size: clamp(38px, 13vw, 76px);
  font-weight: 800;
  letter-spacing: .02em;
  line-height: 1;
}
.verdict .code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 15px;
  opacity: .9;
  word-break: break-all;
  max-width: 90%;
}
.verdict .sub { font-size: 14px; opacity: .85; }

/* ---------------------------------------------------------------- ticket card */

.ticket {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 14px calc(16px + var(--safe-bottom));
  background: #000000a6;
  backdrop-filter: blur(3px);
}
.ticket.show { display: flex; }

.ticket-card {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 6px solid var(--muted);
  border-radius: var(--r-lg);
  padding: 16px 16px 14px;
  box-shadow: 0 18px 50px #000000a6;
}
.ticket.valid   .ticket-card { border-top-color: var(--ok); }
.ticket.expired .ticket-card { border-top-color: var(--warn); }
.ticket.invalid .ticket-card { border-top-color: var(--bad); }

.status {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: .04em;
  margin-bottom: 12px;
}
.ticket.valid   .status { color: var(--ok-soft); }
.ticket.expired .status { color: var(--warn-soft); }
.ticket.invalid .status { color: var(--bad-soft); }

.fields {
  margin: 0;
  display: grid;
  gap: 1px;
  background: var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
}
.fields > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 12px;
  background: var(--surface-2);
}
.fields dt {
  flex: 0 0 82px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--faint);
}
.fields dd {
  margin: 0;
  flex: 1;
  font-size: 19px;
  font-weight: 700;
  word-break: break-word;
}
.fields dd.mono { font-size: 17px; }

.note { margin: 12px 2px 0; font-size: 13px; color: var(--muted); min-height: 18px; }

.approve, .dismiss {
  width: 100%;
  margin-top: 10px;
  padding: 16px;
  border: 0;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: 18px;
}
.approve { background: var(--ok); color: #fff; }
.approve:active { background: #0d7d3d; }
.dismiss {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 12px;
}

.manage-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
}
.manage-row .manage-open {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
}
.manage-row .manage-open:active { background: #1c2534; }
.manage-row .manage-open .scan-id { font-family: inherit; font-size: 16px; }
.manage-row .del { align-self: center; }

/* A list row carries the staff action (open it) and, for admins, a drag
   handle and the editing door — so managing a list never starts by opening
   the camera. */
.card-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: var(--bg);
}
.card-row .card { flex: 1; min-width: 0; }

.drag-handle {
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  color: var(--faint);
  font-size: 19px;
  line-height: 1;
  cursor: grab;
  /* Without this a drag on the handle scrolls the page instead. */
  touch-action: none;
  user-select: none;
}
.drag-handle:active { color: var(--coral); cursor: grabbing; }

.card-manage {
  flex: 0 0 52px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--coral-soft);
  font-size: 13px;
  font-weight: 600;
}
.card-manage:active { background: var(--surface); }

/* Lifted while dragging, and the rest of the page holds still. */
.card-row.dragging {
  position: relative;
  z-index: 5;
  box-shadow: 0 12px 30px #000000a6;
}
.card-row.dragging .card { border-color: var(--coral); background: #1c2534; }
body.reordering { user-select: none; }
body.reordering .card-row:not(.dragging) { transition: transform .12s ease; }
