/* Zinc documentation site — styled after odin-lang.org / pkg.odin-lang.org.
   Colors and layout rhythm are taken directly from their published
   stylesheets (odin-lang.org/css/style.css, odin-lang.org/scss/custom.min.css,
   pkg.odin-lang.org/style.css) and adapted for Zinc. Light mode is the
   default; a `data-theme="dark"` attribute on <html> switches to dark mode
   (see site.js). No build step or network access is required to view this
   site — open any .html file directly in a browser.
*/

:root {
  --bg: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #f8f8f8;
  --text: #212529;
  --text-muted: #666666;
  --border: #dee2e6;
  --border-strong: #c6c8ca;
  --link: #2179d8;
  --link-procedure: #047919;
  --accent: #3882d2;
  --accent-strong: #1b46a4;
  --header-bg: #ffffff;
  --header-border: #dee2e6;
  --sidebar-bg: #ffffff;
  --code-bg: #f8f8f8;
  --code-border: #c6c8ca;
  --code-text: #202224;
  --toc-active: #3882d2;
  --kw: #d6394a;
  --str: #0a7a3d;
  --num: #1670c9;
  --comment: #888888;
  --directive: #0055aa;
  --table-stripe: #f8f8f8;
  --btn-bg: #f1f3f5;
  --btn-border: #ced4da;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #0d1117;
  --bg-tertiary: #1c1c20;
  --text: #e0f0ff;
  --text-muted: #9aa7b0;
  --border: #242f3f;
  --border-strong: #242f3f;
  --link: #63a6ef;
  --link-procedure: #42b557;
  --accent: #7aade5;
  --accent-strong: #7aade5;
  --header-bg: #0d1117;
  --header-border: #242f3f;
  --sidebar-bg: #0d1117;
  --code-bg: #182028;
  --code-border: #242f3f;
  --code-text: #e0f0ff;
  --toc-active: #ffaa44;
  --kw: #ff5252;
  --str: #4fd17a;
  --num: #79c0ff;
  --comment: #8a97a0;
  --directive: #6fa8dc;
  --table-stripe: #161b22;
  --btn-bg: #1c1c20;
  --btn-border: #242f3f;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --bg-secondary: #0d1117;
    --bg-tertiary: #1c1c20;
    --text: #e0f0ff;
    --text-muted: #9aa7b0;
    --border: #242f3f;
    --border-strong: #242f3f;
    --link: #63a6ef;
    --link-procedure: #42b557;
    --accent: #7aade5;
    --accent-strong: #7aade5;
    --header-bg: #0d1117;
    --header-border: #242f3f;
    --sidebar-bg: #0d1117;
    --code-bg: #182028;
    --code-border: #242f3f;
    --code-text: #e0f0ff;
    --toc-active: #ffaa44;
    --kw: #ff5252;
    --str: #4fd17a;
    --num: #79c0ff;
    --comment: #8a97a0;
    --directive: #6fa8dc;
    --table-stripe: #161b22;
    --btn-bg: #1c1c20;
    --btn-border: #242f3f;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 70px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

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

code, pre, kbd, .mono {
  font-family: Consolas, "Liberation Mono", Menlo, monospace;
}

code:not(pre code) {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 0.25rem;
  padding: 0.1em 0.35em;
  font-size: 0.88em;
  color: var(--code-text);
}

/* ---------- header ---------- */

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 59px;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.25rem;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
}

.site-header .logo {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.site-header .logo:hover { text-decoration: none; }
/* .site-header .logo .dot { color: var(--accent); } */

.site-nav {
  display: flex;
  gap: 1.1rem;
  flex: 1;
  overflow-x: auto;
}
.site-nav a {
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  white-space: nowrap;
  padding: 0.4rem 0;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--text); text-decoration: none; }
.site-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

