/* kex docs — design tokens ported from kex.run (see module comment) */

:root {
  --bg: #fcf5e2;
  --bg-subtle: #f6ecd0;
  --bg-muted: #f0e2bc;
  --bg-sunken: #ead9a8;
  --ink: #2a1c0a;
  --ink-soft: #54380f;
  --muted: #7a5a25;
  --faint: #9c7a3c;
  --line: #ecdcb4;
  --line-strong: #dbc78c;
  --accent: #b06a14;
  --accent-strong: #8a4f0a;
  --accent-soft: #f4e2b8;
  --accent-ink: #5a3408;
  --code-bg: #1b140a;
  --code-bg-soft: #221a0e;
  --code-border: #382a16;
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Fraunces", ui-serif, Georgia, Cambria, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Fira Code", "Cascadia Code", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

/* JetBrains Mono ships programming ligatures (-> to a single arrow, =>,
   !=, ...) on by default. They read well in code blocks, so they stay
   there — but in the search box the reader is TYPING, and -> must
   appear exactly as entered. Disable ligatures there only. */
.search-modal-panel input, .search-page-box input {
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0, "dlig" 0;
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(ellipse 90% 50% at 50% -10%, rgba(236, 178, 94, 0.28), transparent 70%);
  background-repeat: no-repeat;
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.6;
}

::selection { background: var(--accent-soft); color: var(--accent-ink); }

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-display);
  letter-spacing: -0.015em;
  color: var(--ink);
}

.wrap { width: 100%; max-width: 76rem; margin-inline: auto; padding-inline: 1.5rem; }

/* ── Header ─────────────────────────────────────────────────────────── */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(252, 245, 226, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.top-inner { display: flex; align-items: center; gap: 0.75rem; height: 3.5rem; }

/* ── Search ─────────────────────────────────────────────────────────── */

.search-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  height: 2.1rem;
  min-width: 14rem;
  padding: 0 0.7rem;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.search-trigger:hover { border-color: var(--accent); color: var(--ink); }
.search-trigger kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1;
  padding: 0.2rem 0.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  color: var(--faint);
}

/* The modal is frosted glass: a translucent warm panel over a blurred
   backdrop, in the same voice as the sticky header. */
.search-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  background: rgba(42, 28, 10, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.search-modal[hidden] { display: none; }

.search-modal-panel {
  width: min(44rem, 92vw);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 253, 248, 0.82);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  border: 1px solid rgba(236, 220, 180, 0.9);
  box-shadow: 0 24px 72px rgba(42, 28, 10, 0.35);
}

.search-modal-panel input {
  width: 100%;
  box-sizing: border-box;
  padding: 1.05rem 1.3rem;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid rgba(236, 220, 180, 0.9);
  outline: none;
}
.search-modal-panel input::placeholder { color: var(--faint); }

.search-modal-results { max-height: 55vh; overflow-y: auto; padding: 0.5rem; }

.search-hit {
  display: block;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.1rem;
  border-radius: 10px;
  text-decoration: none;
}
.search-hit:hover { background: rgba(246, 236, 208, 0.6); }
.search-hit.selected { background: rgba(244, 226, 184, 0.9); }

.search-head { display: flex; align-items: baseline; gap: 0.6rem; }

.search-kind {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
}
/* Each kind has its own hue, so a scan down the list separates
   functions from types from modules at a glance. */
