/* ============================================================
   Cryo · Burnout · Pyro — Documentação
   Estilo inspirado na documentação do Next.js.
   ============================================================ */

:root {
  --topbar-h: 60px;
  --sidebar-w: 280px;
  --toc-w: 240px;
  --content-max: 760px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", "JetBrains Mono", "Fira Code", Consolas, "Liberation Mono", Menlo, monospace;

  --accent-ice: #38bdf8;
  --accent-ice-2: #22d3ee;
  --accent-fire: #fb923c;
  --accent-fire-2: #f97316;
  --radius: 10px;
}

/* ---------- Dark (padrão) ---------- */
:root[data-theme="dark"] {
  --bg: #0a0c10;
  --bg-elev: #0e1117;
  --bg-code: #0d1117;
  --bg-inline: #1b2029;
  --panel: #0d1016;
  --border: #1e242e;
  --border-strong: #2a323e;
  --text: #e6edf3;
  --text-soft: #aeb9c5;
  --text-mut: #7d8894;
  --link: #6cc7ff;
  --accent: var(--accent-ice);
  --accent-soft: rgba(56, 189, 248, 0.14);
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  --sel: rgba(56, 189, 248, 0.28);
}

/* ---------- Light ---------- */
:root[data-theme="light"] {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-code: #f6f8fa;
  --bg-inline: #eef1f5;
  --panel: #fbfcfd;
  --border: #e6e9ee;
  --border-strong: #d4dae2;
  --text: #10151c;
  --text-soft: #3b4650;
  --text-mut: #6b7683;
  --link: #0969da;
  --accent: #0ea5e9;
  --accent-soft: rgba(14, 165, 233, 0.12);
  --shadow: 0 12px 40px rgba(15, 30, 50, 0.14);
  --sel: rgba(14, 165, 233, 0.2);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

::selection { background: var(--sel); }

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

.skip-link {
  position: fixed; left: -999px; top: 8px; z-index: 200;
  background: var(--accent); color: #001018; padding: 8px 14px; border-radius: 8px;
}
.skip-link:focus { left: 8px; }

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-inline);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--text-mut);
}

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 90;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -0.01em; color: var(--text);
  font-size: 15px; white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  position: relative; width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  border-radius: 9px;
  background:
    radial-gradient(circle at 30% 25%, rgba(56,189,248,.55), transparent 60%),
    radial-gradient(circle at 75% 80%, rgba(249,115,22,.55), transparent 60%),
    linear-gradient(135deg, #0b2233, #1a0f08);
  border: 1px solid var(--border-strong);
  font-size: 13px;
}
.brand-mark .flake { position: absolute; top: 1px; left: 3px; filter: drop-shadow(0 0 4px rgba(56,189,248,.8)); }
.brand-mark .spark { position: absolute; bottom: 0; right: 2px; font-size: 12px; }
.brand-sep { color: var(--text-mut); margin: 0 3px; font-weight: 400; }
.brand-text { background: linear-gradient(90deg, var(--accent-ice), #cbd5e1 55%, var(--accent-fire)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
:root[data-theme="light"] .brand-text { background: linear-gradient(90deg, #0284c7, #334155 55%, #ea580c); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

.topbar-search { flex: 1; display: flex; justify-content: flex-start; max-width: 420px; margin-left: 6px; }
.search-trigger {
  width: 100%; max-width: 340px;
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text-mut);
  font: inherit; font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { flex: 1; text-align: left; }
.search-trigger kbd { margin-left: auto; }

.topbar-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }

.icon-btn {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 9px; border: 1px solid transparent;
  background: transparent; color: var(--text-soft);
  cursor: pointer; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel); color: var(--text); border-color: var(--border); text-decoration: none; }
.menu-toggle { display: none; }

#themeToggle .icon-moon { display: none; }
:root[data-theme="light"] #themeToggle .icon-sun { display: none; }
:root[data-theme="light"] #themeToggle .icon-moon { display: block; }

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

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 26px 14px 60px 22px;
  border-right: 1px solid var(--border);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 26px; }
.nav-group-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--text-mut);
  padding: 0 10px 8px; margin: 0;
}
.nav-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-link {
  display: block; padding: 6px 10px; border-radius: 7px;
  color: var(--text-soft); font-size: 13.5px; line-height: 1.4;
  border-left: 2px solid transparent;
}
.nav-link:hover { background: var(--panel); color: var(--text); text-decoration: none; }
.nav-link.active {
  color: var(--accent); background: var(--accent-soft);
  font-weight: 600; border-left-color: var(--accent);
}

