/* Shared stylesheet for the noggin docs site. Designed to feel like a
   readable man-page: high-density typography, clear hierarchy, mirrors
   the dark-on-light + dark-mode contract the CLI demo already uses. */

:root {
  --fg: #1f2328;
  --muted: #6e7781;
  --bg: #ffffff;
  --panel: #f6f8fa;
  --border: #d0d7de;
  --code-bg: #f6f8fa;
  --code-fg: #1f2328;
  --code-block-bg: #0d1117;
  --code-block-fg: #e6edf3;
  --accent: #0969da;
  --accent-bg: rgba(9, 105, 218, 0.08);
  --ok: #1a7f37;
  --warn: #9a6700;
  --err: #d1242f;
  --pill-internal: #6e7781;
  --pill-public: #1a7f37;
  --pill-deprecated: #9a6700;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e6edf3;
    --muted: #8d96a0;
    --bg: #0d1117;
    --panel: #161b22;
    --border: #30363d;
    --code-bg: #161b22;
    --code-fg: #e6edf3;
    --code-block-bg: #010409;
    --code-block-fg: #e6edf3;
    --accent: #58a6ff;
    --accent-bg: rgba(88, 166, 255, 0.12);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "Helvetica Neue", Arial, sans-serif;
}

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

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

aside.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  max-height: 100vh;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px 18px;
  font-size: 13px;
}

aside.sidebar .brand {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
  margin-bottom: 4px;
}
aside.sidebar .tagline {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 18px;
}
aside.sidebar nav { display: block; }

/* ── Collapsible nav blocks ───────────────────────────────────────
 * Structure invariant: at any given depth, every sibling row has
 * the same font size, weight, and left inset. The chevron
 * indicates "this expands"; its absence indicates "this navigates."
 * That's the only visual distinction between a collapsible
 * subgroup and a leaf link at the same depth.
 *
 * Depth scale:
 *   .nav-group header     — top-level eyebrow (uppercase, muted)
 *   depth-0 siblings      — direct children of a group (14 px)
 *   depth-1 siblings      — direct children of a subgroup (13 px)
 *
 * Every row uses a `--chevron-col` reservation on the left so
 * chevronless rows still line up under their siblings.
 */
aside.sidebar nav { --chevron-col: 22px; }
aside.sidebar nav .nav-block { margin: 4px 0; }

aside.sidebar nav .nav-block-header {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 8px;
  margin: 0;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: 4px;
  font: inherit;
}
aside.sidebar nav .nav-block-header:hover { background: var(--accent-bg); }
aside.sidebar nav .nav-block-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Chevron: CSS-only right-pointing triangle, rotates 90° when
 * the parent block is expanded. Width matches --chevron-col
 * minus the gap so leaf sibling padding lines up exactly. */
aside.sidebar nav .nav-chevron {
  display: inline-block;
  flex: 0 0 auto;
  width: calc(var(--chevron-col) - 6px);
  height: 10px;
  position: relative;
}
aside.sidebar nav .nav-chevron::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 1px;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  transform-origin: 1px 5px;
  transition: transform 180ms ease;
}
aside.sidebar nav .nav-block[data-collapsed="false"] > .nav-block-header .nav-chevron::before {
  transform: rotate(90deg);
}

aside.sidebar nav .nav-block-label {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}

/* Top-level group header — the eyebrow. Uppercase muted;
 * clearly a "section label" as opposed to a peer of its own
 * children. */
aside.sidebar nav .nav-group { margin-top: 14px; }
aside.sidebar nav .nav-group:first-child { margin-top: 0; }
aside.sidebar nav .nav-group > .nav-block-header .nav-block-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

/* Subgroup header — visually matches its sibling leaf links.
 * The chevron is the only difference. */
aside.sidebar nav .nav-subgroup > .nav-block-header .nav-block-label {
  font-size: 14px;
  font-weight: 400;
  color: var(--fg);
}

/* Body: grid rows collapse trick for smooth height transition. */
aside.sidebar nav .nav-block-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 200ms ease;
}
aside.sidebar nav .nav-block[data-collapsed="true"] > .nav-block-body {
  grid-template-rows: 0fr;
}
aside.sidebar nav .nav-block-body > .nav-block-body-inner {
  overflow: hidden;
  min-height: 0;
  /* Every level of children steps in by one chevron-column so
   * their chevrons + labels sit under (not on top of) the
   * parent's label. Applies at every depth — group children
   * step in from the group header, subgroup children step in
   * from the subgroup header, and so on. */
  padding-left: var(--chevron-col);
}

/* Leaf navlinks: reserve the same left column as sibling chevrons
 * so text always lines up whether the sibling has a chevron or
 * not. Font size steps down one tier per nesting level. */
