/* BruNett+ — single stylesheet, no framework, no external requests.
   Palette is defined once as tokens; dark mode only swaps the tokens. */

:root {
  --bg:        #f7f8fa;
  --bg-raise:  #ffffff;
  --bg-sunk:   #eef1f5;
  --text:      #10151f;
  --text-soft: #55606f;
  --text-mute: #7c8797;
  --line:      #dfe4ea;
  --line-soft: #e9edf2;
  --accent:      #1f5fd8;
  --accent-ink:  #ffffff;
  --accent-soft: #e8effc;
  --ok:        #0f7b52;
  --shadow:    0 1px 2px rgba(16,21,31,.05), 0 8px 24px rgba(16,21,31,.06);
  --shadow-sm: 0 1px 2px rgba(16,21,31,.06);
  --radius:    12px;
  --radius-sm: 8px;
  --wrap:      1080px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
          "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

/* No-JS fallback; the inline head script normally sets data-theme first. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0e1117; --bg-raise:#161b22; --bg-sunk:#0a0d12;
    --text:#e6edf3; --text-soft:#9aa6b4; --text-mute:#7d8896;
    --line:#252c36; --line-soft:#1d232c;
    --accent:#5b9bff; --accent-ink:#08111f; --accent-soft:#152238;
    --ok:#3fb984;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg:#0e1117; --bg-raise:#161b22; --bg-sunk:#0a0d12;
  --text:#e6edf3; --text-soft:#9aa6b4; --text-mute:#7d8896;
  --line:#252c36; --line-soft:#1d232c;
  --accent:#5b9bff; --accent-ink:#08111f; --accent-soft:#152238;
  --ok:#3fb984;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }
.muted { color: var(--text-soft); }
.small { font-size: .875rem; }
.sr-only, .skip:not(:focus) {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip:focus {
  position: fixed; top: 12px; left: 12px; z-index: 100; width: auto; height: auto;
  clip: auto; background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--radius-sm);
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 20px; min-height: 64px; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 9px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700; font-size: .95rem; letter-spacing: -.02em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { font-size: 1.02rem; letter-spacing: -.01em; }
.brand-text small { color: var(--text-mute); font-size: .74rem; }

.nav { margin-left: auto; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.nav a {
  padding: 7px 11px; border-radius: var(--radius-sm); font-size: .9rem;
  color: var(--text-soft); text-decoration: none; white-space: nowrap;
}
.nav a:hover { background: var(--bg-sunk); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.theme-toggle {
  margin-left: 8px; display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-raise); color: var(--text-soft); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .i-moon { display: none; }
[data-theme="dark"] .theme-toggle .i-sun  { display: none; }
[data-theme="dark"] .theme-toggle .i-moon { display: block; }

.nav-toggle { display: none; }

/* ---------- hero ---------- */
.hero {
  padding: 76px 0 56px;
  background:
    radial-gradient(60rem 26rem at 12% -18%, var(--accent-soft), transparent 70%),
    linear-gradient(var(--bg-raise), var(--bg));
  border-bottom: 1px solid var(--line-soft);
}
.eyebrow {
  margin: 0 0 12px; font-size: .78rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--accent);
}
.hero h1 { margin: 0 0 14px; font-size: clamp(2.2rem, 5.5vw, 3.4rem);
  letter-spacing: -.03em; line-height: 1.08; }
.lead { margin: 0; font-size: 1.1rem; color: var(--text-soft); max-width: 60ch; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

.latest-chip {
  display: inline-flex; align-items: center; gap: 9px; flex-wrap: wrap;
  margin-top: 30px; padding: 9px 15px; font-size: .88rem;
  background: var(--bg-raise); border: 1px solid var(--line);
  border-radius: 999px; box-shadow: var(--shadow-sm);
}
.latest-chip .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--bg-raise); color: var(--text);
  font: inherit; font-size: .92rem; font-weight: 500;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  font-weight: 600;
}
.btn-primary:hover {
  color: var(--accent-ink);
  background: color-mix(in srgb, var(--accent) 86%, #000);
  border-color: color-mix(in srgb, var(--accent) 86%, #000);
}
.btn-sm { padding: 7px 14px; font-size: .86rem; }
.btn-xs { padding: 3px 10px; font-size: .78rem; border-radius: 6px; }

/* ---------- content ---------- */
main { padding-bottom: 72px; }
main > .wrap, .wrap > section { padding-top: 40px; }
h1 { font-size: clamp(1.8rem, 3.6vw, 2.4rem); letter-spacing: -.025em; line-height: 1.15; }
h2 { font-size: 1.4rem; letter-spacing: -.015em; margin-top: 2em; }
h3 { font-size: 1.1rem; letter-spacing: -.01em; }
.prose { max-width: 72ch; }
.prose h2 { padding-bottom: .3em; border-bottom: 1px solid var(--line-soft); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--accent); }
.prose table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: .93rem; }
.prose th, .prose td { padding: 9px 12px; border: 1px solid var(--line); text-align: left; }
.prose th { background: var(--bg-sunk); font-weight: 600; }
.prose blockquote {
  margin: 1.4em 0; padding: .2em 1.1em; border-left: 3px solid var(--accent);
  color: var(--text-soft);
}
.section-block + .section-block { margin-top: 48px; padding-top: 40px; border-top: 1px solid var(--line-soft); }
code { font-family: var(--mono); font-size: .875em; background: var(--bg-sunk);
  padding: .15em .4em; border-radius: 5px; }

