/* ─────────────────────────────────────────────────────────────
   commonsformat.dev — format documentation
   Effectively monochrome. Black on warm white. One muted ochre accent.
   Plus Jakarta Sans for prose; JetBrains Mono for code and labels.
   Denser register than the personal sites. RFC-style two-column.
   ─────────────────────────────────────────────────────────────  */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("./fonts/plus-jakarta-sans.woff2") format("woff2-variations"),
       url("./fonts/plus-jakarta-sans.woff2") format("woff2");
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("./fonts/jetbrains-mono.woff2") format("woff2-variations"),
       url("./fonts/jetbrains-mono.woff2") format("woff2");
}

:root {
  --bg:        #fafaf7;
  --bg-2:      #f3f1ea;
  --bg-3:      #e9e6dc;

  --fg:        #14130f;
  --fg-2:      #3a3833;
  --fg-3:      #6f6c63;
  --fg-4:      #9a968a;

  --rule:      #d6d2c5;
  --rule-soft: #e4e0d3;

  --accent:    #8a6a3b;
  --accent-ink:#5d4724;

  --selection-bg: #e7dcc2;
  --selection-fg: #14130f;

  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont,
               "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas,
               monospace;

  --leading-prose:   1.55;
  --leading-tight:   1.45;
  --leading-display: 1.2;

  --tracking-tight:  -0.012em;
  --tracking-wide:   0.04em;

  --measure-prose: 70ch;
  --measure-wide:  78ch;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;

  --radius-1: 2px;
  --radius-2: 4px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: var(--leading-prose);
  font-feature-settings: "kern", "liga", "calt";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--selection-bg); color: var(--selection-fg); }

/* ── Typography ─────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  color: var(--fg);
  margin: 0;
  text-wrap: balance;
}

h1 {
  font-size: 32px;
  font-weight: 600;
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-tight);
}

h2 {
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: var(--tracking-tight);
}

h3 {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
}

p, li {
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: var(--leading-prose);
  color: var(--fg);
  max-width: var(--measure-prose);
  text-wrap: pretty;
  hyphens: auto;
}

p { margin: 0 0 1em 0; }

small, .meta, time, figcaption {
  font-size: 13px;
  color: var(--fg-3);
}

/* ── Links ──────────────────────────────────────────────── */

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--rule);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  color: var(--accent-ink);
  text-decoration-color: var(--accent);
}

a:visited { color: inherit; }
a:visited:hover { color: var(--accent-ink); }

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a.accent { color: var(--accent); text-decoration-color: var(--accent); }
a.accent:hover { color: var(--accent-ink); }

/* ── Code ───────────────────────────────────────────────── */

code, kbd, samp, pre {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-feature-settings: "calt" 0;
}

code {
  background: var(--bg-2);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-1);
}

pre {
  background: var(--bg-2);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-2);
  overflow-x: auto;
  line-height: var(--leading-tight);
  margin: 1.5em 0;
  font-size: 13.5px;
}

pre code { background: transparent; padding: 0; font-size: inherit; }

kbd {
  background: var(--bg-3);
  border: 1px solid var(--rule);
  border-radius: var(--radius-1);
  padding: 0.05em 0.4em;
  font-size: 0.82em;
}

/* ── Block elements ─────────────────────────────────────── */

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--space-7) 0;
}

ul, ol {
  max-width: var(--measure-prose);
  padding-left: 1.4em;
}

li { margin: 0.25em 0; }

img, picture, video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ── Layout shell ───────────────────────────────────────── */

.shell {
  display: flex;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 24px;
}

.rail {
  width: 240px;
  border-right: 1px solid var(--rule);
  padding: 36px 28px 64px 0;
  flex-shrink: 0;
  min-height: 100vh;
}

.rail .wordmark {
  display: block;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  text-decoration: none;
  margin-bottom: 32px;
}

.rail .eyebrow {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
  margin-bottom: 12px;
}

.rail nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rail nav a {
  font-size: 14px;
  color: var(--fg-2);
  text-decoration: none;
  line-height: 1.45;
  border-left: 1px solid transparent;
  padding-left: 10px;
  margin-left: -11px;
}

.rail nav a:hover {
  color: var(--accent-ink);
}

.rail nav a[aria-current="page"] {
  color: var(--fg);
  font-weight: 600;
  border-left-color: var(--fg);
}

.content {
  flex: 1;
  padding: 36px 0 96px 48px;
  max-width: var(--measure-wide);
  min-width: 0;
}

/* ── Spec home ──────────────────────────────────────────── */

.version-tag {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-3);
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
  margin-bottom: 14px;
}

.spec-h1 {
  margin-bottom: 18px;
}

.spec-lede {
  font-size: 17px;
  color: var(--fg-2);
  max-width: 70ch;
}

.spec-section {
  margin: 48px 0 12px;
}

.spec-section + p,
.spec-section + ul {
  margin-top: 0;
}

/* ── RFC body ───────────────────────────────────────────── */

.rfc-tag {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--fg-3);
  margin-bottom: 6px;
}

.rfc-title {
  font-size: 28px;
  margin-bottom: 14px;
}

.rfc-abstract {
  font-size: 16px;
  color: var(--fg-2);
  border-left: 1px solid var(--rule);
  padding-left: 16px;
  margin: 0 0 36px;
}

.rfc h2 {
  font-size: 19px;
  margin: 32px 0 10px;
}

.rfc p {
  font-size: 17px;
  line-height: 1.55;
  max-width: 70ch;
}

/* ── Reference table ────────────────────────────────────── */

.reference-h1 {
  font-size: 28px;
  margin-bottom: 32px;
}

.reference-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 15px;
  line-height: 1.55;
}

