/* Ninja docs — carries product page design (site/index.html) into a docs layout.
   Same tokens, rail energy, mono chrome, accent red — not Hermes/Docusaurus grey. */

@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap");

:root {
  --bg: #0a0a0b;
  --bg-2: #0f0f11;
  --bg-3: #141417;
  --panel: #111114;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --ink: #f2f2f3;
  --mute: #8b8f98;
  --dim: #5c6069;
  --accent: #ff3b47;
  --accent-2: #ff6b73;
  --accent-dim: rgba(255, 59, 71, 0.14);
  --accent-glow: rgba(255, 59, 71, 0.22);
  --ok: #6cd08a;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --navbar-height: 56px;
  --sidebar-width: 260px;
  --content-max: 52rem;
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--navbar-height) + 1rem);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  * {
    animation: none !important;
    transition: none !important;
  }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ambient particle field (same idea as product page) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255, 255, 255, 0.18) 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 62%, rgba(255, 255, 255, 0.12) 50%, transparent 51%),
    radial-gradient(1px 1px at 44% 30%, rgba(255, 59, 71, 0.25) 50%, transparent 51%),
    radial-gradient(1px 1px at 61% 78%, rgba(255, 255, 255, 0.1) 50%, transparent 51%),
    radial-gradient(1px 1px at 73% 22%, rgba(255, 255, 255, 0.14) 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 55%, rgba(255, 59, 71, 0.2) 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 88%, rgba(255, 255, 255, 0.08) 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 8%, rgba(255, 255, 255, 0.1) 50%, transparent 51%);
}

a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  color: var(--ink);
}
::selection {
  background: var(--accent);
  color: #0a0a0b;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── top bar (product header.top) ───────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--navbar-height);
  display: flex;
  align-items: center;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 11, 0.78);
  backdrop-filter: blur(12px);
  overflow: hidden; /* never let links spill below the bar */
}

.navbar__inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: nowrap;
  min-width: 0;
}

.navbar__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  color: var(--ink);
  min-width: 0;
}
.navbar__brand:hover {
  color: var(--ink);
}

.navbar__logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, var(--accent-dim), transparent 70%),
    var(--bg-2);
  box-shadow: 0 0 14px var(--accent-glow);
}

/* Front-page ANSI ninja (same markup as site/index.html .mascot), scaled down */
.navbar__logo pre.logo-ansi,
.navbar__logo pre.ansi {
  margin: 0;
  font-family: var(--mono);
  /* ~25 cols × 18 rows; ~2.4px fits the 42px tile with a little padding */
  font-size: 2.4px;
  line-height: 1.05;
  letter-spacing: 0;
  white-space: pre;
  color: transparent; /* colors from inline spans, same as product page */
  text-shadow: 0 0 8px var(--accent-glow);
  filter: drop-shadow(0 0 1px rgba(255, 59, 71, 0.35));
  pointer-events: none;
  user-select: none;
}

.navbar__title {
  font-size: 14px;
  white-space: nowrap;
}
.navbar__title .dot {
  color: var(--accent);
}

.navbar__badge {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(255, 59, 71, 0.35);
  background: var(--accent-dim);
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
  white-space: nowrap;
}

.navbar__items {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.navbar__link {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--mute);
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.navbar__link:hover {
  color: var(--ink);
  background: var(--bg-3);
}
.navbar__link--active {
  color: var(--ink);
  border-color: var(--border-strong);
  background: var(--panel);
}
/* Home is always the escape hatch back to the product page */
.navbar__link--home {
  border-color: var(--border-strong);
  background: var(--bg-2);
}
.navbar__link--home:hover {
  border-color: var(--accent);
  box-shadow: 0 0 18px var(--accent-glow);
}

.menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  z-index: 60;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  color: var(--ink);
  border-radius: 7px;
  padding: 0;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.menu-toggle:hover {
  background: var(--bg-3);
  border-color: var(--border-strong);
}
.menu-toggle[aria-expanded="true"] {
  border-color: rgba(255, 59, 71, 0.45);
  background: var(--accent-dim);
  color: var(--accent);
}

/* mobile drawer backdrop — sibling of .sidebar inside .main-wrapper;
   z-index must stay BELOW .sidebar so links remain tappable. */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  top: var(--navbar-height);
  z-index: 2;
  background: rgba(0, 0, 0, 0.55);
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  touch-action: manipulation;
}
body.sidebar-open .sidebar-backdrop {
  display: block;
}

/* ── layout ─────────────────────────────────────────────── */
.main-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  min-height: calc(100vh - var(--navbar-height));
}

/* sidebar — docs rail, same energy as product left rail */
.sidebar {
  position: sticky;
  top: var(--navbar-height);
  align-self: flex-start;
  width: var(--sidebar-width);
  max-height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  padding: 20px 12px 32px 16px;
  border-right: 1px solid var(--border);
  background: rgba(10, 10, 11, 0.72);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.sidebar__category {
  margin-top: 1.25rem;
  margin-bottom: 0.45rem;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}
.sidebar__category:first-child {
  margin-top: 0.15rem;
}

.sidebar a {
  display: block;
  padding: 8px 10px;
  margin: 2px 0;
  border-radius: 7px;
  border-left: 2px solid transparent;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--mute);
  line-height: 1.35;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.sidebar a:hover {
  color: var(--ink);
  background: linear-gradient(90deg, var(--accent-dim), transparent);
  border-left-color: rgba(255, 59, 71, 0.4);
}
.sidebar a.active {
  color: var(--ink);
  border-left-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-dim), transparent);
}

.doc-main {
  flex: 1;
  min-width: 0;
  padding: 36px 32px 72px;
}

.markdown {
  max-width: var(--content-max);
  margin: 0 auto;
}

