/* ═══════════════════════════════════════════════════════════════════════════
   Waiting-hall board.

   Read from across a room, so every size below is set for distance rather
   than for a desk. Committed to a single dark treatment: it is a wall-mounted
   panel in a public hall, not a document, and a light board glares.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  /* Lifted off true black: on a dark board the flag's black band would
     otherwise vanish and the stripe would look like it was only two-thirds
     drawn. */
  --flag-black: #33322B;
  --flag-red:   #BE0000;
  --flag-green: #007A36;

  --gold:       #C8A84B;
  --gold-bright:#F2D888;
  --gold-dim:   rgba(200, 168, 75, .38);

  --call:       #00E37A;
  --call-dim:   rgba(0, 227, 122, .35);

  --bg:         #05070B;
  --panel:      #0B111A;
  --panel-2:    #101927;
  --line:       #1B2637;
  --line-soft:  #131C29;

  --ink:        #FFFFFF;
  --ink-2:      #8FA4BE;
  --ink-3:      #4A5E79;

  --idle:       #1E2C41;

  --fa: 'Noto Naskh Arabic', serif;
  --ui: 'Archivo', system-ui, sans-serif;
  --num: 'Archivo Black', 'Archivo', sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--ui);
  overflow: hidden;
  user-select: none;
  cursor: none;                 /* wall display — no pointer */
  -webkit-font-smoothing: antialiased;
}

body {
  display: grid;
  grid-template-rows: 6px auto 1fr 58px;
  height: 100vh;
}

/* Faint grid, so a large flat black panel does not band on cheap LCDs. */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background-image: radial-gradient(rgba(27, 38, 55, .55) 1px, transparent 1px);
  background-size: 34px 34px;
  pointer-events: none;
}

/* ─── Flag stripe ───────────────────────────────────────────────────────── */
.flag { display: flex; position: relative; z-index: 2; }
.flag i { flex: 1; }
.flag i:nth-child(1) { background: var(--flag-black); }
.flag i:nth-child(2) { background: var(--flag-red); }
.flag i:nth-child(3) { background: var(--flag-green); }

/* ─── Masthead ──────────────────────────────────────────────────────────── */
.masthead {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between;
  gap: 28px;
  padding: 14px 34px;
  background: linear-gradient(180deg, #0A1220 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}

.identity { display: flex; align-items: center; gap: 20px; min-width: 0; }

.emblem {
  width: 68px; height: 68px; flex: none; object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(200, 168, 75, .38));
}

.office-fa {
  font-family: var(--fa);
  font-size: 25px; font-weight: 700; line-height: 1.35;
  color: var(--gold);
}
.office-en {
  font-size: 12px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-2); margin-top: 3px; font-weight: 500;
}
.service {
  display: inline-block; margin-top: 7px;
  font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--gold); font-weight: 600;
  border: 1px solid var(--gold-dim); border-radius: 999px;
  padding: 3px 12px;
}

.masthead-right { display: flex; align-items: center; gap: 26px; flex: none; }

.clock { text-align: right; }
.clock-time {
  font-family: var(--num);
  font-size: 52px; line-height: .95; letter-spacing: .02em;
  color: var(--gold); font-variant-numeric: tabular-nums;
}
.clock-date {
  font-size: 11px; color: var(--ink-2); letter-spacing: .1em; margin-top: 5px;
}

/* ─── Connection state ──────────────────────────────────────────────────── */
.link-state {
  display: flex; align-items: center; gap: 9px;
  font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase;
  font-weight: 600;
  border: 1px solid; border-radius: 999px; padding: 6px 14px;
}
.link-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