.theme-toggle {
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 0.35rem;
  width: 2.1rem;
  height: 2.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle svg { width: 1.05rem; height: 1.05rem; fill: var(--text); }
:root[data-theme="dark"] .icon-sun,
:root:not([data-theme="light"]) .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon,
body:not([data-theme]) .icon-moon { display: inline; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-moon { display: inline; }
  :root:not([data-theme="light"]) .icon-sun { display: none; }
}

.menu-toggle {
  display: none;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 0.35rem;
  width: 2.1rem;
  height: 2.1rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
}

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

.shell {
  display: flex;
  padding-top: 59px;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--sidebar-bg);
  position: fixed;
  top: 59px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 1.25rem 1rem 3rem;
}

.content-wrap {
  margin-left: 260px;
  flex: 1;
  display: flex;
  min-width: 0;
  width: calc(100% - 260px);
}

.content {
  flex: 1;
  min-width: 0;
  padding: 2rem 2.5rem 5rem;
  max-width: 900px;
}

.content.wide { max-width: none; }

.page-toc {
  width: 230px;
  flex-shrink: 0;
  padding: 2rem 1.25rem 3rem 0;
  border-left: 1px solid var(--border);
}

.page-toc-inner { position: sticky; top: 80px; }
.page-toc h6 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0 0 0.6rem;
}
.page-toc ul { list-style: none; padding: 0; margin: 0; }
.page-toc li { margin-bottom: 0.35rem; }
.page-toc a {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: block;
  padding-left: 0.6rem;
  border-left: 2px solid transparent;
}
.page-toc a.active {
  color: var(--toc-active);
  font-weight: 600;
  border-left-color: var(--toc-active);
}
.page-toc ul ul { padding-left: 0.85rem; }

@media (max-width: 1200px) {
  .page-toc { display: none; }
}

@media (max-width: 900px) {
  .menu-toggle { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.15s ease;
    z-index: 999;
    width: 82vw;
    max-width: 320px;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .content-wrap { margin-left: 0; width: 100%; }
  .content { padding: 1.5rem 1.25rem 4rem; }
  .site-nav { display: none; }
}

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

.sidebar h6 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin: 1.4rem 0 0.5rem;
}
.sidebar h6:first-child { margin-top: 0; }

.sidebar ul { list-style: none; padding: 0; margin: 0; }
.sidebar li { margin-bottom: 0.15rem; }
.sidebar a {
  display: block;
  padding: 0.28rem 0.5rem;
  border-radius: 0.3rem;
  color: var(--text);
  font-size: 0.9rem;
}
.sidebar a:hover { background: var(--bg-tertiary); text-decoration: none; }
.sidebar a.active { background: var(--bg-tertiary); font-weight: 600; color: var(--accent); }
.sidebar .sub { padding-left: 1rem; font-size: 0.85rem; color: var(--text-muted); }
.sidebar .sub-list { padding-left: 0.6rem; }

.sidebar-search {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  border-radius: 0.3rem;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}
.sidebar-search:focus { outline: none; border-color: var(--accent); }

/* ---------- prose ---------- */

.content h1 {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 0.3rem;
}
.content > .lede {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 2rem;
}
.content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}
.content h2:first-of-type { border-top: none; padding-top: 0; }
.content h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 1.75rem 0 0.75rem;
}
.content h4 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 1.4rem 0 0.5rem;
}
.content p { margin: 0.75rem 0; }
.content ul, .content ol { margin: 0.75rem 0; padding-left: 1.5rem; }
.content li { margin: 0.3rem 0; }
.content hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.content h2 a.anchor, .content h3 a.anchor, .content h4 a.anchor {
  opacity: 0;
  margin-left: 0.4rem;
  font-weight: 400;
  color: var(--text-muted);
}
.content h2:hover a.anchor,
.content h3:hover a.anchor,
.content h4:hover a.anchor { opacity: 1; text-decoration: none; }

