/* 航跡簿 logbook — editorial print, zero build */

:root {
  --bg: #f6f3ee;
  --fg: #1c1b19;
  --muted: #6b6660;
  --rule: #dcd6cc;
  --accent: #1f4e79;
  --land: #e6e0d6;
  --grat: #cfc7ba;
  --sans: "Noto Sans TC", system-ui, -apple-system, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", sans-serif;
  --serif: "Noto Serif TC", "Songti TC", "Source Han Serif TC", Georgia, serif;
  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --pad: 24px;
  --col: 1040px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101210;
    --fg: #ebe7e0;
    --muted: #97918a;
    --rule: #282a27;
    --accent: #d9b98a;
    --land: #1b1d1a;
    --grat: #262a26;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.7;
  overflow-x: hidden;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

.serif { font-family: var(--serif); font-weight: 700; }

a { color: inherit; }

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

:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 3px;
}

/* ---------- layout ---------- */

.site-head,
.col,
.site-foot {
  max-width: var(--col);
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.bleed { width: 100%; }

.site-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.brand {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.brand:hover { color: var(--fg); }

.site-name {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
}

.col > section { padding-block: 56px; }

.col > section + section { border-top: 1px solid var(--rule); }

/* 區塊標題：編號（等寬）＋ 字距寬的小標＋細線 */

.sec-h {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 32px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 12px;
  line-height: 1.6;
  letter-spacing: 0.22em;
  color: var(--muted);
}

.sec-h .sec-n {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.sec-h::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--rule);
}

h3 {
  margin: 0 0 16px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

/* ---------- hero ---------- */

.col > section.hero { padding-top: 0; padding-bottom: 56px; }

.year-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--rule);
}

.year-btn {
  appearance: none;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  line-height: 1.4;
  cursor: pointer;
}

.year-btn:hover { color: var(--fg); }

.year-btn[aria-pressed="true"] {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 5px;
}

.lede {
  margin: 40px 0 0;
  font-size: clamp(26px, 5.2vw, 40px);
  line-height: 1.4;
  letter-spacing: 0.01em;
  max-width: 18em;
}

