﻿/* ==========================================================================
   Colrows Docs - Light theme system
   Single stylesheet. No build step. Inspired by Stripe / Vercel / Supabase docs.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Surfaces */
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --bg-sidebar: #fbfbfc;
  --bg-code: #f6f6f7;
  --bg-callout-info: #eff6ff;
  --bg-callout-tip: #f0fdf4;
  --bg-callout-warn: #fffbeb;

  /* Borders */
  --border: #e5e5e7;
  --border-strong: #d4d4d8;
  --border-callout-info: #bfdbfe;
  --border-callout-tip: #bbf7d0;
  --border-callout-warn: #fde68a;

  /* Text */
  --text: #18181b;
  --text-secondary: #52525b;
  --text-muted: #71717a;
  --text-inverse: #ffffff;

  /* Brand */
  --orange: #f48120;
  --orange-hover: #e2730f;
  --orange-soft: rgba(244, 129, 32, 0.08);
  --orange-border: rgba(244, 129, 32, 0.32);

  /* Accents (semantic) */
  --blue: #2563eb;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;

  /* Sizing */
  --header-h: 60px;
  --sidebar-w: 272px;
  --toc-w: 220px;
  --content-max: 760px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Type scale */
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 15px;
  --fs-md: 16px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --fs-3xl: 36px;

  /* Motion */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; display: block; }
a { color: var(--orange); text-decoration: none; }
a:hover { color: var(--orange-hover); text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Header ---------- */
.docs-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.docs-header__inner {
  display: flex; align-items: center; gap: 24px;
  height: 100%; padding: 0 24px;
}
.docs-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); font-weight: 600; font-size: var(--fs-md);
  text-decoration: none;
  flex-shrink: 0;
  min-width: 0;
}
.docs-brand:hover { text-decoration: none; color: var(--text); }
.docs-brand img {
  height: 28px;
  width: auto;
  max-width: none;
  flex-shrink: 0;
  display: block;
}
.docs-brand__divider {
  width: 1px; height: 22px; background: var(--border-strong); margin: 0 4px;
}
.docs-brand__label {
  color: var(--text-secondary); font-size: var(--fs-sm); font-weight: 500;
  letter-spacing: 0.01em;
}

.docs-search {
  flex: 1; max-width: 480px; position: relative;
}
.docs-search input {
  width: 100%; height: 36px; padding: 0 12px 0 38px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius-md); font-size: var(--fs-sm); color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.docs-search input::placeholder { color: var(--text-muted); }
.docs-search input:focus {
  outline: none; border-color: var(--orange-border);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--orange-soft);
}
.docs-search__icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--text-muted); pointer-events: none;
}
.docs-search__kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  height: 22px; min-width: 22px; padding: 0 6px;
  border: 1px solid var(--border); border-radius: 4px;
  background: var(--bg);
  font-family: 'Source Code Pro', monospace; font-size: 11px; color: var(--text-muted);
}

.docs-header__nav {
  display: flex; align-items: center; gap: 4px;
}
.docs-header__nav a {
  display: inline-flex; align-items: center; height: 32px;
  padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none; transition: background 0.15s, color 0.15s;
}
.docs-header__nav a:hover { color: var(--text); background: var(--bg-subtle); }
.docs-header__cta {
  display: inline-flex; align-items: center; height: 32px;
  padding: 0 14px; background: var(--text); color: var(--bg);
  border-radius: var(--radius-md); font-size: var(--fs-sm); font-weight: 500;
  text-decoration: none; transition: background 0.15s;
}
.docs-header__cta:hover { background: #2a2a2e; color: var(--bg); text-decoration: none; }

.docs-header__menu-toggle {
  display: none; background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); width: 36px; height: 36px;
  align-items: center; justify-content: center; color: var(--text);
}

/* ---------- Layout ---------- */
.docs-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  max-width: 1440px;
  margin: 0 auto;
  align-items: start;
}

/* ---------- Sidebar ---------- */
.docs-sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 28px 16px 32px 24px;
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
}
.docs-sidebar::-webkit-scrollbar { width: 6px; }
.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 3px;
}
.docs-sidebar__group { margin-bottom: 22px; }
.docs-sidebar__title {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 8px;
  padding: 0 8px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.docs-sidebar__title svg { width: 14px; height: 14px; color: var(--orange); }
.docs-sidebar__list { list-style: none; margin: 0; padding: 0; }
.docs-sidebar__list a {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: var(--fs-sm); font-weight: 400;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.docs-sidebar__list a:hover {
  color: var(--text); background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
}
.docs-sidebar__list a.is-active {
  color: var(--orange); background: var(--orange-soft); font-weight: 500;
}
.docs-sidebar__sub {
  list-style: none; padding: 2px 0 4px 18px; margin: 0;
  border-left: 1px solid var(--border);
  margin-left: 8px;
}
.docs-sidebar__sub a {
  font-size: 13px; color: var(--text-muted); padding: 4px 8px;
}

/* ---------- Article ---------- */
.docs-main {
  min-width: 0;
  padding: 40px 48px 96px;
}
.docs-article { max-width: var(--content-max); }
.docs-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); color: var(--text-muted);
  margin-bottom: 18px;
}
.docs-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.docs-breadcrumb a:hover { color: var(--text-secondary); }
.docs-breadcrumb__sep { color: var(--border-strong); }

