/* ==========================================================================
   AERO PANEL — METAR/TAF page
   Extends the site's existing type (B612 / B612fixed / Futura, already
   @font-face'd in aero.css) and color language (#036 blue, #4f496b purple,
   #aaa borders) rather than introducing a new one, so this page still
   looks like the rest of the site. Load this AFTER aero.css.
   ========================================================================== */

:root {
  --brand-blue: #003366;
  --brand-blue-soft: #e7edf5;
  --brand-purple: #4f496b;
  --brand-purple-dark: #38334a;
  --border-gray: #aaa;
  --bg-gray: #f3f3f3;
  --text-dark: #222;
  --text-muted: #888;

  --wind-calm: #2e7d32;
  --wind-calm-bg: rgba(46, 125, 50, 0.12);
  --wind-caution: #b06500;
  --wind-caution-bg: rgba(224, 123, 0, 0.16);
  --wind-warning: #b71c1c;
  --wind-warning-bg: rgba(198, 40, 40, 0.16);
  --wind-extreme: #7b1fa2;
  --wind-extreme-bg: rgba(142, 36, 170, 0.16);

  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Futura', 'Helvetica', Arial, sans-serif;
  color: var(--text-dark);
  margin: 0;
}

.wx-page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

/* ---------- Ident form ---------- */

.ident-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.ident-label {
  font-family: 'B612', Arial, sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ident-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ident-input {
  font-family: 'B612fixed', monospace;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand-blue);
  background: #fff;
  border: 2px solid var(--brand-purple);
  border-radius: var(--radius);
  padding: 7px 12px;
  width: 120px;
  outline: none;
}

.ident-input:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--brand-blue-soft);
}

.btn-nearest {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'Futura', Arial, sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-purple);
  background: #fff;
  border: 1.5px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 8px 13px;
  cursor: pointer;
}

.btn-nearest:hover { border-color: var(--brand-purple); background: var(--brand-blue-soft); }

/* ---------- Airport header ---------- */

.apt-header {
  background: var(--brand-purple);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 18px;
}

.apt-header-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }

.apt-header .format_name,
.apt-header .format_id {
  color: #fff; /* override aero.css's #036 — this sits on a dark bar */
}

.apt-header-sub {
  font-size: 0.85rem;
  color: #d8d5e2;
  margin-top: 4px;
}

.apt-badges {
  margin-top: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge-pill {
  display: inline-block;
  font-family: 'B612', Arial, sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--brand-purple);
  background: #fff;
  border-radius: 999px;
  padding: 3px 11px;
  text-decoration: none;
}
.badge-pill:hover { background: var(--brand-blue-soft); color: var(--brand-blue); }

/* ---------- Layout grid ---------- */

.wx-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 860px) {
  .wx-grid {
    grid-template-columns: 1.3fr 1fr;
    grid-template-areas:
      "metar taf"
      "runways runways";
  }
  .aero-box-metar   { grid-area: metar; }
  .aero-box-taf     { grid-area: taf; }
  .aero-box-runways { grid-area: runways; }
}

/* These override the absolute-positioned floating-label .aero-box from
   aero.css with a cleaner boxed-header version, scoped to this page only
   via the extra classes below — aero.css's own .aero-box is untouched,
   so other pages that rely on it keep their current look. */

.wx-grid .aero-box {
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
  padding: 0;
  overflow: hidden;
}

.wx-grid .aero-box-title {
  position: static;
  background: var(--brand-purple);
  color: #fff;
  font-family: 'B612', Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
  padding: 9px 14px;
}

.wx-grid .aero-content { padding: 14px; }
.text-break { overflow-wrap: break-word; word-break: break-word; }

/* ---------- Alerts ---------- */

.wx-alert {
  background: var(--wind-warning-bg);
  color: var(--wind-warning);
  border-left: 3px solid var(--wind-warning);
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.86rem;
  padding: 7px 11px;
  margin-bottom: 10px;
}

