/* UCIP documentation stylesheet — minimal navy + neutral palette matching
   the product's design language (Plus Jakarta Sans + IBM Plex Mono).

   Used by every .html doc under /docs (and any sub-path). Single file so
   restyling all docs is one edit. */

:root {
  /* YouNet Group ("The Measure Group") palette — product source of truth is
     packages/ui/src/styles.css. Navy #00084f, sky #1188ea, cyan #00aeef,
     indigo #3137aa, Plus Jakarta Sans. Light theme is the primary look:
     bright, airy surfaces with sky-blue accents. */

  /* Surfaces */
  --doc-bg: #f2f5fa;
  --doc-surface: #ffffff;
  --doc-surface-strong: #eef3fb;
  --doc-border: #e3e8f2;
  --doc-border-strong: #cfd6e6;

  /* Text */
  --doc-text: #0a1122;
  --doc-text-muted: #4a5578;
  --doc-text-dim: #6b7599;

  /* Brand — YouNet sky blue is the interactive accent; navy is deep emphasis;
     cyan is the secondary highlight. */
  --doc-accent: #1188ea;
  --doc-accent-strong: #00084f;
  --doc-accent-soft: #e6f1fc;
  --doc-accent-2: #00aeef;
  --doc-link: #0a5bbf;

  /* Code — YouNet navy field with sky/cyan syntax accents. */
  --doc-code-bg: #00084f;
  --doc-code-fg: #dbe4f5;
  --doc-code-string: #74f3ff;
  --doc-code-comment: #8183a6;
  --doc-code-keyword: #4aa3f0;

  /* Semantic (readable on light) */
  --doc-success: #12805a;
  --doc-warning: #9a5b00;
  --doc-danger: #c0322f;

  --doc-radius: 8px;
  --doc-radius-lg: 14px;
  --doc-shadow: 0 1px 2px rgba(0, 8, 79, 0.04), 0 8px 24px rgba(0, 8, 79, 0.06);

  /* Persistent left navigation (site shell) */
  --doc-sidebar-w: 288px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --doc-bg: #02062b;
    --doc-surface: #0a1140;
    --doc-surface-strong: #111a52;
    --doc-border: #1e2a63;
    --doc-border-strong: #2c3a7a;
    --doc-text: #e4e9f7;
    --doc-text-muted: #9aa1c8;
    --doc-text-dim: #737aa6;
    --doc-accent: #4aa3f0;
    --doc-accent-strong: #9db4ff;
    --doc-accent-soft: #10205a;
    --doc-accent-2: #35c6f4;
    --doc-link: #7cc0ff;
    --doc-code-bg: #050a30;
    --doc-code-fg: #cdd6ee;
    --doc-shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--doc-bg);
  color: var(--doc-text);
  font-family:
    'Plus Jakarta Sans',
    -apple-system,
    BlinkMacSystemFont,
    'Segoe UI',
    Roboto,
    'Helvetica Neue',
    Arial,
    sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.doc-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 32px 80px;
}

/* The reading column stays a comfortable measure even inside the wide shell. */
.doc-content {
  max-width: 860px;
  min-width: 0;
}

/* ─── Header ─── */

.doc-header {
  border-bottom: 1px solid var(--doc-border);
  padding-bottom: 18px;
  margin-bottom: 28px;
}

.doc-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--doc-accent);
  margin-bottom: 8px;
}

.doc-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 6px;
  color: var(--doc-accent-strong);
}

.doc-subtitle {
  font-size: 14px;
  color: var(--doc-text-muted);
  margin: 0;
}

.doc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--doc-text-dim);
}

.doc-meta a {
  color: var(--doc-link);
  text-decoration: none;
}

.doc-meta a:hover {
  text-decoration: underline;
}

/* ─── Content typography ─── */

.doc-content h1,
.doc-content h2,
.doc-content h3,
.doc-content h4,
.doc-content h5 {
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--doc-accent-strong);
}

.doc-content h1 {
  font-size: 26px;
  margin: 32px 0 12px;
}

.doc-content h2 {
  font-size: 20px;
  margin: 0;
}

.doc-content h3 {
  font-size: 16px;
  margin: 22px 0 8px;
  color: var(--doc-accent);
}

.doc-content h4 {
  font-size: 14px;
  margin: 18px 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--doc-text-muted);
}

.doc-content p {
  margin: 10px 0;
}

.doc-content a {
  color: var(--doc-link);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in oklab, var(--doc-link), transparent 70%);
}

.doc-content a:hover {
  border-bottom-color: var(--doc-link);
}

.doc-content strong {
  color: var(--doc-accent-strong);
  font-weight: 600;
}

.doc-content em {
  font-style: italic;
}

/* ─── Collapsible sections ─── */

