:root {
  --bg: #07254a;
  --bg-row-alt: #0a2f5e;
  --bg-header: #051a37;
  --fg: #ffffff;
  --fg-muted: #c8d6ec;
  --fg-dim: #8aa5c8;
  --accent-time: #ffd54a;
  --rule: rgba(255, 255, 255, 0.12);

  --status-on-time: #ffffff;
  --status-go-to-gate: #5cd68a;
  --status-boarding: #5cd6ff;
  --status-final: #ffd54a;
  --status-departed: #8aa5c8;
  --status-landed: #8aa5c8;
  --status-delayed: #ff8a3d;
  --status-cancelled: #ff4d4d;
  --status-diverted: #ff4d4d;
  --status-unknown: #c8d6ec;

  --font-ui: "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Consolas", "JetBrains Mono", monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: 18px;
  line-height: 1.4;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.board__header {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 1.5rem 2rem 1rem;
  background: var(--bg-header);
  border-bottom: 1px solid var(--rule);
  z-index: 2;
}

.board__title {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: baseline;
  column-gap: 1.5rem;
}

.board__title-en {
  margin: 0;
  font-size: 3.25rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--fg);
}

.board__title-fi,
.board__title-sv {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 400;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
}

.board__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.6rem;
}

.board__airport {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--fg-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.board__nav {
  display: flex;
  gap: 0.4rem;
}

.nav-pill {
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  background: transparent;
  border: 1px solid var(--rule);
  text-decoration: none;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.nav-pill:hover,
.nav-pill:focus-visible {
  color: var(--fg);
  border-color: var(--fg-muted);
  outline: none;
}

.nav-pill--active {
  color: #07254a;
  background: var(--accent-time);
  border-color: var(--accent-time);
  cursor: default;
}

.nav-pill--active:hover,
.nav-pill--active:focus-visible {
  color: #07254a;
  border-color: var(--accent-time);
}

.board__search {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
}

.board__search input {
  width: 14rem;
  padding: 0.4rem 0.75rem;
  border-radius: 0.4rem;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
}

.board__search input::placeholder {
  color: var(--fg-dim);
  text-transform: none;
  letter-spacing: 0.02em;
}

.board__search input:focus {
  outline: none;
  border-color: var(--accent-time);
  background: rgba(255, 255, 255, 0.08);
}

.board__search-msg {
  margin: 0;
  min-height: 1em;
  font-size: 0.8rem;
  color: var(--status-cancelled);
  letter-spacing: 0.02em;
}

#board {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.strip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 2rem 0.5rem;
}

.table-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.clock {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 4rem;
  font-weight: 700;
  color: var(--accent-time);
  line-height: 1;
}

.banner {
  margin: 0;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.banner--stale {
  background: rgba(255, 213, 74, 0.12);
  color: var(--accent-time);
  border: 1px solid rgba(255, 213, 74, 0.4);
}

.banner--error {
  background: rgba(255, 77, 77, 0.12);
  color: var(--status-cancelled);
  border: 1px solid rgba(255, 77, 77, 0.4);
}

.empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
  color: var(--fg-muted);
  padding: 4rem 2rem;
}

.empty h2 {
  margin: 0;
  font-size: 1.6rem;
  color: var(--fg);
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

.grid thead {
  background: var(--bg-header);
}

.grid thead th {
  position: sticky;
  top: 0;
  background: var(--bg-header);
  font-family: var(--font-ui);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--rule);
  text-align: left;
  z-index: 1;
}

.grid thead th.cell--status {
  text-align: right;
}

.grid thead th.cell--gate,
.grid thead th.cell--belt,
.grid thead th.cell--logo {
  text-align: center;
}

.grid tbody tr.row {
  border-bottom: 1px solid var(--rule);
}

.grid tbody tr:nth-child(even) {
  background: var(--bg-row-alt);
}

.row--past {
  opacity: 0.55;
}

.cell {
  padding: 0.65rem 1rem;
  vertical-align: middle;
}

.cell--time,
.cell--flight,
.cell--gate,
.cell--belt {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.cell--time {
  width: 7rem;
}

.cell--logo {
  width: 6rem;
  text-align: center;
  padding: 0.5rem 0.5rem;
}

.airline-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.6rem;
  height: 2rem;
  background: #ffffff;
  border-radius: 0.35rem;
  padding: 0.2rem 0.35rem;
  vertical-align: middle;
  box-sizing: border-box;
}

.airline-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.cell--flight {
  width: 12rem;
  white-space: nowrap;
}

.cell--gate,
.cell--belt {
  width: 6rem;
  text-align: center;
}

.belt-chip {
  display: inline-block;
  min-width: 2.4rem;
  padding: 0.2rem 0.55rem;
  border-radius: 0.35rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  color: #ffffff;
  letter-spacing: 0.04em;
  text-align: center;
  background: var(--fg-dim);
}

.belt-chip--1  { background: #f3a83a; color: #1a1a1a; }
.belt-chip--2a { background: #e0345b; }
.belt-chip--2b { background: #2a90c2; }

.cell--status {
  width: 14rem;
  text-align: right;
}

.cell--destination,
.cell--origin {
  font-family: var(--font-ui);
}

.time-scheduled {
  display: block;
  font-size: 1.4rem;
  font-weight: 600;
}

.time-estimated {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.9rem;
  color: var(--accent-time);
}

.flight-number {
  display: inline-block;
  vertical-align: middle;
  font-size: 1.15rem;
  font-weight: 600;
}

.flight-codeshare {
  display: inline-block;
  margin-left: 0.6rem;
  vertical-align: middle;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: help;
}

.codeshare-first {
  display: inline;
}

.codeshare-rest {
  display: none;
  margin-left: 0.4rem;
  letter-spacing: 0.05em;
}

.codeshare-badge {
  display: inline-block;
  margin-left: 0.3rem;
  padding: 0.05rem 0.4rem;
  border-radius: 0.25rem;
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg-dim);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.place-primary {
  display: block;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--fg);
}

.place-via {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.status {
  display: inline-block;
  padding: 0.3rem 0.75rem;
  border-radius: 0.4rem;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Quiet states: colored text only */
.status--scheduled  { color: var(--status-on-time); }
.status--departed   { color: var(--status-departed); }
.status--landed     { color: var(--status-landed); }
.status--unknown    { color: var(--status-unknown); }

/* Noteworthy states: filled pills */
.status--gate-open {
  color: #053a1c;
  background: var(--status-go-to-gate);
  animation: status-pulse 2.4s ease-in-out infinite;
}

.status--boarding {
  color: #002a3a;
  background: var(--status-boarding);
  animation: status-pulse 2.4s ease-in-out infinite;
}

.status--approaching {
  color: #002a3a;
  background: var(--status-boarding);
  animation: status-pulse 2.4s ease-in-out infinite;
}

.status--final-call {
  color: #2a1f00;
  background: var(--status-final);
  animation: status-pulse 1.4s ease-in-out infinite;
}

.status--gate-closed {
  color: #ffffff;
  background: var(--status-delayed);
}

.status--delayed {
  color: #ffffff;
  background: var(--status-delayed);
}

.status--cancelled {
  color: #ffffff;
  background: var(--status-cancelled);
  text-decoration: line-through;
}

.status--diverted {
  color: #ffffff;
  background: var(--status-diverted);
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* Row-level accents — left-edge bar so the eye catches the row at a glance */
.row[data-state="cancelled"]   > .cell:first-child,
.row[data-state="diverted"]    > .cell:first-child {
  box-shadow: inset 4px 0 0 var(--status-cancelled);
}
.row[data-state="final-call"]  > .cell:first-child {
  box-shadow: inset 4px 0 0 var(--status-final);
}
.row[data-state="boarding"]    > .cell:first-child,
.row[data-state="approaching"] > .cell:first-child {
  box-shadow: inset 4px 0 0 var(--status-boarding);
}
.row[data-state="gate-open"]   > .cell:first-child {
  box-shadow: inset 4px 0 0 var(--status-go-to-gate);
}
.row[data-state="gate-closed"] > .cell:first-child,
.row[data-state="delayed"]     > .cell:first-child {
  box-shadow: inset 4px 0 0 var(--status-delayed);
}

/* Cancelled rows: dim and strike the rest of the row so it's clearly off-the-board */
.row[data-state="cancelled"] .place-primary,
.row[data-state="cancelled"] .flight-number,
.row[data-state="cancelled"] .time-scheduled {
  text-decoration: line-through;
  color: var(--fg-muted);
}
.row[data-state="cancelled"] .place-via,
.row[data-state="cancelled"] .time-estimated {
  color: var(--fg-dim);
}

/* Subtle row tint so noteworthy rows don't blend into the stripe rhythm */
.row[data-state="final-call"] {
  background: rgba(255, 213, 74, 0.08) !important;
}
.row[data-state="boarding"],
.row[data-state="approaching"] {
  background: rgba(92, 214, 255, 0.07) !important;
}
.row[data-state="gate-open"] {
  background: rgba(92, 214, 138, 0.08) !important;
}
.row[data-state="delayed"],
.row[data-state="gate-closed"] {
  background: rgba(255, 138, 61, 0.08) !important;
}
.row[data-state="cancelled"],
.row[data-state="diverted"] {
  background: rgba(255, 77, 77, 0.10) !important;
}

@media (prefers-reduced-motion: reduce) {
  .status--gate-open,
  .status--boarding,
  .status--approaching,
  .status--final-call,
  .row.row--highlight {
    animation: none;
  }
}

/* Search-result highlight — chained class selector matches the specificity
   of the .row[data-state="..."] tints, and being later in the file wins. */
.row.row--highlight {
  outline: 2px solid var(--accent-time);
  outline-offset: -2px;
  background-color: rgba(255, 213, 74, 0.22) !important;
  animation: row-highlight-pulse 0.7s ease-in-out 3;
}

@keyframes row-highlight-pulse {
  0%, 100% { background-color: rgba(255, 213, 74, 0.22); }
  50%      { background-color: rgba(255, 213, 74, 0.5); }
}

.footstrip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 2rem 1rem;
  font-size: 0.85rem;
  color: var(--fg-dim);
  border-top: 1px solid var(--rule);
  background: var(--bg);
}

.dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--fg-dim);
}

.dot--live {
  background: #5cd68a;
  box-shadow: 0 0 8px rgba(92, 214, 138, 0.6);
}

.dot--stale {
  background: var(--accent-time);
  box-shadow: 0 0 8px rgba(255, 213, 74, 0.6);
}

@media (max-width: 768px) {
  body {
    font-size: 16px;
  }

  /* Header chrome */
  .board__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    padding: 0.6rem 0.85rem;
  }
  .board__title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.05rem 0.55rem;
  }
  .board__title-en {
    font-size: 1.5rem;
  }
  .board__title-fi,
  .board__title-sv {
    font-size: 0.85rem;
  }
  .board__airport {
    display: none;
  }
  .board__meta {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.6rem;
    width: 100%;
  }
  .board__nav {
    flex: 0 0 auto;
  }
  .board__search {
    flex: 1 1 auto;
    min-width: 8rem;
    flex-direction: column;
  }
  .board__search input {
    width: 100%;
    max-width: none;
    padding: 0.32rem 0.6rem;
    font-size: 0.85rem;
  }
  .nav-pill {
    padding: 0.3rem 0.85rem;
    font-size: 0.85rem;
  }
  .strip {
    padding: 0.55rem 0.85rem 0.2rem;
  }
  .clock {
    font-size: 1.85rem;
  }

  /* Drop column headers; each row becomes a self-contained card */
  .grid thead {
    display: none;
  }
  .grid,
  .grid tbody {
    display: block;
    width: 100%;
  }

  .grid tr.row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.1rem 0.6rem;
    padding: 0.55rem 0.85rem;
    border-bottom: 1px solid var(--rule);
  }

  .cell {
    display: block;
    padding: 0;
    border: none;
    text-align: left !important;
    white-space: normal;
    width: auto !important;
  }

  /* Top line: logo, time, status (status pushed to the right) */
  .cell--logo   { order: 1; align-self: center; }
  .cell--time   { order: 2; font-family: var(--font-mono); font-weight: 600; }
  .cell--status { order: 3; margin-left: auto; text-align: right; }

  /* Second line: flight number + codeshares (full width so it always breaks) */
  .cell--flight {
    order: 4;
    flex-basis: 100%;
  }

  /* Third line shares destination with gate / belt — destination shrinks first */
  .cell--destination,
  .cell--origin {
    order: 5;
    flex: 1 1 0;
    min-width: 0;
  }

  .cell--gate {
    order: 6;
    flex: 0 0 auto;
  }
  .cell--belt {
    order: 7;
    flex: 0 0 auto;
  }
  .cell--gate::before {
    content: "Gate ";
    color: var(--fg-dim);
    font-size: 0.85rem;
    margin-right: 0.25rem;
  }
  .cell--belt::before {
    content: "Belt ";
    color: var(--fg-dim);
    font-size: 0.85rem;
    margin-right: 0.25rem;
  }

  /* Compact sizing for the card */
  .airline-logo {
    width: 3.2rem;
    height: 1.4rem;
    padding: 0.1rem 0.22rem;
  }
  .time-scheduled {
    display: inline-block;
    font-size: 1.15rem;
  }
  .time-estimated {
    display: inline-block;
    margin-left: 0.35rem;
    font-size: 0.8rem;
  }
  .flight-number {
    font-size: 1rem;
  }
  .flight-codeshare {
    font-size: 0.85rem;
    margin-left: 0.4rem;
  }
  .codeshare-rest {
    margin-left: 0.3rem;
  }
  .place-primary {
    font-size: 0.95rem;
  }
  .place-via {
    font-size: 0.75rem;
  }
  .status {
    font-size: 0.8rem;
    padding: 0.18rem 0.5rem;
  }
  .belt-chip {
    min-width: 1.6rem;
    font-size: 0.8rem;
    padding: 0.12rem 0.35rem;
  }
  .cell--gate,
  .cell--belt {
    font-size: 0.95rem;
  }
  .cell--gate::before,
  .cell--belt::before {
    font-size: 0.75rem;
  }

  /* Codeshares: full list, no +N */
  .cell--flight {
    white-space: normal;
  }
  .codeshare-rest {
    display: inline;
  }
  .codeshare-badge {
    display: none;
  }
  .flight-codeshare {
    cursor: default;
    margin-left: 0.4rem;
  }

  /* Move the row accent bar from the time cell (now at the top of the card)
     to the row itself so it runs along the whole left edge. */
  .row > .cell:first-child {
    box-shadow: none !important;
  }
  .row[data-state="cancelled"],
  .row[data-state="diverted"] {
    box-shadow: inset 4px 0 0 var(--status-cancelled);
  }
  .row[data-state="final-call"] {
    box-shadow: inset 4px 0 0 var(--status-final);
  }
  .row[data-state="boarding"],
  .row[data-state="approaching"] {
    box-shadow: inset 4px 0 0 var(--status-boarding);
  }
  .row[data-state="gate-open"] {
    box-shadow: inset 4px 0 0 var(--status-go-to-gate);
  }
  .row[data-state="gate-closed"],
  .row[data-state="delayed"] {
    box-shadow: inset 4px 0 0 var(--status-delayed);
  }

  .footstrip {
    padding: 0.75rem 1rem 1rem;
  }
}
