/* DMM -> AMM Flight Tracker
   Theme: light, cool zinc neutrals + one cobalt accent (locked for the page).
   Type: Geist (self-hosted variable) + Geist Mono for data.
   Radius system: cards 12px, controls 8px, chips full pill. */

@font-face {
  font-family: 'Geist';
  src: url('fonts/geist-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'Geist Mono';
  src: url('fonts/geist-mono-latin-wght-normal.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #fafafa;
  --panel: #ffffff;
  --panel-2: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #52525b;
  --text-3: #8b8b93;
  --accent: #1d4ed8;
  --accent-soft: #eaf0fe;
  --accent-ink: #1e3fae;

  --ok: #047857;
  --ok-soft: #e7f6ef;
  --warn: #b45309;
  --warn-soft: #fdf3e7;
  --bad: #be123c;
  --bad-soft: #fdeef2;
  --neutral-soft: #f0f0f2;

  --radius-card: 12px;
  --radius-ctl: 8px;
  --shadow-card: 0 1px 2px rgb(24 24 27 / 0.05), 0 10px 28px -22px rgb(24 24 27 / 0.25);

  --font-sans: 'Geist', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Geist Mono', 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.skip-link {
  position: absolute;
  left: 12px; top: -48px;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: var(--radius-ctl);
  transition: top .15s ease;
  z-index: 50;
}
.skip-link:focus { top: 12px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgb(250 250 250 / 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  flex: none;
}
.brand-mark svg { width: 22px; height: 22px; }

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand-text .arrow { color: var(--accent); font-family: var(--font-mono); }
.brand-sub {
  margin: 1px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
}

.topbar-right { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }

.clock-block { display: flex; align-items: baseline; gap: 8px; }
.clock-label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
.clock {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.clock-date { font-size: 12px; color: var(--text-2); }

.refresh-block { display: flex; align-items: center; gap: 12px; }
.refresh-meta {
  display: flex; flex-direction: column;
  font-size: 11.5px;
  color: var(--text-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  padding: 8px 14px;
  border-radius: var(--radius-ctl);
  cursor: pointer;
  transition: background .15s ease, transform .05s ease, border-color .15s ease;
}
.btn:hover { background: var(--panel-2); border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn svg { width: 15px; height: 15px; }
.btn[disabled] { opacity: 0.55; cursor: default; }
.btn-refresh.busy svg { animation: spin 1s linear infinite; }
.btn-ghost {
  border: none;
  background: transparent;
  color: var(--accent);
  padding: 4px 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- route strip ---------- */

main {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 22px 20px 40px;
  flex: 1;
}

.route-strip {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  grid-template-areas: 'dep path arr';
  align-items: center;
  gap: 10px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px 22px;
  box-shadow: var(--shadow-card);
}

.route-end { display: flex; flex-direction: column; gap: 0; }
.route-end-right { text-align: right; align-items: flex-end; }
.route-code {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.route-city { font-size: 15px; font-weight: 600; }
.route-airport { font-size: 12px; color: var(--text-3); }
.route-role {
  margin-top: 4px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  font-weight: 650;
}

.route-path {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  min-width: 220px;
  justify-content: center;
}
.route-path svg { width: 18px; height: 18px; }
.route-line {
  flex: 1;
  height: 2px;
  background-image: linear-gradient(90deg, var(--accent) 45%, transparent 0);
  background-size: 8px 2px;
  background-repeat: repeat-x;
  opacity: 0.5;
}
.route-duration {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  position: absolute;
  transform: translateY(22px);
}

.rank {
  display: inline-grid;
  place-items: center;
  width: 18px; height: 18px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  flex: none;
}
.rank-note { color: var(--text-3); }

/* ---------- error banner ---------- */

.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  padding: 12px 16px;
  border: 1px solid #f3c6cf;
  background: var(--bad-soft);
  color: var(--bad);
  border-radius: var(--radius-card);
  font-size: 13.5px;
}
.error-banner svg { width: 18px; height: 18px; flex: none; }
.error-banner .btn-ghost { color: var(--bad); font-weight: 650; margin-left: auto; }
.error-banner[hidden] { display: none; }

/* ---------- flight cards ---------- */

.flights {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.flight-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.flight-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.flight-id {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0;
}
.flight-airline { font-size: 12.5px; color: var(--text-2); margin-top: -2px; }

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: 0.01em;
}
.status-chip svg { width: 14px; height: 14px; }
.status-chip .dot {
  width: 7px; height: 7px;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}
.status-scheduled { background: var(--neutral-soft); color: var(--text-2); }
.status-boarding, .status-delayed { background: var(--warn-soft); color: var(--warn); }
.status-airborne { background: var(--accent-soft); color: var(--accent-ink); }
.status-landed, .status-arrived, .status-delivered { background: var(--ok-soft); color: var(--ok); }
.status-cancelled { background: var(--bad-soft); color: var(--bad); }
.status-unknown { background: var(--neutral-soft); color: var(--text-3); }

.head-when {
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.head-when .kind {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  display: block;
}
.head-when .countdown {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}
.head-when .date-note { font-size: 11.5px; color: var(--text-3); display: block; }

.flight-body {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(220px, 1fr);
  gap: 0;
}

.leg-panel { padding: 18px 20px; border-right: 1px solid var(--border); }
.detail-panel { padding: 18px 20px; background: #fcfcfd; }

.legs {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
}

.leg { display: flex; flex-direction: column; gap: 3px; }
.leg-arr { text-align: right; align-items: flex-end; }
.leg-code {
  font-family: var(--font-mono);
  font-size: 17px;
  font-weight: 700;
}
.leg-city { font-size: 12px; color: var(--text-2); }
.leg-times {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-variant-numeric: tabular-nums;
}
.leg-times .row {
  display: flex;
  gap: 8px;
  font-size: 12.5px;
}
.leg-arr .leg-times .row { justify-content: flex-end; }
.leg-times .k { color: var(--text-3); min-width: 62px; }
.leg-times .v { font-family: var(--font-mono); font-weight: 600; }
.leg-times .v.actual { color: var(--ok); }
.leg-times .v.changed { color: var(--warn); }
.leg-times .v.muted { color: var(--text-3); font-weight: 500; }

.track {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding-top: 6px;
  min-width: 120px;
}
.track svg { width: 16px; height: 16px; color: var(--accent); }
.track-bar {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
  position: relative;
}
.track-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  width: 0;
  transition: width .8s ease;
}
.track-note { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}
.detail {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.detail .k {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}
.detail .v {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 600;
  overflow-wrap: anywhere;
}
.detail .v.empty { color: var(--text-3); font-weight: 500; }

.alerts { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.alert-chip {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--warn);
  background: var(--warn-soft);
  border-radius: var(--radius-ctl);
  padding: 8px 10px;
}
.alert-chip svg { width: 14px; height: 14px; flex: none; margin-top: 1px; }

/* ---------- source ledger ---------- */

.ledger {
  border-top: 1px solid var(--border);
  padding: 12px 20px 14px;
}
.ledger-title {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  margin: 0 0 8px;
}
.ledger-rows {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}
.ledger-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
  padding: 8px 10px;
  min-width: 0;
}
.ledger-row .rank { width: 17px; height: 17px; font-size: 10px; }
.ledger-row .who {
  font-weight: 650;
  font-size: 12.5px;
  white-space: nowrap;
}
.ledger-row .says {
  font-size: 11.5px;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.ledger-row .verdict {
  font-size: 10.5px;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.verdict-used { background: var(--ok-soft); color: var(--ok); }
.verdict-skip { background: var(--neutral-soft); color: var(--text-3); }
.verdict-none { background: var(--bad-soft); color: var(--bad); }
.ledger-row a.ext {
  display: inline-grid;
  place-items: center;
  color: var(--text-3);
  flex: none;
}
.ledger-row a.ext:hover { color: var(--accent); }
.ledger-row a.ext svg { width: 13px; height: 13px; }

/* ---------- empty / not-scheduled state ---------- */

.not-scheduled {
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.not-scheduled .big {
  font-size: 15px;
  font-weight: 650;
}
.not-scheduled p { margin: 0; color: var(--text-2); font-size: 13.5px; max-width: 62ch; }
.not-scheduled .next-line {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border-radius: var(--radius-ctl);
  padding: 8px 12px;
  align-self: flex-start;
}

/* ---------- spotlight (previous / next) ---------- */

.spotlight {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 18px;
}

.spot-card { display: flex; flex-direction: column; }

.spot-label {
  margin: 0;
  padding: 12px 20px 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--accent);
}

.spot-card .flight-head {
  border-bottom: 1px solid var(--border);
  padding-top: 10px;
}

.spot-card .flight-body { grid-template-columns: 1fr; }
.spot-card .leg-panel { border-right: none; border-bottom: 1px solid var(--border); }

/* ---------- minimal flight rows ---------- */

.flight-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.row-main {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  flex-wrap: wrap;
}

.row-id { min-width: 110px; }
.row-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
}
.row-airline { font-size: 11.5px; color: var(--text-2); }

.row-when {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 150px;
}
.row-when .kind {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
}
.row-times {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.row-countdown {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn-details {
  padding: 7px 12px;
  font-size: 12.5px;
}
.btn-details .chev { transition: transform .15s ease; }
.btn-details.open .chev { transform: rotate(180deg); }

.row-expand {
  border-top: 1px solid var(--border);
  background: #fcfcfd;
}
.row-expand .flight-body { grid-template-columns: 1fr 1fr; }

/* ---------- disclosure (sources & history) ---------- */

.disclosure {
  border-top: 1px solid var(--border);
  padding: 8px 12px 12px;
}

.disclosure summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-2);
  padding: 6px 8px;
  border-radius: var(--radius-ctl);
  user-select: none;
}
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary:hover { background: var(--panel-2); color: var(--text); }
.disclosure summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.disclosure .chev {
  width: 14px;
  height: 14px;
  transition: transform .15s ease;
}
.disclosure[open] .chev { transform: rotate(180deg); }

.disclosure-body { padding: 8px 8px 4px; }
.disclosure-body .ledger-title { margin-top: 10px; }

.occ-line {
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-ctl);
  padding: 8px 10px;
  margin-bottom: 8px;
}

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--border);
  padding: 18px 20px 26px;
  text-align: center;
  color: var(--text-2);
  font-size: 12.5px;
}
.footer p { margin: 2px 0; }
.footer-meta { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ---------- skeleton ---------- */

.skeleton .sk {
  background: linear-gradient(90deg, #f0f0f2 25%, #e6e6ea 37%, #f0f0f2 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 6px;
}
.sk-row { display: flex; justify-content: space-between; gap: 12px; }
.sk-title { width: 120px; height: 26px; }
.sk-chip { width: 110px; height: 26px; border-radius: 999px !important; }
.sk-line { height: 14px; margin-top: 14px; }
.sk-line.short { width: 60%; }
.sk-block { height: 74px; margin-top: 18px; }
.skeleton { padding: 18px 20px; }

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

/* ---------- responsive ---------- */

@media (max-width: 900px) {
  .flight-body { grid-template-columns: 1fr; }
  .leg-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .spotlight { grid-template-columns: 1fr; }
  .row-expand .flight-body { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar-inner { padding: 12px 14px; }
  .topbar-right { width: 100%; justify-content: space-between; gap: 12px; }
  .clock { font-size: 19px; }
  .route-strip {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      'dep arr'
      'path path';
    text-align: left;
  }
  .route-end-right { align-items: flex-end; }
  .route-path { min-width: 0; }
  .route-duration { position: static; transform: none; }
  main { padding: 16px 14px 32px; }
  .flight-head { padding: 14px 16px; }
  .head-when { margin-left: 0; text-align: left; width: 100%; }
  .leg-panel, .detail-panel { padding: 16px; }
  .legs { grid-template-columns: 1fr; gap: 18px; }
  .leg-arr { text-align: left; align-items: flex-start; }
  .leg-arr .leg-times .row { justify-content: flex-start; }
  .track { align-self: stretch; }
  .ledger-rows { grid-template-columns: 1fr; }
}

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