aside.sidebar nav a.navlink {
  display: block;
  padding: 4px 8px 4px calc(8px + var(--chevron-col));
  margin: 0;
  border-radius: 4px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;   /* depth-1 default (direct group child) */
  font-weight: 400;
  line-height: 1.35;
}
aside.sidebar nav a.navlink:hover { background: var(--accent-bg); }
aside.sidebar nav a.navlink.active {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

/* Nested (inside a subgroup) navlinks step down one tier. */
aside.sidebar nav a.navlink.nested { font-size: 13px; }
/* Nested subgroup headers step down to match. */
aside.sidebar nav .nav-subgroup .nav-subgroup > .nav-block-header .nav-block-label {
  font-size: 13px;
}
aside.sidebar .meta {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}
aside.sidebar .meta a { color: var(--accent); }

main.content {
  padding: 32px 40px 80px;
  max-width: 920px;
  min-width: 0;
}

/* ── Narrow-screen drawer ────────────────────────────────────
 * Desktop layout (sidebar + content) collapses into a top bar
 * with a hamburger that toggles the sidebar as an overlay drawer.
 * Default: drawer hidden, content takes the full width. */

.topbar {
  display: none;  /* desktop hides it */
}

@media (max-width: 800px) {
  .layout {
    grid-template-columns: 1fr;
  }

  /* Top bar with brand + hamburger. Sticky so it's reachable from
   * anywhere in the page. */
  .topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 20;
  }
  .topbar .brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
  }
  .topbar button.nav-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    color: var(--fg);
    font: inherit;
    line-height: 1;
    cursor: pointer;
  }
  .topbar button.nav-toggle:hover { background: var(--accent-bg); }

  /* Drawer = the sidebar, slid off-screen when closed, slid in
   * over the content when open. */
  aside.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(280px, 80vw);
    max-height: none;
    border-right: 1px solid var(--border);
    border-bottom: none;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 30;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  }
  body[data-nav-open="true"] aside.sidebar {
    transform: translateX(0);
  }

  /* Backdrop. Click anywhere outside the drawer to close. */
  .nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 25;
  }
  body[data-nav-open="true"] .nav-backdrop {
    display: block;
  }

  main.content {
    padding: 20px 16px 60px;
  }
}

footer.page-footer {
  margin-top: 56px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

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

h1, h2, h3, h4 { color: var(--fg); line-height: 1.25; }
h1 { font-size: 30px; margin: 0 0 12px; }
h2 { font-size: 22px; margin: 36px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
h3 { font-size: 17px; margin: 28px 0 8px; }
h4 { font-size: 14px; margin: 20px 0 6px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
p { margin: 0 0 12px; }
.lead { font-size: 17px; color: var(--fg); margin: 0 0 24px; }
.muted { color: var(--muted); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

ul, ol { padding-left: 22px; margin: 0 0 12px; }
li { margin: 2px 0; }

blockquote {
  border-left: 3px solid var(--border);
  padding: 4px 14px;
  margin: 12px 0;
  color: var(--muted);
  background: var(--panel);
}

table {
  border-collapse: collapse;
  margin: 12px 0;
  display: block;
  overflow-x: auto;
  font-size: 14px;
}
th, td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
th { background: var(--panel); font-weight: 600; }

code {
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, "Liberation Mono", monospace;
  font-size: 0.93em;
  background: var(--code-bg);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
pre {
  background: var(--code-block-bg);
  color: var(--code-block-fg);
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 12px 0;
  font-size: 13px;
  line-height: 1.5;
}
pre code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 13px;
  color: inherit;
}

/* ── Pills (API tier tags) ───────────────────────────────── */

.pill {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 10px;
  color: #fff;
  vertical-align: middle;
  margin-left: 6px;
}
.pill.public { background: var(--pill-public); }
.pill.internal { background: var(--pill-internal); }
.pill.deprecated { background: var(--pill-deprecated); }
.pill.experimental { background: var(--warn); }

/* ── Verb cards (CLI reference, API reference) ───────────── */

.entry {
  margin: 22px 0 28px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.entry:first-of-type { border-top: 0; padding-top: 0; }
.entry .name {
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
}
.entry .sig {
  font-family: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  color: var(--muted);
  background: var(--code-bg);
  padding: 8px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre;
  margin: 8px 0;
}
.entry .desc { margin: 8px 0; }
.entry .meta-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

/* ── Tag/badge for matrix-style tables ───────────────────── */

.yes { color: var(--ok); font-weight: 700; }
.no { color: var(--muted); }

/* ── Hero panels on landing page ─────────────────────────── */

.hero {
  background: linear-gradient(135deg, var(--accent-bg), transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px 28px;
  margin: 0 0 28px;
}
.hero h1 { margin: 0 0 8px; }
.hero p { font-size: 16px; color: var(--muted); margin: 0; }
.hero .cta {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  font-weight: 600;
}
.hero .cta:hover { text-decoration: none; opacity: 0.92; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 20px 0;
}
.card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  background: var(--panel);
  text-decoration: none;
  color: var(--fg);
  display: block;
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { margin: 0 0 4px; font-size: 15px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }
