/* GLM documentation -- minimal stylesheet, no framework, no JS dependency. */

:root {
  --ink: #1c2530;
  --muted: #5b6875;
  --line: #dde3e9;
  --bg: #ffffff;
  --panel: #f6f8fa;
  --accent: #1c6ea4;
  --accent-soft: #e8f1f7;
  --req: #8a5a00;
  --req-bg: #fff6e0;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  /* Height of the sticky jump bar. It now runs to one row per category, and
     that row count changes with the viewport, so search.js measures it and
     overwrites this; the value here is only the pre-script fallback. */
  --jump-h: 150px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #dbe3ea;
    --muted: #9aa7b4;
    --line: #2c3742;
    --bg: #131920;
    --panel: #1a2129;
    --accent: #6cb6e6;
    --accent-soft: #17242e;
    --req: #e8b968;
    --req-bg: #2a2214;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

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

/* ---- header ---- */

header {
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 56px; flex-wrap: wrap;
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; font-size: 17px; color: var(--ink); text-decoration: none;
}
.brand img { display: block; }
nav.top a {
  color: var(--muted); text-decoration: none; margin-left: 18px; font-size: 14px;
}
nav.top a:hover { color: var(--accent); }

/* ---- layout ---- */

.layout { padding-top: 28px; padding-bottom: 64px; }

/* ---- landing page ---- */

.page { max-width: 900px; padding-top: 44px; padding-bottom: 72px; }

.hero h1 { font-size: 38px; line-height: 1.15; margin: 0 0 12px; }
/* Prose here runs to the same width as the figures and the tile grid above it,
   rather than the narrower measure the reference page uses -- a short column
   floating beside empty space reads as a mistake at this page width. */
.hero .lede { font-size: 18px; max-width: none; margin: 0; }

/* The landing page has no sticky bar to clear, so its anchors want a normal
   offset rather than the jump-bar allowance the reference page needs. */
.page h2.group, .page section { scroll-margin-top: 20px; }

figure.shot { margin: 30px 0 0; }
figure.shot img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
figure.shot figcaption {
  margin: 9px 0 0; font-size: 13px; color: var(--muted); max-width: none;
}

.prose p { max-width: none; }
.prose p + p { margin-top: 14px; }
.prose h3 { font-size: 18px; margin: 28px 0 8px; }

/* Link cards -- one per documentation destination. */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
  gap: 14px; margin: 20px 0 0;
}
.card {
  display: block; padding: 16px 18px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); text-decoration: none;
  transition: background .12s, border-color .12s, transform .12s;
}
.card:hover, .card:focus-visible {
  border-color: var(--accent); background: var(--accent-soft);
}
.card h3 { font-size: 16px; margin: 0 0 5px; color: var(--accent); }
.card p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
/* The one card that stays on this page -- the arrow says so before the click. */
.card.here h3::after { content: " \2193"; font-weight: 400; opacity: .65; }

@media (max-width: 620px) {
  .hero h1 { font-size: 30px; }
  .hero .lede { font-size: 16px; }
}

/* ---- search ---- */

.searchbar { border-bottom: 1px solid var(--line); background: var(--bg); }
.searchbar .wrap {
  display: flex; align-items: center; gap: 12px;
  padding-top: 12px; padding-bottom: 12px;
}
.field {
  display: flex; align-items: center; gap: 8px; flex: 1; max-width: 420px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel);
}
.field:focus-within { border-color: var(--accent); background: var(--bg); }
.field svg { fill: var(--muted); flex: none; }
.field input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  color: var(--ink); font: inherit; font-size: 14px;
}
.field input::-webkit-search-cancel-button { cursor: pointer; }
.count { color: var(--muted); font-size: 13px; white-space: nowrap; }

.noresults {
  margin: 32px 0; padding: 16px; text-align: center;
  color: var(--muted); background: var(--panel);
  border: 1px dashed var(--line); border-radius: 6px;
}

/* ---- sticky "jump to" bar ---- */

nav.jump {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--line);
}
/* One row per category: the label sits in the first column and its chips fill
   the second, so the five groups read as five lines rather than one long wrap. */