.meta {
  margin: 16px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.meta time { font-family: var(--mono); }

/* ---------- totals ---------- */

.totals {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px 24px;
  margin: 48px 0 0;
}

.total {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-top: 8px;
  border-top: 1px solid var(--rule);
}

.num {
  margin: 8px 0 0;
  font-size: var(--num-size, 40px);
  line-height: 1;
  letter-spacing: -0.015em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.label {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.micro {
  margin: 40px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.micro .sep { padding: 0 10px; color: var(--rule); }

.fleet {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.8;
  color: var(--muted);
}

.fleet .fleet-k {
  padding-right: 10px;
  letter-spacing: 0.12em;
}

.fleet .fleet-v { font-family: var(--mono); font-size: 11px; }

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

.map {
  position: relative;
  width: 100%;
  min-height: 96px;
}

.map svg { display: block; width: 100%; height: auto; }

.land { fill: var(--land); stroke: none; }

.grat {
  fill: none;
  stroke: var(--grat);
  stroke-width: 0.5;
  opacity: 0.55;
}

.arc {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  transition: opacity 180ms ease;
}

.dot {
  fill: var(--accent);
  stroke: var(--bg);
  stroke-width: 0.75;
  transition: opacity 180ms ease;
  cursor: default;
}

.code-label {
  fill: var(--fg);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.map-note {
  max-width: var(--col);
  margin: 0 auto;
  padding: 32px var(--pad);
  font-size: 13px;
  color: var(--muted);
}

.tip {
  position: fixed;
  z-index: 5;
  transform: translate(-50%, -140%);
  padding: 4px 8px;
  background: var(--bg);
  border: 1px solid var(--rule);
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
}

.tip .pair { font-family: var(--mono); }

/* ---------- timeline ---------- */

.timeline { width: 100%; }

.timeline svg { display: block; width: 100%; height: auto; }

.tl-rule { stroke: var(--rule); stroke-width: 1; }

.tl-tick {
  stroke: var(--accent);
  stroke-width: 1.25;
  stroke-linecap: butt;
  transition: opacity 180ms ease;
}

.tl-year-tick { stroke: var(--rule); stroke-width: 1; }

.tl-year {
  fill: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.04em;
  transition: fill 180ms ease;
}

.tl-year.on { fill: var(--fg); }

.tl-hit { fill: transparent; cursor: default; }

/* ---------- frequent ---------- */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
}

.rank {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.rank li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-top: 1px solid var(--rule);
}

.rank li:last-child { border-bottom: 1px solid var(--rule); }

.rank .k { min-width: 0; overflow-wrap: anywhere; }

.rank .pair { font-family: var(--mono); }

.rank .n {
  flex: none;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.longest {
  margin: 32px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.longest .pair { font-family: var(--mono); color: var(--fg); }

.longest .sep { padding: 0 10px; color: var(--rule); }

/* ---------- trips ---------- */

.trip {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 24px 0;
  border-top: 1px solid var(--rule);
  outline-offset: 4px;
}

.trip:last-child { border-bottom: 1px solid var(--rule); }

.trip .mini-wrap { min-width: 0; }

.trip .trip-text { min-width: 0; }

.trip .mini {
  display: block;
  width: 100%;
  height: auto;
  min-height: 8px;
}

.trip .mini-land { fill: var(--land); }
.trip .mini-arc { fill: none; stroke: var(--accent); stroke-width: 1; opacity: 0.75; }
.trip .mini-dot { fill: var(--accent); }
.trip .mini-frame { fill: none; stroke: var(--rule); stroke-width: 1; }

.trip .y {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.trip .name {
  margin: 4px 0 12px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 24px;
  line-height: 1.35;
}

.trip .chain {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.trip .sub {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

.trip .cancelled {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
  text-decoration: line-through;
}

.trip.on .name { text-decoration: underline; text-underline-offset: 6px; }

.next-line {
  margin: 0;
  font-size: clamp(22px, 4vw, 32px);
  line-height: 1.4;
}

/* ---------- table ---------- */

.linkish {
  appearance: none;
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 5px;
  cursor: pointer;
}

.linkish:hover { color: var(--accent); }

.table-wrap { margin-top: 24px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

thead th {
  padding: 0 8px 8px 0;
  border-bottom: 1px solid var(--rule);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-align: left;
}

tbody td {
  padding: 8px 8px 8px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: baseline;
  overflow-wrap: anywhere;
}

tbody td:last-child,
thead th:last-child { padding-right: 0; }

.c-date, .c-route, .c-no { font-family: var(--mono); }

.c-date { width: 15%; }
.c-route { width: 17%; }
.c-airline { width: 22%; }
.c-no { width: 12%; }
.c-aircraft { width: 20%; color: var(--muted); }
.c-km { width: 14%; text-align: right; font-variant-numeric: tabular-nums; }

th.c-km { text-align: right; }

/* ---------- footer ---------- */

.site-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 56px;
  border-top: 1px solid var(--rule);
  font-size: 12px;
  color: var(--muted);
}

.site-foot p { margin: 0; }

/* ---------- wide ---------- */

@media (min-width: 720px) {
  :root { --pad: 48px; }
  .col > section { padding-block: 80px; }
  .col > section.hero { padding-bottom: 80px; }
  .sec-h { margin-bottom: 40px; }
}

/* ---------- narrow ---------- */

@media (max-width: 640px) {
  .totals { grid-template-columns: repeat(2, 1fr); }
  .site-foot { flex-direction: column; gap: 8px; }
  .two-col { grid-template-columns: 1fr; gap: 32px; }

  .trip { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .trip .name { font-size: 22px; }

  table { table-layout: auto; }
  table, thead, tbody, tr, th, td { display: block; }

  thead {
    position: absolute;
    width: 1px; height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
  }

  tbody tr {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "route aircraft date"
      "airline no km";
    column-gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--rule);
  }

  tbody td {
    padding: 0;
    border: 0;
    width: auto;
    min-width: 0;
  }

  td.c-route { grid-area: route; width: auto; font-size: 14px; white-space: nowrap; }
  td.c-aircraft { grid-area: aircraft; width: auto; font-size: 11px; overflow-wrap: normal; }
  td.c-date { grid-area: date; width: auto; text-align: right; font-size: 11px; white-space: nowrap; color: var(--muted); }
  td.c-airline { grid-area: airline; width: auto; font-size: 12px; color: var(--muted); overflow-wrap: normal; }
  td.c-no { grid-area: no; width: auto; font-size: 12px; white-space: nowrap; color: var(--muted); }
  td.c-km { grid-area: km; width: auto; font-size: 12px; white-space: nowrap; text-align: right; color: var(--muted); }
}

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