/* docs.css: layout + components for the /docs page.
   Builds on examples.css (tokens, body base, .code/pre/.c-* syntax, .tabwrap)
   and header.css (shared top nav). The goal here is a plain, legible reference
   page (content first, low chrome) rather than a marketing layout. */

/* ---- docs shell: sidebar + main ----
   Share the 920px width of the header's .wrap (and the hero/examples) so the
   page content lines up with the shared header on every page: the brand sits
   directly above the sidebar and the nav links above the main panel's right
   edge. A tighter gap and sidebar reclaim width for the main column at this
   narrower measure. */
.docs {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}
/* the core docs page is an overview with no sidebar: a single centered
   reading column so the header and cards share one width and one center,
   instead of hugging the left where the sidebar used to be. */
.docs.docs-overview {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  max-width: 760px;
}
.docs-overview .doc-section,
.docs-overview .doc-cards { max-width: none; }

/* sidebar sits below the 64px header and stays put while the panel scrolls */
.docs-side {
  position: sticky;
  top: 24px;
  align-self: start;
  padding: 44px 0 48px;
}
.docs-side .side-group + .side-group { margin-top: 26px; }
/* group titles label a category. On the group pages they are links to the
   page itself (a.side-title); on a single self-navigating page (the GitHub
   integration) they are plain labels. Every group stays expanded: navigation
   is by page, and a scrollspy tracks the section of the current page in view. */
.docs-side .side-title {
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--faint);
  margin: 0 0 10px;
  padding: 0 6px 0 14px;
  background: none;
  border: 0;
  font-family: inherit;
  text-align: left;
}
.docs-side a.side-title { cursor: pointer; text-decoration: none; }
.docs-side a.side-title:hover { color: var(--muted); }
.docs-side .side-title.is-current { color: var(--ink); }
.docs-side .side-link {
  display: block;
  font-size: 14px;
  color: var(--muted);
  padding: 5px 14px;
  border-left: 2px solid var(--line);
  transition: color .15s, border-color .15s;
}
.docs-side .side-link:hover { color: var(--ink); border-left-color: var(--line-2); }
.docs-side .side-link.is-active {
  color: var(--ink);
  border-left-color: var(--accent);
  font-weight: 600;
}
/* Section pages: every family stays listed as a title-link for navigation,
   but only the current family expands to show its items. The others collapse
   to title-only. Desktop only (the mobile menu lists every group in full). The
   single-page GitHub sidebar uses <p> titles, so :has(a.side-title) leaves it
   fully expanded. The current group is marked .is-open in its page markup (and
   by docs.js as a fallback). */
@media (min-width: 861px) {
  .docs-side .side-group:has(a.side-title):not(.is-open) .side-links { display: none; }
}

/* main panel: a comfortable reading measure for prose, code can run wider */
.docs-main { min-width: 0; padding: 44px 0 96px; }

/* inline prose links: the shared reset (examples.css) strips color and
   underline from every <a>, which leaves links in running text looking like
   plain copy. Restore the accent + underline for links inside prose paragraphs
   so they read as links. Component links (sidebar, section pills, pager,
   footer) live outside <p> or carry their own class, so they keep the reset. */
.docs-main p a[href] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
.docs-main p a[href]:hover {
  color: var(--accent-2);
  text-decoration-thickness: 2px;
}
.docs-head { padding-bottom: 28px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.docs-head .sec-tag {
  color: var(--faint); font-size: 13px; font-weight: 600; letter-spacing: 0;
  text-transform: none; margin: 0 0 10px;
}
.docs-head h1 {
  font-size: clamp(26px, 3.4vw, 32px); line-height: 1.15;
  letter-spacing: -0.015em; margin: 0 0 16px; font-weight: 600;
}

/* the intro lede, with the four named pieces emphasized */
.sec-lede { font-size: 16.5px; color: var(--muted); max-width: 680px; margin: 0; line-height: 1.7; }
.sec-lede b { color: var(--ink); font-weight: 600; }
.sec-lede code { font-family: var(--mono); color: var(--accent-2); background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 14px; }
.sec-lede .term { color: var(--ink); font-weight: 600; }

/* ---- hub cards (the /docs landing page) ----
   The docs index is a grid of cards, one per group page: a title link, a
   one-line summary, and quick links to the sections inside. Plain token
   surfaces with a hairline, no window chrome. */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 8px 0 4px;
  max-width: 720px;
}
.doc-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  padding: 18px 18px 16px;
  transition: border-color .15s, box-shadow .15s;
}
.doc-card:hover { border-color: var(--line-2); box-shadow: var(--elev); }
.doc-card .dc-head { display: block; }
/* Make the whole card tappable: the title link stretches to cover the card,
   while the deep links below sit above it and stay individually clickable. */
