/* Netherrack docs - shared stylesheet.
   Themes: follows the visitor's system setting, unless they picked one with the toggle
   (saved as data-theme="light" or "dark" on <html>). */

:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --max: 1100px;

  /* light theme */
  --bg: #fbf8f6;
  --surface: #ffffff;
  --text: #1d1b1a;
  --muted: #5d5551;
  --border: #e4dbd7;
  --accent: #a62a2f;
  --accent-hover: #86191e;
  --on-accent: #ffffff;
  --code-bg: #f1e9e5;
  --pre-bg: #1c1617;
  --pre-text: #f2eae7;
  --note: #2b6aaa;
  --tip: #2a7d46;
  --warning: #a35505;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #141011;
  --surface: #1e1819;
  --text: #efe9e6;
  --muted: #b6aba6;
  --border: #382c2d;
  --accent: #ff7a73;
  --accent-hover: #ffa09b;
  --on-accent: #1a0c0c;
  --code-bg: #2a2122;
  --pre-bg: #0d0a0a;
  --pre-text: #f2eae7;
  --note: #7db4ee;
  --tip: #7fd49b;
  --warning: #f0b35c;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141011;
    --surface: #1e1819;
    --text: #efe9e6;
    --muted: #b6aba6;
    --border: #382c2d;
    --accent: #ff7a73;
    --accent-hover: #ffa09b;
    --on-accent: #1a0c0c;
    --code-bg: #2a2122;
    --pre-bg: #0d0a0a;
    --pre-text: #f2eae7;
    --note: #7db4ee;
    --tip: #7fd49b;
    --warning: #f0b35c;
    color-scheme: dark;
  }
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font: 1rem/1.65 var(--font);
  background: var(--bg);
  color: var(--text);
}

img { max-width: 100%; height: auto; }

a { color: var(--accent); text-underline-offset: 0.18em; }
a:hover { color: var(--accent-hover); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.skip-link {
  position: absolute; left: 0.75rem; top: -4rem; z-index: 100;
  background: var(--accent); color: var(--on-accent);
  padding: 0.6rem 1rem; border-radius: var(--radius); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 0.75rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- logo / theme swapping ---------- */

.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline-block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-light { display: none; }
  :root:not([data-theme="light"]) .logo-dark { display: inline-block; }
}

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

.site-header {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--max); margin: 0 auto; padding: 0.6rem 1.25rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1.25rem;
}

.brand { display: inline-flex; align-items: center; line-height: 0; }
.brand img { height: 34px; width: auto; }

.site-nav { flex: 1 1 auto; }
.site-nav ul { display: flex; flex-wrap: wrap; gap: 0.15rem; list-style: none; margin: 0; padding: 0; }
.site-nav a {
  display: block; padding: 0.4rem 0.7rem; border-radius: 8px;
  color: var(--text); text-decoration: none; font-weight: 500; font-size: 0.95rem;
}
.site-nav a:hover { background: var(--code-bg); color: var(--text); }
.site-nav a[aria-current="page"] { background: var(--code-bg); color: var(--accent); font-weight: 700; }

.header-tools { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.4rem; height: 2.4rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; text-decoration: none;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 1.2rem; height: 1.2rem; fill: currentColor; }

.theme-toggle { display: none; }
.js .theme-toggle { display: inline-flex; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

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

.page {
  max-width: var(--max); margin: 0 auto; padding: 2rem 1.25rem 4rem;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 2.5rem;
}

@media (min-width: 1000px) {
  .page.has-toc { grid-template-columns: minmax(0, 1fr) 230px; }
}

.content { min-width: 0; max-width: 820px; }
.page:not(.has-toc) .content { max-width: none; }

.toc {
  position: sticky; top: 5.5rem; align-self: start;
  max-height: calc(100vh - 7rem); overflow: auto;
  font-size: 0.9rem; border-left: 1px solid var(--border); padding-left: 1rem;
}
.toc[hidden] { display: none; }
@media (max-width: 999px) { .toc { display: none; } }
.toc-title { margin: 0 0 0.5rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0.15rem 0; }
.toc a { display: block; padding: 0.2rem 0; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent); font-weight: 600; }

/* ---------- typography ---------- */

