/* ──────────────────────────────────────────────────────────────
   ATL Arrivals — styles
   Maps onto /assets/tokens.css brand vars
   ────────────────────────────────────────────────────────────── */
:root {
  --bg:       var(--brand-bg);
  --bg2:      var(--brand-bg-2);
  --surface:  var(--brand-surface);
  --border:   var(--brand-border);
  --text:     var(--brand-text);
  --muted:    var(--brand-text-muted);
  --accent:   var(--brand-accent);
  --accent2:  var(--brand-accent-2);
  --glow:     var(--brand-accent-glow);
  --display:  var(--brand-font-display);
  --head:     var(--brand-font-head);
  --body:     var(--brand-font-body);
  --mono:     var(--brand-font-mono);
  --gold:     var(--brand-gold);
  --ease:     var(--brand-ease);

  --landed:    #22c55e;
  --estimated: #6366f1;
  --scheduled: #71717a;
  --delayed:   #f59e0b;
  --canceled:  #ef4444;
  --diverted:  #f97316;
  --intl:      #a78bfa;
  --domestic:  #38bdf8;

  --sidebar-w: 280px;
}

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

html { overflow-x: hidden; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  padding: 1.5rem 1.25rem;
  display: flex; flex-direction: column; gap: .85rem;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  z-index: 100;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: .6rem;
  text-decoration: none; color: var(--text);
}
.brand-logo { font-size: 1.5rem; }
.brand-name { display: block; font-family: var(--display); font-style: italic; font-weight: 400; font-size: 1.15rem; letter-spacing: 0.01em; }
.brand-tag  { display: block; font-size: .7rem; color: var(--muted); }

.airport-badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .75rem;
  text-align: center;
}
.airport-code {
  display: block;
  font-family: var(--head);
  font-weight: 800;
  font-size: 2rem;
  letter-spacing: .05em;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.airport-name {
  display: block;
  font-size: .65rem;
  color: var(--muted);
  margin-top: .15rem;
}

.data-freshness {
  display: flex; align-items: flex-start; gap: .45rem;
  font-size: .75rem; color: var(--muted);
}
.fresh-lines { display: flex; flex-direction: column; gap: .12rem; }
.next-refresh { font-size: .68rem; opacity: .8; }
.fresh-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: .3rem;
  flex-shrink: 0;
  background: var(--landed);
  animation: pulse-dot 2s ease infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: .4; }
}

.btn-refresh {
  width: 100%; padding: .55rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .4rem;
  color: var(--text);
  font-family: var(--body);
  font-size: .8rem;
  cursor: pointer;
  transition: background .2s var(--ease);
}
.btn-refresh:hover { background: rgba(255,255,255,.08); }

.about-box {
  font-size: .7rem; color: var(--muted);
  line-height: 1.5;
  margin-top: auto;
}
.about-box b { color: var(--text); display: block; margin-bottom: .2rem; }
.disclaimer { display: block; margin-top: .3rem; font-style: italic; opacity: .7; }

.back-link {
  font-size: .75rem; color: var(--muted);
  text-decoration: none;
  transition: color .2s;
}
.back-link:hover { color: var(--accent); }

/* ── Main ──────────────────────────────────────────────────── */
.dash {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 1.5rem 2rem 3rem;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}

/* States */
.state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1rem; min-height: 60vh;
}
.state[hidden] { display: none; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-msg { color: var(--canceled); font-size: .95rem; }
.btn-load {
  padding: .45rem 1.2rem;
  background: var(--accent);
  border: none; border-radius: .35rem;
  color: #fff;
  font-family: var(--body);
  cursor: pointer;
}

/* ── KPI Row ───────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .75rem;
  margin-bottom: 1.25rem;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .85rem 1rem;
}
.kpi-label {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.kpi-value {
  font-family: var(--head);
  font-weight: 700;
  font-size: 1.6rem;
  margin-top: .15rem;
}
.kpi-sub {
  font-size: .72rem;
  color: var(--muted);
  margin-top: .1rem;
}
.kpi--peak .kpi-value { color: var(--landed); }
.kpi--now .kpi-value  { color: var(--accent); }
.kpi--slow .kpi-value { color: var(--muted); }
.kpi--dom .kpi-value  { color: var(--domestic); }
.kpi--intl .kpi-value { color: var(--intl); }

/* ── Charts ────────────────────────────────────────────────── */
.chart-section {
  margin-bottom: 1.5rem;
}
.section-head {
  display: flex; align-items: center; gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .75rem;
}
/* Keep the title + rule on their own line so each filter group gets a
   full-width row below it. */
.section-head h3 { flex: 0 0 auto; }
.section-head .line { flex: 1 1 60px; }
.section-head h3 {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: var(--brand-credit-tracking, .32em);
  text-transform: uppercase;
  color: var(--gold);
  white-space: nowrap;
}
.line { flex: 1; height: 1px; background: linear-gradient(to right, rgba(217,164,65,0.35), var(--border) 40%); }

.chart-note {
  font-size: .75rem;
  color: var(--muted);
  margin-bottom: .5rem;
  padding-left: .25rem;
}

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .75rem;
  overflow-x: auto;
  min-width: 0;
}

/* Wave chart bar styling via canvas — handled in JS */
.wave-canvas {
  width: 100%;
  height: 320px;
  display: block;
}

