/* ==========================================================================
   Frontier Route Network — styled after a night en-route aeronautical chart.
   Ink ground, hairline landforms, signage type, navigational data in mono.
   ========================================================================== */

:root {
  /* Chart ground: deep navy, never black — land reads as a raised plate. */
  --ink:        #08131F;
  --ink-plate:  #16304A;
  --ink-line:   #2A5478;
  --ink-panel:  rgba(8, 19, 31, 0.88);

  /* Ink-side type */
  --haze:       #6E8DA8;   /* dormant: inactive routes, secondary labels */
  --haze-dim:   #43617C;
  --paper:      #DDE9F3;   /* primary type, cool white */

  /* Two signals only: the network, and your plan. */
  --signal:     #24C877;   /* Frontier green — live network, destinations */
  --signal-rest:#3F7F6A;   /* the same network at rest: quiet, but still green */
  --signal-dim: #12613C;
  --plan:       #FFB020;   /* amber — the itinerary you chose */
  --plan-dim:   #6B4A0E;

  --font-sign: "Avenir Next Condensed", "Helvetica Neue", "Arial Narrow", sans-serif;
  --font-body: "Avenir Next", "Helvetica Neue", -apple-system, system-ui, sans-serif;
  --font-data: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;

  --rail: 336px;
  --hair: 1px solid var(--ink-line);
}

* { box-sizing: border-box; }

/* A class that sets `display` outranks the hidden attribute, and .plan/.trip
   both do. Make hiding win regardless. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

.fallback { padding: 2rem; font-family: var(--font-body); }

.stage { position: relative; width: 100%; height: 100vh; overflow: hidden; }

#map { display: block; width: 100%; height: 100%; cursor: grab; }
#map.is-dragging { cursor: grabbing; }

/* --- map layers ---------------------------------------------------------- */

.graticule {
  fill: none;
  stroke: var(--ink-line);
  stroke-width: 0.5;
  stroke-opacity: 0.2;
  stroke-dasharray: 2 6;
  vector-effect: non-scaling-stroke;
}
.land      { fill: var(--ink-plate); stroke: none; }
.coastline {
  fill: none; stroke: var(--ink-line); stroke-width: 0.9;
  vector-effect: non-scaling-stroke;
}
.states {
  fill: none; stroke: var(--ink-line); stroke-width: 0.5;
  stroke-opacity: 0.55; vector-effect: non-scaling-stroke;
}

.route {
  fill: none;
  stroke: var(--signal-rest);
  stroke-width: 0.7;
  stroke-opacity: 0.45;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}
.route.is-lit    { stroke: var(--signal); stroke-width: 1.4; stroke-opacity: 0.9; }
.route.is-muted  { stroke-opacity: 0.12; }
/* Dimmer and thinner than a committed selection: this is a preview, and it
   should read as one even when both are on screen at once. */
.route.is-peer   { stroke: var(--signal); stroke-width: 1; stroke-opacity: 0.5; }

.leg {
  fill: none; stroke: var(--plan); stroke-width: 2.2;
  stroke-linecap: round; vector-effect: non-scaling-stroke; pointer-events: none;
}
.leg-runner {
  fill: none; stroke: #FFE7B0; stroke-width: 2.2; stroke-linecap: round;
  vector-effect: non-scaling-stroke; pointer-events: none;
}

.city { cursor: pointer; }
.city .halo { fill: transparent; }          /* generous hit target */
/* No base fill: map.js sets it per city, ramped by destination count.
   Every state rule below still overrides that attribute. */
.city .dot  { stroke: var(--ink); stroke-width: 0.45; transition: fill .15s; }
.city .ring { fill: none; stroke: none; }

.city.is-lit   .dot  { fill: var(--signal); }
.city.is-muted .dot  { fill: var(--haze-dim); fill-opacity: 0.45; }
.city.is-hover .dot  { fill: var(--paper); }

/* Hover preview: everywhere you could fly nonstop from the city under the
   cursor. A ring rather than a fill, so the dot's own brightness still reads as
   how big a hub it is. Ordered after .is-muted so a preview lifts cities back
   out of a dimmed view. */
