/* Shared styles for every page. The calculator page adds its own styles on top. */

@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/barlow-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/barlow-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/barlow-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/barlow-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/barlow-condensed-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/barlow-condensed-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Barlow Condensed"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/barlow-condensed-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/jetbrains-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/jetbrains-mono-latin-700-normal.woff2") format("woff2"); }

:root {
  --paper: #f2f3f0;
  --surface: #ffffff;
  --ink: #1b2026;
  --muted: #59636d;
  --line: #d6dad5;
  --accent: #1d5b86;
  --accent-soft: #e2edf5;
  --ok: #2c7349;
  --ok-soft: #e2f1e8;
  --warn: #8f5c0f;
  --warn-soft: #faefd9;
  --bad: #b42318;
  --bad-soft: #fbe5e2;
  --font-display: "Barlow Condensed", "Arial Narrow", "Roboto Condensed", sans-serif;
  --font-body: "Barlow", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", Consolas, "Courier New", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #111417;
    --surface: #1a1f24;
    --ink: #e6e9eb;
    --muted: #9ba5ae;
    --line: #2d343b;
    --accent: #7db7e2;
    --accent-soft: #1c3345;
    --ok: #74c79a;
    --ok-soft: #173021;
    --warn: #e6b45c;
    --warn-soft: #33280f;
    --bad: #f28b80;
    --bad-soft: #3b1c19;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  padding: 0 16px 48px;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
code, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 4px; z-index: 10; }
.skip:focus { left: 16px; }

/* Site bar */
.site-bar {
  max-width: 1120px; margin: 0 auto; padding: 14px 0;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand svg { width: 28px; height: 28px; flex: none; }
.brand span { font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: 0.02em; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 6px; }
.site-nav a {
  display: inline-block; padding: 6px 10px; border-radius: 4px;
  color: var(--ink); text-decoration: none; font-weight: 500;
}
.site-nav a:hover { background: var(--accent-soft); }
.site-nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }

/* Site footer */
.site-footer {
  max-width: 1120px; margin: 40px auto 0; padding-top: 16px;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem;
  display: grid; gap: 8px;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 18px; }
.site-footer p { margin: 0; max-width: 80ch; }

/* Content pages */
.page { max-width: 1120px; margin: 0 auto; }
.crumbs { font-size: 0.88rem; color: var(--muted); margin: 18px 0 0; }
.crumbs a { color: var(--muted); }
.prose { max-width: 70ch; padding-top: 18px; }
.prose h1 {
  font-family: var(--font-display); font-weight: 700; line-height: 1.04; letter-spacing: 0.01em;
  font-size: clamp(2.1rem, 5vw, 3rem); margin: 0 0 12px; text-wrap: balance;
}
.prose h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.6rem; line-height: 1.15; margin: 36px 0 10px; text-wrap: balance; }
.prose h3 { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; margin: 24px 0 6px; }
.prose p, .prose ul, .prose ol { margin: 0 0 14px; }
.prose li { margin-bottom: 6px; }
.prose li > ul, .prose li > ol { margin: 6px 0 0; }
.prose .lede { font-size: 1.15rem; color: var(--muted); }
.prose .meta { font-size: 0.88rem; color: var(--muted); font-family: var(--font-mono); }
.prose code { white-space: nowrap; font-size: 0.92em; background: var(--surface); border: 1px solid var(--line); border-radius: 3px; padding: 0 4px; }
.prose strong { font-weight: 600; }

.callout { border-left: 5px solid var(--accent); background: var(--accent-soft); padding: 12px 16px; border-radius: 4px; margin: 0 0 16px; }
.callout.warn { border-color: var(--warn); background: var(--warn-soft); }
.callout.bad { border-color: var(--bad); background: var(--bad-soft); }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 0 0 16px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
.prose th { white-space: nowrap; text-align: left; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 2px solid var(--ink); }
.prose td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.prose td code { white-space: nowrap; }

/* A byte drawn as 8 cells */
.byte-fig { margin: 0 0 16px; display: grid; gap: 6px; overflow-x: auto; }
.byte-row { display: grid; grid-template-columns: 70px repeat(8, minmax(42px, 1fr)); gap: 4px; align-items: center; min-width: 440px; }
.byte-row .lbl { font-size: 0.78rem; color: var(--muted); }
.cell { display: grid; justify-items: center; padding: 5px 0; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); font-family: var(--font-mono); }
.cell b { font-size: 1.05rem; }
.cell small { font-size: 0.66rem; color: var(--muted); }
.cell.hit { border-color: var(--accent); background: var(--accent-soft); }
.cell.hit b { color: var(--accent); }
.byte-fig figcaption { font-size: 0.88rem; color: var(--muted); }

.cta {
  display: inline-block; font-weight: 600; padding: 9px 18px; border-radius: 4px;
  background: var(--ink); color: var(--paper); text-decoration: none;
}
.cta:hover { background: var(--accent); }

.related { border-top: 1px solid var(--line); margin-top: 36px; padding-top: 12px; }
.related h2 { margin-top: 0; font-size: 1.3rem; }

/* Guide cards */
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.cards li { margin: 0; }
.card {
  display: grid; gap: 6px; height: 100%; padding: 16px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface); text-decoration: none; color: var(--ink);
}
.card:hover { border-color: var(--accent); }
.card strong { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; line-height: 1.15; color: var(--accent); }
.card span { color: var(--muted); font-size: 0.95rem; }
