/* Turnleft Fares: one stylesheet, mobile first. Strict monochrome: white and near-black, greys
   only for secondary text and hairlines. Dark mode is the same page inverted, from
   prefers-color-scheme (tokens on :root). One typeface, Inter (OFL), self-hosted in /fonts. */

@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("/fonts/inter-latin-wght-normal.woff2") format("woff2-variations"),
    url("/fonts/inter-latin-wght-normal.woff2") format("woff2");
}

:root {
  color-scheme: light;

  --bg: #ffffff;
  --ink: #0a0a0a;
  --ink-2: #525252; /* secondary text */
  --ink-3: #737373; /* tertiary text, still 4.7:1 on white */
  --rule: #e5e5e5; /* hairlines */
  --hover: #f5f5f5;
  --backdrop: rgba(10, 10, 10, 0.32);

  /* globe (read by globe.js) */
  --globe-sphere: #ffffff;
  --globe-land: #b5b5b5;
  --globe-graticule: #ededed;
  --globe-rim: #0a0a0a;
  --globe-arc: #0a0a0a;
  --globe-expired: #b0b0b0;
  --globe-dot: #0a0a0a;

  --sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --gutter: 16px;
  --max: 1200px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --bg: #0a0a0a;
    --ink: #f5f5f5;
    --ink-2: #a3a3a3;
    --ink-3: #8a8a8a;
    --rule: #262626;
    --hover: #141414;
    --backdrop: rgba(0, 0, 0, 0.6);

    --globe-sphere: #0a0a0a;
    --globe-land: #5c5c5c;
    --globe-graticule: #1c1c1c;
    --globe-rim: #e5e5e5;
    --globe-arc: #f5f5f5;
    --globe-expired: #5a5a5a;
    --globe-dot: #f5f5f5;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 56px;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  font-feature-settings: "cv11", "ss03"; /* single-storey a, round quotes */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

h1,
h2,
h3,
h4,
p,
ul,
dl,
dd,
figure {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

::selection {
  background: var(--ink);
  color: var(--bg);
}

.num,
.fare__usd,
.sub--short,
.status-toggle__n,
.board__count,
.hero__stat,
.fare__detail dd {
  font-variant-numeric: tabular-nums;
}

.wrap {
  width: 100%;
  max-width: calc(var(--max) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 10px 14px;
  background: var(--ink);
  color: var(--bg);
  text-decoration: none;
  transform: translateY(-200%);
}

.skip:focus {
  transform: none;
}

/* Text links and text buttons */
.link {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.link:hover {
  text-decoration-thickness: 2px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 20px;
  border: 1px solid var(--ink);
  border-radius: 2px;
  background: var(--ink);
  color: var(--bg);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.btn--outline {
  background: transparent;
  color: var(--ink);
}

.btn--outline:hover {
  background: var(--ink);
  color: var(--bg);
}

.btn--quiet {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* -- Header ----------------------------------------------------------------------------- */
.topbar {
  border-bottom: 1px solid var(--rule);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.topbar__nav {
  display: flex;
  gap: 4px;
  margin-right: -10px;
}

.topbar__nav a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 10px;
  color: var(--ink-2);
  font-size: 14px;
  text-decoration: none;
}

.topbar__nav a:hover {
  color: var(--ink);
}

/* -- Hero ------------------------------------------------------------------------------- */
.hero {
  padding: 40px 0 8px;
}

.hero__grid {
  display: grid;
  gap: 28px;
}

.hero h1 {
  max-width: 15em;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.032em;
  text-wrap: balance;
}

.hero__pitch {
  max-width: 32em;
  margin-top: 16px;
  color: var(--ink-2);
  font-size: 16px;
  line-height: 1.55;
  text-wrap: pretty;
}

.hero__stat {
  margin-top: 20px;
  font-size: 14px;
  font-weight: 500;
}

.globe {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.globe__stage {
  position: relative;
  aspect-ratio: 1 / 1;
}

#globe-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}

#globe-canvas.is-dragging {
  cursor: grabbing;
}

#globe-canvas.is-pointing {
  cursor: pointer;
}

#globe-canvas:focus-visible {
  outline-offset: -2px;
  border-radius: 50%;
}

.globe__fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--ink-3);
  font-size: 13px;
}

.globe__caption {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 12px;
  text-align: center;
  text-wrap: balance;
}

.globe__pick {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  column-gap: 14px;
  color: var(--ink);
}

.globe__fallback[hidden],
.globe__pick[hidden],
.globe__hint[hidden] {
  display: none;
}

/* -- Fares board ------------------------------------------------------------------------ */
.board {
  padding: 32px 0 56px;
}

.board__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--ink);
}