.city.is-peer .ring {
  stroke: var(--signal);
  stroke-width: 1;
  stroke-opacity: 0.8;
  vector-effect: non-scaling-stroke;
}

.city.is-origin .dot,
.city.is-target .dot { fill: var(--plan); }
.city.is-origin .ring,
.city.is-target .ring { stroke: var(--plan); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.city.is-target .dot { fill: var(--ink); }   /* hollow waypoint = destination */

.city.is-stop .dot { fill: var(--plan); }

/* No font-size here: map.js sets it on the parent group as 9/k, so a label
   holds its size on screen while the chart is zoomed. A fixed size in this
   rule would win over that inherited value, and the labels would swell with
   the map — which is also what the collision pass assumes they do not do. */
.city-label {
  font-family: var(--font-data);
  letter-spacing: 0.06em;
  fill: var(--haze);
  paint-order: stroke;
  stroke: var(--ink);
  stroke-width: 3px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;   /* the halo is a screen effect too */
  pointer-events: none;
}
.city-label.is-lit    { fill: var(--signal); }
.city-label.is-plan   { fill: var(--plan); }
.city-label.is-hidden { display: none; }

/* --- tooltip ------------------------------------------------------------- */

.tooltip {
  position: absolute;
  z-index: 5;
  padding: 6px 9px;
  background: var(--ink-panel);
  border: var(--hair);
  font-family: var(--font-data);
  font-size: 11px;
  line-height: 1.45;
  letter-spacing: 0.02em;
  color: var(--paper);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -140%);
  transition: opacity .12s;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}
.tooltip.is-open { opacity: 1; }
.tooltip b { color: var(--signal); font-weight: 600; }

/* --- panel --------------------------------------------------------------- */

.panel {
  position: absolute;
  top: 20px; left: 20px; bottom: 20px;
  width: var(--rail);
  display: flex;
  flex-direction: column;
  background: var(--ink-panel);
  border: var(--hair);
  backdrop-filter: blur(10px);
  z-index: 4;
}

.block { padding: 16px 18px; }
.block + .block { border-top: var(--hair); }

/* title block, the way a chart carries its own name in the corner */
.eyebrow {
  margin: 0 0 6px;
  font-family: var(--font-data);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--signal);
}
.titleblock h1 {
  margin: 0;
  font-family: var(--font-sign);
  font-stretch: condensed;
  font-size: 34px;
  line-height: 0.92;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-transform: uppercase;
}
.titleblock h1 span { color: var(--haze); }

.counts {
  display: flex;
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: var(--hair);
  gap: 18px;
}
.counts div { display: flex; flex-direction: column; gap: 3px; }
.counts dt {
  font-family: var(--font-data);
  font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--haze-dim);
}
.counts dd {
  margin: 0;
  font-family: var(--font-data);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  color: var(--paper);
}

/* --- the city picker ------------------------------------------------------ */

.field { display: grid; grid-template-columns: 42px 1fr; align-items: center; gap: 10px; }
.field label {
  font-family: var(--font-data);
  font-size: 9.5px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--haze-dim);
}
.combo { position: relative; }

.combo input {
  width: 100%;
  padding: 8px 10px;
  background: rgba(31, 66, 96, 0.22);
  border: var(--hair);
  color: var(--paper);
  font-family: var(--font-body);
  font-size: 13px;
  border-radius: 0;
}
.combo input::placeholder { color: var(--haze-dim); }
.combo input:focus-visible {
  outline: 2px solid var(--signal);
  outline-offset: -2px;
  background: rgba(36, 200, 119, 0.08);
}

.options {
  position: absolute; z-index: 6; top: calc(100% + 3px); left: 0; right: 0;
  max-height: 232px; overflow-y: auto;
  margin: 0; padding: 0; list-style: none;
  background: #0B1B2B;
  border: var(--hair);
}
.options li {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 10px;
  font-size: 12.5px;
  cursor: pointer;
}
.options li span {
  font-family: var(--font-data); font-size: 11px;
  letter-spacing: 0.06em; color: var(--haze);
}
.options li[aria-selected="true"] { background: rgba(36, 200, 119, 0.16); }
.options li[aria-selected="true"] span { color: var(--signal); }
.options .empty { color: var(--haze-dim); cursor: default; justify-content: flex-start; }

