/* air — 多開口機票組合
 *
 * 視覺語彙取自航圖(aeronautical chart):冷灰藍底、細線分隔、小字級的等寬
 * 註記、藍色航路與洋紅色邊界。介面主體用等寬字是刻意的 —— 機場代碼、日期、
 * 票價本來就是機票的原生排版,等寬對齊讓五十列結果能一眼掃完。
 *
 * 大膽的地方只有一處:航線圖示(.routeline)。飛的航段是實線帶節點,自己走的
 * 航段是虛線斷口,所以「開口」這件事直接看得見。其餘一律安靜。
 */

:root {
  --ground:      #e6ebef;
  --paper:       #ffffff;
  --paper-sunk:  #f2f5f7;
  --ink:         #131c26;
  --ink-soft:    #5d6b78;
  --ink-faint:   #8d9aa6;
  --rule:        #ccd6dd;
  --rule-strong: #a9b7c2;

  /* 航路藍:飛的航段、主要動作 */
  --airway:      #1b5e8c;
  --airway-soft: #e2edf4;
  /* 邊界洋紅:自己走的航段、需要注意的事 */
  --boundary:      #b4245f;
  --boundary-soft: #fbe9f0;

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --han: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Hiragino Sans", sans-serif;

  --gap: 1.5rem;
  --radius: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:      #0e161d;
    --paper:       #161f28;
    --paper-sunk:  #1b2630;
    --ink:         #e4ebf0;
    --ink-soft:    #9aa9b6;
    --ink-faint:   #6b7b88;
    --rule:        #2a3945;
    --rule-strong: #3d4f5d;
    --airway:      #67b0e0;
    --airway-soft: #17303f;
    --boundary:      #f0709f;
    --boundary-soft: #331a25;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--han);
  font-size: 15px;
  line-height: 1.65;
}

main {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 var(--gap) 5rem;
}

/* ---- Chart annotation type ------------------------------------------- */

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
}

.wordmark {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.5em;
  color: var(--airway);
}

/* ---- Masthead --------------------------------------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  max-width: 74rem;
  margin: 0 auto;
  padding: 1.75rem var(--gap) 1rem;
  border-bottom: 1px solid var(--rule-strong);
}

.masthead__brand { display: flex; align-items: baseline; gap: 1rem; }

.masthead__tag {
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.masthead__meta { display: flex; gap: 0.5rem; flex-wrap: wrap; }

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

.keys {
  max-width: 74rem;
  margin: 0 auto;
  padding: 0 var(--gap);
}

.keys__summary {
  display: inline-block;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  padding: 0.6rem 0;
  list-style: none;
}

.keys__summary::-webkit-details-marker { display: none; }
.keys__summary::before { content: "＋ "; color: var(--ink-faint); }
.keys[open] .keys__summary::before { content: "− "; }
.keys__summary:hover { color: var(--airway); }

.keys__body {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--airway);
  border-radius: var(--radius);
  padding: 1rem 1.25rem 1.25rem;
  margin-bottom: 0.5rem;
}

.keys__note { margin: 0 0 0.9rem; font-size: 0.85rem; color: var(--ink-soft); max-width: 46rem; }
.keys__note strong { color: var(--ink); font-weight: 600; }

.keys__fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}

.keys__fields input { min-width: 0; flex: 1 1 16rem; }

.keys__state {
  margin: 0.75rem 0 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
}

.keys__state--ok { color: var(--airway); }

/* ---- Hero ------------------------------------------------------------- */

.hero {
  display: grid;
  gap: 2rem;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: center;
  padding: 2.5rem 0 3rem;
}

.hero__lede {
  margin: 0;
  font-size: 1.05rem;
  max-width: 34rem;
  color: var(--ink);
}

.hero__lede strong { color: var(--airway); font-weight: 600; }

.hero__diagram { min-width: 0; }

/* ---- The route line: the signature element ---------------------------- */

.routeline {
  display: flex;
  align-items: center;
  min-width: 0;
}

.node {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--airway);
  background: var(--paper);
}

.seg {
  flex: 1 1 auto;
  position: relative;
  height: 0;
  border-top: 2px solid var(--airway);
  min-width: 2.5rem;
}

.seg--surface {
  border-top-style: dashed;
  border-top-color: var(--boundary);
}

.seg__glyph {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--paper);
  padding: 0 0.4rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1;
  color: var(--airway);
  white-space: nowrap;
}

.seg--surface .seg__glyph { color: var(--boundary); }

.routeline--demo { padding: 0 0.25rem; }

.routeline--demo .node,
.routeline--demo .seg__glyph { background: var(--ground); }

.routeline__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 0.6rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-soft);
}

/* ---- Panels ----------------------------------------------------------- */

.panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem;
}

/* ---- The stop chain --------------------------------------------------- */

.stopchain { display: grid; gap: 0; }

.stop {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0 1rem;
  padding: 0.9rem 0;
  border-top: 1px solid var(--rule);
  min-width: 0;
}

.stop:first-child { border-top: none; }

.stop__role {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 0.55rem;
}

.stop__body { display: grid; gap: 0.6rem; min-width: 0; max-width: 100%; }

/* Grid and flex children default to min-width:auto, so a wide <select>
 * refuses to shrink and drags the whole page sideways on a phone. */
.stop__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  min-width: 0;
}

.stop__remove {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--ink-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
}

.stop__remove:hover { color: var(--boundary); }

/* The gap between two stops: fly it, or get yourself there. */
.hop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0 0.35rem 5.5rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.hop__label { font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.08em; }

/* ---- Chips ------------------------------------------------------------ */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.chip:hover { border-color: var(--airway); color: var(--airway); }