/* ---------- Content ---------- */
.content {
  min-width: 0;
  padding: 44px clamp(24px, 5vw, 64px) 80px;
}
.doc { max-width: var(--content-max); }

.doc .eyebrow {
  display: inline-block; font-size: 12px; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 10px;
}
.doc h1 {
  font-size: clamp(30px, 4vw, 40px); line-height: 1.15;
  letter-spacing: -0.02em; margin: 0 0 14px; font-weight: 800;
}
.doc .lead { font-size: 18px; color: var(--text-soft); margin: 0 0 34px; line-height: 1.6; }

.doc h2 {
  font-size: 24px; font-weight: 700; letter-spacing: -0.01em;
  margin: 48px 0 16px; padding-top: 10px; scroll-margin-top: 80px;
  border-top: 1px solid var(--border);
}
.doc h2:first-of-type { border-top: none; }
.doc h3 { font-size: 18px; font-weight: 700; margin: 32px 0 12px; scroll-margin-top: 80px; }
.doc h4 { font-size: 15px; font-weight: 700; margin: 24px 0 10px; color: var(--text-soft); }

.doc p { margin: 0 0 16px; }
.doc ul, .doc ol { margin: 0 0 16px; padding-left: 24px; }
.doc li { margin: 6px 0; }
.doc li::marker { color: var(--text-mut); }

.doc strong { color: var(--text); font-weight: 700; }

.heading-anchor {
  opacity: 0; margin-left: 8px; font-weight: 400; color: var(--text-mut);
  text-decoration: none; font-size: 0.8em;
}
.doc h2:hover .heading-anchor, .doc h3:hover .heading-anchor { opacity: 1; }

/* inline code */
.doc :not(pre) > code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--bg-inline); border: 1px solid var(--border);
  padding: 0.12em 0.4em; border-radius: 6px;
  color: #ffd7a8; word-break: break-word;
}
:root[data-theme="light"] .doc :not(pre) > code { color: #b4530a; }

/* code blocks */
.code-block {
  position: relative; margin: 0 0 22px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 8px 16px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-code) 60%, var(--panel));
}
.code-lang { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-mut); }
.copy-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font: inherit; font-size: 12px; color: var(--text-mut);
  background: transparent; border: 1px solid var(--border);
  border-radius: 6px; padding: 3px 9px; cursor: pointer;
  transition: color .15s, border-color .15s;
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }
.copy-btn.copied { color: #34d399; border-color: #34d399; }
.code-block pre {
  margin: 0; padding: 16px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7;
}
.code-block code { font-family: inherit; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 0 22px; border: 1px solid var(--border); border-radius: var(--radius); }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; }
.doc thead th {
  text-align: left; font-weight: 700; font-size: 12.5px;
  background: var(--panel); color: var(--text-soft);
  padding: 10px 14px; border-bottom: 1px solid var(--border-strong);
}
.doc tbody td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.doc tbody tr:last-child td { border-bottom: none; }
.doc td code, .doc th code { white-space: nowrap; }

/* blockquote / callout */
.doc blockquote {
  margin: 0 0 22px; padding: 14px 18px;
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  color: var(--text-soft);
}
.doc blockquote p:last-child { margin-bottom: 0; }
.doc blockquote strong { color: var(--text); }

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

/* feature cards on the intro */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin: 8px 0 26px; }
.card {
  display: block; padding: 18px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--panel); color: var(--text);
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.card h4 { margin: 0 0 6px; font-size: 15px; color: var(--text); }
.card p { margin: 0; font-size: 13.5px; color: var(--text-mut); }
.card .card-emoji { font-size: 22px; display: block; margin-bottom: 8px; }