.clear {
  align-self: flex-end;
  margin-top: 2px;
  padding: 5px 12px;
  background: none;
  border: var(--hair);
  color: var(--haze);
  font-family: var(--font-data);
  font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase;
  cursor: pointer;
  border-radius: 0;
}
.clear:hover { color: var(--paper); border-color: var(--haze); }
.clear:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* --- results ------------------------------------------------------------- */

.results { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-bottom: 0; }
.results-head { flex: none; }
.results-head h2 {
  margin: 0;
  font-family: var(--font-sign);
  font-stretch: condensed;
  font-size: 19px; font-weight: 600; letter-spacing: 0.02em;
  text-transform: uppercase;
}
.results-head p {
  margin: 5px 0 12px;
  font-size: 12px; line-height: 1.5; color: var(--haze);
}

.results-list {
  flex: 1; min-height: 0; overflow-y: auto;
  margin: 0 -18px 0 0; padding: 0 18px 16px 0;
  list-style: none;
}
.results-list li { border-top: var(--hair); }
.results-list li:last-child { border-bottom: var(--hair); }

.row {
  display: block; width: 100%;
  padding: 9px 4px;
  background: none; border: 0; border-radius: 0;
  color: inherit; text-align: left; cursor: pointer;
  font: inherit;
}
.row:hover, .row.is-active { background: rgba(36, 200, 119, 0.09); }
.row:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }

/* destination row: CODE · city · miles */
.row-dest { display: grid; grid-template-columns: 38px 1fr auto; align-items: baseline; gap: 10px; }
.row-dest .code { font-family: var(--font-data); font-size: 12px; color: var(--signal); letter-spacing: 0.06em; }
.row-dest .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-dest .miles {
  font-family: var(--font-data); font-size: 11px;
  font-variant-numeric: tabular-nums; color: var(--haze);
}

/* itinerary row: a flight strip */
.row-plan .strip-top {
  display: flex; justify-content: space-between; align-items: baseline;
  font-family: var(--font-data); font-size: 9.5px;
  letter-spacing: 0.16em; text-transform: uppercase;
}
.row-plan .stops { color: var(--plan); }
.row-plan .total { color: var(--haze); font-variant-numeric: tabular-nums; letter-spacing: 0.06em; }
.row-plan .strip-path {
  display: flex; align-items: center; gap: 7px;
  margin: 5px 0 3px;
  font-family: var(--font-data); font-size: 14px; letter-spacing: 0.08em;
}
.row-plan .strip-path b { font-weight: 500; color: var(--paper); }
.row-plan .strip-path i {
  flex: 1; height: 1px; min-width: 12px;
  background: repeating-linear-gradient(to right, var(--haze-dim) 0 3px, transparent 3px 6px);
}
.row-plan .strip-foot {
  font-family: var(--font-data); font-size: 10px;
  color: var(--haze-dim); letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}
.row-plan.is-active .strip-path b { color: var(--plan); }

.results-list .empty {
  border: 0; padding: 8px 0;
  font-size: 12.5px; line-height: 1.5; color: var(--haze);
}

/* --- chart key ----------------------------------------------------------- */

.chartkey {
  position: absolute; right: 20px; bottom: 20px; z-index: 4;
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
  padding: 11px 13px;
  background: var(--ink-panel);
  border: var(--hair);
  backdrop-filter: blur(10px);
  font-family: var(--font-data);
  font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--haze);
}
.key { display: flex; align-items: center; gap: 7px; }
.key i { display: block; width: 16px; height: 0; border-top: 1.5px solid var(--haze-dim); }
.key-hub i { width: 7px; height: 7px; border: 0; border-radius: 50%; background: #DCE6EF; }
.key-route i { border-color: var(--signal-rest); }
.key-plan i { border-color: var(--plan); }
.credit {
  margin: 4px 0 0; padding-top: 7px;
  border-top: var(--hair);
  font-size: 8.5px; letter-spacing: 0.06em; text-transform: none;
  color: var(--haze-dim);
}

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 820px) {
  .stage { height: auto; min-height: 100vh; }
  #map { height: 58vh; }
  .panel {
    position: static;
    width: auto;
    margin: 0;
    border-left: 0; border-right: 0; border-bottom: 0;
    backdrop-filter: none;
  }
  .results-list, .trip-list { max-height: none; overflow: visible; }
  .chartkey { position: static; align-items: flex-start; border-left: 0; border-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; }
  .leg-runner { display: none; }
}