/* ─── Sections: a continuous page, the way reference docs read ─── */

.doc-section {
  margin: 0 0 12px;
  scroll-margin-top: 24px;
}

.doc-h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--doc-accent-strong);
  margin: 40px 0 14px;
  padding-top: 22px;
  border-top: 1px solid var(--doc-border);
}

.doc-section:first-of-type .doc-h2 {
  border-top: none;
  padding-top: 0;
  margin-top: 20px;
}

/* Hover anchor on every heading (the standard reference-docs affordance). */
.doc-anchor {
  margin-left: 8px;
  color: var(--doc-accent);
  text-decoration: none;
  opacity: 0;
  font-weight: 500;
  transition: opacity 120ms ease;
}

.doc-h2:hover .doc-anchor,
.doc-anchor:focus {
  opacity: 1;
}

/* ─── Lists ─── */

.doc-content ul,
.doc-content ol {
  padding-left: 22px;
  margin: 10px 0;
}

.doc-content li {
  margin: 4px 0;
}

.doc-content li > ul,
.doc-content li > ol {
  margin: 4px 0;
}

/* ─── Code ─── */

.doc-content code {
  font-family: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--doc-surface-strong);
  color: var(--doc-accent-strong);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--doc-border);
}

.doc-content pre {
  background: var(--doc-code-bg);
  color: var(--doc-code-fg);
  padding: 16px 18px;
  border-radius: var(--doc-radius-lg);
  overflow-x: auto;
  font-family: 'IBM Plex Mono', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  margin: 14px 0;
}

.doc-content pre code {
  background: transparent;
  color: inherit;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Mermaid diagrams render an SVG into the <pre class="mermaid"> element
   itself — the dark code-block background/padding above would box the
   diagram in a mismatched panel, so strip them for this one case. */
/* Diagrams render as framed figures: centered on a white card (the mermaid
   theme colors are tuned for a light ground, so the card stays white in dark
   mode too). A wider-than-card diagram scrolls INSIDE the card.
   justify-content stays flex-start: centering an overflowing flex child clips
   its left edge beyond reach (the classic flex-center overflow bug — this
   exact bug shipped as a diagram spilling off the landing page). Centering is
   done with auto margins on the svg, which collapse to 0 on overflow. */
.doc-content pre.mermaid {
  display: flex;
  justify-content: flex-start;
  background: #ffffff;
  border: 1px solid var(--doc-border);
  border-radius: var(--doc-radius-lg);
  padding: 22px 14px;
  margin: 22px 0;
  overflow-x: auto;
  box-shadow: var(--doc-shadow, 0 1px 2px rgba(0, 8, 79, 0.05));
}

/* Natural size by default (useMaxWidth: false) so label text never shrinks
   below its 15px base. The mermaid runtime adds .fit to a diagram only
   slightly wider than its card, letting it scale down to fit instead of
   scrolling; genuinely wide diagrams keep natural size and scroll. */
.doc-content pre.mermaid svg {
  flex-shrink: 0;
  margin-inline: auto;
}

.doc-content pre.mermaid svg.fit {
  max-width: 100%;
  height: auto;
}

/* ─── Tables ─── */
/*
 * Rationale: original implementation used `display:block; overflow-x:auto;
 * white-space:nowrap` which forced every cell to a single line. Wide tables
 * (architecture review, permission matrix) became horizontal-scroll
 * nightmares — operator opens the doc, sees clipped text, has to scroll
 * right with the trackpad. Fixed by removing the nowrap + going back to
 * native `display:table` with word-wrapping cells. Horizontal scroll is
 * still possible via the outer `.doc-table-wrap` ONLY when the natural
 * layout overflows the container — which is rare once cells wrap.
 */

.doc-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 14px 0;
  font-size: 14px;
  background: var(--doc-surface);
  border-radius: var(--doc-radius);
  border: 1px solid var(--doc-border);
  table-layout: auto;
}

.doc-content th,
.doc-content td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--doc-border);
  vertical-align: top;
  /* Long single tokens (URLs, paths, code identifiers) wrap instead of
   * blowing out the column. `overflow-wrap: anywhere` handles long
   * unbroken strings without breaking ordinary sentence flow. */
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
}

.doc-content th {
  background: var(--doc-surface-strong);
  color: var(--doc-accent-strong);
  font-weight: 600;
  font-size: 13px;
}

/* First column = the row's LABEL (stream name, permission, endpoint group).
 * `overflow-wrap: anywhere` above is right for long URLs in the body cells but
 * shredded short labels mid-word ("orders" → "order/s") because the browser
 * gives column 1 the least width. Keep whole words intact here and let the
 * column claim the width it needs; body cells keep the aggressive wrapping. */