.board__head h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.board__count {
  color: var(--ink-3);
  font-size: 13px;
}

/* Search + filters */
.controls {
  margin-top: 16px;
}

.controls__bar {
  display: flex;
  align-items: stretch;
  gap: 16px;
}

#q {
  flex: 1;
  min-width: 0;
  height: var(--tap);
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  font-size: 16px; /* no zoom on iOS */
  appearance: none;
  -webkit-appearance: none;
}

#q::placeholder {
  color: var(--ink-3);
  opacity: 1;
}

#q:focus {
  outline: none;
  border-bottom-width: 2px;
}

#q::-webkit-search-decoration {
  -webkit-appearance: none;
}

.controls__toggle {
  flex: none;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.controls__toggle [hidden] {
  display: none;
}

/* Filter sheet: a bottom sheet on phones, an inline row on wide screens. */
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  max-height: 85vh;
  overflow-y: auto;
  padding: 8px var(--gutter) calc(16px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid var(--ink);
  transform: translateY(105%);
  visibility: hidden;
  transition: transform 0.2s ease, visibility 0s linear 0.2s;
}

.sheet.is-open {
  transform: translateY(0);
  visibility: visible;
  transition: transform 0.2s ease;
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--backdrop);
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet__head h3 {
  font-size: 15px;
  font-weight: 600;
}

.sheet__close {
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sheet__fields {
  display: grid;
  gap: 4px;
}

.field {
  position: relative;
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: center;
  border-bottom: 1px solid var(--rule);
}

.field label {
  color: var(--ink-3);
  font-size: 14px;
}

.field select {
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 22px 0 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 16px;
  text-overflow: ellipsis;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.field select:focus-visible {
  outline: none;
}

.field:focus-within {
  border-bottom-color: var(--ink);
  box-shadow: inset 0 -1px 0 var(--ink);
}

.field select option {
  background: var(--bg);
  color: var(--ink);
}

/* Chevron: two hairlines, no image. */
.field::after {
  content: "";
  position: absolute;
  right: 4px;
  top: 50%;
  width: 6px;
  height: 6px;
  margin-top: -5px;
  border-right: 1.25px solid var(--ink-2);
  border-bottom: 1.25px solid var(--ink-2);
  transform: rotate(45deg);
  pointer-events: none;
}

.sheet__foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}

.sheet__foot .btn {
  flex: 1;
}

/* Status: a row of text toggles with a small square, filled when on. */
/* Phones: one line that scrolls sideways inside itself (never the page). */
.statuses {
  display: flex;
  column-gap: 20px;
  margin: 8px calc(-1 * var(--gutter)) 0;
  padding: 0 var(--gutter);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.statuses::-webkit-scrollbar {
  display: none;
}

.status-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-3);
  font-size: 14px;
  white-space: nowrap;
}

.status-toggle::before {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  border: 1px solid currentColor;
}

.status-toggle[aria-pressed="true"] {
  color: var(--ink);
}

.status-toggle[aria-pressed="true"]::before {
  background: currentColor;
}

.status-toggle__n {
  color: var(--ink-3);
}

.active {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
}

.active[hidden] {
  display: none;
}

.notice {
  margin-top: 8px;
  color: var(--ink-3);
  font-size: 13px;
}

/* -- The fares table ---------------------------------------------------------------------
   Phones: two lines per fare (route + price; airline · cabin · dates · status).
   900px and up: a real grid of columns under a sticky header. */
.table {
  margin-top: 16px;
  border-top: 1px solid var(--ink);
}

.thead {
  display: none;
}

.fare {
  border-bottom: 1px solid var(--rule);
}

.fare__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto 14px;
  grid-template-areas:
    "route disc price toggle"
    "meta  meta meta  meta";
  column-gap: 12px;
  row-gap: 2px;
  align-items: baseline;
  width: 100%;
  min-height: 64px;
  padding: 14px 0;
  border: 0;
  background: none;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.fare__row:focus-visible {
  outline-offset: -2px;
}

.c-route {
  grid-area: route;
  min-width: 0;
}

.fare__codes {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.fare__arrow {
  font-weight: 400;
  color: var(--ink-3);
}

.c-route .sub {
  display: none;
}

/* Every item starts with a separator; the meta line is shifted left by one separator and
   clipped, so no line ever starts with a dot when it wraps. */
.fare__meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  min-width: 0;
  margin-left: -14px;
  clip-path: inset(0 0 0 14px);
  color: var(--ink-2);
  font-size: 13px;
  line-height: 1.45;
}

.fare__meta > span::before {
  content: "·";
  display: inline-block;
  width: 14px;
  color: var(--ink-3);
  text-align: center;
}

.fare__meta .sub {
  display: none;
}

.c-price {
  display: contents;
}

.fare__usd {
  grid-area: price;
  font-size: 16px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}

.c-price .sub {
  grid-area: disc;
  color: var(--ink-3);
  font-size: 14px;
  text-align: right;
  white-space: nowrap;
}

.sub--long {
  display: none;
}

.c-toggle {
  grid-area: toggle;
  position: relative;
  align-self: start;
  width: 14px;
  height: 22px;
}

/* A plus that becomes a minus. */
.fare__row .c-toggle::before,
.fare__row .c-toggle::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 11px;
  height: 1px;
  background: var(--ink-2);
}

