/* CloudPeek documentation: hand-authored styles (sky accent on slate, light + dark). */

:root {
  --accent: #0284c7;
  --accent-strong: #0369a1;
  --accent-soft: #e0f2fe;
  --bg: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-code: #f1f5f9;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --sidebar-w: 17rem;
  --toc-w: 15rem;
  --header-h: 4rem;
  --radius: 0.5rem;
  --maxw: 48rem;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --accent: #38bdf8;
  --accent-strong: #7dd3fc;
  --accent-soft: #0c2438;
  --bg: #0b1120;
  --bg-subtle: #0f172a;
  --bg-code: #111c30;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-faint: #64748b;
  --border: #1e293b;
  --border-strong: #334155;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .logo { height: 1.6rem; width: auto; fill: currentColor; display: block; }
.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}
.header-spacer { flex: 1; }

.nav-toggle, .theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: var(--radius);
  width: 2.25rem;
  height: 2.25rem;
  cursor: pointer;
}
.nav-toggle { display: none; }
.theme-toggle:hover, .nav-toggle:hover { background: var(--bg-subtle); color: var(--text); }
.theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

/* ---------- Search ---------- */
.search { position: relative; }
.search input {
  width: 14rem;
  max-width: 40vw;
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.search input:focus { outline: none; border-color: var(--accent); }
.search-results {
  position: absolute;
  right: 0;
  top: 2.6rem;
  width: 26rem;
  max-width: 80vw;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(2, 8, 23, 0.18);
  padding: 0.4rem;
}
.search-results a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius);
  color: var(--text);
}
.search-results a:hover, .search-results a.sel { background: var(--bg-subtle); text-decoration: none; }
.search-results .sr-section { font-size: 0.7rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; }
.search-results .sr-title { font-weight: 600; color: var(--text); }
.search-results .sr-empty { padding: 0.75rem; color: var(--text-muted); font-size: 0.875rem; }

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

.sidebar {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 1.5rem 1rem 3rem;
  border-right: 1px solid var(--border);
}
.site-nav .nav-group { margin-bottom: 1.5rem; }
.site-nav h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 0.5rem 0.5rem;
  font-weight: 700;
}
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.site-nav li a {
  display: block;
  padding: 0.32rem 0.6rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.9rem;
  border-left: 2px solid transparent;
}
.site-nav li a:hover { color: var(--text); background: var(--bg-subtle); text-decoration: none; }
.site-nav li a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.content {
  min-width: 0;
  padding: 2.5rem 3rem 4rem;
}

.toc-rail {
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  padding: 2.5rem 1rem 3rem;
}
.toc h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 0.6rem;
  font-weight: 700;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li a {
  display: block;
  padding: 0.2rem 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  padding-left: 0.75rem;
}
.toc li.toc-3 a { padding-left: 1.5rem; }
.toc li a:hover { color: var(--text); text-decoration: none; }
.toc li a.active { color: var(--accent); border-left-color: var(--accent); }

.sidebar-backdrop { display: none; }

/* ---------- Prose ---------- */
.prose { max-width: var(--maxw); }
.prose h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 1rem; letter-spacing: -0.02em; }
.prose h2 {
  font-size: 1.5rem;
  margin: 2.75rem 0 1rem;
  letter-spacing: -0.01em;
  border-top: 1px solid var(--border);
  padding-top: 1.75rem;
}
.prose h3 { font-size: 1.18rem; margin: 2rem 0 0.75rem; }
.prose h4 { font-size: 1rem; margin: 1.5rem 0 0.5rem; text-transform: none; color: var(--text); }
.prose p { margin: 0.9rem 0; }
.prose ul, .prose ol { margin: 0.9rem 0; padding-left: 1.4rem; }
.prose li { margin: 0.35rem 0; }
.prose li > ul, .prose li > ol { margin: 0.3rem 0; }
.prose strong { color: var(--text); font-weight: 650; }
.prose a { font-weight: 500; }
.prose a:hover { text-decoration: underline; }