.link-state[data-state="live"]         { color: var(--call);  border-color: var(--call-dim); }
.link-state[data-state="live"] .link-dot { animation: pulse 1.6s ease-in-out infinite; }
.link-state[data-state="connecting"],
.link-state[data-state="reconnecting"] { color: #F0B429; border-color: rgba(240,180,41,.4); }
.link-state[data-state="reconnecting"] .link-dot { animation: blink .7s steps(2) infinite; }
.link-state[data-state="offline"]      { color: #FF6B5E; border-color: rgba(255,107,94,.45); background: rgba(255,107,94,.08); }

@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Dim the whole board when the data is not trustworthy, so nobody reads a
   stale number as current. */
body[data-stale="true"] .stage { opacity: .42; filter: grayscale(.65); }
.stage { transition: opacity .5s, filter .5s; }

/* ─── Stage ─────────────────────────────────────────────────────────────── */
/*
  Organised around the applicant's actual question — "is it my turn?" — not
  around the four windows. Windows that are serving somebody take the space;
  free windows collapse to a strip, because a free window is not news to
  anyone standing in the hall. The next few numbers get real size beside them.
*/
.stage {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 1fr 400px;
  min-height: 0;
}

.rail {
  display: flex; align-items: center; gap: 16px;
  font-size: 15px; font-weight: 700;
  letter-spacing: .2em; text-transform: uppercase;
  color: var(--gold);
  flex: none;
}
.rail span[dir="rtl"] { font-family: var(--fa); letter-spacing: 0; font-size: 20px; font-weight: 700; }
.rail::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold-dim), transparent); }

/* ─── Serving ───────────────────────────────────────────────────────────── */
.serving-col {
  display: flex; flex-direction: column; gap: 18px;
  padding: 20px 24px 20px 34px;
  border-right: 1px solid var(--line);
  min-height: 0;
}

.active-grid {
  display: grid;
  grid-auto-rows: 1fr;
  gap: 18px;
  flex: 1;
  min-height: 0;
}
/* Columns follow how many windows are actually serving, so two busy windows
   get half the board each instead of a quarter. */
.active-grid[data-active="0"] { grid-template-columns: 1fr; }
.active-grid[data-active="1"] { grid-template-columns: 1fr; }
.active-grid[data-active="2"] { grid-template-columns: repeat(2, 1fr); }
.active-grid[data-active="3"] { grid-template-columns: repeat(3, 1fr); }
.active-grid[data-active="4"] { grid-template-columns: repeat(2, 1fr); }
.active-grid[data-active="5"],
.active-grid[data-active="6"] { grid-template-columns: repeat(3, 1fr); }

.card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  background: var(--panel-2);
  border: 2px solid var(--gold-dim);
  border-radius: 22px;
  padding: 14px;
  min-height: 0;
  overflow: hidden;
  transition: border-color .45s, box-shadow .45s, background .45s;
}

.card-no {
  font-family: var(--num);
  font-size: clamp(22px, 2.2vw, 38px);
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold);
  line-height: 1;
  transition: color .4s;
}

/* The number is the point of the card, so it takes the space the old layout
   was giving to padding. */
.card-token {
  font-family: var(--num);
  font-size: clamp(120px, 17vw, 320px);
  line-height: .86;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: color .35s;
}

/* Fewer windows serving means more room per window, so the number grows into
   it rather than leaving the card half empty.
   Width, not height, is what runs out first — and the busiest day on record
   issued 161 tokens, so three-digit numbers are normal and have to be stepped
   down or they run past the card edge. */
.active-grid[data-active="1"] .card-token { font-size: clamp(200px, 30vw, 520px); }
.active-grid[data-active="2"] .card-token { font-size: clamp(160px, 21vw, 400px); }
.active-grid[data-active="3"] .card-token { font-size: clamp(110px, 14vw, 260px); }

.active-grid[data-active="1"] .card-token[data-len="3"] { font-size: clamp(150px, 21vw, 380px); }
.active-grid[data-active="2"] .card-token[data-len="3"] { font-size: clamp(110px, 14vw, 270px); }
.active-grid[data-active="3"] .card-token[data-len="3"] { font-size: clamp(78px, 9.5vw, 175px); }
.active-grid[data-active="4"] .card-token[data-len="3"],
.active-grid[data-active="5"] .card-token[data-len="3"],
.active-grid[data-active="6"] .card-token[data-len="3"] { font-size: clamp(84px, 11.5vw, 215px); }

/* Four digits would mean a day past 999 — not realistic here, but the board
   should degrade rather than break if it ever happens. */
.card-token[data-len="4"] { font-size: clamp(60px, 8vw, 150px) !important; }

