/* Palette borrows from VFR sectional charts: pale chart paper, navy ink,
   airspace magenta, and towered-airport blue. */
:root {
  --paper: #edf0ea;
  --paper-2: #e1e7df;
  --ink: #16283a;
  --muted: #56687a;
  --rule: #c3ccc1;
  --magenta: #a3226e;
  --blue: #2a5c8e;
  --photo-bg: #d4dbd2;

  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0f1b27;
    --paper-2: #17263a;
    --ink: #e3e9ee;
    --muted: #93a4b4;
    --rule: #2a3b4d;
    --magenta: #e46cb2;
    --blue: #86b4e2;
    --photo-bg: #1b2a3b;
  }
}
:root[data-theme="dark"] {
  --paper: #0f1b27;
  --paper-2: #17263a;
  --ink: #e3e9ee;
  --muted: #93a4b4;
  --rule: #2a3b4d;
  --magenta: #e46cb2;
  --blue: #86b4e2;
  --photo-bg: #1b2a3b;
}

*, *::before, *::after { box-sizing: border-box; }
:root {
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--blue); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--magenta); }
:focus-visible { outline: 2px solid var(--magenta); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 8px; z-index: 10; background: var(--paper); padding: 6px 10px; }

/* Header: the fading magenta band under it echoes the Class E airspace
   vignette on a sectional chart. */
.site-header { position: relative; border-bottom: 1px solid var(--magenta); }
.site-header::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 10px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--magenta) 22%, transparent), transparent);
  pointer-events: none;
}
.header-inner { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 18px; padding-bottom: 14px; }
.brand {
  font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; line-height: 1;
  color: var(--ink); text-decoration: none; letter-spacing: 0.01em;
}
.site-header nav { display: flex; gap: 22px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-weight: 500; }
.site-header nav a:hover { color: var(--ink); }
.site-header nav a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--magenta); }

main.wrap { padding-top: clamp(28px, 5vw, 56px); padding-bottom: 72px; min-height: 60vh; }

/* The registration is the one loud element on every page. */
.reg-display {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(3.4rem, 11vw, 8.75rem); line-height: 0.86;
  letter-spacing: 0.005em; margin: 0; color: var(--ink);
  font-variant-numeric: lining-nums;
}
.reg-display a { color: inherit; text-decoration: none; }
.reg-display a:hover { color: var(--magenta); }

.page-title, .section-title {
  font-family: var(--font-display); font-weight: 600; line-height: 1; margin: 0;
}
.page-title { font-size: clamp(2.6rem, 6vw, 4.25rem); }
.section-title { font-size: 2rem; }
.summary { color: var(--muted); margin: 8px 0 0; max-width: 62ch; }
.crumb { margin: 0 0 12px; color: var(--muted); font-size: 0.95rem; }
.crumb a { color: var(--muted); }

/* Home hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr);
  gap: clamp(20px, 3vw, 40px); align-items: end; margin-bottom: clamp(48px, 7vw, 88px);
}
.hero-photo { display: block; background: var(--photo-bg); }
.hero-photo img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.hero-when { margin: 0 0 10px; color: var(--muted); }
.hero .reg-display { font-size: clamp(3.4rem, 7.2vw, 6.5rem); overflow-wrap: anywhere; }
.hero-type { margin: 14px 0 0; font-size: 1.15rem; line-height: 1.4; }
@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
}

.section-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 20px; margin-bottom: 18px; }
.section-top .summary { margin: 0; }

/* Ledger: the log as rows, like a spotter's notebook. */
.ledger-tools { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; margin-bottom: 18px; }
.search { flex: 1 1 260px; }
.search input, .sort select {
  font: inherit; color: var(--ink); background: var(--paper);
  border: 1px solid var(--rule); border-radius: 6px; padding: 9px 12px;
}
.search input { width: 100%; }
.search input:focus, .sort select:focus { border-color: var(--blue); }
.cats { display: flex; flex-wrap: wrap; gap: 6px; }
.cats button {
  font: inherit; font-size: 0.92rem; cursor: pointer;
  color: var(--ink); background: transparent;
  border: 1px solid var(--rule); border-radius: 999px; padding: 6px 13px;
}
.cats button:hover { border-color: var(--ink); }
.cats button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.sort { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.92rem; }

