/**
 * scaber-mini — styles.
 *
 * Deliberately NOT the SCABER look. SCABER is a light "Lufthansa Ops" surface
 * in navy and yellow; this is the other half of the airport: the departure
 * board. Near-black ground, split-flap tiles for the number that matters,
 * a viewfinder reticle over the camera, a runway centreline as the divider.
 *
 * One accent colour does the signalling — white while counting, mint on the
 * exact target, amber past it, red for a foreign flight — so the screen can be
 * read at arm's length in a jet bridge without reading a single word.
 */

/* ==================== Fonts (self-hosted, no network) ==================== */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('./fonts/inter-var.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('./fonts/jetbrains-mono-var.woff2') format('woff2');
}

/* ==================== Tokens ==================== */
:root {
  color-scheme: dark;

  --bg: #0A0D11;
  --panel: #131920;
  --panel-2: #1A212B;
  --line: #232C38;
  --line-soft: #1A2029;

  --text: #EDF1F6;
  --dim: #8A97A6;
  --soft: #5A6673;

  --go: #00E29A;        /* target reached, scan counted */
  --hold: #FFB84D;      /* already counted, past the target */
  --stop: #FF5A52;      /* foreign flight, unreadable pass */

  --radius: 3px;
  --radius-lg: 6px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* ==================== Header ==================== */
.header {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg);
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: baseline; gap: 7px; }
.brand-mark {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
}
.brand-sub {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--go);
  border: 1px solid var(--go);
  border-radius: 2px;
  padding: 1px 5px;
}
.header .spacer { flex: 1; }
.header-btn {
  background: none;
  border: 0;
  color: var(--dim);
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  border-radius: var(--radius);
}
.header-btn:active { color: var(--text); background: var(--panel); }

/* Runway centreline under the header */
.runway {
  height: 3px;
  background: repeating-linear-gradient(90deg, var(--soft) 0 20px, transparent 20px 38px);
  opacity: 0.4;
}

/* ==================== Screens ==================== */
main { padding: 22px 16px 28px; max-width: 560px; margin: 0 auto; }
.screen { display: none; }
.screen.active { display: block; }

h2 {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 16px;
}

/* ==================== Form ==================== */
.field { margin-bottom: 24px; }
.field label {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}
.field .hint {
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--soft);
  text-transform: none;
}
.field input {
  width: 100%;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--line);
  border-radius: 0;
  padding: 6px 2px 10px;
}
.field input:focus { outline: none; border-bottom-color: var(--go); }
.field input::placeholder { color: #2C3742; font-weight: 700; }

.form-error {
  color: var(--stop);
  border-left: 2px solid var(--stop);
  background: rgba(255, 90, 82, 0.08);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.45;
  padding: 10px 12px;
  margin-bottom: 20px;
}

/* ==================== Buttons ==================== */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
}
.btn + .btn { margin-top: 10px; }
.btn-primary { background: var(--go); color: #04120C; }
.btn-primary:active { background: #00C889; }
.btn-outline { background: transparent; color: var(--text); border-color: var(--line); }
.btn-outline:active { background: var(--panel); }
.btn-sm { padding: 13px; font-size: 0.72rem; }

/* ==================== Notice ==================== */
.notice {
  display: flex;
  gap: 10px;
  border-left: 2px solid var(--hold);
  background: rgba(255, 184, 77, 0.07);
  color: var(--hold);
  font-size: 0.76rem;
  line-height: 1.5;
  padding: 12px 14px;
  margin-bottom: 22px;
}
.notice svg { flex: 0 0 auto; margin-top: 2px; }
.notice b { color: #FFD08A; }

/* ==================== Split-flap board ==================== */
.board {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}
.flaps { display: flex; gap: 5px; }
.flap {
  position: relative;
  min-width: 0.78em;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 3.9rem;
  font-weight: 700;
  line-height: 1.12;
  text-align: center;
  color: var(--text);
  background: linear-gradient(180deg, #1D2530 0%, #161D26 49.6%, #10161D 50.4%, #19212B 100%);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.06em;
  transition: color 0.15s ease;
}
/* the flap seam */
.flap::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(0, 0, 0, 0.6);
}
.board-slash { font-size: 1.5rem; font-weight: 300; color: var(--soft); }
.board-total {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--dim);
}

/* Signal colour of the count, readable without reading a word */
.board.full .flap { color: var(--go); }
.board.over .flap { color: var(--hold); }

.status-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 18px;
  min-height: 20px;
}
.status-line .tag {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  letter-spacing: 1.5px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 2px 6px;
}
.status-line .over-flag { color: var(--hold); }

/* ==================== Camera ==================== */
#scanner-container {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  max-height: 54vh;
  background: #05070A;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
}
#scanner-container video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.camera-error {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--dim);
  font-size: 0.82rem;
  line-height: 1.6;
  text-align: center;
  padding: 24px;
}