.fare__row .c-toggle::after {
  transform: rotate(90deg);
  transition: transform 0.15s ease;
}

.fare.is-open .c-toggle::after {
  transform: rotate(0deg);
}

.st--live {
  color: var(--ink);
  font-weight: 600;
}

.st--price_up,
.st--price_down {
  color: var(--ink);
}

.st--unverified,
.st--expired {
  color: var(--ink-3);
}

.fare.is-expired .fare__codes,
.fare.is-expired .fare__meta,
.fare.is-expired .fare__usd {
  color: var(--ink-3);
}

.fare.is-expired .fare__usd {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
  font-weight: 500;
}

@media (hover: hover) {
  .fare__row:hover {
    background: var(--hover);
  }

  .fare__row:hover .c-toggle::before,
  .fare__row:hover .c-toggle::after {
    background: var(--ink);
  }
}

/* Detail */
.fare__detail {
  padding: 4px 0 28px;
}

.detail__grid {
  display: grid;
  gap: 20px;
}

.fare__detail h4 {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.fare__detail dl > div {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr);
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
  font-size: 14px;
}

.fare__detail dt {
  color: var(--ink-3);
}

.fare__detail dd {
  min-width: 0;
}

.fare__detail .note {
  margin-left: 8px;
  color: var(--ink-3);
}

.detail__notes {
  margin-top: 20px;
}

.detail__notes ul {
  border-top: 1px solid var(--rule);
  padding-top: 8px;
  color: var(--ink-2);
  font-size: 14px;
}

.detail__notes li {
  position: relative;
  padding: 2px 0 2px 16px;
}

.detail__notes li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--ink-3);
}

.detail__actions {
  margin-top: 20px;
}

/* Empty, no-match and error states */
.empty {
  padding: 40px 0 48px;
  border-bottom: 1px solid var(--rule);
}

.empty h3 {
  font-size: 17px;
  font-weight: 600;
}

.empty p {
  margin-top: 4px;
  color: var(--ink-2);
}

.empty .link {
  margin-top: 4px;
}

/* -- Footer ----------------------------------------------------------------------------- */
.footer {
  border-top: 1px solid var(--rule);
}

.footer__inner {
  padding-top: 24px;
  padding-bottom: calc(40px + env(safe-area-inset-bottom));
  color: var(--ink-3);
  font-size: 13px;
}

.footer p + p {
  margin-top: 2px;
}

/* -- Larger phones and tablets ---------------------------------------------------------- */
@media (min-width: 600px) {
  :root {
    --gutter: 24px;
  }

  .hero {
    padding-top: 56px;
  }

  .hero h1 {
    font-size: 40px;
  }

  .hero__pitch {
    font-size: 17px;
  }

  .sheet {
    left: 50%;
    right: auto;
    width: 560px;
    margin-left: -280px;
    border-left: 1px solid var(--ink);
    border-right: 1px solid var(--ink);
  }

  .fare__meta {
    font-size: 14px;
  }
}

