/* acorn: the monad-lang.org site styles. The palette is the landing page's
   (docs/site/sass/landing.scss); the book layout replaces mdBook's theme. */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-hover: #1c2330;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-bright: #79c0ff;
  --accent-dim: #1f6feb;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --radius: 8px;
  --sidebar: 260px;
  --content: 780px;
  color-scheme: dark;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

/* ---- Header ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.site-header .brand { color: var(--text); font-weight: 600; font-size: 17px; }
.site-header .brand:hover { text-decoration: none; }
.site-nav { display: flex; gap: 20px; font-size: 14px; }
.site-nav a { color: var(--text-muted); }
.site-nav a:hover { color: var(--text); text-decoration: none; }

/* ---- Book layout ---- */
.book {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: calc(100vh - 50px);
}
.sidebar {
  position: sticky;
  top: 50px;
  align-self: start;
  max-height: calc(100vh - 50px);
  overflow-y: auto;
  padding: 20px 12px 40px 20px;
  border-right: 1px solid var(--border);
  font-size: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar ol { list-style: none; margin: 0; padding: 0; }
.sidebar .part-title {
  margin: 18px 0 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.sidebar .chapter a {
  display: block;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--text);
}
.sidebar .chapter a:hover { background: var(--bg-hover); text-decoration: none; }
.sidebar .chapter.active a { background: var(--bg-card); color: var(--accent-bright); font-weight: 600; }
.sidebar .depth-1 { padding-left: 14px; }
.sidebar .depth-2 { padding-left: 28px; }

.content {
  width: 100%;
  max-width: var(--content);
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ---- Prose ---- */
.content h1 { font-size: 2em; line-height: 1.25; margin: 0 0 0.6em; letter-spacing: -0.02em; }
.content h2 { font-size: 1.5em; margin: 1.8em 0 0.6em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.content h3 { font-size: 1.2em; margin: 1.5em 0 0.5em; }
.content h4 { font-size: 1em; margin: 1.3em 0 0.4em; }
.content p, .content ul, .content ol, .content table, .content pre, .content blockquote { margin: 0 0 1em; }
.content ul, .content ol { padding-left: 1.6em; }
.content li + li { margin-top: 0.25em; }
.content img { max-width: 100%; }
.content hr { border: 0; border-top: 1px solid var(--border); margin: 2em 0; }

.content blockquote {
  margin-left: 0;
  padding: 0.2em 1em;
  color: var(--text-muted);
  border-left: 3px solid var(--border);
}

.content table { border-collapse: collapse; display: block; overflow-x: auto; }
.content th, .content td { padding: 6px 12px; border: 1px solid var(--border); text-align: left; }
.content th { background: var(--bg-card); }

/* ---- Code ---- */
code { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code {
  padding: 0.15em 0.35em;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
}
pre {
  padding: 14px 16px;
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  line-height: 1.5;
}
pre code { font-size: 13.5px; }

/* Highlight classes (shared with the landing page's hand-written spans). */
.kw { color: var(--purple); }
.fn { color: var(--accent-bright); }
.type { color: var(--orange); }
.num { color: var(--green); }
.str { color: #a5d6ff; }
.comment { color: var(--text-muted); font-style: italic; }
.attr { color: var(--orange); }

/* ---- Heading self-links ---- */
.content h2, .content h3, .content h4 { scroll-margin-top: 64px; }
.content .anchor {
  margin-left: 0.35em;
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0;
  transition: opacity 0.1s;
}
.content h2:hover .anchor, .content h3:hover .anchor, .content h4:hover .anchor,
.content .anchor:focus { opacity: 1; text-decoration: none; }

/* ---- On-page TOC (wide screens only) ---- */
.toc { display: none; }
@media (min-width: 1200px) {
  .book { grid-template-columns: var(--sidebar) minmax(0, 1fr) 220px; }
  .toc {
    display: block;
    position: sticky;
    top: 50px;
    align-self: start;
    max-height: calc(100vh - 50px);
    overflow-y: auto;
    padding: 32px 20px 40px 8px;
    font-size: 13px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .toc-title {
    margin: 0 0 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }
  .toc ol { list-style: none; margin: 0; padding: 0; }
  .toc li { margin: 0; }
  .toc a { display: block; padding: 3px 0; color: var(--text-muted); }
  .toc a:hover { color: var(--text); text-decoration: none; }
  .toc .toc-h3 { padding-left: 12px; }
}

/* ---- Admonitions ---- */
.admonition {
  margin: 0 0 1em;
  padding: 0.6em 1em;
  border-left: 4px solid var(--accent-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--bg-card);
}
.admonition > :last-child { margin-bottom: 0; }
.admonition-title { margin-bottom: 0.3em; font-weight: 600; }
.admonition.note .admonition-title { color: var(--accent); }
.admonition.tip { border-left-color: var(--green); }
.admonition.tip .admonition-title { color: var(--green); }
.admonition.important { border-left-color: var(--purple); }
.admonition.important .admonition-title { color: var(--purple); }
.admonition.warning { border-left-color: var(--orange); }
.admonition.warning .admonition-title { color: var(--orange); }
.admonition.caution { border-left-color: var(--red); }
.admonition.caution .admonition-title { color: var(--red); }

/* ---- Pager ---- */
.pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 3em;
  padding-top: 1.5em;
  border-top: 1px solid var(--border);
}
.pager a {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.pager a:hover { border-color: var(--accent-dim); text-decoration: none; }
.pager .next { margin-left: auto; text-align: right; }
.pager-label { color: var(--text-muted); font-size: 12px; }

/* ---- Footer ---- */
.site-footer {
  padding: 24px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* ---- Narrow screens: the sidebar folds above the content ---- */
@media (max-width: 860px) {
  .book { display: block; }
  .sidebar {
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .content { padding: 24px 16px 48px; }
}

/* ---- Print (print.html, or any page): the content alone ---- */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; color: #000; }
  .site-header, .sidebar, .toc, .pager, .site-footer, .content .anchor { display: none; }
  .book { display: block; }
  .content { max-width: none; padding: 0; }
  pre, :not(pre) > code { background: #f6f8fa; border-color: #d0d7de; }
}
