/* ==========================================================================
   Zornux documentation — theme
   Plain CSS, custom properties, light/dark via [data-theme] on <html>.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f6f7f9;
  --bg-elevated: #ffffff;
  --text: #1b1f24;
  --text-soft: #5a636e;
  --text-faint: #8b95a1;
  --border: #e4e8ed;
  --border-strong: #d2d8e0;
  --brand: #5b3df5;
  --brand-soft: #efeaff;
  --brand-text: #4a2fd6;
  --accent: #14b8a6;
  --code-bg: #f4f3fb;
  --code-border: #e6e3f6;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);

  --kw: #b5179e;
  --str: #0b8a3e;
  --num: #b45309;
  --com: #8b95a1;

  --sidebar-w: 16rem;
  --header-h: 3.75rem;
  --content-max: 52rem;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --bg-soft: #161b22;
  --bg-elevated: #161b22;
  --text: #e6edf3;
  --text-soft: #aeb8c4;
  --text-faint: #7d8794;
  --border: #232a33;
  --border-strong: #313a45;
  --brand: #8b6dff;
  --brand-soft: #211c3a;
  --brand-text: #b6a4ff;
  --accent: #2dd4bf;
  --code-bg: #12151c;
  --code-border: #232a33;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);

  --kw: #ff7ad9;
  --str: #6ee7a0;
  --num: #fbbf73;
  --com: #6b7280;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

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

.boot {
  padding: 4rem;
  text-align: center;
  color: var(--text-faint);
}

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

/* ----------------------------------------------------------------- layout */

.shell { min-height: 100vh; }

.header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }

.brand .logo {
  width: 1.9rem;
  height: 1.9rem;
  display: block;
  object-fit: contain;
}

.brand .tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--brand-text);
  background: var(--brand-soft);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  margin-left: 0.1rem;
}

.header-spacer { flex: 1; }

.header-link {
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 500;
}
.header-link:hover { color: var(--text); text-decoration: none; }

.icon-btn {
  display: grid;
  place-items: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }

.menu-btn { display: none; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  align-items: start;
}

/* ---------------------------------------------------------------- sidebar */

.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);
  background: var(--bg);
}

.nav-section { margin-bottom: 1.5rem; }
.nav-section h4 {
  margin: 0 0 0.5rem;
  padding: 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.nav-section ul { list-style: none; margin: 0; padding: 0; }

.nav-section a {
  display: block;
  padding: 0.38rem 0.6rem;
  border-radius: 0.45rem;
  color: var(--text-soft);
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-section a:hover { background: var(--bg-soft); color: var(--text); text-decoration: none; }
.nav-section a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-text);
  font-weight: 600;
}

/* ---------------------------------------------------------------- content */

.main { min-width: 0; }

.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 2.5rem 1.75rem 5rem;
}

.content h1 {
  font-size: 2.25rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
}
.content h2 {
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  margin: 2.5rem 0 0.75rem;
  padding-top: 0.5rem;
}
.content h3 { font-size: 1.18rem; margin: 1.75rem 0 0.5rem; }
.content p { margin: 0.75rem 0; }
.content ul, .content ol { margin: 0.75rem 0; padding-left: 1.4rem; }
.content li { margin: 0.3rem 0; }
.content .lead { font-size: 1.2rem; color: var(--text-soft); margin-bottom: 1.5rem; }
.content strong { font-weight: 650; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand-text);
  margin-bottom: 0.5rem;
}

/* inline code */
:not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 0.35rem;
  padding: 0.1rem 0.35rem;
  color: var(--brand-text);
}

/* code block */
.code {
  position: relative;
  margin: 1.25rem 0;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 0.7rem;
  overflow: hidden;
}
.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.5rem 0.4rem 0.9rem;
  border-bottom: 1px solid var(--code-border);
  font-size: 0.74rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-transform: lowercase;
}
.code pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
  color: var(--text);
  tab-size: 4;
}
.code code { font-family: inherit; }
.copy-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-soft);
  border-radius: 0.4rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  cursor: pointer;
  font-family: var(--font-sans);
}
.copy-btn:hover { color: var(--text); border-color: var(--border-strong); }

.tok-kw { color: var(--kw); font-weight: 600; }
.tok-str { color: var(--str); }
.tok-num { color: var(--num); }
.tok-com { color: var(--com); font-style: italic; }

/* callouts */
.callout {
  margin: 1.25rem 0;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 0.5rem;
  background: var(--bg-soft);
}
.callout.note { border-left-color: var(--brand); }
.callout.tip { border-left-color: var(--accent); }
.callout.warn { border-left-color: #e0a106; }
.callout .callout-title { font-weight: 650; margin-bottom: 0.2rem; }
.callout p { margin: 0.2rem 0; }

/* tables */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.92rem;
}
.content th, .content td {
  text-align: left;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.content th { font-weight: 650; color: var(--text); background: var(--bg-soft); }
.content tbody tr:hover { background: var(--bg-soft); }
.content td code { white-space: nowrap; }

/* hero (home) */
.hero { padding: 1rem 0 1.5rem; }
.hero h1 {
  font-size: clamp(2.4rem, 5vw, 3.5rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin-bottom: 0.75rem;
}
.hero .grad {
  background: linear-gradient(120deg, var(--brand), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero .lead { font-size: 1.3rem; max-width: 40rem; }

.cta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin: 1.5rem 0 0.5rem; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.2rem;
  border-radius: 0.6rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-text); text-decoration: none; }
.btn-ghost { background: var(--bg-elevated); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--bg-soft); text-decoration: none; }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 2rem 0;
}
.feature {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.feature .ico { font-size: 1.4rem; }
.feature h3 { margin: 0.5rem 0 0.3rem; font-size: 1.05rem; }
.feature p { margin: 0; color: var(--text-soft); font-size: 0.92rem; }

/* pager */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.pager a {
  flex: 1;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  background: var(--bg-elevated);
}
.pager a:hover { border-color: var(--brand); text-decoration: none; }
.pager .dir { display: block; font-size: 0.74rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.pager .ttl { display: block; font-weight: 600; color: var(--text); margin-top: 0.15rem; }
.pager .next { text-align: right; }

.status-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600;
  padding: 0.15rem 0.6rem; border-radius: 999px;
}
.status-done { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.status-next { background: var(--brand-soft); color: var(--brand-text); }
.status-todo { background: var(--bg-soft); color: var(--text-faint); }

/* site footer */
.site-footer {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.5rem 1.75rem 2.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.site-footer p { margin: 0; }
.site-footer .footer-brand {
  font-weight: 650;
  color: var(--brand-text);
}

/* ------------------------------------------------------------- responsive */

.scrim { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .menu-btn { display: grid; }
  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    width: min(18rem, 82vw);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .scrim.show {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 35;
  }
  .header-link.hide-sm { display: none; }
}

/* Phones: reclaim reading width, and never let a wide table push the page
   sideways — it scrolls inside its own box instead. */
@media (max-width: 640px) {
  .content { padding: 1.75rem 1.1rem 4rem; }
  .content h1 { font-size: 1.9rem; }
  .content h2 { font-size: 1.35rem; }
  .hero .lead, .content .lead { font-size: 1.12rem; }
  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}
