/* ————————————————————————————————————————————————
   GAN FIDS — split-flap board
   Palette: warm tarmac black, ivory flap paint, amber times,
   lagoon teal (Addu) for live accents, coral red for cancellations.
   ———————————————————————————————————————————————— */

:root {
  --tarmac: #101214;
  --housing: #1a1e22;
  --housing-edge: #2a2f35;
  --flap-hi: #23272c;
  --flap-lo: #191d21;
  --ivory: #e8e4d8;
  --ivory-dim: #8f8d84;
  --amber: #f5b942;
  --lagoon: #4fc8c4;
  --coral: #e4574f;

  --cell-w: 24px;
  --cell-h: 38px;
  --cell-fs: 25px;
  --cell-gap: 2px;
  --col-gap: 22px;

  --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

* { box-sizing: border-box; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

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

body {
  background: var(--tarmac);
  color: var(--ivory);
  font-family: var(--font-mono);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ————— masthead ————— */

/* 1fr auto 1fr grid keeps the tab pair centred on the viewport (and thus on
   the board's centreline) regardless of how wide the logo/clock blocks are. */
.masthead {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 22px clamp(16px, 4vw, 48px) 18px;
}

.ident { justify-self: start; }
.dir-tabs { justify-self: center; }
.station { justify-self: end; }

.ident { display: flex; align-items: center; gap: 16px; }

.ident-code {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 56px;
  line-height: 1;
  letter-spacing: 0.04em;
  color: var(--amber);
}

.ident-text { display: flex; flex-direction: column; gap: 4px; }

.ident-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ident-sub {
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--ivory-dim);
}

.dir-tabs { display: flex; gap: 4px; width: 100%; }

.dir-tab {
  appearance: none;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--housing);
  border: 1px solid var(--housing-edge);
  color: var(--ivory-dim);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  padding: 10px 26px 8px;
  cursor: pointer;
  border-radius: 3px;
  border-bottom-width: 3px;
  transition: color 0.15s ease;
}

/* AIGA/DOT convention: departures ascend, arrivals descend */
.tab-ico { width: 17px; height: 17px; fill: currentColor; flex: none; }

.dir-tab:hover { color: var(--ivory); }

.dir-tab.is-on {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

.dir-tab:focus-visible,
.footer-tv:focus-visible,
.board-row:focus-visible {
  outline: 2px solid var(--lagoon);
  outline-offset: 2px;
}

.station { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.station-clock {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 34px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.station-meta, .station-wx {
  font-size: 10px;
  letter-spacing: 0.24em;
  color: var(--ivory-dim);
}

.station-wx { color: var(--lagoon); }

/* ————— board ————— */

.board {
  width: fit-content;
  max-width: 100%;
  /* Anchored under the masthead. `margin: auto` here would centre the card in
     the body column's leftover space, which floats it half-way down the screen
     whenever the list is short (e.g. after midnight, when the previous day's
     flights age out). Kiosk mode still centres — see body.tv below. */
  margin: 0 auto;
  /* top padding is the breathing room between the station block and the
     column header — the masthead's own padding alone leaves them crammed */
  padding: 26px 12px 24px;
  overflow-x: auto; /* safety net: degrade to scroll, never blow out the page */
}

.board-head {
  display: flex;
  gap: var(--col-gap);
  padding: 0 15px 8px; /* rows padding 14px + 1px container border */
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

/* column widths = cells × (w + gap) − gap */
.col-time   { width: calc(5 * (var(--cell-w) + var(--cell-gap)) - var(--cell-gap)); }
.col-flight { width: calc(6 * (var(--cell-w) + var(--cell-gap)) - var(--cell-gap)); }
.col-city   { width: calc(11 * (var(--cell-w) + var(--cell-gap)) - var(--cell-gap)); }
.col-exp    { width: calc(5 * (var(--cell-w) + var(--cell-gap)) - var(--cell-gap)); }
.col-status { width: calc(9 * (var(--cell-w) + var(--cell-gap)) - var(--cell-gap)); }

.board-rows {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--housing);
  border: 1px solid var(--housing-edge);
  border-radius: 6px;
  padding: 12px 14px;
}

.day-rule {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.34em;
  color: var(--ivory-dim);
  padding: 8px 2px 4px;
  text-transform: uppercase;
}

.day-rule::before, .day-rule::after {
  content: '';
  height: 1px;
  background: var(--housing-edge);
  flex: 1;
}

/* watched flights get a small bell in a shared left gutter — visible if you
   look for it, quiet enough not to compete with the flaps */
.row-wrap { position: relative; padding-left: 16px; }
.row-wrap.is-watched::before {
  content: '';
  position: absolute;
  left: 0;
  /* line the bell up with the flaps, not the middle of the whole row (which
     on mobile sits between the flaps and the route sub-line) */
  top: calc(var(--cell-h) / 2);
  transform: translateY(-50%);
  width: 11px;
  height: 11px;
  opacity: 0.7;
  background: no-repeat center / contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234fc8c4' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 8a6 6 0 1 0-12 0c0 7-3 9-3 9h18s-3-2-3-9'/%3E%3Cpath d='M13.7 21a2 2 0 0 1-3.4 0'/%3E%3C/svg%3E");
}

.board-row {
  display: flex;
  gap: var(--col-gap);
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.flap-col { display: flex; gap: var(--cell-gap); }

.empty-note {
  padding: 26px 8px;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--ivory-dim);
  text-transform: uppercase;
}

/* ————— flap cell ————— */

.cell {
  position: relative;
  width: var(--cell-w);
  height: var(--cell-h);
  perspective: 240px;
  border-radius: 2px;
}

.cell i {
  display: block;
  font-style: normal;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--cell-fs);
  line-height: var(--cell-h);
  height: var(--cell-h);
  width: 100%;
  text-align: center;
  color: var(--ivory);
}

.half, .leaf { position: absolute; left: 0; width: 100%; height: 50%; overflow: hidden; }

.half.top, .leaf { top: 0; }
.half.bot { bottom: 0; }

.half.top, .leaf-face.front {
  background: linear-gradient(var(--flap-hi), #202429);
  border-radius: 2px 2px 0 0;
}

.half.bot, .leaf-face.back {
  background: linear-gradient(#171b1f, var(--flap-lo));
  border-radius: 0 0 2px 2px;
}

.half.bot i { margin-top: calc(var(--cell-h) / -2); }

/* hinge line */
.cell::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 1px;
  background: rgba(0, 0, 0, 0.55);
  z-index: 4;
  pointer-events: none;
}

.leaf {
  z-index: 3;
  transform-origin: center bottom;
  transform-style: preserve-3d;
  pointer-events: none;
  visibility: hidden;
}

.leaf-face { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; }
.leaf-face.back { transform: rotateX(180deg); }
.leaf-face.back i { margin-top: calc(var(--cell-h) / -2); }

.cell.flipping .leaf { visibility: visible; animation: leaf-fall 110ms ease-in forwards; }

@keyframes leaf-fall {
  from { transform: rotateX(0deg); }
  to   { transform: rotateX(-180deg); }
}

@media (prefers-reduced-motion: reduce) {
  .cell.flipping .leaf { animation: none; visibility: hidden; }
}

/* status / accent colours apply to glyphs */
.c-amber i  { color: var(--amber); }
.c-lagoon i { color: var(--lagoon); }
.c-red i    { color: var(--coral); }
.c-dim i    { color: var(--ivory-dim); }

.row-airborne .col-status-col .cell { animation: live-pulse 2.6s ease-in-out infinite; }

@keyframes live-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

@media (prefers-reduced-motion: reduce) {
  .row-airborne .col-status-col .cell { animation: none; }
}

/* ————— row detail ————— */

/* ————— flight detail drawer ————— */

/* page is pinned while the drawer is open; `top` is set inline to the frozen
   scroll offset so the view doesn't jump to the top */
body.is-locked {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  overscroll-behavior: contain;
  touch-action: none;
  background: rgba(6, 8, 9, 0.72);
  z-index: 40;
}

.drawer {
  position: fixed;
  z-index: 41;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  background: var(--housing);
  border-left: 1px solid var(--housing-edge);
  overflow-y: auto;
  /* keep a flick at the end of the drawer's own scroll from chaining to the
     page behind it */
  overscroll-behavior: contain;
  padding: 20px 22px 28px;
  box-shadow: -18px 0 40px rgba(0, 0, 0, 0.5);
}

.drawer-close {
  position: absolute;
  top: 14px;
  right: 16px;
  appearance: none;
  background: var(--flap-lo);
  border: 1px solid var(--housing-edge);
  color: var(--ivory-dim);
  font-size: 20px;
  line-height: 1;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

.drawer-close:hover { color: var(--ivory); }
.drawer-close:focus-visible { outline: 2px solid var(--lagoon); outline-offset: 2px; }

.dw-flight {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 30px;
  letter-spacing: 0.06em;
  color: var(--ivory);
}

.dw-airline {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  margin-top: 2px;
}

.dw-chip {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 12px 3px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  border: 1px solid var(--housing-edge);
  background: var(--flap-lo);
  color: var(--ivory);
}

.dw-chip.c-amber { color: var(--amber); border-color: rgba(245, 185, 66, 0.4); }
.dw-chip.c-lagoon { color: var(--lagoon); border-color: rgba(79, 200, 196, 0.4); }
.dw-chip.c-red { color: var(--coral); border-color: rgba(228, 87, 79, 0.4); }
.dw-chip.c-dim { color: var(--ivory-dim); }

.dw-section {
  margin-top: 22px;
  border-top: 1px solid var(--housing-edge);
  padding-top: 14px;
}

.dw-section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ivory-dim);
  margin-bottom: 12px;
}

/* route timeline */
.dw-stop { display: flex; gap: 14px; position: relative; padding-bottom: 18px; }
.dw-stop:last-child { padding-bottom: 0; }

.dw-stop::before {
  content: '';
  position: absolute;
  left: 5px;
  top: 14px;
  bottom: 0;
  width: 1px;
  background: var(--housing-edge);
}

.dw-stop:last-child::before { display: none; }

.dw-dot {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--ivory-dim);
  background: var(--housing);
  margin-top: 3px;
}

.dw-stop.is-here .dw-dot { border-color: var(--amber); background: var(--amber); }
.dw-stop.is-done .dw-dot { border-color: var(--lagoon); background: var(--lagoon); }

.dw-stop-name { font-size: 14px; color: var(--ivory); letter-spacing: 0.04em; }
.dw-stop-name b { font-family: var(--font-mono); font-weight: 600; }
.dw-stop-tz {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--ivory-dim);
  border: 1px solid var(--housing-edge);
  border-radius: 2px;
  padding: 1px 5px;
  margin-left: 6px;
  vertical-align: 1px;
}
.dw-stop-times { font-size: 12px; color: var(--ivory-dim); margin-top: 3px; line-height: 1.7; }
.dw-stop-times .t-act { color: var(--lagoon); }
.dw-stop-times .t-rev { color: var(--amber); }
.dw-stop-times .t-strike { text-decoration: line-through; opacity: 0.6; }
.dw-stop-times .t-dim { opacity: 0.55; }

/* flight alerts */
.dw-alert {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  margin-top: 22px;
  padding: 13px 16px 11px;
  background: none;
  border: 1px solid var(--housing-edge);
  border-radius: 4px;
  color: var(--ivory);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.dw-alert-ico { display: inline-flex; flex: none; }
.dw-alert-ico svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}
.dw-alert:hover { border-color: var(--ivory-dim); }
.dw-alert.is-on { color: var(--lagoon); border-color: rgba(79, 200, 196, 0.45); }
.dw-alert[disabled] { opacity: 0.5; cursor: default; }

.dw-alert-help {
  margin-top: 10px;
  padding: 14px 16px;
  border: 1px solid var(--housing-edge);
  border-radius: 4px;
  background: var(--housing);
  font-size: 13px;
  line-height: 1.6;
  color: var(--ivory-dim);
}
.dw-alert-help b { display: block; color: var(--ivory); margin-bottom: 8px; font-weight: 600; }
.dw-alert-help ol { margin: 0 0 8px; padding-left: 20px; }
.dw-alert-help li { margin-bottom: 4px; }
.dw-install {
  margin-top: 6px;
  padding: 9px 18px 7px;
  background: none;
  border: 1px solid var(--lagoon);
  border-radius: 3px;
  color: var(--lagoon);
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
}

/* facts + live grids */
.dw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }

