@import url("/shared/tokens.css?v=tl25up");

/* ══════════════════════════════════════════════════════════════════════
   بوابة التحقق والدخول — منصة الدعوات

   Palette and type scale come from shared/tokens.css, which the admin console
   also uses. What lives here is only what the gate needs: a camera-first
   layout and the verdict card.

   Typography roles (defined in tokens):
     display — Damascus / Al Bayan: naskh with the weight of a wedding card
     ui      — SF Arabic / Segoe UI: quiet, legible at arm's length
     mono    — SF Mono / Menlo: digits, times, IDs — ledger material
   ══════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink-900);
  color: var(--parchment);
  font-family: var(--font-ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body { overscroll-behavior: none; }

svg { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
svg circle[cx="12"] { fill: currentColor; stroke: none; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: .02em; }

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

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ─────────────────────────────  views  ───────────────────────────── */

.view { min-height: 100%; }
[hidden] { display: none !important; }

/* ─────────────────────────────  login  ───────────────────────────── */

.login {
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  /* A single brass glow behind the card — the light over a venue doorway. */
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(201, 116, 138, .16), transparent 60%),
    var(--ink-900);
}

.login__card {
  width: 100%;
  max-width: 380px;
  background: var(--ink-850);
  border: 1px solid var(--ink-700);
  border-radius: 20px;
  padding: 30px 24px 26px;
  /* Brass foil edge, as on the card this replaces. */
  box-shadow: var(--shadow-lg);
}

.eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: .22em;
  color: var(--brass);
  text-transform: uppercase;
}

.login h1 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  line-height: 1.35;
}

.login__sub { margin: 0 0 24px; color: var(--muted); font-size: 14px; line-height: 1.6; }

/* ─────────────────────────────  fields  ───────────────────────────── */

.field { display: block; margin-bottom: 16px; }
.field__label { display: block; margin-bottom: 7px; font-size: 13px; color: var(--muted); }

.field__input {
  width: 100%;
  min-height: var(--tap);
  padding: 0 15px;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: var(--radius-sm);
  color: var(--parchment);
  font: inherit;
  font-size: 17px;
  transition: border-color .15s ease;
}

.field__input:focus { border-color: var(--brass); outline: none; }
.field__input--pin { font-family: var(--font-mono); letter-spacing: .35em; }
.field__input--area { min-height: 92px; padding: 13px 15px; line-height: 1.6; resize: vertical; }

.form-error {
  margin: 0 0 14px;
  padding: 11px 14px;
  background: #FDEAEE;
  border: 1px solid rgba(208, 24, 64, .35);
  border-radius: var(--radius-sm);
  color: #8C0F2B;
  font-size: 14px;
  line-height: 1.5;
}

.hint { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.65; }

/* ─────────────────────────────  buttons  ───────────────────────────── */

.btn {
  min-height: var(--tap);
  padding: 0 22px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  color: var(--parchment);
  background: var(--ink-750);
  cursor: pointer;
  transition: transform .1s ease, opacity .15s ease, background-color .15s ease;
}

.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .42; cursor: not-allowed; }
.btn--block { display: block; width: 100%; }