.content h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 0.75rem; }
.content h2 { font-size: 1.5rem; line-height: 1.3; margin: 2.75rem 0 0.75rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.content h2:first-of-type, .content .lead + h2 { margin-top: 2rem; }
.content h3 { font-size: 1.15rem; margin: 1.9rem 0 0.5rem; }
.content p { margin: 0.85rem 0; }
.content ul, .content ol { padding-left: 1.4rem; margin: 0.85rem 0; }
.content li { margin: 0.3rem 0; }

.lead { font-size: 1.15rem; color: var(--muted); margin: 0 0 1.25rem; }

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

code {
  font-family: var(--mono); font-size: 0.9em;
  background: var(--code-bg); padding: 0.12em 0.38em; border-radius: 5px;
  overflow-wrap: anywhere;
}

.code-wrap { position: relative; margin: 1rem 0; }
pre {
  margin: 0; padding: 1rem 1.1rem; overflow: auto;
  background: var(--pre-bg); color: var(--pre-text);
  border: 1px solid var(--border); border-radius: var(--radius);
  font: 0.88rem/1.55 var(--mono);
}
pre code { background: none; padding: 0; font-size: inherit; color: inherit; overflow-wrap: normal; }
.code-label {
  display: block; margin: 1.1rem 0 -0.55rem; font-size: 0.8rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted);
}

.copy-btn {
  position: absolute; top: 0.45rem; right: 0.45rem;
  padding: 0.25rem 0.6rem; font: 600 0.75rem var(--font);
  background: #3a2f30; color: #f2eae7; border: 1px solid #5a4a4b; border-radius: 6px; cursor: pointer;
}
.copy-btn:hover { background: #4a3d3e; }

kbd {
  font: 0.85em var(--mono); background: var(--surface); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 5px; padding: 0.05em 0.4em;
}

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

.table-wrap { overflow-x: auto; margin: 1.1rem 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { text-align: left; vertical-align: top; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }

.status { display: inline-block; padding: 0.05rem 0.5rem; border-radius: 999px; font-size: 0.78rem; font-weight: 700; white-space: nowrap; border: 1px solid currentColor; }
.status-ok { color: var(--tip); }
.status-no { color: var(--warning); }

/* ---------- callouts ---------- */

.callout {
  --c: var(--note);
  margin: 1.25rem 0; padding: 0.85rem 1.1rem;
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--c);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout-title { display: block; font-weight: 700; color: var(--c); margin-bottom: 0.2rem; }
.callout-tip { --c: var(--tip); }
.callout-warning { --c: var(--warning); }
.callout-danger { --c: var(--accent); }

/* ---------- buttons, cards, hero ---------- */

.btn {
  display: inline-block; padding: 0.6rem 1.15rem; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }

.hero { text-align: center; padding: 1.5rem 0 0.5rem; }
.hero-logo { margin: 0 0 1rem; line-height: 0; }
.hero-logo img { width: min(560px, 92%); height: auto; }
.hero .lead { max-width: 40rem; margin: 0 auto 1.5rem; font-size: 1.25rem; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; margin: 0 0 1.25rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; list-style: none; margin: 0; padding: 0; }
.chips li { margin: 0; padding: 0.15rem 0.7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 0.82rem; color: var(--muted); }

.home .content { max-width: none; }
.home h2 { border-top: 0; padding-top: 0; margin-top: 3rem; text-align: center; }
.section-intro { text-align: center; color: var(--muted); max-width: 40rem; margin: 0 auto 1.5rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; margin: 1.25rem 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; }
.card h3 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.card p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.home .narrow { max-width: 760px; margin-left: auto; margin-right: auto; }

/* ---------- numbered steps ---------- */

.steps { counter-reset: step; list-style: none; padding: 0; margin: 1.25rem 0; }
.steps > li { counter-increment: step; position: relative; padding-left: 3rem; margin: 1.4rem 0; }
.steps > li::before {
  content: counter(step); position: absolute; left: 0; top: 0;
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: var(--accent); color: var(--on-accent);
}
.steps > li > :first-child { margin-top: 0; }

.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 { display: block; padding: 0.7rem 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-decoration: none; font-weight: 600; }
.pager a:hover { border-color: var(--accent); }
.pager small { display: block; color: var(--muted); font-weight: 400; }
.pager .next { margin-left: auto; text-align: right; }

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

.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; }
.footer-inner { max-width: var(--max); margin: 0 auto; padding: 1.75rem 1.25rem 2.5rem; display: grid; gap: 0.6rem; }
.footer-inner p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.25rem 1.1rem; list-style: none; margin: 0; padding: 0; }

@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

@media (max-width: 640px) {
  .content h1 { font-size: 1.75rem; }
  .content h2 { font-size: 1.3rem; }
  .header-tools { order: 2; }
  .site-nav { order: 3; flex-basis: 100%; }
}

@media print {
  .site-header, .toc, .copy-btn, .site-footer, .skip-link, .pager { display: none; }
  body { background: #fff; color: #000; }
  .page { display: block; padding: 0; }
  pre { white-space: pre-wrap; }
}