.docs-article h1 {
  margin: 0 0 12px;
  font-size: var(--fs-3xl);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--text);
}
.docs-article__lede {
  font-size: var(--fs-lg);
  line-height: 1.55;
  color: var(--text-secondary);
  margin: 0 0 32px;
}
.docs-article h2 {
  margin: 48px 0 14px;
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.015em;
  scroll-margin-top: 80px;
}
.docs-article h3 {
  margin: 32px 0 12px;
  font-size: var(--fs-xl);
  font-weight: 600;
  line-height: 1.3;
  scroll-margin-top: 80px;
}
.docs-article h4 {
  margin: 24px 0 8px;
  font-size: var(--fs-md);
  font-weight: 600;
  scroll-margin-top: 80px;
}
.docs-article p { margin: 0 0 16px; }
.docs-article ul, .docs-article ol { margin: 0 0 16px; padding-left: 24px; }
.docs-article li { margin-bottom: 6px; }
.docs-article li > p { margin-bottom: 6px; }
.docs-article strong { color: var(--text); font-weight: 600; }
.docs-article hr {
  border: 0; border-top: 1px solid var(--border); margin: 40px 0;
}

/* Heading anchor */
.docs-article h2, .docs-article h3 { position: relative; }
.docs-article .anchor {
  position: absolute; left: -22px; top: 50%; transform: translateY(-50%);
  opacity: 0; color: var(--text-muted); text-decoration: none;
  font-size: 18px; font-weight: 400;
  transition: opacity 0.15s;
}
.docs-article h2:hover .anchor,
.docs-article h3:hover .anchor { opacity: 1; }

/* ---------- Code ---------- */
.docs-article code {
  font-family: 'Source Code Pro', ui-monospace, SFMono-Regular, monospace;
  font-size: 0.9em;
  padding: 2px 6px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}