/* --- the itinerary builder ------------------------------------------------ */

.build { display: flex; flex-direction: column; gap: 10px; }
.build .field { grid-template-columns: 42px 1fr; }

/* Whatever the field could not settle on. Amber, not red: nothing broke, a
   token just needs a better name. */
.add-miss {
  margin: -2px 0 0 52px;
  font-family: var(--font-body);
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--plan);
}

.trip-list {
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  /* Tall enough that a normal trip — including its closing row — is never
     silently cut off. Longer lists scroll. */
  max-height: 40vh;
  overflow-y: auto;
}
.trip-list:empty { display: none; }
.trip-list li {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-top: var(--hair);
}
.trip-list li:first-child { border-top: 0; }
.trip-list .code {
  padding: 0;
  background: none; border: 0; border-radius: 0;
  font-family: var(--font-data); font-size: 11.5px;
  letter-spacing: 0.06em; color: var(--signal);
  text-align: left;
}
button.code { cursor: pointer; }
button.code:hover { color: var(--paper); }
button.code:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
.trip-list li.is-return { opacity: 0.75; }
.trip-list li.is-return .code { color: var(--plan); }
.trip-list li.is-start .code { color: var(--plan); }
.trip-list .name {
  font-size: 12.5px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.trip-list .start-tag {
  font-family: var(--font-data); font-size: 8.5px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--plan);
}
.trip-list select {
  padding: 2px 4px;
  background: rgba(31, 66, 96, 0.3);
  border: var(--hair);
  border-radius: 0;
  color: var(--paper);
  font-family: var(--font-data);
  font-size: 10.5px;
}
.trip-list select:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }
.trip-list .drop {
  padding: 2px 6px;
  background: none; border: 0; border-radius: 0;
  color: var(--haze-dim); font-size: 14px; line-height: 1; cursor: pointer;
}
.trip-list .drop:hover { color: var(--paper); }
.trip-list .drop:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }

.trip-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.trip-controls .clear[hidden] { display: none !important; }
/* --- trip results --------------------------------------------------------- */

.tour-summary {
  display: flex; gap: 16px;
  margin: 0 0 10px; padding-bottom: 10px;
  border-bottom: var(--hair);
  font-family: var(--font-data); font-size: 11px;
  font-variant-numeric: tabular-nums; color: var(--haze);
}
.tour-summary b { color: var(--paper); font-weight: 500; }

.notice {
  margin: 0 0 10px; padding: 8px 10px;
  border-left: 2px solid var(--plan);
  background: rgba(255, 176, 32, 0.07);
  font-size: 12px; line-height: 1.5; color: var(--haze);
}
.notice b { color: var(--plan); font-weight: 500; }
.notice.is-good { border-left-color: var(--signal); background: rgba(36, 200, 119, 0.07); }
.notice.is-good b { color: var(--signal); }

.row-leg { display: grid; grid-template-columns: 22px 1fr auto; align-items: baseline; gap: 9px; }
.row-leg .seq {
  font-family: var(--font-data); font-size: 10px;
  color: var(--plan); font-variant-numeric: tabular-nums;
}
.row-leg .hop { font-family: var(--font-data); font-size: 13px; letter-spacing: 0.06em; }
.row-leg .hop b { font-weight: 500; color: var(--paper); }
.row-leg .hop i { color: var(--haze-dim); font-style: normal; }
.row-leg .via {
  display: block; margin-top: 2px;
  font-family: var(--font-data); font-size: 10px; color: var(--haze-dim);
}
.row-leg .miles {
  font-family: var(--font-data); font-size: 10.5px;
  color: var(--haze); font-variant-numeric: tabular-nums;
}

/* --- numbered tour stops on the chart ------------------------------------- */

.tour-stop circle { fill: var(--plan); stroke: var(--ink); stroke-width: 1; }
.tour-stop text {
  fill: var(--ink); font-family: var(--font-data); font-weight: 600;
  pointer-events: none;
}
