/* board.css — split-flap "Solari board" theme for the PHL flight tracker. */

:root {
  --bg:        #0a0b0d;
  --panel:     #121417;
  --tile:      #1c1f24;
  --tile-top:  #23272e;
  --tile-bot:  #15181c;
  --ink:       #f4f4f1;
  --ink-dim:   #c8c8be;
  --amber:     #f5b301;
  --green:     #38d66b;
  --red:       #ff5a52;
  --line:      #000;
  --tile-h:    1.5em;
  --tile-w:    0.78em;
  --flip-ms:   30ms;
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Brand header ---------- */
.brandbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  background: linear-gradient(#1c1e23, #0c0d10);
  border-bottom: 2px solid #000;
  cursor: pointer;
}
.brandbar .logo { width: 34px; height: 34px; flex: none; display: block; }
.brandbar .brandname {
  font-weight: 800;
  letter-spacing: 0.16em;
  font-size: 1.25rem;
  color: var(--ink);
}
.brandbar .brandname b { color: var(--amber); font-weight: 800; }

/* ---------- Controls bar (airport + clock + status) ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 0.7rem 1rem;
  padding: 0.5rem 1rem;
  background: #0d0e10;
  border-bottom: 1px solid #000;
  flex-wrap: wrap;
}
.current-airport {
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--amber);
  font-size: 1rem;
  white-space: nowrap;
}
.topbar .clock {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.topbar .updated { color: var(--ink-dim); font-size: 0.65rem; letter-spacing: 0.1em; white-space: nowrap; }
.topbar .updated.stale { color: var(--amber); }

/* airport search */
.airport-search { position: relative; flex: 1 1 12rem; min-width: 11rem; max-width: 24rem; order: 5; }
.airport-search input {
  width: 100%;
  background: var(--tile);
  color: var(--ink);
  border: 1px solid #000;
  border-radius: 4px;
  padding: 0.45rem 0.7rem;
  font: inherit;
  letter-spacing: 0.05em;
}
.airport-search input::placeholder { color: #7a7d83; }
#airport-results {
  position: absolute; left: 0; right: 0; top: 100%;
  margin: 2px 0 0; padding: 0; list-style: none;
  background: #15181c; border: 1px solid #000; border-radius: 0 0 6px 6px;
  max-height: 60vh; overflow: auto; z-index: 30;
  box-shadow: 0 10px 28px rgba(0,0,0,.55);
}
#airport-results li {
  padding: 0.55rem 0.7rem; cursor: pointer; border-bottom: 1px solid #1e2126;
  display: flex; gap: 0.6rem; align-items: baseline;
}
#airport-results li.active, #airport-results li:hover { background: #23272e; }
#airport-results .iata { color: var(--amber); font-weight: 800; width: 3em; flex: none; }
#airport-results .nm { color: var(--ink); }
#airport-results .ct { color: var(--ink-dim); font-size: 0.8em; margin-left: auto; white-space: nowrap; }
#airport-results.hidden { display: none; }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 0;
  background: #0d0e10;
  border-bottom: 1px solid #000;
}
.tabs button {
  flex: 1;
  background: none;
  border: none;
  color: var(--ink-dim);
  padding: 0.7rem 0.4rem;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tabs button.active { color: var(--amber); border-bottom-color: var(--amber); }

/* ---------- Sub controls (departures/arrivals toggle, search) ---------- */
.controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  margin-top: 0.6rem;
  flex-wrap: wrap;
}
.controls .seg button {
  background: var(--tile);
  border: 1px solid #000;
  color: var(--ink-dim);
  padding: 0.4rem 0.9rem;
  font: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
.controls .seg button.active { background: var(--amber); color: #1a1300; font-weight: 700; }
.controls input[type="text"] {
  background: var(--tile);
  border: 1px solid #000;
  color: var(--ink);
  padding: 0.5rem 0.7rem;
  font: inherit;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  min-width: 9rem;
}
.controls button.go {
  background: var(--amber);
  border: none;
  color: #1a1300;
  font-weight: 700;
  padding: 0.5rem 1rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 3px;
}

/* Track view: centre the search vertically on the page */
[data-view="track"]:not(.hidden) {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 72vh;
}
[data-view="track"] #track-result { width: 100%; }

main { flex: 1; padding: 0 0.5rem 2rem; }

/* ---------- Board ----------
   Header and rows are flex with identical fixed column widths so they always
   line up. Widths are sized to the split-flap fields and fit a portrait iPad. */
.board { width: 100%; margin: 0; }
.board-head, .board-row {
  display: flex;
  width: 100%;
  gap: 0.6rem;
  align-items: center;
  padding: 0.32rem 0.6rem;
}
/* Widths in rem (not em) so the small-font header lines up with the rows. */
.col-time   { width: 4.5rem;  flex: none; }
.col-flight { width: 6.4rem;  flex: none; }
.col-dest   { flex: 1 1 auto; min-width: 16.5rem; overflow: hidden; }
.col-alt    { width: 4.8rem;  flex: none; }
.col-status { width: 8rem;    flex: none; }
.col-star   { width: 1.7rem;  flex: none; text-align: center; }

/* status colours applied to the flap tiles themselves */
.col-status.status-ontime   .sf-ch { color: var(--green); }
.col-status.status-boarding  .sf-ch { color: var(--amber); }
.col-status.status-delayed   .sf-ch,
.col-status.status-cancelled .sf-ch { color: var(--red); }

.board-head {
  color: var(--amber);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  border-bottom: 1px solid #2a2d33;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 2;
}
.board-row { border-bottom: 1px solid #17191d; cursor: pointer; }
.board-row .star {
  cursor: pointer;
  color: #4a4d53;
  font-size: 1.1rem;
  user-select: none;
}
.board-row .star.on { color: var(--amber); }
.sf-field { flex-wrap: nowrap; }

/* ---------- Split-flap field & tiles ---------- */
.sf-field {
  display: inline-flex;
  gap: 2px;
  font-family: Menlo, "Roboto Mono", "DejaVu Sans Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  font-weight: 700;
}
.sf-cell {
  position: relative;
  display: inline-block;
  width: var(--tile-w);
  height: var(--tile-h);
  line-height: var(--tile-h);
  background: var(--line);
  border-radius: 2px;
  perspective: 180px;
  font-size: 1rem;
  color: var(--ink);
  overflow: hidden;
}
.sf-half, .sf-flap {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  background: var(--tile-top);
}
.sf-half .sf-ch, .sf-flap .sf-ch {
  position: absolute;
  left: 0;
  width: 100%;
  height: var(--tile-h);
  line-height: var(--tile-h);
  text-align: center;
}
.sf-top    { top: 0;    border-bottom: 1px solid #000; border-radius: 2px 2px 0 0; }
.sf-bottom { bottom: 0; background: var(--tile-bot); border-radius: 0 0 2px 2px; }
.sf-top .sf-ch    { top: 0; }
.sf-bottom .sf-ch { top: -100%; }

/* Folding leaves (hidden until a flip runs) */
.sf-flap { backface-visibility: hidden; transform: rotateX(90deg); opacity: 0; }
.sf-flap-front {
  top: 0;
  transform-origin: bottom;
  background: var(--tile-top);
  border-bottom: 1px solid #000;
  border-radius: 2px 2px 0 0;
  transform: rotateX(0deg);
  opacity: 0;            /* hidden at rest — only shown mid-flip */
}
.sf-flap-front .sf-ch { top: 0; }
.sf-flap-back {
  bottom: 0;
  transform-origin: top;
  background: var(--tile-bot);
  border-radius: 0 0 2px 2px;
  transform: rotateX(90deg);
}
.sf-flap-back .sf-ch { top: -100%; }

/* During a flip: front folds down, then back folds up into place. */
.sf-flip .sf-flap-front {
  opacity: 1;
  animation: sf-fold-down var(--flip-ms) ease-in forwards;
}
.sf-flip .sf-flap-back {
  opacity: 1;
  animation: sf-fold-up var(--flip-ms) ease-out var(--flip-ms) forwards;
}
@keyframes sf-fold-down {
  from { transform: rotateX(0deg); }
  to   { transform: rotateX(-90deg); }
}
@keyframes sf-fold-up {
  from { transform: rotateX(90deg); }
  to   { transform: rotateX(0deg); }
}

/* status colouring via modifier classes added by JS */
.status-ontime  { color: var(--green) !important; }
.status-delayed, .status-cancelled, .status-diverted { color: var(--red) !important; }
.status-boarding, .status-departed, .status-landed   { color: var(--amber) !important; }

/* ---------- Track / Tracked / Map panels ---------- */
.panel { max-width: 760px; margin: 1rem auto; padding: 0 0.6rem; }
.flightcard {
  background: var(--panel);
  border: 1px solid #000;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 0.8rem;
}
.flightcard .fc-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.flightcard .fc-num { color: var(--amber); font-weight: 800; letter-spacing: 0.12em; font-size: 1.1rem; }
.flightcard .fc-route {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.6rem; align-items: center;
  font-family: "Helvetica Neue", Arial, sans-serif;
}
.flightcard .fc-ap .code { font-weight: 800; }
.flightcard .fc-ap { text-align: center; }
.flightcard .fc-ap .code { font-size: 1.6rem; font-weight: 800; color: var(--ink); }
.flightcard .fc-ap .city { font-size: 0.7rem; color: var(--ink-dim); letter-spacing: 0.1em; }
.flightcard .fc-ap .time { font-size: 1rem; color: var(--amber); margin-top: 0.2rem; }
.flightcard .fc-arrow { color: var(--ink-dim); font-size: 1.3rem; }
.flightcard .fc-meta { margin-top: 0.7rem; color: var(--ink-dim); font-size: 0.78rem; letter-spacing: 0.06em; }
.flightcard .fc-meta b { color: var(--ink); font-weight: 700; }
.empty { color: var(--ink-dim); text-align: center; padding: 2rem 1rem; letter-spacing: 0.1em; }

#map { width: 100%; height: 70vh; max-width: 1000px; margin: 0.5rem auto; border: 1px solid #000; border-radius: 6px; }
.leaflet-container { background: #0a0b0d; }
.plane-marker { color: var(--amber); font-size: 1.2rem; line-height: 1; will-change: transform; transition: transform 1s linear; }
.plane-marker.on-ground { color: #6a6d73; font-size: 1rem; }

.radar-bar { max-width: 1000px; margin: 0 auto; gap: 0.8rem; }
.radar-title { color: var(--amber); font-weight: 800; letter-spacing: 0.18em; font-size: 0.8rem; }
#radar-count { color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: 0.1em; font-size: 0.8rem; }
.radar-src { margin-left: auto; color: var(--ink-dim); font-size: 0.65rem; letter-spacing: 0.08em; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: #15181c; color: var(--ink); }
.leaflet-popup-content { font-family: Menlo, "Roboto Mono", ui-monospace, monospace; }
.leaflet-popup-content .more-info { color: var(--amber); font-weight: 700; }

/* ---------- Install hint ---------- */
.install-hint {
  margin: 0.6rem auto; max-width: 760px;
  background: #1a1d22; border: 1px solid var(--amber);
  color: var(--ink-dim); padding: 0.7rem 1rem; border-radius: 6px;
  font-size: 0.75rem; letter-spacing: 0.05em; display: none;
}
.install-hint.show { display: block; }
.install-hint b { color: var(--amber); }
.install-hint .close { float: right; cursor: pointer; color: var(--ink-dim); }

.hidden { display: none !important; }

/* ---------- Home launchpad ---------- */
body.home-active .tabs { display: none; }
.home {
  max-width: 640px;
  margin: 1.5rem auto;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.home a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.6rem;
  aspect-ratio: 1 / 1;
  background: linear-gradient(#1a1d22, #111317);
  border: 1px solid #000; border-radius: 14px;
  color: var(--ink); text-decoration: none;
  font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; font-size: 1rem;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
}
.home a:active { transform: scale(0.98); }
.home a .ico { font-size: 2.6rem; line-height: 1; color: var(--amber); }
.home a .sub { font-size: 0.6rem; letter-spacing: 0.1em; color: var(--ink-dim); text-transform: none; font-weight: 600; }

/* ---------- Flight detail ---------- */
.fp { max-width: 760px; margin: 0.5rem auto 2rem; padding: 0 0.8rem; }
.fp-back { background: none; border: none; color: var(--amber); font: inherit; font-weight: 700;
  letter-spacing: 0.08em; cursor: pointer; padding: 0.6rem 0; }
.fp-head { display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap; }
.fp-num { color: var(--amber); font-weight: 800; letter-spacing: 0.1em; font-size: 1.6rem; }
.fp-status { font-weight: 700; letter-spacing: 0.08em; }
.fp-airline { color: var(--ink-dim); letter-spacing: 0.06em; margin-top: 0.2rem; }
.fp-route { display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.6rem; align-items: center;
  margin: 0.8rem 0; font-family: "Helvetica Neue", Arial, sans-serif; }
.fp-times { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.6rem 0; }
.fp-ap { text-align: center; }
.fp-ap .code { font-size: 2rem; font-weight: 800; color: var(--ink); }
.fp-ap .city { font-size: 0.72rem; color: var(--ink-dim); letter-spacing: 0.08em; }
.fp-arrow { color: var(--amber); font-size: 1.4rem; }
.fp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; margin: 0.8rem 0; }
.fp-stat { background: var(--panel); border: 1px solid #000; border-radius: 8px; padding: 0.7rem; text-align: center; }
.fp-stat .v { font-size: 1.2rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.fp-stat .k { font-size: 0.6rem; letter-spacing: 0.12em; color: var(--ink-dim); text-transform: uppercase; margin-top: 0.2rem; }
.fp-meta { color: var(--ink-dim); font-size: 0.8rem; letter-spacing: 0.05em; margin: 0.3rem 0 0.6rem; }
.fp-meta b { color: var(--ink); }
#fp-map { width: 100%; height: 320px; border: 1px solid #000; border-radius: 10px; }
.fp-note { color: var(--ink-dim); font-size: 0.7rem; margin-top: 0.5rem; letter-spacing: 0.04em; }
.fp-star { background: var(--tile); border: 1px solid #000; color: var(--ink); font: inherit; font-weight: 700;
  padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; letter-spacing: 0.06em; }
.fp-star.on { color: var(--amber); border-color: var(--amber); }

/* Narrow phones: shrink tiles a touch so the board still fits. */
/* Narrow phones: shrink tiles a touch so the board still fits. */
@media (max-width: 430px) {
  :root { --tile-w: 0.68em; }
  .board-head, .board-row { gap: 0.35rem; padding-left: 0.4rem; padding-right: 0.4rem; }
  .col-time   { width: 4.1rem; }
  .col-flight { width: 5.7rem; }
  .col-dest   { min-width: 7rem; }
  .col-alt    { width: 4.2rem; }
  .col-status { width: 7.3rem; }
}