.btn--primary { background: var(--brass); border-color: var(--brass); color: #FFFFFF; }
.btn--ghost { background: transparent; border-color: var(--ink-600); color: var(--parchment); }
.btn--quiet { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn--danger { background: var(--red); border-color: var(--red); color: #fff; }

.btn--confirm {
  background: var(--state);
  border-color: var(--state);
  color: var(--state-ink);
  font-size: 19px;
  min-height: 62px;
  letter-spacing: .01em;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:active { background: var(--ink-750); }
.icon-btn--on-state { color: var(--state-ink); opacity: .85; }

/* ─────────────────────────────  topbar  ───────────────────────────── */

.gate {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
  height: 100dvh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(var(--safe-top) + 9px) 12px 9px;
  background: var(--ink-850);
  border-bottom: 1px solid var(--ink-700);
  /* the brass hairline */
  box-shadow: inset 0 -1px 0 rgba(201, 162, 74, .18);
}

.topbar__identity { flex: 1; min-width: 0; }

.topbar__event {
  display: block;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.topbar__staff { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: 999px;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.pill__dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted-dim);
  flex: none;
}

.pill[data-conn="online"] { color: #10592B; background: #E9F7EE; border-color: rgba(21, 136, 63, .4); }
.pill[data-conn="online"] .pill__dot { background: var(--green); box-shadow: 0 0 0 3px rgba(21, 136, 63, .16); }
.pill[data-conn="offline"] { color: #7C3A0A; background: #FDF0E4; border-color: rgba(210, 96, 11, .45); }
.pill[data-conn="offline"] .pill__dot { background: var(--orange); }
.pill[data-conn="syncing"] { color: #143A8A; background: #E8EEFC; border-color: rgba(33, 88, 208, .45); }
.pill[data-conn="syncing"] .pill__dot { background: var(--blue); animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .3; } }

/* ─────────────────────────────  scanner  ───────────────────────────── */

.scanner {
  position: relative;
  overflow: hidden;
  background: #05070A;
}

.scanner__video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  /* The preview is a tool, not a photograph: dimming it keeps the brass frame
     and the hint legible over any background. */
  filter: saturate(.85) contrast(1.05) brightness(.82);
}

.scanner__frame {
  position: absolute;
  top: 50%; right: 50%;
  transform: translate(50%, -50%);
  width: min(74vw, 320px);
  aspect-ratio: 1;
}

.corner { position: absolute; width: 34px; height: 34px; border: 2.5px solid var(--brass); }
.corner--tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-top-right-radius: 8px; }
.corner--tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-top-left-radius: 8px; }
.corner--br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-bottom-right-radius: 8px; }
.corner--bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-bottom-left-radius: 8px; }

.scanner__hint {
  position: absolute;
  right: 0; left: 0; bottom: 22px;
  margin: 0;
  text-align: center;
  font-size: 15px;
  color: var(--parchment);
  text-shadow: 0 1px 8px rgba(0, 0, 0, .9);
}

.scanner__fallback {
  position: absolute; inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 30px;
  background: var(--ink-900);
  text-align: center;
}

.scanner__fallback-msg { margin: 0; max-width: 320px; color: var(--muted); font-size: 15px; line-height: 1.7; }

/* ─────────────────────────────  rail  ───────────────────────────── */

.rail {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px calc(var(--safe-bottom) + 11px);
  background: var(--ink-850);
  border-top: 1px solid var(--ink-700);
}

.rail__btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 0 18px;
  background: var(--ink-750);
  border: 1px solid var(--ink-700);
  border-radius: var(--radius-sm);
  color: var(--parchment);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.counters { display: flex; gap: 22px; margin: 0 auto 0 0; }
.counters__item { text-align: center; }
.counters dt { font-size: 11px; color: var(--muted-dim); letter-spacing: .04em; }
.counters dd {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ─────────────────────────────  sheets  ───────────────────────────── */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(59, 44, 49, .38);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: fade .16s ease;
}

@keyframes fade { from { opacity: 0; } }

.card {
  box-shadow: var(--shadow-lg);
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - 24px);
  display: flex;
  flex-direction: column;
  background: var(--ink-850);
  border: 1px solid var(--ink-700);
  border-radius: 22px 22px 0 0;
  overflow: hidden;
  animation: rise .24s cubic-bezier(.22, .8, .28, 1);
}

@keyframes rise { from { transform: translateY(14px); opacity: .6; } }

