/*
 * Copyright (C) 2026 StackGen, Inc. All rights reserved.
 * SPDX-License-Identifier: Apache-2.0
 */
/* chinit docs — clean, engaging, readable technical documentation. */
:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-side: #0f172a;
  --fg: #0f172a;
  --fg-soft: #475569;
  --fg-muted: #64748b;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eff6ff;
  --border: #e2e8f0;
  --crit: #b91c1c;
  --crit-bg: #fef2f2;
  --best: #1d4ed8;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --ok: #15803d;
  --ok-bg: #f0fdf4;
  --code-bg: #f1f5f9;
  --pre-bg: #0f172a;
  --pre-fg: #e2e8f0;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font: 16px/1.75 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}
code, pre, kbd {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
}
code {
  background: var(--code-bg);
  color: #1e293b;
  padding: .18em .42em;
  border-radius: 5px;
  border: 1px solid #e2e8f0;
}
pre {
  position: relative;
  background: var(--pre-bg);
  color: var(--pre-fg);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 16px 20px;
  overflow-x: auto;
  line-height: 1.55;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}
pre code {
  background: none;
  color: inherit;
  padding: 0;
  border: none;
  font-size: 0.9em;
}
/* Rouge syntax highlighting on dark pre background */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs { color: #94a3b8; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt { color: #93c5fd; font-weight: 600; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sc, .highlight .sd, .highlight .sh { color: #86efac; }
.highlight .na, .highlight .nl, .highlight .py { color: #7dd3fc; }
.highlight .nb, .highlight .bp { color: #fda4af; }
.highlight .nf, .highlight .fm, .highlight .nc, .highlight .nn { color: #fde047; }
.highlight .mi, .highlight .mf, .highlight .mh, .highlight .mo, .highlight .il { color: #f9a8d4; }
.highlight .nv, .highlight .vc, .highlight .vg, .highlight .vi { color: #c4b5fd; }
.highlight .o, .highlight .ow { color: #cbd5e1; }

/* --- sidebar --- */
.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: var(--bg-side);
  color: #cbd5e1;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #1e293b;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  border-radius: 9px;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
}
.brand-name { color: #fff; font-weight: 700; font-size: 21px; letter-spacing: .2px; }
.tagline { margin: 2px 0 6px; font-size: 13px; color: #94a3b8; line-height: 1.5; }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; margin-top: 8px; }
.nav-link {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 14.5px;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover { background: #1e293b; color: #fff; }
.nav-link.current {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.35);
}
.side-links {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #1e293b;
  font-size: 12.5px;
  color: #64748b;
}
.side-links a { color: #94a3b8; text-decoration: none; }
.side-links a:hover { color: #fff; text-decoration: underline; }

/* --- sidebar: badges & star CTA --- */
.sidebar-badges {
  margin: 0;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.sidebar-badges img { height: 20px; display: block; border-radius: 3px; }
.star-cta {
  display: block;
  text-align: center;
  margin-top: 6px;
  padding: 9px 12px;
  background: linear-gradient(135deg, #f8c555, #eab308);
  color: #1c1917;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  border-radius: 8px;
  transition: filter 0.15s ease, transform 0.1s ease;
}
.star-cta:hover { filter: brightness(1.06); transform: translateY(-1px); text-decoration: none; }

/* --- accessibility --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; text-decoration: none; }

/* --- main --- */
main {
  flex: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 52px 40px 96px;
  min-width: 0;
}
h1 {
  font-size: 36px;
  line-height: 1.18;
  margin: 0 0 12px;
  letter-spacing: -.02em;
  color: #0f172a;
}
/* pronunciation / name etymology line under the h1 on the home page */
p.pronunciation {
  margin: -2px 0 18px;
  font-size: 15.5px;
  color: var(--fg-muted);
}
p.pronunciation strong { color: var(--fg-soft); }
h1 + p.lead, p.lead {
  font-size: 19px;
  line-height: 1.65;
  color: var(--fg-soft);
  margin-top: 0;
  margin-bottom: 24px;
}
h2 {
  font-size: 24px;
  line-height: 1.3;
  margin-top: 52px;
  margin-bottom: 14px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  letter-spacing: -.01em;
}
h3 {
  font-size: 18.5px;
  margin-top: 32px;
  margin-bottom: 10px;
  color: #1e293b;
}
h4 {
  font-size: 16px;
  margin-top: 24px;
  margin-bottom: 8px;
  color: #334155;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { padding-left: 22px; }
li { margin-bottom: 6px; }
li > strong { color: #0f172a; }

blockquote {
  margin: 24px 0;
  padding: 14px 20px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 10px 10px 0;
  color: #1e3a8a;
}
blockquote p:first-child { margin-top: 0; }
blockquote p:last-child { margin-bottom: 0; }

/* --- cards & callouts --- */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.card {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.card h3, .card h4 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 16.5px;
}
.card p {
  margin: 0;
  font-size: 14.5px;
  color: var(--fg-soft);
}
.callout {
  margin: 24px 0;
  padding: 16px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.callout-title {
  font-weight: 700;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.callout-warn {
  background: var(--warn-bg);
  border-color: #fcd34d;
  color: #78350f;
}
.callout-crit {
  background: var(--crit-bg);
  border-color: #fecaca;
  color: #7f1d1d;
}
.callout-ok {
  background: var(--ok-bg);
  border-color: #bbf7d0;
  color: #14532d;
}

/* --- tables --- */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 22px 0;
  font-size: 14.5px;
  border-radius: 8px;
  overflow: hidden;
}
th, td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
}
th {
  background: #f1f5f9;
  font-weight: 600;
  color: #0f172a;
}
tr:nth-child(even) td { background: #f8fafc; }

/* --- horizontal scroll wrapper for wide tables (added via JS) --- */
.table-wrap { overflow-x: auto; margin: 22px 0; }
.table-wrap > table { margin: 0; }

/* --- diagrams --- */
.mermaid-figure {
  margin: 28px 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #ffffff;
  text-align: center;
  overflow-x: auto;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.mermaid-figure svg { max-width: 100%; height: auto; }

/* --- copy-to-clipboard buttons --- */
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font: 600 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  color: #cbd5e1;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
pre:hover .copy-btn, .copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { background: #334155; color: #fff; }
.copy-btn.copied { background: #14532d; border-color: #166534; color: #bbf7d0; opacity: 1; }

/* --- heading anchor links --- */
.anchor-link {
  margin-left: 8px;
  font-size: 0.75em;
  font-weight: 400;
  color: var(--fg-muted);
  opacity: 0;
  text-decoration: none;
  transition: opacity 0.15s ease, color 0.15s ease;
}
h2:hover .anchor-link, h3:hover .anchor-link, h4:hover .anchor-link,
.anchor-link:focus-visible { opacity: 1; }
.anchor-link:hover { color: var(--accent); text-decoration: none; }

/* --- landing-page badge & call-to-action rows --- */
.badges-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 18px 0 4px;
}
.badges-row img { height: 22px; display: block; border-radius: 4px; }
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 22px 0;
}
.button {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 9px;
  font-weight: 650;
  font-size: 15px;
  text-decoration: none;
  border: 1px solid transparent;
  transition: filter 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.button:hover { text-decoration: none; transform: translateY(-1px); }
.button-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.35);
}
.button-primary:hover { background: var(--accent-dark); color: #fff; }
.button-secondary {
  background: #fff;
  color: var(--accent-dark);
  border-color: #bfdbfe;
}
.button-secondary:hover { border-color: var(--accent); color: var(--accent-dark); }
.button-github {
  background: #0f172a;
  color: #fff;
}
.button-github:hover { background: #1e293b; color: #fbbf24; }

/* --- footer --- */
.doc-footer {
  margin-top: 64px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 13.5px;
  color: var(--fg-muted);
}

/* --- small screens --- */
@media (max-width: 860px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px;
  }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; margin-top: 0; }
  .tagline, .side-links, .star-cta, .sidebar-badges { display: none; }
  /* In a column flex container, cross-axis `margin: 0 auto` disables
     stretch and lets max-width: 920px balloon main past the viewport —
     pin it to full width instead. */
  main { width: 100%; margin: 0; padding: 28px 18px 64px; }
  .copy-btn { opacity: 1; }  /* touchscreens have no hover */
}