/* Terminal heatmap grid */
.heatmap-grid {
  display: grid;
  gap: 2px;
}
.heatmap-cell {
  border-radius: .25rem;
  padding: .3rem .25rem;
  text-align: center;
  font-size: .65rem;
  font-family: var(--mono);
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: transform .15s var(--ease);
}
.heatmap-cell:hover { transform: scale(1.05); }
.heatmap-label {
  font-family: var(--head);
  font-weight: 700;
  font-size: .75rem;
  color: var(--text);
  padding: .3rem .5rem;
  display: flex;
  align-items: center;
}
.heatmap-hour-label {
  font-size: .6rem;
  color: var(--muted);
  text-align: center;
  padding: .2rem 0;
}

/* Intl chart */
.intl-bars { display: flex; flex-direction: column; gap: 3px; }
.intl-row {
  display: flex; align-items: center; gap: .5rem;
  font-size: .7rem;
}
.intl-time {
  width: 40px;
  font-family: var(--mono);
  color: var(--muted);
  text-align: right;
  flex-shrink: 0;
}
.intl-bar-wrap {
  flex: 1; display: flex; height: 22px; border-radius: .2rem; overflow: hidden;
}
.intl-bar-dom { background: var(--domestic); height: 100%; }
.intl-bar-intl { background: var(--intl); height: 100%; }
.intl-count {
  width: 40px;
  font-family: var(--mono);
  color: var(--muted);
  text-align: left;
  flex-shrink: 0;
}

.intl-legend {
  display: flex; gap: 1rem; margin-top: .5rem; font-size: .7rem; color: var(--muted);
}
.intl-legend span::before {
  content: '';
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 2px;
  margin-right: .3rem;
  vertical-align: middle;
}
.intl-legend .leg-dom::before  { background: var(--domestic); }
.intl-legend .leg-intl::before { background: var(--intl); }

/* ── Window filter pills ──────────────────────────────────────
   Each filter group takes a full-width row and its buttons stretch to
   share it equally — big, easy tap targets that auto-fit any screen. */
.window-filter {
  display: flex;
  gap: .4rem;
  width: 100%;
  margin-left: 0;
  margin-top: .1rem;
}
.wf-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 40px;
  padding: .5rem .5rem;
  font-size: .85rem;
  font-family: var(--body);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: .45rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .2s var(--ease);
}
.wf-btn:hover { border-color: var(--accent); color: var(--text); }
.wf-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ── Board table ───────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
.data {
  width: 100%;
  border-collapse: collapse;
  font-size: .78rem;
}
.data th {
  font-family: var(--head);
  font-weight: 600;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  text-align: left;
  padding: .5rem .6rem;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg);
}
.data td {
  padding: .4rem .6rem;
  border-bottom: 1px solid rgba(255,255,255,.03);
  white-space: nowrap;
}
.data tbody tr:hover { background: rgba(255,255,255,.03); }
.data .st-landed   { color: var(--landed); }
.data .st-estimated { color: var(--estimated); }
.data .st-scheduled { color: var(--scheduled); }
.data .st-delayed   { color: var(--delayed); }
.data .st-canceled  { color: var(--canceled); text-decoration: line-through; }
.data .st-diverted  { color: var(--diverted); }
.data .intl-flag    { color: var(--intl); font-weight: 600; }

/* ── Footer ────────────────────────────────────────────────── */
.dash-foot {
  text-align: center;
  font-size: .7rem;
  color: var(--muted);
  opacity: .6;
  padding-top: 2rem;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: .75rem 1rem;
    gap: .5rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .airport-badge { display: none; }
  .about-box { display: none; }
  .back-link { display: none; }
  .data-freshness { order: 2; margin-left: auto; font-size: .65rem; }
  .btn-refresh { width: auto; order: 3; padding: .4rem .75rem; font-size: .7rem; }

  body { flex-direction: column; }

  .dash {
    margin-left: 0;
    padding: .75rem;
    width: 100%;
    max-width: 100vw;
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
  }
  .kpi { padding: .5rem .6rem; }
  .kpi-value { font-size: 1.1rem; }
  .kpi-label { font-size: .55rem; }
  .kpi-sub { font-size: .55rem; }

  .chart-section { margin-bottom: 1rem; }
  .chart-wrap { padding: .4rem; }

  .section-head { gap: .4rem; margin-bottom: .5rem; }
  .section-head h3 { font-size: .85rem; }
  .line { display: none; }
  /* Buttons still stretch to fill the row (flex:1 from base) — just a touch
     tighter so all of them fit without scrolling on a phone. */
  .window-filter { gap: .3rem; }
  .wf-btn { min-height: 38px; padding: .5rem .3rem; font-size: .8rem; }

  .heatmap-grid { font-size: .5rem; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .heatmap-cell { min-height: 24px; padding: .15rem .1rem; font-size: .5rem; }
  .heatmap-label { font-size: .6rem; padding: .15rem .25rem; min-width: 55px; }
  .heatmap-hour-label { font-size: .5rem; }

  .intl-time { width: 28px; font-size: .55rem; }
  .intl-count { width: 36px; font-size: .55rem; }
  .intl-row { gap: .3rem; }
  .intl-bar-wrap { height: 18px; }
  .intl-legend { font-size: .6rem; flex-wrap: wrap; }

  .chart-note { font-size: .65rem; }

  .data { font-size: .68rem; }
  .data th { font-size: .58rem; padding: .3rem .35rem; }
  .data td { padding: .25rem .35rem; }
}

@media (max-width: 500px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
  .kpi { padding: .45rem .5rem; }
  .kpi-value { font-size: .95rem; }
  .kpi-label { font-size: .5rem; }
  .kpi-sub { font-size: .5rem; }
  .brand-name { font-size: .8rem; }
  .brand-tag { font-size: .55rem; }
  .section-head h3 { font-size: .8rem; }
}