/* Viewfinder reticle — an aiming guide, and the app's face */
.reticle { position: absolute; inset: 16px; pointer-events: none; z-index: 5; }
.reticle span {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 3px;
}
.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; }

/* Foreign-flight banner — over the camera, never blocks the scan */
.flight-banner {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 30;
  background: var(--stop);
  color: #1A0402;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 12px;
  animation: bannerIn 0.15s ease;
}
.flight-banner .sub {
  display: block;
  font-weight: 600;
  letter-spacing: 1.5px;
  opacity: 0.75;
  font-size: 0.64rem;
  margin-top: 2px;
}
@keyframes bannerIn { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* ==================== Scan feedback ==================== */
.feedback-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 8px;
  pointer-events: none;
  animation: feedbackIn 0.15s ease;
}
@keyframes feedbackIn { from { opacity: 0; } to { opacity: 1; } }
.feedback-overlay.ok    { background: #04120C; color: var(--go); }
.feedback-overlay.warn  { background: #150E02; color: var(--hold); }
.feedback-overlay.error { background: #160402; color: var(--stop); }

.feedback-icon { line-height: 1; margin-bottom: 6px; }
.feedback-icon svg { width: 30px; height: 30px; }
.feedback-text {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 4px;
  text-transform: uppercase;
  text-align: center;
  padding: 0 10px;
}
.feedback-seq {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  margin: 8px 0 4px;
}
.feedback-seq-label {
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 5px;
  text-transform: uppercase;
  opacity: 0.6;
  margin-bottom: 4px;
}
.feedback-seq-num {
  font-weight: 700;
  line-height: 0.86;
  letter-spacing: 2px;
}
.feedback-sub {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 0.72rem;
  letter-spacing: 2px;
  opacity: 0.65;
  margin-top: 6px;
}

/* ==================== Result ==================== */
.done-panel {
  border: 1px solid var(--line);
  border-top: 2px solid var(--dim);
  border-radius: var(--radius-lg);
  background: var(--panel);
  text-align: center;
  padding: 26px 20px 22px;
  margin-bottom: 20px;
}
.done-panel.full { border-top-color: var(--go); }
.done-panel.over { border-top-color: var(--hold); }

.done-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--dim);
}
.done-mark svg { width: 22px; height: 22px; }
.done-panel.full .done-mark { color: var(--go); }
.done-panel.over .done-mark { color: var(--hold); }

.done-board { margin: 18px 0 10px; }
.done-sub {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--soft);
}

/* ==================== Seq list ==================== */
.seq-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 22px 0 10px;
}
.seq-head h2 { margin: 0; }
.seq-count { font-size: 0.66rem; letter-spacing: 2px; color: var(--soft); }

.seq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 6px;
  margin-bottom: 20px;
}
.seq-chip {
  position: relative;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  background: linear-gradient(180deg, #1A212B 0%, #141A23 49.6%, #0F141B 50.4%, #171E27 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 4px;
}
.seq-chip::after {
  content: '';
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: 1px;
  background: rgba(0, 0, 0, 0.5);
}
/* A pass counted although it came from another flight stays visible as such */
.seq-chip.foreign { color: var(--stop); border-color: rgba(255, 90, 82, 0.45); }
.seq-chip .flag {
  display: block;
  position: relative;
  z-index: 1;
  font-size: 0.52rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  color: var(--soft);
  font-size: 0.78rem;
  letter-spacing: 1px;
  padding: 26px 10px;
}