@media (min-width: 620px) {
  .sheet { align-items: center; padding: 24px; }
  .card { border-radius: 22px; max-height: calc(100dvh - 48px); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .card { animation: none; }
  .pill[data-conn="syncing"] .pill__dot { animation: none; }
  .btn:active { transform: none; }
}

.card__body {
  padding: 20px 20px 24px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

/* Each verdict sets the card's accent once; the band, the selected slots, the
   note edge and the confirm button all inherit it, so a state change repaints
   the whole card from a single source. Ink colour is chosen per state for
   contrast: dark ink on orange, white on green/red/blue, parchment on the void. */
.card[data-state="green"]  { --state: var(--green);  --state-deep: var(--green-deep);  --state-ink: #FFFFFF; }
.card[data-state="orange"] { --state: var(--orange); --state-deep: var(--orange-deep); --state-ink: #FFFFFF; }
.card[data-state="red"]    { --state: var(--red);    --state-deep: var(--red-deep);    --state-ink: #FFFFFF; }
.card[data-state="blue"]   { --state: var(--blue);   --state-deep: var(--blue-deep);   --state-ink: #FFFFFF; }
/* The void state paints its own hatched band below, so --state is free to carry
   bone instead — that keeps the note edge visible against the dark card. */
.card[data-state="black"]  { --state: var(--void);      --state-deep: #171214;         --state-ink: #F6EFE9; }

/* ── the verdict band: the one loud element on the screen ── */

.card__verdict {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 16px 15px 12px;
  background: var(--state);
  color: var(--state-ink);
}

.card__state {
  flex: 1;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: .01em;
  animation: stamp .28s cubic-bezier(.2, .9, .3, 1) both;
}

@keyframes stamp { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .card__state { animation: none; } }

/* Black is the one verdict that cannot be a filled band on a near-black UI, so
   it becomes a void: pure black, hatched, outlined in bone. */
.card[data-state="black"] .card__verdict {
  background:
    repeating-linear-gradient(-45deg,
      rgba(246, 239, 233, .10) 0 8px,
      transparent 8px 17px),
    var(--void);
}

.card__identity { display: flex; gap: 15px; align-items: flex-start; }

.card__photo {
  width: 72px; height: 72px;
  flex: none;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid var(--ink-700);
  background: var(--ink-800);
}

/* The single largest thing on the page: the receptionist reads this from
   arm's length while the guest is still walking up. */
.card__name {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(28px, 7.4vw, 38px);
  font-weight: 700;
  line-height: 1.28;
  letter-spacing: -.01em;
  text-wrap: balance;
}

.card__reason {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}

.card__note {
  margin: 16px 0 0;
  padding: 12px 14px;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-right: 3px solid var(--state);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.6;
  color: var(--parchment);
}

.card__plainhead {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 12px 15px 16px;
  border-bottom: 1px solid var(--ink-700);
}

.card__plainhead h2 {
  flex: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
}

.card__actions {
  display: grid;
  gap: 9px;
  padding: 4px 16px calc(var(--safe-bottom) + 16px);
  background: var(--ink-800);
  border-top: 1px solid var(--ink-700);
}

/* ─────────────────────────  verbal verification  ───────────────────────── */

.verify {
  margin-top: 18px;
  padding: 14px 15px;
  background: rgba(37, 99, 235, .1);
  border: 1px solid rgba(37, 99, 235, .38);
  border-radius: var(--radius-sm);
}

.verify__ask { margin: 0 0 11px; font-size: 14.5px; line-height: 1.7; }

.verify__digits {
  display: inline-block;
  padding: 2px 9px;
  margin: 0 3px;
  background: var(--ink-900);
  border-radius: 7px;
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: .18em;
  color: var(--parchment);
}

.check { display: flex; align-items: center; gap: 11px; min-height: 44px; font-size: 15px; cursor: pointer; }
.check--row { margin: 4px 0 18px; }
.check input { width: 24px; height: 24px; accent-color: var(--brass); flex: none; }

.ack {
  margin-top: 16px;
  padding: 4px 15px;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: var(--radius-sm);
}

/* ─────────────────────────────  facts  ───────────────────────────── */

.facts { margin: 20px 0 0; padding: 0; }

.facts__row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 11px 0;
  border-top: 1px solid var(--ink-700);
}

.facts__row:last-child { border-bottom: 1px solid var(--ink-700); }
.facts dt { flex: none; width: 108px; color: var(--muted-dim); font-size: 13px; }
.facts dd { margin: 0; font-size: 15.5px; font-weight: 500; }

/* ─────────────────  capacity as slots (signature control)  ───────────────── */

.capacity { padding: 14px 0 4px; }

.capacity__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.capacity__title { margin: 0; font-size: 16px; font-weight: 600; }
.capacity__tally { margin: 0; font-size: 12.5px; color: var(--muted-dim); }
.capacity__tally span { font-family: var(--font-mono); color: var(--muted); }

.slots { display: flex; flex-wrap: wrap; gap: 9px; }

/* Each slot is one admitted guest. Tapping slot N selects N people, so the
   common case (2, 3, 4 arriving) is a single tap, and the widget still shows
   what is used and what is left. */
.slot {
  position: relative;
  width: 54px; height: 58px;
  display: grid;
  place-items: center;
  background: var(--ink-800);
  border: 1.5px solid var(--ink-600);
  border-radius: 12px;
  color: var(--parchment);
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, transform .1s ease;
}

.slot:active { transform: scale(.94); }

.slot[data-role="used"] {
  background: transparent;
  border-style: dashed;
  border-color: var(--ink-600);
  color: var(--muted-dim);
  cursor: not-allowed;
}

.slot[data-role="used"]::after {
  content: "";
  position: absolute;
  right: 12%; left: 12%;
  height: 1.5px;
  background: var(--muted-dim);
  transform: rotate(-32deg);
}

.slot[data-selected="true"] {
  background: var(--state);
  border-color: var(--state);
  color: var(--state-ink);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 6px 0;
}

.stepper__btn {
  width: 54px; height: 54px;
  background: var(--ink-750);
  border: 1px solid var(--ink-600);
  border-radius: 12px;
  color: var(--parchment);
  font-size: 26px;
  font-weight: 600;
  cursor: pointer;
}

.stepper__value { min-width: 62px; text-align: center; font-size: 26px; font-weight: 700; }

/* ─────────────────────────────  history  ───────────────────────────── */

.history { margin-top: 20px; }

.history summary {
  padding: 12px 0;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  border-top: 1px solid var(--ink-700);
}

.history__list { margin: 6px 0 0; padding: 0; list-style: none; display: grid; gap: 9px; }

.history__list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  background: var(--ink-800);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--muted);
}

.history__list b { color: var(--parchment); font-family: var(--font-mono); }

/* ─────────────────────────────  results list  ───────────────────────────── */

.results { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }

.result {
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  padding: 14px;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-right-width: 4px;
  border-radius: var(--radius-sm);
  color: inherit;
  font: inherit;
  text-align: right;
  cursor: pointer;
}

.result[data-state="green"]  { border-right-color: var(--green); }
.result[data-state="orange"] { border-right-color: var(--orange); }
.result[data-state="red"]    { border-right-color: var(--red); }
.result[data-state="black"]  { border-right-color: var(--parchment); }
.result[data-state="blue"]   { border-right-color: var(--blue); }

.result__main { flex: 1; min-width: 0; }
.result__name { display: block; font-size: 16.5px; font-weight: 600; margin-bottom: 4px; }
.result__meta { display: block; font-size: 12.5px; color: var(--muted); }
.result__tally { flex: none; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }

.result--info {
  display: block;
  padding: 13px 14px;
  background: var(--ink-800);
  border: 1px solid var(--ink-700);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
}

.result--info b { color: var(--parchment); }

/* ─────────────────────────────  toast  ───────────────────────────── */

.toast {
  position: fixed;
  right: 16px; left: 16px;
  bottom: calc(var(--safe-bottom) + 20px);
  z-index: 60;
  margin: 0 auto;
  max-width: 460px;
  padding: 14px 17px;
  background: var(--ink-700);
  border: 1px solid var(--ink-600);
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.55;
  box-shadow: var(--shadow-md);
  animation: rise .2s ease;
}

.toast[data-tone="success"] { border-color: rgba(21, 136, 63, .45);  background: #E9F7EE; color: #10592B; }
.toast[data-tone="warn"]    { border-color: rgba(210, 96, 11, .45); background: #FDF0E4; color: #7C3A0A; }
.toast[data-tone="error"]   { border-color: rgba(208, 24, 64, .45);  background: #FDEAEE; color: #8C0F2B; }

/* ── iPad and larger: the scanner and the card sit side by side, so a busy
      gate never loses sight of the camera while confirming. ── */
@media (min-width: 900px) and (min-height: 600px) {
  .scanner__frame { width: min(46vw, 380px); }
  .counters dd { font-size: 22px; }
}