.breadcrumb {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 14px;
}
.breadcrumb a {
  color: var(--mute);
}
.breadcrumb a:hover {
  color: var(--accent);
}
.breadcrumb span {
  margin: 0 0.4rem;
  color: var(--dim);
}

/* headings */
.markdown h1 {
  font-size: clamp(32px, 4.5vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.12;
  color: var(--ink);
  margin: 0 0 14px;
}

.markdown h2 {
  font-size: clamp(22px, 2.8vw, 30px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--ink);
  margin: 2.4rem 0 0.85rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}
.markdown h2:first-of-type {
  margin-top: 1.75rem;
}

.markdown h3 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--ink);
  margin: 1.5rem 0 0.55rem;
  font-family: var(--sans);
}

.markdown p {
  margin: 0 0 1rem;
  color: #c8cad0;
}
.markdown p strong,
.markdown li strong {
  color: var(--ink);
  font-weight: 600;
}

.markdown ul,
.markdown ol {
  margin: 0 0 1rem;
  padding-left: 1.35rem;
  color: #c8cad0;
}
.markdown li {
  margin: 0.28rem 0;
}

.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.hero-lead {
  font-size: clamp(15px, 1.5vw, 17px);
  color: var(--mute);
  max-width: 54ch;
  margin: 0 0 1.5rem;
}

/* inline code */
.markdown code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.12em 0.38em;
  color: var(--accent-2);
}

/* code blocks — product .install panel language */
.markdown pre {
  margin: 0 0 1.15rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  overflow: hidden;
}
.markdown pre code {
  display: block;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.55;
  overflow-x: auto;
  white-space: pre;
}

/* tables */
.markdown table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  display: block;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.markdown th,
.markdown td {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}
.markdown th:last-child,
.markdown td:last-child {
  border-right: 0;
}
.markdown tr:last-child td {
  border-bottom: 0;
}
.markdown th {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mute);
  background: rgba(255, 255, 255, 0.02);
  font-weight: 600;
}
.markdown td {
  color: #c8cad0;
}
.markdown td code {
  font-size: 0.82em;
}

/* links in content */
.markdown a {
  color: var(--accent-2);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 107, 115, 0.35);
}
.markdown a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
/* cards are block links — don't underline like prose links */
.markdown a.card {
  color: inherit;
  border-bottom: 0;
  text-decoration: none;
}
.markdown a.card:hover {
  color: inherit;
  border-bottom: 0;
}
.markdown a.card h3 {
  border: 0;
}

/* admonitions — product tag/pill language */
.admonition {
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 14px 16px;
  margin: 0 0 1.15rem;
}
.admonition-title {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}
.admonition p {
  margin: 0;
  color: var(--mute);
}
.admonition p + p {
  margin-top: 0.5rem;
}
.admonition--note {
  border-left-color: #5b8def;
}
.admonition--note .admonition-title {
  color: #8eb6ff;
}
.admonition--tip {
  border-left-color: var(--ok);
}
.admonition--tip .admonition-title {
  color: var(--ok);
}
.admonition--warning {
  border-left-color: #e6a700;
}
.admonition--warning .admonition-title {
  color: #f0c14a;
}
.admonition--danger {
  border-left-color: var(--accent);
}

/* home cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin: 1.25rem 0 1.75rem;
}
.card {
  display: block;
  padding: 16px 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 28px var(--accent-glow);
  transform: translateY(-1px);
  color: inherit;
}
.card h3 {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.card p {
  margin: 0;
  font-size: 13px;
  color: var(--mute);
  line-height: 1.5;
}

.footer-note {
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--dim);
}

/* mobile / tablet — section nav lives in the burger drawer; keep only Home */
@media (max-width: 996px) {
  .menu-toggle {
    display: inline-flex;
  }
  .navbar {
    padding: 0 12px;
    /* stay above drawer + dimmer */
    z-index: 60;
  }
  /* Hide Docs / Install / Models / MCP — Home stays as the product-page tab */
  .navbar__link--desktop {
    display: none !important;
  }
  /*
   * Stacking fix: .main-wrapper used z-index:1, which trapped .sidebar inside a
   * low stacking context. The body-level .sidebar-backdrop (z-index 45) then
   * painted ON TOP of the drawer — phone users saw a dark screen and could not
   * tap any nav link. Drop the wrapper's z-index on mobile so fixed drawer +
   * dimmer compete at the root (dimmer < drawer < header).
   */
  .main-wrapper {
    z-index: auto;
  }
  .doc-main {
    position: relative;
    z-index: 1;
    padding: 24px 16px 56px;
  }
  .sidebar-backdrop {
    z-index: 40;
  }
  .sidebar {
    position: fixed !important;
    left: 0 !important;
    top: var(--navbar-height) !important;
    bottom: 0 !important;
    z-index: 50 !important;
    width: min(var(--sidebar-width), 86vw) !important;
    max-height: none !important;
    transform: translate3d(-105%, 0, 0) !important;
    transition: transform 0.2s ease;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
    background: rgba(10, 10, 11, 0.98) !important;
    -webkit-overflow-scrolling: touch;
    visibility: visible;
    pointer-events: auto;
  }
  body.sidebar-open {
    overflow: hidden !important;
  }
  body.sidebar-open .sidebar {
    transform: translate3d(0, 0, 0) !important;
  }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }
  .markdown h1 {
    font-size: clamp(28px, 8vw, 40px);
  }
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* very narrow phones — drop the docs badge to free brand space */
@media (max-width: 380px) {
  .navbar__badge {
    display: none;
  }
  .navbar__logo {
    width: 36px;
    height: 36px;
  }
  .navbar__logo pre.logo-ansi,
  .navbar__logo pre.ansi {
    font-size: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }
}
