/* Muster docs — re-skinned to the reference docs design system (Fumadocs-
 * style: light-first with a persisted dark toggle, flat surfaces, hairline
 * borders, 268px rails, right-hand "On this page" TOC, 16/1.75 prose) in
 * Muster's palette: one orange accent, no gradients, no wash. Shared by
 * every page under /docs/; docs.js injects the TOC, theme toggle and code
 * copy buttons so the page markup stays plain. No build step. */

:root {
  /* light (default, like the reference site) */
  --page: #ffffff;
  --surface: #f7f8f8;
  --surface-soft: #fafbfb;
  --surface-raised: #f1f2f3;
  --ink: #0a0a0b;
  --body: #26262b;
  --muted: #5f6570;
  --muted-2: #8b909a;
  --line: #e5e7ea;
  --line-2: #d4d7dc;
  --accent: #f0460e;
  --accent-soft: #c93a0b;
  --accent-line: rgba(240, 70, 14, 0.35);
  --accent-wash: rgba(240, 70, 14, 0.07);
  --accent-wash-2: rgba(240, 70, 14, 0.14);
  --code-bg: #f6f7f8;
  --card-shadow: 0 1px 2px rgba(10, 10, 11, 0.04);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --radius-card: 12px;
}
html[data-theme="dark"] {
  --page: #070708;
  --surface: #131315;
  --surface-soft: #0d0d0f;
  --surface-raised: #1a1a1e;
  --ink: #f4f4f5;
  --body: #c9c9cf;
  --muted: #9a9aa4;
  --muted-2: #77777f;
  --line: #232327;
  --line-2: #303036;
  --accent: #ff6a33;
  --accent-soft: #ff8758;
  --accent-line: rgba(255, 106, 51, 0.4);
  --accent-wash: rgba(255, 106, 51, 0.1);
  --accent-wash-2: rgba(255, 106, 51, 0.18);
  --code-bg: #101013;
  --card-shadow: none;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--body);
  font: 400 16px/1.75 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s ease, color 0.2s ease;
}

a { color: inherit; text-decoration: none; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── top bar ─────────────────────────────────────────────────────────── */

.docs-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--page) 84%, transparent);
  backdrop-filter: blur(10px);
}

.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.015em;
}
.brand-lockup img { display: block; }

.docs-tag {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2.5px 9px;
}

.docs-header__spacer { flex: 1; }

.docs-header__links {
  display: flex;
  align-items: center;
  gap: 8px;
}
.docs-header__links > a:not(.button) {
  color: var(--muted);
  font-size: 13.5px;
  padding: 6px 8px;
  border-radius: 8px;
}
.docs-header__links > a:not(.button):hover { color: var(--ink); background: var(--surface); }

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.theme-toggle:hover { color: var(--ink); background: var(--surface); }

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  border: 1px solid var(--line-2);
  color: var(--ink);
  background: var(--surface);
  transition: filter 0.15s ease, transform 0.15s ease;
}
.button:hover { text-decoration: none; filter: brightness(1.05); background: var(--surface-raised); }
.button--primary { background: var(--accent); border-color: transparent; color: #fff; }
.button--primary:hover { filter: brightness(1.1); }
.button--small { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }

/* ── layout: sidebar · content · TOC ─────────────────────────────────── */

.docs-shell {
  position: relative;
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: 48px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}
@media (min-width: 1280px) {
  .docs-shell { grid-template-columns: 268px minmax(0, 1fr) 268px; }
}

.docs-sidebar {
  position: sticky;
  top: 68px;
  align-self: start;
  font-size: 14px;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  scrollbar-width: none;
  padding-right: 8px;
  mask-image: linear-gradient(to bottom, transparent, white 12px, white calc(100% - 12px), transparent);
}
.docs-sidebar::-webkit-scrollbar { display: none; }

.docs-sidebar__group { margin-bottom: 20px; }

.docs-sidebar__label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-2);
  margin: 0 0 6px;
}

.docs-sidebar__group a {
  display: block;
  padding: 7px 10px;
  margin-left: -10px;
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.45;
  transition: background 0.12s ease, color 0.12s ease;
}
.docs-sidebar__group a:hover { color: var(--ink); background: var(--surface); }
.docs-sidebar__group a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-wash);
  font-weight: 600;
}

/* No auto margins here: a grid item with margin-inline:auto resolves its
 * width against max-content, which overflows the track on narrow screens.
 * The shell's 1400px cap already centers the whole layout. */
.docs-content { min-width: 0; max-width: 900px; overflow-wrap: anywhere; }
.docs-content [id] { scroll-margin-top: 84px; }