.doc-card .dc-head::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}
.doc-card .dc-tag {
  font-size: 12px; font-weight: 700; color: var(--faint); letter-spacing: 0.02em;
}
.doc-card h3 {
  font-size: 17px; font-weight: 600; margin: 4px 0 7px;
  letter-spacing: -0.01em; color: var(--ink); line-height: 1.25;
}
.doc-card:hover h3 { color: var(--accent); }
.doc-card p { font-size: 13.5px; color: var(--muted); margin: 0 0 12px; line-height: 1.6; }
.doc-card .dc-links { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: auto; }
.doc-card .dc-links a {
  font-family: var(--mono); font-size: 12px; color: var(--accent-2);
  background: var(--code-bg); padding: 2px 8px; border-radius: var(--r-pill);
}
.doc-card .dc-links a:hover { color: var(--ink); }

/* ---- prev / next pager (foot of each group page) ---- */
.docs-pager {
  display: flex;
  gap: 14px;
  margin-top: 52px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  max-width: 720px;
}
.docs-pager-link, .docs-pager-spacer { flex: 1 1 0; min-width: 0; }
.docs-pager-link {
  display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px 16px; transition: border-color .15s;
}
.docs-pager-link:hover { border-color: var(--line-2); }
.docs-pager-link.is-next { text-align: right; align-items: flex-end; }
.docs-pager-dir { font-size: 12px; color: var(--faint); }
.docs-pager-title { font-size: 15px; font-weight: 600; color: var(--ink); }

@media (max-width: 640px) {
  .doc-cards { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .docs-pager { flex-direction: column; }
  .docs-pager-link.is-next { text-align: left; align-items: flex-start; }
  .docs-pager-spacer { display: none; }
}

/* ---- doc sections (one per sidebar entry) ---- */
.doc-section { padding-top: 44px; scroll-margin-top: 24px; max-width: 720px; }
.doc-section + .doc-section { margin-top: 12px; border-top: 1px solid var(--line); }
/* the loud per-section eyebrow is gone. The heading carries the section,
   and the sidebar already names it. kept in markup as an anchor label only. */
.abs-eyebrow { display: none; }
.abs-h { font-size: 23px; letter-spacing: -0.015em; margin: 0 0 10px; font-weight: 600; line-height: 1.2; }
.abs-lede { font-size: 15.5px; color: var(--muted); margin: 0 0 24px; line-height: 1.7; max-width: 680px; }
.abs-lede b { color: var(--ink); font-weight: 600; }
.abs-lede .term { color: var(--ink); font-weight: 600; }
.abs-lede code { font-family: var(--mono); color: var(--accent-2); background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 13px; }

/* softwrap variant for the wider Python / YAML samples */
.code.softwrap pre code { white-space: pre-wrap; overflow-wrap: anywhere; }
.c-com { font-style: italic; }
.c-mut { color: var(--muted); }

/* ---- screenshots (the dashboard section) ----
   A captured view of the running dashboard, in a framed figure. Screenshots can
   run wider than the prose measure, so they break out of the 720px section and
   scroll horizontally on narrow screens rather than squashing. */
.shot {
  margin: 0 0 8px;
  max-width: 860px;
}
.shot + .shot { margin-top: 28px; }
.shot img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--elev);
}
.shot figcaption {
  margin-top: 10px;
  font-size: 13px;
  color: var(--faint);
  line-height: 1.55;
}
.shot figcaption code {
  font-family: var(--mono); color: var(--accent-2);
  background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 12px;
}
/* the sensors and registry views stack so each gets the full reading width */
.shot-row { display: grid; grid-template-columns: 1fr; gap: 28px; max-width: 860px; }
.shot-row .shot { margin-bottom: 0; }

/* ---- architecture diagram ----
   A vertical flow of tiers: the running system top to bottom, sources in,
   targets out. Plain cards (token surfaces + hairlines), no window chrome.
   Stacks cleanly on mobile because each tier is its own full-width row. */
.arch { margin: 8px 0 4px; max-width: 720px; }

/* one tier: a labeled card. The engine tier groups its inner pieces in a row. */
.arch-tier {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  padding: 14px 16px;
}
.arch-tier.is-ext { background: var(--code-bg); border-style: dashed; }
.arch-tier.is-engine { border-color: var(--line-2); box-shadow: var(--elev); }
.arch-tier.is-sandbox { border-color: var(--accent-sb); }

