/* Basalt documentation — one stylesheet, no framework. */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f6;
  --fg: #1c1b1a;
  --fg-muted: #6a6763;
  --border: #e3e1de;
  --accent: #8a4b2a;
  --accent-soft: #f4ece7;
  --code-bg: #f5f3f1;
  --warn-border: #c98a3a;
  --font: ui-sans-serif, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;
  --measure: 46rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --bg-soft: #1d1c1a;
    --fg: #e8e6e3;
    --fg-muted: #a19c96;
    --border: #302e2b;
    --accent: #d99a6c;
    --accent-soft: #2a2320;
    --code-bg: #201f1d;
    --warn-border: #b3803c;
  }
}

:root[data-theme='dark'] {
  --bg: #161514;
  --bg-soft: #1d1c1a;
  --fg: #e8e6e3;
  --fg-muted: #a19c96;
  --border: #302e2b;
  --accent: #d99a6c;
  --accent-soft: #2a2320;
  --code-bg: #201f1d;
  --warn-border: #b3803c;
}

:root[data-theme='light'] {
  --bg: #ffffff;
  --bg-soft: #f7f7f6;
  --fg: #1c1b1a;
  --fg-muted: #6a6763;
  --border: #e3e1de;
  --accent: #8a4b2a;
  --accent-soft: #f4ece7;
  --code-bg: #f5f3f1;
  --warn-border: #c98a3a;
}

* {
  box-sizing: border-box;
}

html {
  scroll-padding-top: 5rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  -webkit-text-size-adjust: 100%;
}

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

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 0.5rem;
  z-index: 20;
  background: var(--bg);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* --- top bar --------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.75rem 1.5rem;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--fg);
}

.brand span {
  color: var(--fg-muted);
  font-weight: 400;
}

.tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
}

.tools input {
  font: inherit;
  padding: 0.3rem 0.6rem;
  width: 12rem;
  max-width: 40vw;
  color: var(--fg);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.tools input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.tools button {
  font: inherit;
  cursor: pointer;
  color: var(--fg-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
}

#results {
  position: absolute;
  top: 100%;
  right: 1.5rem;
  width: min(30rem, 90vw);
  max-height: 60vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgb(0 0 0 / 12%);
}

#results a {
  display: block;
  padding: 0.5rem 0.9rem;
  text-decoration: none;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
}

#results a:last-child {
  border-bottom: 0;
}

#results a:hover,
#results a:focus-visible {
  background: var(--accent-soft);
}

#results small {
  display: block;
  color: var(--fg-muted);
}

#results p {
  margin: 0;
  padding: 0.75rem 0.9rem;
  color: var(--fg-muted);
}

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

.layout {
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr) 14rem;
  gap: 2.5rem;
  max-width: 84rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
  align-items: start;
}

.sidebar,
.toc {
  position: sticky;
  top: 4.5rem;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  font-size: 0.9rem;
}

.sidebar ul,
.toc ul {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
}

.sidebar li,
.toc li {
  margin: 0.15rem 0;
}

.sidebar a,
.toc a {
  display: block;
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
  color: var(--fg-muted);
  text-decoration: none;
}

.sidebar a:hover,
.toc a:hover {
  color: var(--fg);
  background: var(--bg-soft);
}

.sidebar a.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 550;
}

.nav-title {
  margin: 0 0 0.35rem;
  padding-left: 0.5rem;
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.toc .d3 a {
  padding-left: 1.4rem;
  font-size: 0.85rem;
}

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

main {
  min-width: 0;
}

article {
  max-width: var(--measure);
}

article h1 {
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 1.5rem;
}

article h2 {
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  margin: 2.75rem 0 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

article h3 {
  font-size: 1.08rem;
  margin: 2rem 0 0.5rem;
}

article h4 {
  font-size: 0.95rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--fg-muted);
}

article p,
article li {
  overflow-wrap: break-word;
}

article ul,
article ol {
  padding-left: 1.35rem;
}

article li {
  margin: 0.3rem 0;
}

article code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

article pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  line-height: 1.55;
}

article pre code {
  background: none;
  padding: 0;
  font-size: 0.83rem;
}

article blockquote {
  margin: 1.5rem 0;
  padding: 0.1rem 1.1rem;
  border-left: 3px solid var(--warn-border);
  background: var(--bg-soft);
  border-radius: 0 6px 6px 0;
}

article hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

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

article table {
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 100%;
}

article th,
article td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.7rem;
  text-align: left;
  vertical-align: top;
}

article th {
  background: var(--bg-soft);
  font-weight: 600;
}

main footer {
  max-width: var(--measure);
  margin-top: 4rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

main footer a {
  color: var(--fg-muted);
}

/* --- syntax highlighting (lowlight class names) ----------------------- */

.hljs-comment,
.hljs-quote {
  color: var(--fg-muted);
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-section {
  color: var(--accent);
}

.hljs-string,
.hljs-attr,
.hljs-symbol,
.hljs-bullet,
.hljs-addition {
  color: #3f7d58;
}

.hljs-number,
.hljs-meta {
  color: #7a6ac0;
}

.hljs-title,
.hljs-name {
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  .hljs-string,
  .hljs-attr,
  .hljs-symbol,
  .hljs-bullet,
  .hljs-addition {
    color: #85c39a;
  }

  .hljs-number,
  .hljs-meta {
    color: #b3a4ec;
  }
}

:root[data-theme='dark'] .hljs-string,
:root[data-theme='dark'] .hljs-attr,
:root[data-theme='dark'] .hljs-symbol,
:root[data-theme='dark'] .hljs-bullet,
:root[data-theme='dark'] .hljs-addition {
  color: #85c39a;
}

:root[data-theme='dark'] .hljs-number,
:root[data-theme='dark'] .hljs-meta {
  color: #b3a4ec;
}

/* --- narrow screens --------------------------------------------------- */

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 14rem minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 1.5rem;
    padding-top: 1.25rem;
  }

  .sidebar {
    position: static;
    max-height: none;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .sidebar ul {
    margin-bottom: 0.75rem;
  }

  article h1 {
    font-size: 1.7rem;
  }

  #results {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
  }
}