.doc-content td:first-child,
.doc-content th:first-child {
  overflow-wrap: normal;
  word-break: keep-all;
  hyphens: none;
}

.doc-content tr:last-child td {
  border-bottom: none;
}

.doc-content tr:hover td {
  background: color-mix(in oklab, var(--doc-accent-soft), transparent 70%);
}

/* ─── Blockquotes ─── */

.doc-content blockquote {
  border-left: 3px solid var(--doc-accent);
  background: var(--doc-surface-strong);
  padding: 10px 16px;
  margin: 14px 0;
  border-radius: 0 var(--doc-radius) var(--doc-radius) 0;
  color: var(--doc-text-muted);
}

.doc-content blockquote p {
  margin: 6px 0;
}

/* ─── HR ─── */

.doc-content hr {
  border: 0;
  border-top: 1px solid var(--doc-border);
  margin: 28px 0;
}

/* ─── Images ─── */

.doc-content img {
  max-width: 100%;
  border-radius: var(--doc-radius-lg);
  border: 1px solid var(--doc-border);
  margin: 12px 0;
}

/* ─── Footer ─── */

.doc-footer {
  margin-top: 60px;
  padding-top: 18px;
  border-top: 1px solid var(--doc-border);
  font-size: 12px;
  color: var(--doc-text-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
}

.doc-footer a {
  color: var(--doc-link);
  text-decoration: none;
}

.doc-footer a:hover {
  text-decoration: underline;
}

/* ─── "On this page" rail (right side, sticky, with scrollspy) ─── */

html {
  scroll-behavior: smooth;
}

.doc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

@media (min-width: 1240px) {
  .doc-layout {
    grid-template-columns: minmax(0, 1fr) 200px;
  }
}

.doc-toc-rail {
  display: none;
}

@media (min-width: 1240px) {
  .doc-toc-rail {
    display: block;
    /*
     * STRETCH, or the rail cannot stick.
     *
     * `.doc-layout` sets `align-items: start`, which shrinks every grid item to
     * its content height. A `position: sticky` child can only travel inside its
     * containing block, so a rail 220px tall scrolled away after 220px and the
     * reader lost the in-page menu for the rest of a long document — no way to
     * jump to another section, no indication of where they were. Stretching the
     * rail to the row height gives the sticky element the whole column to
     * travel in.
     */
    align-self: stretch;
  }
}

.doc-toc-sticky {
  position: sticky;
  top: 28px;
  /* A page with many sections has a rail taller than the window; it scrolls on
     its own rather than pushing entries out of reach. */
  max-height: calc(100vh - 56px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.doc-toc-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--doc-text-dim);
  margin-bottom: 10px;
}

.doc-toc {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--doc-border);
}

.doc-toc-link {
  font-size: 13px;
  line-height: 1.35;
  color: var(--doc-text-muted);
  text-decoration: none;
  padding: 5px 0 5px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  transition:
    color 120ms ease,
    border-color 120ms ease;
}

.doc-toc-link:hover {
  color: var(--doc-accent);
}

/*
 * The collapsed in-page menu, for a window too narrow for the rail. Same links,
 * same active marker; it simply lives above the article instead of beside it.
 */
.doc-toc-inline {
  margin: 0 0 28px;
  border: 1px solid var(--doc-border);
  border-radius: 10px;
  padding: 10px 14px;
}

.doc-toc-inline > summary {
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--doc-text-dim);
  list-style: none;
}

.doc-toc-inline > summary::-webkit-details-marker {
  display: none;
}

.doc-toc-inline > summary::after {
  content: ' ▾';
}

.doc-toc-inline[open] > summary::after {
  content: ' ▴';
}

.doc-toc-inline > summary:focus-visible {
  outline: 2px solid var(--doc-accent);
  outline-offset: 3px;
}

.doc-toc-inline .doc-toc {
  margin-top: 10px;
}

/*
 * The inline copy lives INSIDE `.doc-content`, whose link rule underlines every
 * anchor. Applied to a full-width column of TOC entries that reads as a ruled
 * table, not a menu — so the rail's own left-marker treatment is restored here.
 */
.doc-toc-inline .doc-toc-link {
  border-bottom: none;
}

.doc-toc-inline .doc-toc-link:hover {
  border-bottom-color: transparent;
}

@media (min-width: 1240px) {
  /* The rail is on screen — a second copy above the article would be noise. */
  .doc-toc-inline {
    display: none;
  }
}

.doc-toc-link.active {
  color: var(--doc-accent);
  border-left-color: var(--doc-accent);
  font-weight: 600;
}