.active-grid[data-active="1"] .card-no,
.active-grid[data-active="2"] .card-no { font-size: clamp(26px, 2.6vw, 46px); }

.card-dot, .card-foot { display: none; }

/* ─── Free windows ──────────────────────────────────────────────────────── */
.idle-strip { display: flex; gap: 12px; flex: none; }
.idle-strip:empty { display: none; }

.idle-chip {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 13px 16px;
}
.idle-chip .n {
  font-family: var(--num); font-size: 21px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-2);
}
.idle-chip .s {
  font-size: 12px; font-weight: 600; letter-spacing: .2em; text-transform: uppercase;
  color: var(--flag-green);
}
.idle-chip .s::before { content: '● '; font-size: 9px; vertical-align: middle; }

/* ─── Next in line ──────────────────────────────────────────────────────── */
.next-col {
  display: flex; flex-direction: column; gap: 16px;
  padding: 20px 30px 20px 24px;
  min-height: 0;
}

.next-list { display: flex; flex-direction: column; gap: 12px; flex: 1; min-height: 0; }

.next-item {
  display: flex; align-items: center; gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 20px;
  animation: slide .3s ease both;
}
@keyframes slide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.next-item .pos {
  font-family: var(--num); font-size: 20px;
  color: var(--ink-3); min-width: 42px;
  font-variant-numeric: tabular-nums;
}
.next-item .num {
  font-family: var(--num);
  font-size: clamp(48px, 4.4vw, 86px);
  line-height: 1; color: var(--ink);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
}

/* The one at the front of the line is called out — that is the person who
   most needs to be paying attention. */
.next-item.first {
  border-color: var(--gold); background: linear-gradient(90deg, rgba(200,168,75,.14), var(--panel));
}
.next-item.first .pos { color: var(--gold); }
.next-item.first .num { color: var(--gold-bright); }

.next-empty {
  text-align: center; color: var(--ink-3); margin-top: 40px; line-height: 2.2;
  font-size: 15px;
}
.next-empty .fa { font-family: var(--fa); font-size: 22px; color: var(--idle); display: block; }