/* -- Desktop ---------------------------------------------------------------------------- */
@media (min-width: 900px) {
  :root {
    --gutter: 40px;
  }

  .topbar__inner {
    height: 64px;
  }

  .hero {
    padding: 48px 0 24px;
  }

  .hero__grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
    column-gap: 48px;
    align-items: center;
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(38px, 3.6vw, 52px);
  }

  .globe {
    max-width: 500px;
    margin: 0 0 0 auto;
  }

  .board {
    padding-top: 40px;
  }

  .board__head h2 {
    font-size: 26px;
  }

  /* The sheet becomes one inline row: search, then quiet label + value selects. */
  .controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    column-gap: 32px;
    margin-top: 20px;
  }

  .controls__bar {
    flex: 1 1 260px;
    max-width: 340px;
  }

  .controls__toggle,
  .sheet__head,
  .sheet__foot,
  .sheet-backdrop {
    display: none !important;
  }

  .sheet {
    position: static;
    left: auto;
    width: auto;
    max-height: none;
    margin: 0;
    overflow: visible;
    padding: 0;
    border: 0;
    background: none;
    transform: none;
    visibility: visible;
    transition: none;
  }

  .sheet__fields {
    display: flex;
    flex-wrap: wrap;
    column-gap: 28px;
  }

  .field {
    display: inline-flex;
    gap: 8px;
    border: 0;
  }

  .field label {
    font-size: 14px;
  }

  .field:focus-within {
    box-shadow: none;
  }

  .field select:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
  }

  .field select {
    width: auto;
    field-sizing: content;
    max-width: 13rem;
    height: var(--tap);
    padding-right: 16px;
    font-size: 14px;
    font-weight: 500;
  }

  .field::after {
    right: 2px;
    width: 5px;
    height: 5px;
    margin-top: -4px;
  }

  .statuses {
    flex-basis: 100%;
    flex-wrap: wrap;
    column-gap: 28px;
    margin: 4px 0 0;
    padding: 0;
    overflow: visible;
  }

  /* Columns: Route | Airline | Cabin | Dates | Status | Price | toggle */
  .table {
    --cols: minmax(0, 1.35fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(7rem, 0.8fr) 14px;
    margin-top: 20px;
  }

  .table.is-empty .thead {
    display: none;
  }

  .thead {
    position: sticky;
    top: 0;
    z-index: 5;
    display: grid;
    grid-template-columns: var(--cols);
    column-gap: 24px;
    align-items: center;
    height: 44px;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 500;
  }

  .thead > span {
    grid-area: auto;
    min-width: 0;
  }

  .thead .c-price {
    display: block;
    text-align: right;
  }

  .thead__sort {
    min-height: var(--tap);
    padding: 0;
    border: 0;
    background: none;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
  }

  .thead__sort:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .fare__row {
    grid-template-columns: var(--cols);
    grid-template-areas: none;
    column-gap: 24px;
    min-height: 68px;
    padding: 14px 0;
    align-items: start;
  }

  .fare__row .c-route,
  .fare__row .c-toggle,
  .fare__usd,
  .c-price .sub {
    grid-area: auto;
  }

  .sub--short {
    display: none;
  }

  .sub--long {
    display: inline;
  }

  .c-route .sub,
  .fare__meta .sub {
    display: block;
  }

  .fare__meta {
    display: contents;
    font-size: 15px;
  }

  .fare__meta > span::before {
    content: none;
  }

  .fare__meta > span,
  .fare__row .c-route,
  .fare__row .c-price {
    display: flex;
    flex-direction: column;
    min-width: 0;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.45;
  }

  .fare__meta > span .main,
  .fare__row .c-route .main {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sub,
  .c-price .sub {
    margin-top: 1px;
    overflow: hidden;
    color: var(--ink-3);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fare__codes,
  .fare__usd {
    font-size: 15px;
  }

  .fare__row .c-price {
    align-items: flex-end;
  }

  .fare.is-expired .fare__meta > span,
  .fare.is-expired .fare__row .c-route {
    color: var(--ink-3);
  }

  .c-toggle {
    height: 22px;
  }

  .fare__detail {
    padding: 4px 0 32px;
  }

  .detail__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 40px;
  }

  .detail__notes {
    max-width: 52rem;
    margin-top: 24px;
  }
}

@media (min-width: 1200px) {
  .hero {
    padding: 64px 0 32px;
  }

  .globe {
    max-width: 520px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sheet,
  .sheet.is-open,
  .c-toggle::after {
    transition: none;
  }
}

/* "Show more" under the first page of rows */
.more {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  color: var(--ink-3);
  font-size: 14px;
}

.more .link {
  font-weight: 500;
}