.docs-article pre {
  margin: 0 0 20px;
  padding: 16px 18px;
  background: #0f0f10;
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: 1.55;
}
.docs-article pre code {
  background: transparent; border: 0; padding: 0;
  color: #e4e4e7; font-size: 13.5px;
}
.docs-article pre code .k { color: #c084fc; }   /* keywords */
.docs-article pre code .s { color: #86efac; }   /* strings */
.docs-article pre code .n { color: #fbbf24; }   /* numbers */
.docs-article pre code .c { color: #71717a; font-style: italic; } /* comments */
.docs-article pre code .f { color: #60a5fa; }   /* functions */

/* ---------- Callouts ---------- */
.callout {
  display: flex; gap: 12px;
  padding: 14px 16px; margin: 0 0 24px;
  border-radius: var(--radius-md);
  border: 1px solid;
  font-size: var(--fs-sm);
  line-height: 1.55;
}
.callout svg { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 2px; }
.callout p:last-child { margin-bottom: 0; }
.callout--info { background: var(--bg-callout-info); border-color: var(--border-callout-info); color: #1e3a8a; }
.callout--info svg { color: var(--blue); }
.callout--tip  { background: var(--bg-callout-tip);  border-color: var(--border-callout-tip);  color: #064e3b; }
.callout--tip svg  { color: var(--green); }
.callout--warn { background: var(--bg-callout-warn); border-color: var(--border-callout-warn); color: #78350f; }
.callout--warn svg { color: var(--amber); }
.callout strong { color: inherit; }

/* ---------- Tables ---------- */
.docs-article table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.docs-article thead { background: var(--bg-subtle); }
.docs-article th {
  text-align: left; padding: 10px 14px;
  font-weight: 600; color: var(--text);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.docs-article td {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  vertical-align: top;
}
.docs-article tr:first-child td { border-top: 0; }

/* ---------- Steps ---------- */
.steps { counter-reset: step; padding-left: 0; list-style: none; margin: 0 0 24px; }
.steps > li {
  counter-increment: step;
  position: relative;
  padding: 0 0 20px 44px;
  border-left: 1px solid var(--border);
  margin-left: 14px;
}
.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute; left: -14px; top: -2px;
  width: 28px; height: 28px;
  background: var(--bg); border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}
.steps > li:last-child { border-left-color: transparent; }
.steps h4 { margin: 0 0 6px; }

/* ---------- Cards (home page) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 0 0 32px;
}
.card-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.doc-card {
  display: block;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.doc-card:hover {
  text-decoration: none;
  border-color: var(--orange-border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 12px rgba(244, 129, 32, 0.08);
}
.doc-card__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--orange-soft); color: var(--orange);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}
.doc-card__icon svg { width: 20px; height: 20px; }
.doc-card__title {
  margin: 0 0 4px;
  font-size: var(--fs-md); font-weight: 600;
  color: var(--text);
}
.doc-card__desc {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.5;
}
.doc-card__arrow {
  display: inline-flex; margin-top: 12px;
  font-size: var(--fs-sm); font-weight: 500;
  color: var(--orange);
}

/* ---------- Hero (home) ---------- */
.docs-hero {
  padding: 32px 0 36px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}
.docs-hero__eyebrow {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--orange-soft);
  color: var(--orange);
  border-radius: 9999px;
  font-size: 12px; font-weight: 500;
  margin-bottom: 16px;
}
.docs-hero h1 {
  font-size: 40px; line-height: 1.15; margin: 0 0 12px;
  letter-spacing: -0.02em; font-weight: 600;
}
.docs-hero p {
  font-size: 18px; line-height: 1.55;
  color: var(--text-secondary);
  margin: 0; max-width: 640px;
}

/* ---------- TOC (right sidebar) ---------- */
.docs-toc {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 40px 24px 32px 16px;
  font-size: var(--fs-sm);
}
.docs-toc__title {
  margin: 0 0 10px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.docs-toc ul { list-style: none; margin: 0; padding: 0; }
.docs-toc a {
  display: block;
  padding: 4px 0;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  padding-left: 10px;
  margin-left: -12px;
  font-size: 13px; line-height: 1.4;
  transition: color 0.12s, border-color 0.12s;
}
.docs-toc a:hover { color: var(--text); }
.docs-toc a.is-active {
  color: var(--orange);
  border-left-color: var(--orange);
}
.docs-toc__sub { padding-left: 12px !important; font-size: 12px; }

/* ---------- Page footer (next/prev + edit) ---------- */
.docs-pagination {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin: 60px 0 0;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.docs-pagination__link {
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.docs-pagination__link:hover {
  border-color: var(--orange-border);
  background: var(--orange-soft);
  text-decoration: none;
}
.docs-pagination__link--next { text-align: right; }
.docs-pagination__label {
  font-size: 12px; color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.04em;
}
.docs-pagination__title { font-size: var(--fs-md); font-weight: 600; }

/* ---------- Footer ---------- */
.docs-footer {
  border-top: 1px solid var(--border);
  background: var(--bg-sidebar);
  padding: 28px 24px;
  text-align: center;
  font-size: var(--fs-sm); color: var(--text-muted);
}
.docs-footer__row {
  max-width: 1440px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.docs-footer__links { display: flex; gap: 18px; }
.docs-footer__links a { color: var(--text-muted); }
.docs-footer__links a:hover { color: var(--text); text-decoration: none; }

/* ---------- Diagram blocks ---------- */
.diagram {
  margin: 24px 0;
  padding: 20px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}
.diagram svg { margin: 0 auto; max-width: 100%; height: auto; }
.diagram__caption {
  margin: 12px 0 0;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-style: italic;
}

/* ---------- Pill / Tag ---------- */
.pill {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 12px; color: var(--text-secondary);
  font-family: 'Source Code Pro', monospace;
}
.pill--orange { background: var(--orange-soft); border-color: var(--orange-border); color: var(--orange); }
.pill--green  { background: var(--bg-callout-tip); border-color: var(--border-callout-tip); color: var(--green); }

/* ---------- Feature list ---------- */
.feature-list {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin: 16px 0 24px; padding: 0; list-style: none;
}
.feature-list li {
  display: flex; gap: 10px; padding: 12px 14px;
  background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.feature-list svg {
  flex: 0 0 16px; width: 16px; height: 16px;
  margin-top: 3px; color: var(--orange);
}
.feature-list strong { display: block; margin-bottom: 2px; color: var(--text); }
.feature-list span { font-size: 13px; color: var(--text-secondary); line-height: 1.45; }

/* ---------- Mobile drawer overlay ---------- */
.docs-drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 80;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s var(--ease);
}
body.is-drawer-open .docs-drawer-overlay { opacity: 1; pointer-events: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .docs-layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar {
    position: fixed; top: var(--header-h); left: 0;
    width: 84vw; max-width: 320px; z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.25s var(--ease);
    box-shadow: 2px 0 16px rgba(0,0,0,0.05);
  }
  body.is-drawer-open .docs-sidebar { transform: translateX(0); }
  .docs-header__menu-toggle { display: inline-flex; }
  .docs-search { max-width: none; flex: 1; }
  .docs-header__nav { display: none; }
  .docs-main { padding: 28px 22px 64px; }
  .docs-hero h1 { font-size: 32px; }
  .docs-hero p { font-size: 16px; }
  .card-grid, .card-grid--3 { grid-template-columns: 1fr; }
  .feature-list { grid-template-columns: 1fr; }
  .docs-article h1 { font-size: 28px; }
  .docs-article h2 { font-size: 22px; }
  .docs-article h3 { font-size: 18px; }
  .docs-pagination { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .docs-header__inner { gap: 10px; padding: 0 14px; }
  .docs-brand__divider, .docs-brand__label { display: none; }
  .docs-header__cta { padding: 0 10px; font-size: 12px; }
  .docs-search input { font-size: 13px; }
}

/* ---------- Print ---------- */
@media print {
  .docs-header, .docs-sidebar, .docs-toc, .docs-pagination, .docs-footer { display: none; }
  .docs-layout { display: block; }
  .docs-main { padding: 0; }
}