.callout {
  padding: 20px 24px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); background: var(--bg-raise); box-shadow: var(--shadow-sm);
}
.callout :first-child { margin-top: 0; }
.callout :last-child { margin-bottom: 0; }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.card {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raise); color: inherit; text-decoration: none;
  box-shadow: var(--shadow-sm); transition: border-color .15s, transform .15s, box-shadow .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.card h3 { margin: 0; font-size: 1rem; }
.card-go { color: var(--accent); font-size: 1.1rem; }

/* ---------- downloads ---------- */
.group-head { margin-top: 2em; color: var(--text-soft); font-size: .82rem;
  font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.file-list { list-style: none; margin: 12px 0 0; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-raise); overflow: hidden; }
.file {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; flex-wrap: wrap;
}
.file + .file { border-top: 1px solid var(--line-soft); }
.file:hover { background: var(--bg-sunk); }
.file-name { font-weight: 600; text-decoration: none; word-break: break-all; }
.file-meta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 2px;
  font-size: .82rem; color: var(--text-mute); }
.file-side { display: flex; align-items: center; gap: 12px; }
.hash {
  border: 1px solid var(--line); background: var(--bg-sunk); color: var(--text-mute);
  border-radius: 6px; padding: 4px 9px; cursor: pointer; font: inherit;
}
.hash:hover { border-color: var(--accent); color: var(--accent); }
.hash code { background: none; padding: 0; font-size: .76rem; }
.hash.copied { color: var(--ok); border-color: var(--ok); }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: .76rem; font-weight: 600; font-family: var(--mono);
}

.filter { display: flex; align-items: center; gap: 12px; margin: 16px 0 4px; }
.filter input {
  flex: 1; max-width: 420px; padding: 10px 14px; font: inherit; font-size: .92rem;
  color: var(--text); background: var(--bg-raise);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.filter input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-count { font-size: .84rem; color: var(--text-mute); }

.timeline { list-style: none; margin: 20px 0 0; padding: 0 0 0 22px;
  border-left: 2px solid var(--line); }
.rel { position: relative; padding: 0 0 26px 20px; }
.rel::before {
  content: ""; position: absolute; left: -29px; top: 9px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--line);
}
.rel:first-child::before { background: var(--accent); border-color: var(--accent); }
.rel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rel-head time { font-weight: 600; font-size: .92rem; }
.rel-changes { margin: 8px 0 0; padding-left: 1.2em; color: var(--text-soft); font-size: .93rem; }
.rel-changes li { margin: .2em 0; }
.rel[hidden] { display: none; }
.empty { padding: 24px; text-align: center; color: var(--text-mute); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-raise); padding: 40px 0; }
.footer-inner { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.site-footer p { margin: .25em 0; font-size: .89rem; color: var(--text-soft); }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .nav-toggle {
    display: grid; gap: 4px; margin-left: auto; width: 40px; height: 40px;
    place-content: center; background: none; border: 1px solid var(--line);
    border-radius: var(--radius-sm); cursor: pointer;
  }
  .nav-toggle span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 2px; }
  .nav {
    display: none; order: 3; width: 100%; margin: 0;
    flex-direction: column; align-items: stretch; gap: 2px; padding-bottom: 14px;
  }
  .nav.open { display: flex; }
  .nav a { padding: 10px 12px; font-size: .95rem; }
  .theme-toggle { margin: 8px 0 0; width: 100%; }
  .hero { padding: 52px 0 40px; }
  .file { align-items: flex-start; }
  .file-side { width: 100%; justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- media: gallery, lightbox, video ---------- */
.gallery {
  display: grid; gap: 12px; margin: 24px 0;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.shot {
  display: block; overflow: hidden; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--bg-raise); line-height: 0;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.shot:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow); }
.shot img { width: 100%; height: 150px; object-fit: cover; object-position: top; display: block; }

.video { margin: 24px 0; }
.video video {
  width: 100%; max-width: 780px; display: block; background: #000;
  border: 1px solid var(--line); border-radius: var(--radius);
}

.lightbox {
  position: fixed; inset: 0; z-index: 90; display: none;
  align-items: center; justify-content: center; padding: 28px;
  background: rgba(6, 9, 14, .88); backdrop-filter: blur(3px);
}
.lightbox[open], .lightbox.open { display: flex; }
.lightbox img {
  max-width: 100%; max-height: 100%; border-radius: var(--radius-sm);
  box-shadow: 0 24px 70px rgba(0,0,0,.6); background: #fff;
}
.lightbox-close, .lightbox-nav {
  position: absolute; display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.22);
  font-size: 1.4rem; line-height: 1;
}
.lightbox-close:hover, .lightbox-nav:hover { background: rgba(255,255,255,.22); }
.lightbox-close { top: 18px; right: 18px; }
.lightbox-nav.prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-nav.next { right: 18px; top: 50%; transform: translateY(-50%); }
.lightbox-count {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%);
  color: rgba(255,255,255,.8); font-size: .85rem;
}
@media (max-width: 600px) {
  .gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .shot img { height: 115px; }
  .lightbox { padding: 12px; }
  .lightbox-nav.prev { left: 6px; }
  .lightbox-nav.next { right: 6px; }
}

/* The gallery is 37 scans of white paper. At full brightness in dark mode a
   grid of them reads as a broken theme, so tone them down and restore full
   fidelity on hover and in the lightbox, where the document is the subject. */
[data-theme="dark"] .shot {
  background: var(--bg-sunk);
}
[data-theme="dark"] .shot img {
  filter: brightness(.82) contrast(1.04);
  transition: filter .15s;
}
[data-theme="dark"] .shot:hover img,
[data-theme="dark"] .shot:focus-visible img {
  filter: none;
}
[data-theme="dark"] .video video {
  border-color: var(--line);
}