.reference-table th {
  text-align: left;
  font-weight: 600;
  color: var(--fg-2);
  font-size: 13px;
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
  padding: 10px 16px 10px 0;
  border-bottom: 1px solid var(--rule);
}

.reference-table th + th { padding: 10px 16px; }
.reference-table th:last-child { padding: 10px 0 10px 16px; }

.reference-table td {
  padding: 12px 16px 12px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--rule-soft);
}

.reference-table td + td { padding: 12px 16px; }
.reference-table td:last-child { padding: 12px 0 12px 16px; }

.reference-table .field {
  font-family: var(--font-mono);
  font-size: 13.5px;
  white-space: nowrap;
}

.reference-table .where {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-3);
  white-space: nowrap;
}

/* ── Module page ────────────────────────────────────────── */

.module-tag {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
  margin-bottom: 6px;
}

.module-title {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.2;
  margin-bottom: 8px;
}

.module-version {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--fg-3);
  margin-bottom: 22px;
}

.module-abstract {
  font-size: 16px;
  color: var(--fg-2);
  border-left: 1px solid var(--rule);
  padding-left: 16px;
  margin: 0 0 24px;
  max-width: 70ch;
}

.module-meta {
  background: var(--bg-2);
  padding: 12px 16px;
  border-radius: var(--radius-2);
  font-size: 13px;
  margin-bottom: 36px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.module-meta code {
  background: transparent;
  padding: 0;
  font-size: 13px;
}

.module-meta-key {
  display: inline-block;
  width: 96px;
  font-family: var(--font-mono);
  color: var(--fg-3);
  font-size: 11.5px;
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
}

.module-meta-constraint {
  font-family: var(--font-mono);
  color: var(--fg-3);
  font-size: 12.5px;
  margin-left: 6px;
}

article.module h2 {
  font-size: 19px;
  margin: 36px 0 12px;
}

article.module p,
article.module ul,
article.module ol {
  font-size: 16px;
  line-height: 1.55;
  max-width: 70ch;
}

/* ── Tagged sections ────────────────────────────────────── */

.tagged {
  background: var(--bg-2);
  border-left: 2px solid var(--accent);
  padding: 16px 20px 4px;
  margin: 18px 0 24px;
  border-radius: 0 var(--radius-2) var(--radius-2) 0;
}

.tagged::before {
  content: attr(data-tag);
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-ink);
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
  margin-bottom: 10px;
}

.tagged > :last-child { margin-bottom: 12px; }

.tagged code { background: var(--bg-3); }

.constraint-list {
  list-style: none;
  padding-left: 0;
  max-width: 78ch;
}

.constraint-list li { margin: 4px 0; }

.constraint-list code {
  font-size: 0.9em;
  background: var(--bg-3);
  margin-right: 4px;
}

/* ── Tier badge (reuses .reference-table) ──────────────── */

.reference-table .tier {
  font-family: var(--font-mono);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--accent-ink);
  white-space: nowrap;
}

/* ── Rail group label and module list ──────────────────── */

.rail nav .rail-group-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
  margin-top: 18px;
}

.rail nav a.rail-module {
  font-family: var(--font-mono);
  font-size: 13px;
  padding-left: 20px;
  margin-left: -21px;
}

/* ── Page meta footer ──────────────────────────────────── */

.page-meta {
  margin-top: 56px;
  padding-top: 14px;
  border-top: 1px solid var(--rule-soft);
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--fg-3);
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
}

/* ── Spec page (numbered sections) ─────────────────────── */

article.spec h2 {
  font-size: 20px;
  margin: 40px 0 12px;
  scroll-margin-top: 16px;
}

article.spec h3 {
  font-size: 16.5px;
  margin: 26px 0 10px;
  scroll-margin-top: 16px;
}

article.spec h4 {
  font-size: 15px;
  font-weight: 600;
  margin: 22px 0 8px;
  scroll-margin-top: 16px;
  color: var(--fg-2);
}

article.spec p,
article.spec ul,
article.spec ol {
  font-size: 16px;
  max-width: 70ch;
}

.spec-toc {
  background: var(--bg-2);
  padding: 16px 22px 18px;
  border-radius: var(--radius-2);
  margin: 28px 0 40px;
}

.spec-toc-heading {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  letter-spacing: var(--tracking-wide);
  text-transform: lowercase;
  margin-bottom: 10px;
}

.spec-toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 28px;
  max-width: none;
}

.spec-toc li {
  margin: 2px 0;
  break-inside: avoid;
  font-size: 14px;
}

.spec-toc a {
  text-decoration: none;
  color: var(--fg-2);
}

.spec-toc a:hover {
  color: var(--accent-ink);
}

.spec-toc-num {
  font-family: var(--font-mono);
  color: var(--fg-3);
  font-size: 12.5px;
  margin-right: 8px;
  display: inline-block;
  width: 1.6em;
}

@media (max-width: 760px) {
  .spec-toc ol { columns: 1; }
}

/* ── 404 ────────────────────────────────────────────────── */

.notfound {
  max-width: 52ch;
  padding-top: 48px;
}

.notfound h1 { margin: 0 0 16px; font-size: 28px; }

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 760px) {
  .shell {
    flex-direction: column;
    padding: 0 20px;
  }
  .rail {
    width: auto;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
    padding: 24px 0 20px;
    min-height: 0;
  }
  .rail .wordmark { margin-bottom: 20px; }
  .rail nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
  }
  .rail nav a {
    border-left: 0;
    padding-left: 0;
    margin-left: 0;
  }
  .rail nav a[aria-current="page"] {
    border-left: 0;
    text-decoration: underline;
    text-decoration-color: var(--rule);
    text-underline-offset: 0.18em;
  }
  .content {
    padding: 28px 0 64px;
    max-width: none;
  }
  .reference-table .where { white-space: normal; }
}
