:root {
  --body-bg:      #CCC;
  --bg:           #ffffff;
  --sidebar-bg:   #f8f9fb;
  --fg:           #1b1b1b;
  --muted:        #5f6368;
  --accent:       #0067b8;
  --border:       #e1e4e8;
  --code-bg:      #f6f8fa;
  --code-border:  #d0d7de;
  --radius:       10px;

  /* Font roles (more granular than --mono/--sans) */
  --font-ui:       Helvetica;
  --font-heading:  Helvetica;
  --font-code:     Cascadia Mono;
  --font-symbol:   Segoe UI;

  /* Syntax highlight palette */
  --tok-pp:  #6f42c1;
  --tok-kw:  #005cc5;
  --tok-id:  #24292f;
  --tok-num: #b31d28;
  --tok-str: #032f62;
  --tok-crt: #032f62;
  --tok-pun: #6a737d;
  --tok-doc: #22863a;

  --content-max:  980px;
  --sidebar-max:  360px;
  --layout-max:  calc(var(--sidebar-max) + var(--content-max) + 6rem);
}

* { box-sizing: border-box; }

html {
  font-size: 16px;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font-ui);
  background: var(--body-bg);
  color: var(--fg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Links */
a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

a:focus-visible {
  outline: 3px solid rgba(0, 103, 184, 0.35);
  outline-offset: 2px;
  border-radius: 6px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: minmax(280px, var(--sidebar-max)) minmax(0, 1fr);
  min-height: 100vh;

  width: 100%;
  max-width: var(--layout-max);
  margin: 0 auto; /* centers whole page on ultrawide */
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  padding: 1.75rem 1.25rem;

  /* Scrollable + sticky */
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

/* Content */
.content {
  min-width: 0; /* prevents grid overflow issues */
  padding: 2.25rem 3rem 4rem;

  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto; /* centers the article column */
}

/* Sidebar headings */
.sidebar h1 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.sidebar h2 {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  margin: 1.25rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}


/* Breadcrumb-ish */
.file-name {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
  word-break: break-word;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.file-name a { color: var(--muted); }
.file-name a:hover { color: var(--accent); }

.file-name span { color: var(--muted); }

/* Sidebar lists (no extra classes required) */
.sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
}

.sidebar li { margin: 0.15rem 0; }

.sidebar li a {
}

.sidebar li a {
  color: var(--fg);
  font-size: 0.9rem;
  display: block;
  padding: 0.22rem 0.45rem;
  border-radius: 8px;

  /* keep sidebar tidy */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar li a:hover,
.sidebar li a:focus-visible
{
  background: rgba(0, 103, 184, 0.10);
  color: var(--accent);
  text-decoration: none;

  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Collapsible sidebar sections */
.sidebar details {
  margin: 0 0 0.75rem;
}

.sidebar summary {
  font-family: var(--font-heading);
  cursor: pointer;
  list-style: none;
  user-select: none;

  font-size: 0.8rem;
  margin: 1.25rem 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

/* Hide default markers in WebKit + Firefox (so we control the chevron) */
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary::marker { content: ""; }

/* Simple disclosure chevron */
.sidebar summary::before {
  content: "▸";
  display: inline-block;
  width: 1.1em;
  color: var(--muted);
  transform: translateY(-1px);
}

.sidebar details[open] > summary::before {
  content: "▾";
}

/* Tighten top spacing for the first section */
.sidebar details:first-of-type > summary {
  margin-top: 0.75rem;
}

/* Page header */
.page-header {
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

.page-header h1 {
  font-family: var(--font-heading);
  font-size: 2.35rem;
  line-height: 1.15;
  margin: 0 0 0.45rem;
  font-weight: 750;
  letter-spacing: -0.02em;
}

.home-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--muted);
}

.home-link:hover { color: var(--accent); }

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.symbol {
  position: relative;
  padding: 1.75rem 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 1rem;
}

.symbol:last-of-type { border-bottom: 0; }

.symbol > h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  line-height: 1.25;
  font-family: var(--font-symbol);
  font-weight: 700;
}

.symbol:target::before {
  content: "";
  position: absolute;
  left: -70px;
  top: 1.75rem;
  bottom: 1.75rem;
  width: 2px;
  border-radius: 999px;
  background: var(--accent);
}

.meta {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  margin-bottom: 0.25rem;
}

.symbol-kind {
  font-family: var(--font-heading);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.symbol .brief {
  margin: 0.25rem 0 0.9rem;
}

/* Code blocks: NEVER horizontal scroll, wrap/break instead */
pre { margin: 0; }

.symbol-decl {
  margin: 0.25rem 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius);

  overflow-x: hidden; /* no horizontal scrollbars */
}

/* Preserve newlines, but allow wrapping + breaking long tokens */
.symbol-decl code,
pre code {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;

  font-family: var(--font-code);
  font-size: 0.98rem;
  line-height: 1.45;

  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Ensure token spans don't create “pill” backgrounds */
.symbol-decl .tok,
.symbol-decl [class^="tok_"],
.symbol-decl [class*=" tok_"] {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
}

/* Inline code in prose only */
:not(pre) > code,
p code,
li code,
dd code,
dt code {
  font-family: var(--font-code);
  font-size: 0.95em;
  background: rgba(27, 31, 36, 0.06);
  padding: 0.12rem 0.32rem;
  border-radius: 6px;
}

/* Links inside code blocks (cross-page types) */
.symbol-decl a {
  color: inherit;
  text-decoration: underline transparent;
  text-underline-offset: 2px;
}

.symbol-decl a:hover {
  text-decoration-color: currentColor;
  color: inherit;
}

.params,
.returns {
  margin-top: 1.1rem;
}

.params h3,
.returns h3 {
  font-family: var(--font-heading);
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  line-height: 1.25;
}

.params dl { margin: 0; }

.params dt {
  margin-top: 0.6rem;
  font-family: var(--font-code);
  font-weight: 700;
}

.params dd {
  margin: 0.15rem 0 0.6rem;
  color: var(--fg);
}

::selection { background: rgba(0, 103, 184, 0.18); }

/* Syntax highlight */

/* Two-class form: <span class="tok pp"> ... */
.tok.pp  { color: var(--tok-pp);  font-weight: 800; }
.tok.kw  { color: var(--tok-kw);  font-weight: 650; }
.tok.id  { color: var(--tok-id); }
.tok.num { color: var(--tok-num); font-variant-numeric: tabular-nums; }
.tok.str { color: var(--tok-str); font-style: italic; }
.tok.crt { color: var(--tok-crt); font-style: italic; }
.tok.pun { color: var(--tok-pun); }
.tok.doc { color: var(--tok-doc); font-style: italic; opacity: 0.9; }

/* Single-class form: <span class="tok_pp"> ... */
.tok_pp  { color: var(--tok-pp);  font-weight: 800; }
.tok_kw  { color: var(--tok-kw);  font-weight: 650; }
.tok_id  { color: var(--tok-id); }
.tok_num { color: var(--tok-num); font-variant-numeric: tabular-nums; }
.tok_str { color: var(--tok-str); font-style: italic; }
.tok_crt { color: var(--tok-crt); font-style: italic; }
.tok_pun { color: var(--tok-pun); }
.tok_doc { color: var(--tok-doc); font-style: italic; opacity: 0.9; }

/* Responsive */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 1.5rem 1.25rem 2.5rem;
  }

  .page-header h1 { font-size: 2rem; }
  .symbol > h2 { font-size: 1.3rem; }

  /* In mobile, allow sidebar items to wrap instead of ellipsis */
  .sidebar li a {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

/* Webfont (place @font-face anywhere; top is conventional) */
@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("fonts/JetBrainsMono-Italic.woff2") format("woff2");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