/* pipeline diagram */
.pipeline {
  display: flex; align-items: stretch; gap: 0; flex-wrap: wrap;
  margin: 4px 0 28px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.pipeline .stage { flex: 1 1 160px; padding: 16px 18px; background: var(--panel); border-right: 1px solid var(--border); }
.pipeline .stage:last-child { border-right: none; }
.pipeline .stage .st-tag { font-family: var(--font-mono); font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: .05em; }
.pipeline .stage h4 { margin: 6px 0 4px; font-size: 15px; }
.pipeline .stage p { margin: 0; font-size: 12.5px; color: var(--text-mut); }

/* ---------- TOC ---------- */
.toc {
  position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 44px 22px 60px 8px;
  font-size: 13px;
}
.toc-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-mut); margin: 0 0 12px; }
.toc ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid var(--border); }
.toc a { display: block; padding: 4px 0 4px 14px; margin-left: -1px; color: var(--text-mut); border-left: 2px solid transparent; line-height: 1.4; }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.h3 { padding-left: 26px; font-size: 12.5px; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc:empty { display: none; }

/* ---------- Pager ---------- */
.pager { max-width: var(--content-max); display: flex; justify-content: space-between; gap: 16px; margin-top: 56px; }
.pager a {
  flex: 1 1 0; min-width: 0; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); color: var(--text);
  transition: border-color .15s;
}
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager a.next { text-align: right; }
.pager .pg-dir { font-size: 12px; color: var(--text-mut); }
.pager .pg-title { font-size: 15px; font-weight: 600; color: var(--accent); margin-top: 2px; }
.pager a.placeholder { visibility: hidden; }

.doc-footer { max-width: var(--content-max); margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }
.doc-footer p { font-size: 12.5px; color: var(--text-mut); margin: 0; }

/* ============================================================
   Search modal
   ============================================================ */
.search-modal {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  display: flex; justify-content: center; align-items: flex-start;
  padding-top: 12vh;
}
.search-modal[hidden] { display: none; }
.search-box {
  width: min(600px, 92vw);
  background: var(--bg-elev); border: 1px solid var(--border-strong);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
}
.search-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-mut); }
.search-input-row input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font: inherit; font-size: 16px; }
.search-results { max-height: 56vh; overflow-y: auto; padding: 8px; }
.search-results:empty::after { content: "Type to search the entire documentation."; display: block; padding: 22px 14px; color: var(--text-mut); font-size: 13px; text-align: center; }
.sr-item { display: block; padding: 10px 12px; border-radius: 9px; color: var(--text); }
.sr-item:hover, .sr-item.sel { background: var(--accent-soft); text-decoration: none; }
.sr-group { font-size: 11px; color: var(--text-mut); text-transform: uppercase; letter-spacing: .05em; }
.sr-title { font-weight: 600; font-size: 14px; margin-top: 1px; }
.sr-snippet { font-size: 12.5px; color: var(--text-mut); margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-item mark { background: transparent; color: var(--accent); font-weight: 700; }

/* ============================================================
   Syntax highlighting tokens
   ============================================================ */
.tok-comment { color: #6b7686; font-style: italic; }
.tok-keyword { color: #ff7b9c; }
.tok-type    { color: #5ccde3; }
.tok-string  { color: #9ece6a; }
.tok-number  { color: #ff9e64; }
.tok-func    { color: #7aa2f7; }
.tok-builtin { color: #e0af68; }
.tok-punct   { color: var(--text-mut); }
.tok-op      { color: #89ddff; }
.tok-meta    { color: #bb9af7; }
:root[data-theme="light"] .tok-comment { color: #6a737d; }
:root[data-theme="light"] .tok-keyword { color: #cf222e; }
:root[data-theme="light"] .tok-type    { color: #0550ae; }
:root[data-theme="light"] .tok-string  { color: #0a7d33; }
:root[data-theme="light"] .tok-number  { color: #953800; }
:root[data-theme="light"] .tok-func    { color: #6639ba; }
:root[data-theme="light"] .tok-builtin { color: #953800; }
:root[data-theme="light"] .tok-op      { color: #0550ae; }
:root[data-theme="light"] .tok-meta    { color: #8250df; }

/* ============================================================
   Responsivo
   ============================================================ */
.sidebar-backdrop { display: none; }

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

@media (max-width: 860px) {
  :root { --sidebar-w: 300px; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-toggle { display: grid; }
  .brand-text { font-size: 13.5px; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; z-index: 80;
    width: var(--sidebar-w); max-width: 84vw;
    background: var(--bg-elev); border-right: 1px solid var(--border-strong);
    transform: translateX(-105%); transition: transform .22s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 70; background: rgba(0,0,0,.45); }
  .content { padding: 30px 20px 60px; }
  .topbar-search { display: none; }
}

@media (max-width: 520px) {
  .brand-text { display: none; }
  .topbar { gap: 8px; padding: 0 12px; }
}
