/* Site styles. Uses only variables from tokens.css. */
*, *::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-body);
  font-size: var(--text-base);
  line-height: var(--leading);
}
img, svg { max-width: 100%; height: auto; }
a { color: var(--link); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:visited { color: var(--link-visited); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.skip-link {
  position: absolute; left: var(--space-3); top: -100px;
  background: var(--surface); color: var(--text);
  padding: var(--space-2) var(--space-4); border: 2px solid var(--focus); border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { top: var(--space-3); }

.wrap { max-width: var(--page-width); margin: 0 auto; padding: 0 var(--space-5); }

/* Header */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; gap: var(--space-5); min-height: 68px; flex-wrap: wrap; padding-top: var(--space-2); padding-bottom: var(--space-2); }
.brand { display: flex; align-items: center; gap: var(--space-3); text-decoration: none; color: var(--text); }
.brand:visited { color: var(--text); }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand-name { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 700; letter-spacing: 0.01em; }
.site-nav ul { list-style: none; display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-4); margin: 0; padding: 0; }
.site-nav a { color: var(--text); text-decoration: none; font-size: var(--text-sm); font-weight: 500; padding: var(--space-1) 0; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); text-decoration: underline; }
.header-tools { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); }
.header-search { display: flex; }
.header-search input {
  font: inherit; font-size: var(--text-sm); width: 15rem; max-width: 50vw;
  padding: var(--space-2) var(--space-3); border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--text);
}
.theme-toggle {
  font: inherit; font-size: var(--text-xs); color: var(--muted); background: none;
  border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-1) var(--space-3); cursor: pointer;
}

/* Main layout */
main { padding: var(--space-6) 0 var(--space-8); }
.breadcrumb { font-size: var(--text-sm); color: var(--muted); margin-bottom: var(--space-3); }
.breadcrumb ol { list-style: none; display: flex; gap: var(--space-2); padding: 0; margin: 0; flex-wrap: wrap; }
.breadcrumb li + li::before { content: "/"; margin-right: var(--space-2); color: var(--border); }
.breadcrumb a { color: var(--muted); }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.22; color: var(--text); }
h1 { font-size: var(--text-3xl); margin: 0 0 var(--space-3); letter-spacing: -0.01em; }
h2 { font-size: var(--text-xl); margin: var(--space-7) 0 var(--space-3); padding-bottom: var(--space-2); border-bottom: 1px solid var(--border); }
h3 { font-size: var(--text-lg); margin: var(--space-6) 0 var(--space-2); }
p, ul, ol { margin: 0 0 var(--space-4); }
.type-label { display: inline-block; font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--space-2); }
.aliases { color: var(--muted); font-size: var(--text-sm); margin-top: calc(-1 * var(--space-2)); }

.entry { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-6); }
@media (min-width: 980px) {
  .entry { grid-template-columns: minmax(0, 1fr) 300px; gap: var(--space-7); }
  .entry-aside { grid-column: 2; grid-row: 1 / span 2; }
}
.entry-body { max-width: var(--measure); }

.summary {
  background: var(--accent-tint); border-left: 4px solid var(--accent);
  padding: var(--space-4) var(--space-5); border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--text-lg); line-height: 1.55; margin: var(--space-5) 0 var(--space-6);
}
.summary-label { display: block; font-size: var(--text-xs); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-strong); margin-bottom: var(--space-1); font-family: var(--font-body); }

.cite { font-size: 0.72em; line-height: 0; margin-left: 1px; }
.cite a { text-decoration: none; padding: 0 2px; }

/* Infobox */
.infobox { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4) var(--space-5); font-size: var(--text-sm); }
.infobox h2 { font-size: var(--text-base); margin: 0 0 var(--space-3); padding: 0; border: 0; }
.infobox dl { margin: 0; display: grid; grid-template-columns: 1fr; gap: var(--space-3); }
.infobox dt { font-weight: 600; color: var(--muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; }
.infobox dd { margin: 0; }
.infobox ul { list-style: none; padding: 0; margin: 0; }
.infobox li + li { margin-top: var(--space-1); }
.page-tools { margin-top: var(--space-4); background: var(--surface-2); border-radius: var(--radius); padding: var(--space-4) var(--space-5); font-size: var(--text-sm); }
.page-tools h2 { font-size: var(--text-base); margin: 0 0 var(--space-2); padding: 0; border: 0; }
.page-tools ul { list-style: none; padding: 0; margin: 0; }
.page-tools li + li { margin-top: var(--space-2); }

/* Relations, sources, meta */
.relations ul { columns: 2 16rem; padding-left: var(--space-5); }
.sources ol { padding-left: var(--space-5); font-size: var(--text-sm); }
.sources li { margin-bottom: var(--space-3); }
.sources li:target { background: var(--mark); }
.source-link { word-break: break-word; }
.entry-meta { margin-top: var(--space-7); padding-top: var(--space-4); border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--muted); }
.entry-meta dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-4); margin: 0 0 var(--space-4); }
.entry-meta dt { font-weight: 600; }
.entry-meta dd { margin: 0; }
.cite-box { background: var(--surface-2); border-radius: var(--radius); padding: var(--space-3) var(--space-4); font-size: var(--text-sm); }
.cite-box p { margin: 0 0 var(--space-2); }
.copy-btn { font: inherit; font-size: var(--text-xs); border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius); padding: var(--space-1) var(--space-3); cursor: pointer; }