.search-kind-module { color: #6b5bd2; }
.search-kind-function { color: #2f855a; }
.search-kind-make { color: #b06a14; }
.search-kind-trait { color: #c2498a; }
.search-kind-record { color: #2b6cb0; }
.search-kind-type { color: #0f8a8a; }
.search-kind-constant { color: #9a5a13; }
.search-name { font-family: var(--font-mono); font-size: 15px; font-weight: 600; color: var(--ink); }
.search-qual { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-align: right; }
.search-sig {
  display: block;
  margin-top: 0.15rem;
  font-size: 12.5px;
  color: var(--faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-empty { padding: 0.8rem 0.9rem; font-size: 13px; color: var(--faint); }

.search-modal-footer {
  border-top: 1px solid rgba(236, 220, 180, 0.9);
  padding: 0.55rem 0.9rem;
  font-size: 12.5px;
}
.search-modal-footer a { color: var(--accent-strong); text-decoration: none; }
.search-modal-footer a:hover { text-decoration: underline; }

/* The empty state: an explainer, example chips, and this page's items. */
.search-hint, .search-local { padding: 0.8rem 1rem 0.6rem; }

.search-hint-title { margin: 0 0 0.25rem; font-size: 13px; font-weight: 600; color: var(--ink); }
.search-hint-body { margin: 0 0 0.6rem; font-size: 12.5px; color: var(--muted); }

.search-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.search-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 0.25rem 0.6rem;
  color: var(--ink-soft);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
}
.search-chip:hover { border-color: var(--accent); color: var(--ink); }

.search-local { border-top: 1px solid rgba(236, 220, 180, 0.7); }

/* ── Full search page ──────────────────────────────────────────────── */

.search-page { max-width: 52rem; }

.search-page-box input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.85rem 1rem;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--ink);
  background: rgba(246, 236, 208, 0.6);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}
.search-page-box input:focus { border-color: var(--accent); }

.search-page-results { margin-top: 1.25rem; }

.search-page-hit {
  display: block;
  padding: 0.8rem 0.9rem;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.search-page-hit:hover { background: var(--bg-subtle); }

.search-summary {
  display: block;
  margin-top: 0.25rem;
  font-size: 13px;
  color: var(--muted);
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.brand-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
  padding-top: 0.2rem;
}

.spacer { flex: 1; }

.pkg-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
}

.version-select {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.15rem 0.4rem 0.15rem 0.7rem;
  cursor: pointer;
}

.version-select:hover { border-color: var(--accent); }

.back { font-size: 13.5px; color: var(--muted); }
.back:hover { color: var(--accent-strong); }

/* ── Layout ─────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  gap: 3rem;
  grid-template-columns: 15rem minmax(0, 1fr);
  padding-block: 2.5rem;
}

/* The module list is longer than the viewport, and it is stuck to it —
   so it needs its own scrollbar, or everything past the fold is
   unreachable. The height is what is left below the sticky header. */
.side nav {
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6.5rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.35rem;
}

.side-heading {
  margin: 0 0 0.6rem;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
}

.side-list { list-style: none; margin: 0; padding: 0; }

.side-list > li > a {
  display: block;
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 13.5px;
  color: var(--muted);
}

.side-list > li > a:hover { background: var(--bg-subtle); color: var(--ink); }

.side-list > li > a.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 500;
}

.side-sub { list-style: none; margin: 0.15rem 0 0.4rem; padding: 0 0 0 1.1rem; }

.side-sub a {
  display: block;
  border-radius: 6px;
  padding: 0.15rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--faint);
}

.side-sub a:hover { color: var(--accent-strong); background: var(--bg-subtle); }

/* Nested modules ("FS" → "FS.Path"): same voice as the top list, one
   step quieter and indented under their parent. */
.side-nest { list-style: none; margin: 0; padding: 0 0 0.25rem 0.75rem; }
.side-nest > li > a {
  display: block;
  border-radius: 6px;
  padding: 0.18rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--faint);
}
.side-nest > li > a:hover { background: var(--bg-subtle); color: var(--ink); }
.side-nest > li > a.active {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 500;
}

/* Cross-reference links inside code spans: the code face stays, the
   colour signals "this goes somewhere". */
a.xref { color: var(--accent-strong); text-decoration: none; border-bottom: 1px solid color-mix(in oklab, var(--accent) 45%, transparent); }
a.xref:hover { border-bottom-color: var(--accent-strong); }

.content { min-width: 0; max-width: 48rem; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--faint);
  margin-bottom: 1rem;
}

.crumbs a:hover { color: var(--accent-strong); }
.crumbs .sep { opacity: 0.6; }

/* ── Prose ──────────────────────────────────────────────────────────── */

.prose { color: var(--ink-soft); font-size: 1.0125rem; line-height: 1.75; }

.prose h1 { font-size: 2.1rem; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 1rem; line-height: 1.15; }

/* The standalone index pages (site root, package versions) carry their
   h1 directly in .content.prose — unlike the entity pages, which get
   top breathing room from .layout's padding. Give those a little air
   under the header. */
.content.prose > h1 { margin-top: 2rem; }

.prose h1 .ver {
  font-family: var(--font-mono);
  font-size: 0.45em;
  font-weight: 500;
  color: var(--muted);
  vertical-align: middle;
  letter-spacing: 0;
}

.prose h2 {
  font-size: 1.35rem;
  font-weight: 650;
  margin: 2.6rem 0 0.9rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.prose h3 { font-size: 1.05rem; font-weight: 600; margin: 1.6rem 0 0.5rem; }

.prose h5 {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--faint);
  margin: 1.4rem 0 0.4rem;
}

.prose p { margin: 0 0 1.1rem; }

.prose a { color: var(--accent-strong); text-decoration: underline; text-decoration-color: var(--accent-soft); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: currentColor; }

.prose code:not(pre code) {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--bg-muted);
  border: 1px solid var(--line);
  padding: 0.12rem 0.4rem;
  border-radius: 6px;
  color: var(--muted);
}

.prose strong { color: var(--ink); font-weight: 600; }

.lede { font-size: 1.05rem; color: var(--muted); }

/* ── Entities ───────────────────────────────────────────────────────── */

/* Anchor navigation lands a heading below the sticky header, not under
   it: reserve the header's height (3.5rem) plus breathing room. */
.entity, .fn { scroll-margin-top: 4.75rem; }

.entity h2 code { font-size: 0.95em; }

.kind {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-ink);
  background: var(--accent-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0.1rem 0.45rem;
  margin-right: 0.5rem;
  vertical-align: middle;
}
/* Each declaration kind has its own hue — the same palette as the
   search results — so a module, a trait and a make are told apart at
   a glance rather than all reading as one amber badge. */
.kind-module { color: #6b5bd2; border-color: #d6cdf3; background: #efeafc; }
.kind-function { color: #2f855a; border-color: #c6e6d4; background: #e8f4ec; }
.kind-make { color: #b06a14; border-color: #ecd6ac; background: #f7ecd6; }
.kind-trait { color: #c2498a; border-color: #efcfe0; background: #f9ecf3; }
.kind-record { color: #2b6cb0; border-color: #c8dcf0; background: #e9f1fa; }
.kind-type { color: #0f8a8a; border-color: #c0e4e2; background: #e4f4f3; }
.kind-constant { color: #9a5a13; border-color: #e6d2b4; background: #f6ecdd; }

.fields, .params { margin: 0 0 1.1rem; }

.field, .param {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.field dt, .param dt { flex-shrink: 0; }
.field dd, .param dd { margin: 0; color: var(--muted); font-size: 0.95rem; }

.opt {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--faint);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 0.5rem;
  margin-left: 0.4rem;
}

.variants { margin: 0 0 1.1rem; padding-left: 1.3rem; list-style: disc; }
.variants li { margin: 0.3rem 0; }
.variants .abstract { color: var(--faint); }

.fn {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin: 0 0 0.9rem;
  background: rgba(255, 255, 255, 0.35);
}

.fn h4 { margin: 0 0 0.4rem; font-size: 1rem; }
.fn p:last-child, .fn pre:last-child { margin-bottom: 0; }

.caption { margin: 0 0 0.3rem; color: var(--muted); font-size: 0.95rem; }

.returns { color: var(--muted); }
.returns strong { color: var(--ink-soft); }

.deprecated {
  border-left: 3px solid var(--accent);
  background: var(--bg-subtle);
  padding: 0.7rem 1rem;
  margin: 1.2rem 0;
  border-radius: 0 8px 8px 0;
}

/* ── Code surface ───────────────────────────────────────────────────── */

pre.code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.1rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: #e9e0cf;
}

pre.code code { font-family: inherit; }

.tok-comment { color: #94876a; font-style: italic; }
.tok-keyword { color: #f0c987; }
.tok-type    { color: #e6a960; }
.tok-string  { color: #c9e0a0; }
.tok-interp  { color: #e9e0cf; }
.tok-number  { color: #ffc18a; }
.tok-fn      { color: #ffe0a0; }
.tok-method  { color: #ffe0a0; }
.tok-op      { color: #d8b878; }
.tok-punct   { color: #a89a78; }
.tok-const   { color: #e6a960; }
.tok-field   { color: #f0e8d4; }
.tok-bool    { color: #ffc18a; }

/* ── Cards (version index) ──────────────────────────────────────────── */

.cards {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  margin-top: 1.6rem;
}

/* Section headings on the index and the prelude page: what separates
   "given to you" from "one using away". */
.group {
  margin: 2.6rem 0 0.2rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--ink);
}

.group-note { margin: 0; color: var(--muted); font-size: 0.92rem; }

/* "prelude": this page needs no import. It sits on the page heading,
   beside the module name it qualifies. */
.tag-prelude {
  margin-left: 0.5rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  vertical-align: middle;
  white-space: nowrap;
}

h1 .tag-prelude { font-size: 11px; vertical-align: 0.45em; }

.prelude-list {
  list-style: none;
  margin: 1.2rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
}

.prelude-list li {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--line);
}

.prelude-note {
  color: var(--faint);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card {
  display: block;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1.1rem;
  background: rgba(255, 255, 255, 0.35);
}

.card:hover { border-color: var(--line-strong); background: var(--bg-subtle); }

.card-title { display: block; font-family: var(--font-mono); font-weight: 600; color: var(--ink); }
.card:hover .card-title { color: var(--accent-strong); }
.card-meta { display: block; margin-top: 0.25rem; font-size: 12.5px; color: var(--faint); }

/* ── Footer ─────────────────────────────────────────────────────────── */

.foot {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.4rem 0 2rem;
  font-size: 13px;
  color: var(--faint);
}

.foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.foot a:hover { color: var(--accent-strong); }

/* ── Responsive ─────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .layout { grid-template-columns: 1fr; }
  .side { display: none; }
}