.waiting-total {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 16px; flex: none;
}
.waiting-total b {
  font-family: var(--num); font-size: 52px; line-height: 1;
  color: var(--gold); font-variant-numeric: tabular-nums;
}
.waiting-total span { font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.waiting-total .fa { font-family: var(--fa); font-size: 17px; letter-spacing: 0; text-transform: none; }

/* Being called right now */
.card.calling {
  border-color: var(--call);
  box-shadow: 0 0 0 1px var(--call), 0 0 70px rgba(0,227,122,.30), inset 0 0 60px rgba(0,227,122,.07);
}
.card.calling .card-no   { color: var(--call); }
.card.calling .card-dot  { background: var(--call); animation: blink .4s steps(2) infinite; }
.card.calling .card-foot { color: var(--call); }
.card.calling .card-token { animation: tokenFlash 2.4s ease both; }

@keyframes tokenFlash {
  0%   { color: var(--call); transform: scale(1.06); text-shadow: 0 0 50px rgba(0,227,122,.75); }
  12%  { opacity: .15; }
  24%  { opacity: 1; color: var(--gold-bright); }
  36%  { opacity: .15; }
  48%  { opacity: 1; color: var(--call); }
  60%  { opacity: .2; }
  72%  { opacity: 1; color: var(--gold-bright); }
  100% { color: var(--ink); transform: scale(1); text-shadow: none; }
}

/* ─── Status bar ────────────────────────────────────────────────────────── */
/* Served-today and issued-today counts have been removed: they are staff
   figures, and an applicant standing in the hall has no use for them. */
.statusbar {
  position: relative; z-index: 2;
  display: flex; align-items: center;
  background: #070C13;
  border-top: 1px solid var(--line);
  overflow: hidden;
}

.ticker { flex: 1; overflow: hidden; height: 100%; display: flex; align-items: center; mask-image: linear-gradient(90deg, transparent, #000 40px, #000 calc(100% - 40px), transparent); }
.ticker-track {
  display: inline-flex; align-items: center; gap: 70px;
  white-space: nowrap; padding-left: 100%;
  animation: marquee 46s linear infinite;
  font-size: 13px; color: var(--ink-2);
}
.ticker-track .sep { color: var(--gold); font-size: 7px; margin-right: 12px; }
.ticker-track .fa { font-family: var(--fa); font-size: 16px; }
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(-100%); } }

/* ─── Call moment ───────────────────────────────────────────────────────── */
/* The single most important element on the board: one in three applicants
   currently misses their number, so the call takes over the whole screen. */
/* An author `display` beats the UA rule behind the `hidden` attribute, so it
   has to be restated explicitly or the overlay never hides. */
.callout[hidden], .audio-nudge[hidden] { display: none !important; }

.callout {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #0A1B14 0%, #04070A 70%);
  animation: calloutIn .45s cubic-bezier(.2, .8, .2, 1) both;
}
.callout[data-closing="true"] { animation: calloutOut .4s ease both; }

@keyframes calloutIn  { from { opacity: 0; transform: scale(1.04); } to { opacity: 1; transform: none; } }
@keyframes calloutOut { to { opacity: 0; transform: scale(.99); } }

.callout::before {
  content: ''; position: absolute; inset: 0;
  border: 4px solid var(--call);
  animation: frame 1s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes frame { from { opacity: .25; } to { opacity: .9; } }

.callout-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }

.callout-label {
  font-size: 15px; font-weight: 700; letter-spacing: .5em; text-transform: uppercase;
  color: var(--call); margin-bottom: 6px;
}
.callout-token {
  font-family: var(--num);
  font-size: clamp(200px, 34vw, 460px);
  line-height: .85;
  color: #FFFFFF;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 90px rgba(0, 227, 122, .55);
  animation: tokenPop .5s cubic-bezier(.2, 1.5, .4, 1) both;
}
@keyframes tokenPop { from { transform: scale(.8); opacity: 0; } to { transform: none; opacity: 1; } }

.callout-counter {
  font-family: var(--num);
  font-size: clamp(38px, 5.5vw, 76px);
  color: var(--call);
  letter-spacing: .06em; text-transform: uppercase;
  margin-top: 10px;
}
.callout-lines { margin-top: 26px; display: flex; flex-direction: column; gap: 9px; }
.callout-lines div { font-size: clamp(17px, 1.9vw, 27px); color: #C9DCEC; font-weight: 500; }
.callout-lines div[dir="rtl"] { font-family: var(--fa); font-size: clamp(20px, 2.2vw, 32px); }

/* A recall says so, so staff and applicants can tell it apart from a new call. */
.callout[data-recall="true"] .callout-label::after { content: ' · Repeat'; color: var(--gold-bright); }

/* ─── Audio nudge (kiosk mode should make this unnecessary) ─────────────── */
.audio-nudge {
  position: fixed; bottom: 74px; right: 26px; z-index: 60;
  background: rgba(200,168,75,.14);
  border: 1px solid var(--gold); color: var(--gold-bright);
  border-radius: 999px; padding: 12px 22px;
  font-family: var(--ui); font-size: 13px; font-weight: 600; letter-spacing: .1em;
  /* The board hides the cursor; this is the one thing on it meant to be
     clicked, so the pointer has to come back or it cannot be aimed at. */
  cursor: pointer;
  animation: pulseSoft 2s ease-in-out infinite;
}
body:has(.audio-nudge:not([hidden])) { cursor: default; }
@keyframes pulseSoft { 0%,100% { opacity: .65; } 50% { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* All windows free — before the first call of the day, and after the last.
   Deliberately quiet: a full-size empty card shouting AVAILABLE looked like a
   fault rather than a closed counter. */
.card.idle-all {
  background: transparent;
  border: 1px dashed var(--line);
  gap: 10px;
}
.card.idle-all .idle-all-fa,
.card.idle-all .idle-all-ps {
  font-family: var(--fa);
  font-size: clamp(22px, 2.4vw, 38px);
  color: var(--ink-3);
}
.card.idle-all .idle-all-en {
  font-size: clamp(15px, 1.5vw, 24px);
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--idle);
}
