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

:root {
  --bg: #f6f3ee;
  --fg: #1c1b19;
  --muted: #6b6660;
  --rule: #dcd6cc;
  --accent: #1f4e79;
  --land: #e6e0d6;
  --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;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121311;
    --fg: #ebe7e0;
    --muted: #9a948b;
    --rule: #2a2b28;
    --accent: #7fa7d0;
    --land: #1e201d;
  }
}

*,
*::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;
  -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,
main,
.site-foot {
  max-width: 1040px;
  margin: 0 auto;
  padding-left: var(--pad);
  padding-right: var(--pad);
}

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

.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;
}

main > section { padding-block: 56px; }

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

h2 {
  margin: 0 0 28px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.16em;
  color: var(--muted);
}

h3 {
  margin: 0 0 14px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ---------- lede ---------- */

.lede { padding-top: 40px; }

.lede h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 46px);
  line-height: 1.35;
  letter-spacing: 0.01em;
}

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

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

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

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

.total {
  display: flex;
  flex-direction: column-reverse;
  min-width: 0;
}

.num {
  margin: 0;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.label {
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

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

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

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

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

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

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

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

.map-note {
  margin: 0;
  padding: 24px 0;
  font-size: 13px;
  color: var(--muted);
}

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

.year-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 20px;
}

.year-btn {
  appearance: none;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
}

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

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

/* ---------- year bars ---------- */

.year-bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  width: 100%;
}

.year-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.year-col .bar-area {
  display: flex;
  align-items: flex-end;
  height: 80px;
  width: 100%;
}

.year-col .bar {
  width: 100%;
  max-width: 22px;
  margin: 0 auto;
  background: var(--accent);
  min-height: 1px;
}

.year-col .bar.zero { background: var(--rule); }

.year-col .yl {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  min-height: 1em;
}

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

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

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

.rank li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 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: 14px;
  color: var(--muted);
}

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

.longest .sep { padding: 0 10px; }

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

.trip {
  padding: 22px 0;
  border-top: 1px solid var(--rule);
}

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

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

.trip .name {
  margin: 2px 0 8px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.4;
}

.trip .chain {
  font-family: var(--mono);
  font-size: 14px;
  overflow-wrap: anywhere;
}

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

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

.next-line {
  margin: 0;
  font-size: clamp(22px, 4vw, 30px);
  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: 4px;
  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.08em;
  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: 28px;
  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; }
  main > section { padding-block: 80px; }
  .lede { padding-top: 56px; }
}

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

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

  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); }
}