.arch-label {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--ink); margin: 0 0 2px; letter-spacing: -0.01em;
}
.arch-label .arch-sub { color: var(--faint); font-weight: 400; }
.arch-note { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.55; }
.arch-note code { font-family: var(--mono); color: var(--accent-2); background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 11.5px; }

/* the row of inner pieces inside the engine tier */
.arch-pieces { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin-top: 10px; }
.arch-piece {
  flex: 1 1 0; min-width: 116px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); padding: 10px 12px;
}
.arch-piece .pn { font-family: var(--mono); font-size: 12px; font-weight: 600; color: var(--ink); }
.arch-piece .pd { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.arch-piece.is-swappable { border-color: var(--accent); }
.arch-piece.is-swappable .pn { color: var(--accent); }

/* external source/target chips */
.arch-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.arch-chips .lui-chip, .arch-chip {
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line); border-radius: var(--r-pill);
  padding: 2px 10px; background: var(--bg);
}

/* the connector between two tiers: a down arrow with a caption */
.arch-flow {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 0 7px 4px;
}
.arch-flow svg { width: 14px; height: 16px; color: var(--faint); flex: none; }
.arch-flow span { font-size: 12px; color: var(--faint); line-height: 1.45; }
.arch-flow code { font-family: var(--mono); color: var(--accent-2); background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 11px; }

@media (max-width: 560px) {
  .arch-pieces { flex-direction: column; }
  .arch-piece { min-width: 0; }
}

/* ---- event catalog (the integrations page) ----
   Reference material inside the GitHub section: one h4 entry per event, each
   an event-name heading, a one-line trigger description, a payload sample,
   and a keys list. .ev-index is the jump list at the top of the catalog. The
   entry headings sit one level below the section's 16px h3 subheads. */
.ev-index { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0 0 10px; }
.ev-index a {
  font-family: var(--mono); font-size: 12px; color: var(--accent-2);
  background: var(--code-bg); padding: 3px 10px; border-radius: var(--r-pill);
}
.ev-index a:hover { color: var(--ink); }
.ev-h { font-size: 15px; font-weight: 600; margin: 34px 0 6px; scroll-margin-top: 24px; }
.ev-h code {
  font-family: var(--mono); color: var(--accent-2); background: var(--code-bg);
  padding: 2px 7px; border-radius: 5px; font-size: 13.5px;
}

/* ---- key reference (header fields, sensor args) ----
   a plain definition list instead of a grid of bordered cards: term on the
   left, plain-language description on the right, separated by hairlines. */