.dt-pair { display: flex; flex-direction: column; gap: 2px; }

.dt-label {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--ivory-dim);
}

/* label pictograms: hairline stroke, sized to the label cap height */
.dt-ico { display: inline-block; vertical-align: -2px; margin-right: 5px; }
.dt-ico svg {
  width: 12px; height: 12px;
  fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round;
}
.dt-ico svg.ico-fill { fill: currentColor; stroke: none; }
.dw-section-title .dt-ico { vertical-align: -1px; }

.dt-value {
  font-size: 14px;
  letter-spacing: 0.04em;
  color: var(--ivory);
}

.dw-note { margin-top: 20px; font-size: 10px; letter-spacing: 0.16em; color: var(--ivory-dim); text-transform: uppercase; }

@media (max-width: 640px) {
  .drawer {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 82vh;
    border-left: 0;
    border-top: 1px solid var(--housing-edge);
    box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.5);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .drawer { animation: drawer-in 180ms ease-out; }
  @keyframes drawer-in {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
  @media (max-width: 640px) {
    @keyframes drawer-in {
      from { transform: translateY(40px); opacity: 0; }
      to { transform: none; opacity: 1; }
    }
  }
}

/* ————— sponsor row ————— */

.sponsor-row {
  margin-top: 6px;
  border-top: 1px solid var(--housing-edge);
  padding: 12px 2px 2px;
}

.sponsor-eyebrow {
  font-size: 9px;
  letter-spacing: 0.34em;
  color: var(--ivory-dim);
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}

.sponsor-link {
  display: flex;
  align-items: baseline;
  gap: 16px;
  text-decoration: none;
  background: linear-gradient(var(--flap-hi), var(--flap-lo));
  padding: 12px 16px;
  color: var(--ivory);
  border-top: 1px solid rgba(0, 0, 0, 0.55); /* echoes the flap hinge line */
}

.sponsor-link .sp-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--amber);
  white-space: nowrap;
}