nav.jump .wrap {
  display: grid; grid-template-columns: max-content minmax(0, 1fr);
  align-items: baseline; column-gap: 14px; row-gap: 7px;
  padding-top: 9px; padding-bottom: 9px;
}
.jump-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 600; text-align: right;
}
nav.jump ul {
  display: flex; flex-wrap: wrap; gap: 6px;
  list-style: none; margin: 0; padding: 0;
}
nav.jump a {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg);
  color: var(--muted); text-decoration: none;
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  white-space: nowrap; transition: background .12s, color .12s, border-color .12s;
}
nav.jump a:hover, nav.jump a:focus-visible {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
/* Block filtered out by the current search. */
nav.jump a.dim { opacity: .3; }

main { min-width: 0; }

h1 { font-size: 30px; margin: 0 0 8px; letter-spacing: -0.01em; }
.lede { color: var(--muted); margin: 0 0 8px; max-width: 62ch; }

h2.group {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 48px 0 0; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

h2.group { scroll-margin-top: calc(var(--jump-h) + 12px); }

section { margin: 32px 0 0; scroll-margin-top: calc(var(--jump-h) + 8px); }
section h3 { font-size: 20px; margin: 0 0 10px; }
/* Briefly mark whichever block was jumped to. */
section:target h3 code { color: var(--ink); }
section:target h3::before {
  content: ""; position: absolute; margin-left: -14px; margin-top: 4px;
  width: 4px; height: 22px; border-radius: 2px; background: var(--accent);
}
section:target h3 { position: relative; }
section h3 code { background: none; padding: 0; color: var(--accent); font-size: inherit; }

/* ---- notes ---- */

p.note {
  margin: 0 0 14px; padding: 8px 12px; font-size: 14px;
  color: var(--muted); background: var(--panel);
  border-left: 3px solid var(--line); border-radius: 0 4px 4px 0;
}
p.note.req {
  color: var(--req); background: var(--req-bg); border-left-color: var(--req);
}
/* A block the reader still parses but that has no effect on the simulation. */
p.note.warn { border-left-style: dashed; border-left-width: 4px; }

/* Provenance note at the foot of the reference. Deliberately neither a
   <section> nor an h2.group -- the search filter hides both of those once
   their rows stop matching, and this note should survive any query. */
.audit { margin: 56px 0 0; }
.audit h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 0 0 16px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

/* A lede that introduces a whole group rather than a single block; it is
   hidden alongside its heading when the filter empties the group. */
.group-note { margin: 12px 0 0; }

/* ---- tables ---- */

.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
thead th {
  background: var(--panel); text-align: left; font-weight: 600;
  font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody th, tbody td {
  padding: 9px 12px; border-bottom: 1px solid var(--line);
  vertical-align: top; text-align: left;
}
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
tbody th { font-weight: 600; white-space: nowrap; }

code {
  font-family: var(--mono); font-size: .9em;
  background: var(--panel); padding: 1px 5px; border-radius: 3px;
}

/* Keep the LaTeX in the Options column from stretching the row. */
tbody td mjx-container { margin: 2px 0 !important; }

/* Parameters the reader accepts but the model does not yet act on. Greyed so
   they read as inactive without being hidden -- they still need to be findable,
   because they turn up in existing nml files. */
tbody tr.unused th, tbody tr.unused td { color: var(--muted); }

/* ---- examples ---- */

details {
  margin: 14px 0 0; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel);
}
summary {
  cursor: pointer; padding: 8px 12px; font-size: 13px; font-weight: 600;
  color: var(--muted); user-select: none;
}
summary:hover { color: var(--accent); }
details pre {
  margin: 0; padding: 0 14px 14px; overflow-x: auto;
}
details pre code {
  background: none; padding: 0; font-size: 13px; line-height: 1.5;
  color: var(--ink); white-space: pre;
}

/* ---- footer ---- */

footer {
  border-top: 1px solid var(--line); background: var(--panel);
  color: var(--muted); font-size: 14px;
}
footer p { margin: 18px 0; }
footer a { color: var(--accent); }

a { color: var(--accent); }

@media (max-width: 860px) {
  /* Wrapping five rows of chips would take most of the screen -- keep one row
     per category and scroll each sideways instead. */
  nav.jump ul {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  nav.jump ul::-webkit-scrollbar { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

tbody tr.subhead th {
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  padding: 7px 12px;
}
tbody tr.subhead:hover th { background: var(--accent-soft); }