.chip[aria-pressed="true"] {
  background: var(--airway-soft);
  border-color: var(--airway);
  color: var(--airway);
  font-weight: 600;
}

.chip--quiet { cursor: default; border-style: dashed; }
.chip--quiet:hover { border-color: var(--rule-strong); color: var(--ink-soft); }

.chip--alert {
  border-color: var(--boundary);
  color: var(--boundary);
  background: var(--boundary-soft);
}

.citygroup {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  overflow: hidden;
}

.citygroup__name,
.citygroup__code {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1;
  padding: 0.42rem 0.55rem;
  background: var(--paper);
  border: none;
  border-left: 1px solid var(--rule);
  color: var(--ink-soft);
  cursor: pointer;
}

.citygroup__name {
  border-left: none;
  font-family: var(--han);
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
}

.citygroup__name:hover,
.citygroup__code:hover { color: var(--airway); }

.citygroup__code[aria-pressed="true"],
.citygroup__name[aria-pressed="true"] {
  background: var(--airway-soft);
  color: var(--airway);
  font-weight: 600;
}

/* ---- Form controls ---------------------------------------------------- */

select, input[type="date"], input[type="number"] {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 0.4rem 0.5rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  max-width: 100%;
}

/* A <select> is sized by its widest option, and 「沙烏地阿拉伯 (46)」 is wider
 * than a phone. Without this it pushes the whole page sideways. */
.stop__row > select { flex: 1 1 14rem; min-width: 0; }

select:focus-visible,
input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--airway);
  outline-offset: 2px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  padding-top: 1.25rem;
  margin-top: 1rem;
  border-top: 1px solid var(--rule);
}

.field { display: grid; gap: 0.3rem; }
.field--narrow input { width: 5rem; }

.field__label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.switch {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
  padding-bottom: 0.4rem;
}

.btn {
  font-family: var(--mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--airway);
  background: var(--paper);
  color: var(--airway);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.btn:hover { background: var(--airway-soft); }

.btn--primary { background: var(--airway); color: var(--paper); }
.btn--primary:hover { filter: brightness(1.12); background: var(--airway); }
.btn--primary[disabled] { opacity: 0.55; cursor: progress; }

.btn--ghost {
  border-style: dashed;
  border-color: var(--rule-strong);
  color: var(--ink-soft);
  margin-top: 0.5rem;
}

.btn--ghost:hover { border-color: var(--airway); color: var(--airway); background: none; }

.plan__submit {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-top: 1.25rem;
}

.plan__cost {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink-faint);
}

/* ---- Notices ---------------------------------------------------------- */

.notices { display: grid; gap: 0.6rem; margin-top: 1.5rem; }

.notice {
  border: 1px solid var(--rule-strong);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--paper);
  padding: 0.8rem 1rem;
  font-size: 0.9rem;
}

.notice--alert { border-left-color: var(--boundary); }
.notice--info { border-left-color: var(--airway); }

.notice__title {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: block;
  margin-bottom: 0.25rem;
}

/* ---- Results ---------------------------------------------------------- */

.results { margin-top: 2.5rem; }
.results--muted { opacity: 0.92; }

.results__head { margin-bottom: 1rem; }

.results__summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  max-width: 46rem;
}

.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.75rem; }

.card {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  display: grid;
  gap: 0.9rem;
}

.card--best { border-color: var(--airway); border-left-width: 3px; }

.card__top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: baseline;
  justify-content: space-between;
}

.card__rank {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--ink-faint);
}

.card__price {
  font-family: var(--mono);
  font-size: 1.3rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.card__price--none { font-size: 0.85rem; font-weight: 400; color: var(--boundary); }

.card__saving {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--airway);
}

.card__saving--worse { color: var(--ink-faint); }

/* Route line inside a result, with each node's airport and date beneath. */
.card__route { display: grid; gap: 0.5rem; }

.legs {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.legs__stop { display: grid; gap: 0.1rem; text-align: center; min-width: 0; }
.legs__stop:first-child { text-align: left; }
.legs__stop:last-child { text-align: right; }

.legs__code { color: var(--ink); font-weight: 600; letter-spacing: 0.06em; }
.legs__place { font-family: var(--han); font-size: 0.72rem; color: var(--ink-faint); }
.legs__date { font-size: 0.7rem; }

/* Provenance rides with the number, never separately. */
.stamp {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.15rem 0.35rem;
  white-space: nowrap;
}

.stamp--live { color: var(--airway); border-color: var(--airway); }
.stamp--none { color: var(--boundary); border-color: var(--boundary); }

.card__risks {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.2rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.card__risks li::before {
  content: "△ ";
  color: var(--boundary);
  font-family: var(--mono);
}

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--rule);
}

.card__actions .label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-right: 0.15rem;
}

a.chip { text-decoration: none; }

.verdict {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  display: grid;
  gap: 0.25rem;
  padding: 0.6rem 0.75rem;
  background: var(--paper-sunk);
  border-radius: var(--radius);
}

.verdict__row { display: flex; justify-content: space-between; gap: 1rem; }
.verdict__win { color: var(--airway); font-weight: 600; }

/* ---- Colophon --------------------------------------------------------- */

.colophon {
  max-width: 74rem;
  margin: 0 auto;
  padding: 1.5rem var(--gap) 3rem;
  border-top: 1px solid var(--rule-strong);
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.colophon p { margin: 0 0 0.4rem; max-width: 52rem; }
.colophon__meta { font-family: var(--mono); font-size: 0.72rem; color: var(--ink-faint); }

/* ---- Responsive ------------------------------------------------------- */

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 1.5rem; padding: 1.75rem 0 2rem; }
  .stop { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .stop__role { padding-top: 0; }
  .hop { padding-left: 0; }
  .legs__place { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