.ledger-head, .ledger .row {
  display: grid;
  grid-template-columns: 120px minmax(8.5rem, 1.1fr) minmax(0, 1.3fr) minmax(0, 1.3fr) 9.5rem 9rem 5.5rem;
  gap: 18px; align-items: center;
}
.ledger-head {
  padding: 0 0 8px; border-bottom: 1px solid var(--ink);
  color: var(--muted); font-size: 0.85rem;
}
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { border-bottom: 1px solid var(--rule); }
.ledger .row { padding: 10px 0; color: var(--ink); text-decoration: none; }
.ledger .row:hover { background: var(--paper-2); }
.ledger .row:hover .reg { color: var(--magenta); }
.ledger .thumb { width: 120px; aspect-ratio: 3 / 2; object-fit: cover; background: var(--photo-bg); height: auto; }
.thumb-empty {
  display: block;
  background: repeating-linear-gradient(135deg, var(--photo-bg) 0 6px, transparent 6px 12px);
  border: 1px dashed var(--rule);
}
.ledger .reg {
  font-family: var(--font-display); font-weight: 600; font-size: 1.7rem; line-height: 1;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
}
.ledger .type, .ledger .op { min-width: 0; }
.ledger .cat, .ledger .seen, .ledger .count { color: var(--muted); font-size: 0.92rem; }
.ledger-head span:first-child { visibility: hidden; }
@media (min-width: 821px) { .seen-label { display: none; } }
.ledger .seen { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rarity {
  font-family: var(--font-body); font-weight: 600; font-size: 0.72rem; line-height: 1;
  color: var(--magenta); border: 1px solid currentColor; border-radius: 999px; padding: 3px 7px;
  position: relative; top: -0.35em;
}
.ledger-empty { color: var(--muted); padding: 24px 0; }

@media (max-width: 820px) {
  .ledger-head { display: none; }
  .ledger .row {
    grid-template-columns: 104px minmax(0, 1fr);
    grid-template-areas:
      "thumb reg"
      "thumb type"
      "thumb op"
      "thumb meta";
    gap: 2px 14px; align-items: start;
  }
  .ledger .thumb { grid-area: thumb; width: 104px; }
  .ledger .reg { grid-area: reg; font-size: 1.55rem; }
  .ledger .type { grid-area: type; }
  .ledger .op { grid-area: op; color: var(--muted); }
  .ledger .cat { display: none; }
  .ledger .seen { grid-area: meta; font-size: 0.85rem; white-space: normal; }
  .ledger .count { display: none; }
}

/* Aircraft page */
.aircraft .subtitle { font-size: clamp(1.1rem, 2.2vw, 1.35rem); margin: 16px 0 0; max-width: 60ch; }
.aircraft .subtitle a { color: var(--ink); }
.aircraft .subtitle a:hover { color: var(--magenta); }
.facts {
  display: flex; flex-wrap: wrap; gap: 14px 40px; margin: 28px 0 0; padding: 16px 0;
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule);
}
.facts div { min-width: 7rem; }
.facts dt { color: var(--muted); font-size: 0.85rem; }
.facts dd { margin: 2px 0 0; font-weight: 500; }
.caption { max-width: 66ch; margin-top: 24px; font-size: 1.05rem; }
.caption p { margin: 0 0 0.9em; }
.empty-note { color: var(--muted); margin-top: 28px; }

.gallery {
  list-style: none; margin: 32px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 10px;
}
.gallery a { display: block; background: var(--photo-bg); }
.gallery img { width: 100%; aspect-ratio: 3 / 2; object-fit: cover; }
.gallery a:hover img { opacity: 0.9; }

.more { margin-top: 72px; }
.more .section-title { margin-bottom: 16px; }

/* Types and operators index */
.groups { list-style: none; margin: 28px 0 0; padding: 0; border-top: 1px solid var(--ink); }
.groups li { border-bottom: 1px solid var(--rule); }
.groups a {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name strip" "count strip";
  gap: 2px 24px; align-items: center; padding: 16px 0; text-decoration: none; color: var(--ink);
}
.groups a:hover { background: var(--paper-2); }
.groups a:hover .group-name { color: var(--magenta); }
.group-name { grid-area: name; font-family: var(--font-display); font-weight: 600; font-size: 2rem; line-height: 1.05; }
.group-count { grid-area: count; color: var(--muted); font-size: 0.92rem; }
.group-strip { grid-area: strip; display: flex; gap: 6px; }
.group-strip .thumb { width: 96px; aspect-ratio: 3 / 2; object-fit: cover; height: auto; }
@media (max-width: 640px) {
  .groups a { grid-template-columns: 1fr; grid-template-areas: "name" "count" "strip"; }
  .group-strip { margin-top: 10px; }
  .group-strip .thumb { width: calc(25% - 5px); }
}

/* Lightbox */
.lightbox {
  width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0;
  border: 0; background: rgba(6, 12, 18, 0.95); color: #e3e9ee;
}
.lightbox::backdrop { background: rgba(6, 12, 18, 0.95); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox figure {
  margin: 0; display: flex; flex-direction: column; align-items: center;
  max-width: calc(100vw - 32px);
  padding: calc(56px + env(safe-area-inset-top, 0px)) 0 calc(16px + env(safe-area-inset-bottom, 0px));
}
.lightbox img { max-width: min(100%, 2048px); max-height: calc(100vh - 150px); max-height: calc(100dvh - 150px); object-fit: contain; }
.lightbox figcaption {
  width: 100%; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 20px;
  padding: 12px 4px 0; font-size: 0.95rem;
}
.lb-meta { display: flex; gap: 18px; color: #93a4b4; }
.lightbox a { color: #e3e9ee; }
.lightbox a:hover { color: #e46cb2; }
.lb-btn {
  position: absolute; display: grid; place-items: center; width: 48px; height: 48px;
  background: rgba(15, 27, 39, 0.7); color: #e3e9ee; border: 1px solid rgba(227, 233, 238, 0.25);
  border-radius: 50%; cursor: pointer;
}
.lb-btn:hover { background: rgba(15, 27, 39, 0.95); border-color: #e3e9ee; }
.lb-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lb-close { top: calc(12px + env(safe-area-inset-top, 0px)); right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lb-btn[hidden] { display: none; }
@media (min-width: 641px) {
  .lightbox figure { max-width: calc(100vw - 176px); }
}
@media (max-width: 640px) {
  .lb-prev, .lb-next { top: auto; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); transform: none; }
  .lightbox figure { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
}

/* Footer */
.site-footer { border-top: 1px solid var(--rule); color: var(--muted); font-size: 0.9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 24px; padding-top: 20px; padding-bottom: 28px; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