.sponsor-link .sp-text {
  font-size: 12px;
  color: var(--ivory-dim);
  letter-spacing: 0.04em;
  flex: 1;
}

.sponsor-link::after {
  content: '→';
  color: var(--ivory-dim);
  font-size: 14px;
  align-self: center;
}

/* ————— footer ————— */

.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px) 20px;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--ivory-dim);
  text-transform: uppercase;
}

.data-pulse.is-stale { color: var(--amber); }
.footer-tv { color: var(--ivory-dim); text-decoration: none; border-bottom: 1px solid var(--housing-edge); }
.footer-tv:hover { color: var(--ivory); }

/* ————— compact layout (phones AND tablets): drop CITY/EXP flap columns,
   add plain sub-line. The desktop 5-column grid needs ~1070px minimum, so
   everything below that gets the stacked layout. ————— */

.row-sub { display: none; }

@media (max-width: 1080px) {
  :root {
    --cell-w: clamp(12px, 3.7vw, 26px);
    --cell-h: clamp(21px, 6.2vw, 42px);
    --cell-fs: clamp(13px, 4.1vw, 28px);
    --cell-gap: 1px;
    --col-gap: 10px;
  }

  .col-city, .col-exp, .col-city-col, .col-exp-col { display: none; }

  .board-row { flex-wrap: wrap; }

  .row-sub {
    display: block;
    /* 0 intrinsic width so this line never inflates the row's max-content
       size (it wraps below the flaps); min-width lays it out full-width */
    width: 0;
    min-width: 100%;
    font-size: 11px;
    letter-spacing: 0.14em;
    color: var(--ivory-dim);
    text-transform: uppercase;
    padding: 3px 2px 0;
  }

  /* group each flight (flaps + sub-line) into one unit, hairline between
     flights, so the sub-line unambiguously belongs to the row above it */
  .board-rows { gap: 0; }
  .row-wrap { padding: 8px 0 8px 16px; }
  .row-wrap.is-watched::before { top: calc(8px + var(--cell-h) / 2); }
  .row-wrap + .row-wrap { border-top: 1px solid var(--housing-edge); }

  .masthead {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding-bottom: 8px;
  }
  .ident { gap: 10px; }
  .ident-code { font-size: 36px; }
  .ident-name { font-size: 15px; }
  .ident-sub { font-size: 8px; letter-spacing: 0.2em; }

  /* clock on its own centred line; meta + weather wrap as whole units below */
  .station {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: baseline;
    column-gap: 12px;
    row-gap: 2px;
  }
  .station-clock { width: 100%; text-align: center; font-size: 24px; }
  .station-meta, .station-wx { white-space: nowrap; }

  .dir-tab { font-size: 16px; padding: 8px 16px 6px; }
  .board { padding: 22px 6px 18px; }
  .board-rows { padding: 8px; width: fit-content; margin-inline: auto; }
  .board-head { padding: 0 9px 6px; font-size: 11px; letter-spacing: 0.2em; width: fit-content; margin-inline: auto; }

  .footer { flex-direction: column; align-items: center; gap: 6px; text-align: center; }

  .sponsor-link { flex-direction: column; align-items: flex-start; gap: 4px; }
  .sponsor-link::after { content: 'Sponsor this row →'; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase; align-self: flex-end; }
  .sponsor-link .sp-name { font-size: 16px; }
}

/* ————— TV mode: composed for a 1080p screen read at distance ————— */

body.tv { cursor: none; }
/* a kiosk screen has nothing below the board, so centre it vertically */
body.tv .board { margin: auto; }
body.tv #tv-link, body.tv .footer-note { display: none; }
body.tv .dir-tab { pointer-events: none; }
body.tv .board-row { cursor: default; }
body.tv .footer { justify-content: center; padding-top: 6px; }

@media (min-width: 1081px) {
  body.tv { --cell-w: 40px; --cell-h: 64px; --cell-fs: 43px; --col-gap: 30px; }
  body.tv .ident-code { font-size: 76px; }
  body.tv .ident-name { font-size: 26px; }
  body.tv .station-clock { font-size: 52px; }
  body.tv .dir-tab { font-size: 26px; padding: 12px 34px 10px; }
  body.tv .board-head { font-size: 16px; }
  body.tv .board-rows { gap: 10px; padding: 18px 20px; }
  body.tv .day-rule { font-size: 15px; }
}