/* Home and index pages */
.hero { padding: var(--space-6) 0 var(--space-5); max-width: 52rem; }
.hero h1 { font-size: var(--text-3xl); }
.lede { font-size: var(--text-lg); color: var(--muted); max-width: 46rem; }
.hero-search { display: flex; gap: var(--space-2); margin-top: var(--space-5); max-width: 36rem; }
.hero-search input { flex: 1; font: inherit; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.hero-search button, .button { font: inherit; font-weight: 600; padding: var(--space-3) var(--space-5); border: 0; border-radius: var(--radius); background: var(--accent); color: var(--bg); cursor: pointer; text-decoration: none; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--space-4); list-style: none; padding: 0; margin: var(--space-4) 0 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-4) var(--space-5); height: 100%; }
.card h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.card h3 a { text-decoration: none; color: var(--text); }
.card h3 a:hover { text-decoration: underline; color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: var(--text-sm); }
.card .type-label { margin-bottom: var(--space-1); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.section-head a { font-size: var(--text-sm); }
.entry-list { list-style: none; padding: 0; margin: var(--space-5) 0 0; max-width: var(--measure); }
.entry-list li { padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.entry-list a { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; }
.entry-list p { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-sm); }
.machine-note { margin-top: var(--space-7); padding: var(--space-5); border: 1px dashed var(--border); border-radius: var(--radius); font-size: var(--text-sm); color: var(--muted); }

/* Prose pages */
.prose { max-width: var(--measure); }
.prose table { border-collapse: collapse; width: 100%; margin: 0 0 var(--space-5); font-size: var(--text-sm); }
.prose th, .prose td { border: 1px solid var(--border); padding: var(--space-2) var(--space-3); text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.prose code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }
.prose pre { background: var(--surface-2); padding: var(--space-4); border-radius: var(--radius); overflow-x: auto; }
.prose pre code { background: none; padding: 0; }

/* Search */
.search-form { display: flex; gap: var(--space-2); max-width: 40rem; margin: var(--space-4) 0 var(--space-5); }
.search-form input { flex: 1; font: inherit; padding: var(--space-3) var(--space-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.search-results { list-style: none; padding: 0; max-width: var(--measure); }
.search-results li { padding: var(--space-4) 0; border-bottom: 1px solid var(--border); }
.search-results a { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; }
.search-results p { margin: var(--space-1) 0 0; color: var(--muted); font-size: var(--text-sm); }
.search-status { color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: var(--space-6) 0; font-size: var(--text-sm); color: var(--muted); }
.site-footer ul { list-style: none; padding: 0; margin: 0 0 var(--space-4); display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); }
.site-footer a { color: var(--muted); }
.site-footer p { margin: 0 0 var(--space-2); max-width: 60rem; }

@media (max-width: 640px) {
  h1, .hero h1 { font-size: var(--text-2xl); }
  .header-tools { margin-left: 0; width: 100%; }
  .header-search { flex: 1; }
  .header-search input { width: 100%; max-width: none; }
  .summary { font-size: var(--text-base); }
}

@media print {
  .site-header, .site-footer, .page-tools, .skip-link, .copy-btn { display: none; }
  body { background: #fff; color: #000; }
}

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

/* Search refinements */
.search-form { flex-wrap: wrap; }
.search-form label { flex-basis: 100%; margin: 0; }
.search-results mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 2px; }

/* Gaps: what an entry does not yet know */
.gaps { margin-top: var(--space-6); background: var(--surface-2); border-radius: var(--radius); padding: var(--space-4) var(--space-5); font-size: var(--text-sm); }
.gaps h2 { font-size: var(--text-base); margin: 0 0 var(--space-2); padding: 0; border: 0; }
.gaps ul { margin: var(--space-2) 0; padding-left: var(--space-5); }
.gap-note { color: var(--muted); }
.cn { font-size: var(--text-xs); white-space: nowrap; }
.cn a { color: var(--muted); }