/* autonumbered long-form pages (overview, spec) */
.content.autonumber { counter-reset: h2; }
.content.autonumber h2 { counter-reset: h3; }
.content.autonumber h3 { counter-reset: h4; }
.content.autonumber h2::before { counter-increment: h2; content: counter(h2) ". "; color: var(--accent); }
.content.autonumber h3::before { counter-increment: h3; content: counter(h2) "." counter(h3) ". "; color: var(--accent); }
.content.autonumber h4::before { counter-increment: h4; content: counter(h2) "." counter(h3) "." counter(h4) ". "; color: var(--accent); }

.note {
  background: var(--bg-tertiary);
  border-left: 3px solid var(--accent);
  border-radius: 0.25rem;
  padding: 0.75rem 1rem;
  margin: 1.25rem 0;
  font-size: 0.95rem;
}
.note strong { color: var(--accent-strong); }
:root[data-theme="dark"] .note strong,
:root:not([data-theme="light"]) .note strong { color: var(--accent); }

/* ---------- tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.25rem 0;
  font-size: 0.92rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
tbody tr:nth-child(even) { background: var(--table-stripe); }
td code, th code { white-space: nowrap; }

.table-wrap { overflow-x: auto; margin: 1.25rem 0; }
.table-wrap table { margin: 0; }

/* ---------- code blocks ---------- */

pre {
  background: var(--code-bg);
  color: var(--code-text);
  border: 1px solid var(--code-border);
  border-radius: 0.35rem;
  padding: 0.85rem 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.88rem;
  line-height: 1.55;
  tab-size: 4;
}
pre code { background: none; border: none; padding: 0; font-size: inherit; color: inherit; }

.zc-kw { color: var(--kw); font-weight: 600; }
.zc-type { color: var(--kw); }
.zc-str { color: var(--str); }
.zc-num { color: var(--num); }
.zc-com { color: var(--comment); font-style: italic; }
.zc-dir { color: var(--directive); }
.zc-fn { color: var(--link-procedure); }

/* ---------- stdlib entity / signature blocks ---------- */

.pkg-header {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.pkg-header .kind-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

.pkg-index {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  columns: 2;
  column-gap: 2rem;
}
@media (max-width: 700px) { .pkg-index { columns: 1; } }
.pkg-index li { break-inside: avoid; margin-bottom: 0.15rem; }
.pkg-index code { background: none; border: none; padding: 0; }

.pkg-entity {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 75px;
}
.pkg-entity:last-child { border-bottom: none; }
.pkg-entity h3 {
  margin: 0 0 0.6rem;
  font-family: Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 1.05rem;
}
.pkg-entity .sig {
  margin: 0 0 0.6rem;
}
.pkg-entity .doc {
  color: var(--text);
  font-size: 0.95rem;
}
.pkg-entity .doc p { margin: 0.4rem 0; }

.module-blurb { color: var(--text-muted); margin-bottom: 1.5rem; }

.badge-native, .badge-zn {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-radius: 0.25rem;
  padding: 0.1rem 0.4rem;
  margin-left: 0.4rem;
  vertical-align: middle;
}
.badge-native { background: rgba(56, 130, 210, 0.15); color: var(--accent); }
.badge-zn { background: rgba(4, 121, 25, 0.15); color: var(--link-procedure); }

/* ---------- landing page ---------- */

.hero {
  padding: 3.5rem 0 2.5rem;
  text-align: center;
}
.hero h1 { font-size: 2.6rem; margin-bottom: 0.5rem; }
.hero p { color: var(--text-muted); font-size: 1.15rem; max-width: 640px; margin: 0 auto; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
  margin: 2rem 0;
}
.card {
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1.5rem;
  background: var(--bg-secondary);
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--accent); }
.card h3 { margin: 0 0 0.4rem; font-size: 1.15rem; }
.card p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }
.card a.card-link { display: block; }
.card a.card-link:hover { text-decoration: none; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 1.5rem 2.5rem;
}