/* ─── Site shell: persistent left navigation ─── */
/*
 * A single fixed sidebar renders on EVERY page (built from docs/nav.manifest.ts
 * by scripts/docs/site-shell.ts). It is `position: fixed` so it needs no wrapper
 * around the page content: on desktop the body is simply padded left by the
 * sidebar width; below the mobile breakpoint the sidebar slides off-canvas and a
 * toggle button brings it back.
 */

body {
  padding-left: var(--doc-sidebar-w);
}

.doc-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--doc-sidebar-w);
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--doc-surface);
  border-right: 1px solid var(--doc-border);
  padding: 18px 14px 40px;
  z-index: 40;
}

.doc-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  padding: 6px 8px 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--doc-border);
}

.doc-nav-brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  object-fit: contain;
}

.doc-nav-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.doc-nav-brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--doc-accent-strong);
  letter-spacing: -0.01em;
}

.doc-nav-brand-sub {
  font-size: 11px;
  font-weight: 500;
  color: var(--doc-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.doc-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Section groups + nested groups — native <details>, scoped so the content-body
   <details> styles never leak in here. */
.doc-nav details {
  margin: 0;
  border: none;
  background: none;
}

.doc-nav summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--doc-radius);
}

.doc-nav summary::-webkit-details-marker {
  display: none;
}

.doc-nav summary::before {
  content: '';
  flex: 0 0 auto;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--doc-text-dim);
  border-bottom: 1.5px solid var(--doc-text-dim);
  transform: rotate(-45deg);
  transition: transform 140ms ease;
}

.doc-nav details[open] > summary::before {
  transform: rotate(45deg);
}

.doc-nav-section > summary {
  padding: 8px 8px;
  margin-top: 6px;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--doc-text-muted);
}

.nav-section-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 4px;
}

.nav-group > summary {
  padding: 6px 8px;
}

.nav-group-label,
.nav-group > summary .nav-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--doc-text);
}

.nav-group-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 14px;
  border-left: 1px solid var(--doc-border);
  margin-left: 9px;
}

.nav-link {
  display: block;
  padding: 6px 10px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--doc-text-muted);
  text-decoration: none;
  border-radius: var(--doc-radius);
  border: none;
}

.nav-link:hover {
  background: var(--doc-surface-strong);
  color: var(--doc-accent);
}

.nav-link.active {
  background: var(--doc-accent-soft);
  color: var(--doc-accent-strong);
  font-weight: 600;
}

.nav-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--doc-accent);
  background: color-mix(in oklab, var(--doc-accent-soft), transparent 30%);
  border: 1px solid var(--doc-border);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
}

/* Audience hint from docs/nav.manifest.ts — quieter than .nav-badge so it
   reads as a filter label, not a status. */
.nav-audience {
  display: inline-block;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--doc-muted);
  border: 1px solid var(--doc-border);
  border-radius: 999px;
  padding: 0 5px;
  margin-left: 4px;
  vertical-align: middle;
  white-space: nowrap;
}

/* Mobile menu toggle + overlay — hidden on desktop. */
.doc-nav-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 60;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--doc-accent-strong);
  background: var(--doc-surface);
  border: 1px solid var(--doc-border-strong);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

.doc-nav-overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.45);
}

/* ─── Mobile ─── */

@media (max-width: 720px) {
  body {
    padding-left: 0;
  }
  .doc-shell {
    padding: 60px 16px 60px;
  }
  .doc-title {
    font-size: 24px;
  }
  .doc-content details > .details-body {
    padding: 14px 16px 18px;
  }

  .doc-nav-toggle {
    display: inline-block;
  }
  .doc-sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: 0 0 24px rgba(15, 23, 42, 0.25);
  }
  body.nav-open .doc-sidebar {
    transform: translateX(0);
  }
  /* Overlay is toggled via [hidden] in the shell script; keep it out of flow
     until the nav opens. */
  .doc-nav-overlay[hidden] {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .doc-sidebar,
  .doc-nav summary::before {
    transition: none;
  }
}

/* ─── Landing page: role cards + document map ─── */

.landing-lede {
  font-size: 17px;
  line-height: 1.6;
  color: var(--doc-text);
  max-width: 62ch;
}

.role-grid,
.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin: 18px 0 8px;
}

.role-card,
.map-card {
  border: 1px solid var(--doc-border);
  background: var(--doc-surface);
  border-radius: var(--doc-radius-lg);
  padding: 16px 18px;
}

.role-card h3,
.map-card h3 {
  margin: 0 0 4px;
  font-size: 15px;
  color: var(--doc-accent);
}

.role-card p {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--doc-text-muted);
}

.role-card ul,
.map-card ul {
  margin: 0;
  padding-left: 18px;
}

.role-card li,
.map-card li {
  font-size: 13px;
  margin: 3px 0;
}

.map-card a {
  font-weight: 500;
}