.keys {
  margin-top: 26px;
  border-top: 1px solid var(--line);
}
.keydef {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 8px 24px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
/* the last keydef's hairline collides with the next section's border-top,
   stacking two rules above the following heading, so drop it. */
.keydef:last-child { border-bottom: none; }
.keydef .k {
  font-family: var(--mono); font-size: 13.5px; font-weight: 500;
  color: var(--accent-2); padding-top: 1px;
}
.keydef p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.65; }
.keydef code { font-family: var(--mono); color: var(--accent-2); background: var(--code-bg); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

/* ---- mobile section selector ----
   On narrow screens the full sidebar becomes a wall of pills that pushes the
   content below the fold and scrolls away once you start reading. Instead, JS
   builds a sticky "current section" bar (.docs-mobnav, from the .docs-side
   links) that opens the full grouped list on tap. Hidden on desktop; the bar
   only appears once JS has added .has-mobnav, so the pill nav below stays as a
   no-JS fallback. */
.docs-mobnav { display: none; }
.docs-mobnav-menu[hidden] { display: none; }

/* ---- mobile ---- */
@media (max-width: 860px) {
  .docs { grid-template-columns: 1fr; gap: 0; }

  /* no-JS fallback: the inline pill nav */
  .docs-side {
    position: static; padding: 24px 0 0;
    border-bottom: 1px solid var(--line);
  }
  .docs-side .side-group { display: inline-block; margin-right: 18px; }
  .docs-side .side-group + .side-group { margin-top: 0; }
  .docs-side .side-title { padding-left: 0; }
  .docs-side .side-title::after { display: none; }
  /* the collapse behavior is desktop-only; the mobile menu shows every group */
  .docs-side .side-group.is-collapsed .side-links,
  .docs-mobnav-menu .side-links { max-height: none; opacity: 1; pointer-events: auto; }
  .docs-side .side-links { display: flex; flex-wrap: wrap; gap: 4px 6px; padding-bottom: 16px; }
  .docs-side .side-link { border-left: 0; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
  .docs-side .side-link.is-active { border-color: var(--accent); }
  .docs-main { padding: 24px 0 64px; }

  /* with JS, the sticky selector replaces the pill nav */
  .has-mobnav .docs-side { display: none; }
  .docs-mobnav {
    display: block;
    position: sticky; top: 0; z-index: 30;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
  .docs-mobnav-toggle {
    display: flex; align-items: center; gap: 10px;
    width: 100%; box-sizing: border-box;
    padding: 13px 24px;
    background: none; border: 0; cursor: pointer;
    font: inherit; color: var(--ink); text-align: left;
  }
  .docs-mobnav-ico { width: 16px; height: 16px; color: var(--faint); flex: none; }
  .docs-mobnav-label { font-size: 15px; font-weight: 600; margin-right: auto; }
  .docs-mobnav-chev {
    width: 16px; height: 16px; color: var(--faint); flex: none;
    transition: transform .18s ease;
  }
  .docs-mobnav.is-open .docs-mobnav-chev { transform: rotate(180deg); }

  .docs-mobnav-menu {
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--elev-2);
    max-height: 70vh; overflow-y: auto;
    padding: 4px 24px 16px;
  }
  .docs-mobnav-menu .side-group { padding-top: 14px; }
  .docs-mobnav-menu .side-title {
    font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
    text-transform: uppercase; color: var(--faint); margin: 0 0 4px;
    background: none; border: 0; padding: 0; width: 100%;
    text-align: left; cursor: default;
  }
  .docs-mobnav-menu .side-links { display: flex; flex-direction: column; }
  .docs-mobnav-menu .side-link {
    display: block; font-size: 15px; color: var(--muted);
    text-decoration: none; padding: 9px 12px; border-radius: 8px;
    border-left: 2px solid transparent;
  }
  .docs-mobnav-menu .side-link:hover { color: var(--ink); }
  .docs-mobnav-menu .side-link.is-active {
    color: var(--ink); font-weight: 600;
    background: var(--code-bg); border-left-color: var(--accent);
  }

  /* clear the sticky bar when jumping to an anchored section */
  .doc-section, .docs-head, .ev-h { scroll-margin-top: 60px; }
}

@media (max-width: 560px) {
  .keydef { grid-template-columns: 1fr; gap: 6px; }
}

@media (max-width: 480px) {
  .docs { padding: 0 16px; }
  pre { padding: 14px 15px; font-size: 12px; }
  .code .bar { padding: 8px 12px; }
  .docs-mobnav-toggle { padding-left: 16px; padding-right: 16px; }
  .docs-mobnav-menu { padding-left: 16px; padding-right: 16px; }
}

/* --- page actions: split "Copy page" button + formats dropdown ----------- */
.page-actions { position: relative; display: inline-flex; margin-top: 18px; }

/* the split button: a copy action joined to a chevron that opens the menu */
.pa-copy, .pa-more {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line-2);
  cursor: pointer;
  transition: background .12s, border-color .12s;
}
.pa-copy { padding: 0 12px; border-radius: var(--r-md) 0 0 var(--r-md); }
.pa-more { padding: 0 7px; border-radius: 0 var(--r-md) var(--r-md) 0; border-left: none; }
.pa-copy:hover, .pa-more:hover { background: var(--code-bg); }
.pa-copy:focus-visible, .pa-more:focus-visible { outline: 2px solid var(--accent-sb); outline-offset: 1px; }
.page-actions.is-open .pa-more { background: var(--code-bg); }
.page-actions.is-copied .pa-copy { color: var(--ok); }

.pa-ic { width: 15px; height: 15px; flex-shrink: 0; }
.pa-copy .pa-ic, .pa-item .pa-ic { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.pa-chev { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.page-actions.is-open .pa-chev { transform: rotate(180deg); }

/* the dropdown */
.pa-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 40;
  min-width: 320px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--elev-2);
}
.pa-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  background: none;
  border-radius: var(--r-sm);
  text-align: left;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--sans);
}
.pa-item + .pa-item { margin-top: 1px; }
.pa-item:hover, .pa-item:focus-visible { background: var(--code-bg); outline: none; }
.pa-item .pa-ic { width: 16px; height: 16px; margin-top: 1px; color: var(--muted); }
.pa-text { display: flex; flex-direction: column; gap: 2px; }
.pa-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.pa-sub { font-size: 12px; color: var(--faint); }
.pa-ext { color: var(--faint); font-weight: 400; }

@media (max-width: 640px) {
  .pa-menu { min-width: 0; width: min(88vw, 340px); }
}