/* right-hand TOC, built by docs.js from h2/h3 */
.docs-toc {
  position: sticky;
  top: 68px;
  align-self: start;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
  scrollbar-width: none;
  font-size: 13.5px;
  padding-top: 48px;
}
.docs-toc::-webkit-scrollbar { display: none; }
.docs-toc__title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-2);
  margin: 0 0 10px;
}
.docs-toc a {
  display: block;
  padding: 5px 0 5px 12px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  line-height: 1.4;
}
.docs-toc a.lv3 { padding-left: 26px; font-size: 12.5px; }
.docs-toc a:hover { color: var(--ink); }
.docs-toc a.active { color: var(--accent); border-left-color: var(--accent); }
@media (max-width: 1279px) { .docs-toc { display: none; } }

/* ── content typography ──────────────────────────────────────────────── */

.docs-content h1 {
  color: var(--ink);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin: 8px 0 10px;
}

.docs-content .lead {
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
  margin: 0 0 32px;
}

.docs-content h2 {
  color: var(--ink);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.33;
  margin: 48px 0 12px;
}

.docs-content h3 {
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 32px 0 8px;
}

.docs-content p { margin: 0 0 16px; }
.docs-content strong { color: var(--ink); font-weight: 600; }

/* reference-site link language: ink text, accent underline */
.docs-content p a, .docs-content li a, .docs-content td a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 0.2em;
}
.docs-content p a:hover, .docs-content li a:hover, .docs-content td a:hover { opacity: 0.8; }

.docs-content ul, .docs-content ol { margin: 0 0 16px; padding-left: 22px; }
.docs-content li { margin-bottom: 6px; }
.docs-content li::marker { color: var(--muted-2); }

code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 5px;
  color: var(--ink);
  white-space: normal;
}

pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  overflow-x: auto;
  margin: 0 0 18px;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  white-space: pre;
  font-size: 13px;
  line-height: 1.65;
  color: var(--body);
}
pre code .c { color: var(--muted-2); } /* comment lines */

.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 9px;
  font: 500 11px var(--mono);
  color: var(--muted);
  background: color-mix(in srgb, var(--page) 80%, transparent);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease;
}
pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: var(--ink); }

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  margin: 0;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
th { color: var(--ink); background: var(--surface); font-weight: 600; font-size: 12.5px; }
td code { white-space: nowrap; }

/* ── components ──────────────────────────────────────────────────────── */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin: 0 0 26px;
}

.card {
  display: block;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 16px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  text-decoration: none;
  background: var(--surface);
  border-color: var(--line-2);
}
.card h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--ink); }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.5; }
.card .card__kicker {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  margin-bottom: 8px;
}

/* reference callout: bordered card with a colored rail + icon */
.callout {
  display: flex;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  padding: 12px 14px 12px 12px;
  margin: 0 0 18px;
  font-size: 14px;
  line-height: 1.6;
  --callout-color: var(--accent);
}
.callout--note { --callout-color: #3080ff; }
.callout--warn { --callout-color: #f99c00; }
.callout__mark {
  flex: none;
  width: 3px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--callout-color) 55%, transparent);
  margin-right: 2px;
}
.callout > :last-child { min-width: 0; }

.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 26px; }
.pill {
  font-size: 12.5px;
  color: var(--body);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
}

.section-cards { margin-top: 8px; }

/* ── footer ──────────────────────────────────────────────────────────── */

.docs-footer {
  border-top: 1px solid var(--line);
  margin-top: 40px;
  padding: 20px 0 30px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  color: var(--muted-2);
  font-size: 13px;
  position: relative;
}
.docs-footer nav { margin-left: auto; display: flex; gap: 16px; }
.docs-footer nav a { color: var(--muted); }
.docs-footer nav a:hover { color: var(--ink); }

/* ── responsive ──────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  /* minmax(0,1fr): a bare 1fr takes its min-content from the widest grid
   * item — the sidebar's 140px groups would stretch the shared column past
   * the viewport at 320px. */
  .docs-shell { grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 20px 16px 60px; }
  .docs-sidebar {
    position: static;
    max-height: none;
    display: flex;
    flex-wrap: wrap;
    gap: 4px 18px;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--surface-soft);
    mask-image: none;
  }
  .docs-sidebar__group { margin: 0; min-width: 140px; }
  .docs-sidebar__group a { margin-left: 0; padding: 4px 6px; display: inline-block; }
  .docs-content h1 { font-size: 25px; }
  .docs-content .lead { font-size: 16.5px; }
  .docs-header { padding: 10px 14px; }
  .docs-header__links > a:not(.button) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card, .button, body { transition: none; }
}