.prose code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 0.35rem;
  padding: 0.1rem 0.35rem;
  color: var(--accent-strong);
  overflow-wrap: break-word;
}
/* Keep short tokens (paths, permissions) whole in tables; the table scrolls if needed. */
.prose td code, .prose th code { white-space: nowrap; }
.prose pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  overflow-x: auto;
  margin: 1.1rem 0;
  font-size: 0.85rem;
  line-height: 1.55;
}
.prose pre code { background: none; border: none; padding: 0; color: var(--text); font-size: inherit; }

.prose blockquote {
  margin: 1.1rem 0;
  padding: 0.25rem 1.1rem;
  border-left: 3px solid var(--border-strong);
  color: var(--text-muted);
}
.prose hr { border: none; border-top: 1px solid var(--border); margin: 2.5rem 0; }

/* Inline SVG diagrams (e.g. the architecture figure). Themed via CSS variables. */
.prose figure { margin: 1.75rem 0; }
.prose figure.diagram svg { display: block; width: 100%; height: auto; max-width: 680px; margin: 0 auto; }
.prose figure svg text { font-family: var(--font); }
.prose figcaption { text-align: center; font-size: 0.8rem; color: var(--text-faint); margin-top: 0.5rem; }

.table-wrap { overflow-x: auto; margin: 1.2rem 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.prose th, .prose td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  vertical-align: top;
}
.prose th { background: var(--bg-subtle); font-weight: 600; }
.prose tbody tr:nth-child(even) { background: var(--bg-subtle); }

/* ---------- Callouts ---------- */
.callout {
  margin: 1.25rem 0;
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left-width: 3px;
  background: var(--bg-subtle);
}
.callout-title { font-weight: 650; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.25rem; }
.callout-body > :first-child { margin-top: 0; }
.callout-body > :last-child { margin-bottom: 0; }
.callout-note { border-left-color: var(--accent); }
.callout-note .callout-title { color: var(--accent); }
.callout-tip { border-left-color: #16a34a; }
.callout-tip .callout-title { color: #16a34a; }
.callout-warning { border-left-color: #d97706; }
.callout-warning .callout-title { color: #d97706; }
.callout-important { border-left-color: #dc2626; }
.callout-important .callout-title { color: #dc2626; }

/* ---------- Breadcrumb & pager ---------- */
.breadcrumb { font-size: 0.8rem; color: var(--text-faint); margin-bottom: 1rem; }
.breadcrumb span { color: var(--text-faint); }
.breadcrumb a { color: var(--text-muted); }

.pager { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 48%;
}
.pager-link:hover { border-color: var(--accent); text-decoration: none; }
.pager-next { text-align: right; }
.pager-dir { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); }
.pager-title { font-weight: 600; color: var(--text); }

.site-footer { max-width: var(--maxw); margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 0.8rem; }

/* ---------- Home ---------- */
.hero { padding: 1.5rem 0 1rem; max-width: 42rem; }
.hero-eyebrow { color: var(--accent); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 0.75rem; }
.hero h1 { font-size: 2.6rem; line-height: 1.1; margin: 0 0 1rem; letter-spacing: -0.025em; }
.hero-sub { font-size: 1.15rem; color: var(--text-muted); margin: 0 0 1.75rem; }
.hero-cta { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; padding: 0.6rem 1.2rem; border-radius: var(--radius); font-weight: 600; font-size: 0.95rem; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: var(--bg-subtle); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }

.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1.25rem; margin-top: 2.5rem; }
.home-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.4rem; background: var(--bg-subtle); }
.home-card h3 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.home-card ul { list-style: none; margin: 0; padding: 0; }
.home-card li { margin: 0.3rem 0; }
.home-card li a { color: var(--text-muted); font-size: 0.9rem; }
.home-card li a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc-rail { display: none; }
  .content { padding: 2rem 2rem 4rem; }
}
@media (max-width: 820px) {
  .nav-toggle { display: inline-flex; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .search input { width: 9rem; }
  .content { padding: 1.5rem 1.25rem 3rem; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: min(20rem, 82vw);
    background: var(--bg);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 35;
    box-shadow: 0 12px 40px rgba(2, 8, 23, 0.25);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(2, 8, 23, 0.4);
    z-index: 34;
  }
  .hero h1 { font-size: 2rem; }
}