.wx-alert-sub { background: var(--brand-blue-soft); color: var(--brand-blue); border-left-color: var(--brand-blue); }

/* ---------- METAR ---------- */

.metar-raw {
  font-family: 'B612fixed', monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  background: var(--bg-gray);
  border: 1px solid var(--border-gray);
  color: var(--text-dark);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 0 0 12px;
}

.metar-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
}

.metar-decoded { flex: 1 1 220px; min-width: 200px; }

.metar-age {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.metar-age a { color: var(--brand-purple); font-weight: 600; }

.metar-diagram { flex: 0 0 auto; max-width: 100%; }
.diagram-svg { width: 100%; max-width: 300px; height: auto; display: block; }

.metar-density-alt-na { font-size: 0.85rem; color: var(--text-muted); }

.meteogram-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-purple);
}

/* ==========================================================================
   WIND / RUNWAY TABLE
   Data shape is one row per metric (headwind/crosswind), one column per
   runway end — so the responsive treatment is a horizontally-scrolling
   table with a sticky first column, not stacked cards.
   ========================================================================== */

.wind-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-gray);
  border-radius: var(--radius);
}

.wind-table {
  border-collapse: collapse;
  width: 100%;
  font-family: 'B612fixed', monospace;
  font-size: 0.82rem;
}

.wind-table th,
.wind-table td {
  padding: 8px 12px;
  text-align: center;
  white-space: nowrap;
  border-bottom: 1px solid #e4e4e4;
}

.wind-table thead th {
  background: var(--brand-purple);
  color: #fff;
  font-family: 'B612', Arial, sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  vertical-align: top;
  border-bottom: none;
}

.wind-table thead th small {
  display: block;
  font-family: 'B612fixed', monospace;
  font-weight: 400;
  font-size: 0.68rem;
  color: #d8d5e2;
  text-transform: none;
  letter-spacing: 0;
  margin-top: 2px;
}

.wind-table tbody th[scope="row"] {
  text-align: left;
  font-family: 'B612', Arial, sans-serif;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg-gray);
}

/* Sticky first column so wide runway sets stay orientable while scrolling */
.wind-table .wind-corner,
.wind-table tbody th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 1;
}
.wind-table .wind-corner { background: var(--brand-purple); z-index: 2; }

.wind-cell { font-weight: 600; }
.wind-glyph { margin-right: 3px; }
.wind-unit { font-size: 0.7rem; color: var(--text-muted); font-family: 'Futura', Arial, sans-serif; margin-left: 2px; }

.wind-calm    { background: var(--wind-calm-bg);    color: var(--wind-calm); }
.wind-caution { background: var(--wind-caution-bg); color: var(--wind-caution); }
.wind-warning { background: var(--wind-warning-bg); color: var(--wind-warning); }
.wind-extreme { background: var(--wind-extreme-bg); color: var(--wind-extreme); }

.wind-tail .wind-glyph { color: var(--wind-warning); }

/* Best runway end — subtle column callout, not a full repaint over
   whatever severity color is already doing the important work */
.wind-table .wind-best { box-shadow: inset 0 0 0 2px var(--brand-blue); }
.wind-best-tag {
  display: block;
  font-size: 0.6rem;
  color: #fff;
  background: var(--brand-blue);
  border-radius: 3px;
  padding: 1px 5px;
  margin-top: 3px;
  font-weight: 700;
}

.wind-legend {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.72rem;
}
.wind-legend-item {
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 600;
}

/* ---------- Small screens ---------- */

@media (max-width: 480px) {
  .wx-page { padding: 12px 8px 28px; }
  .ident-input { width: 100px; font-size: 1.1rem; }
  .wx-grid .aero-content { padding: 10px; }
  .wind-table th, .wind-table td { padding: 7px 9px; font-size: 0.76rem; }
}

/* ---------- Focus visibility ---------- */

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

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