/* ─── Design Tokens: Light ─── */
[data-md-color-scheme="default"],
:root {
  --ink: #0e0b09;
  --paper: #f5f0e8;
  --paper-rgb: 245,240,232;
  --red: #c41a1a;
  --red-dim: rgba(196,26,26,0.07);
  --red-fill: rgba(196,26,26,0.12);
  --muted: #2e2a26;
  --rule: rgba(14,11,9,0.12);
  --rule-strong: rgba(14,11,9,0.25);
  --card-bg: rgba(var(--paper-rgb),0.5);
  --code-bg: rgba(14,11,9,0.05);
  --grain-blend: multiply;
  --grain-opacity: 0.3;
  --serif: 'Source Serif 4', Georgia, serif;
  --mono: 'DM Mono', 'SF Mono', monospace;
}

[data-md-color-scheme="default"] {
  --md-default-bg-color: var(--paper);
  --md-default-fg-color: var(--ink);
  --md-default-fg-color--light: var(--muted);
  --md-primary-fg-color: var(--paper);
  --md-primary-fg-color--light: var(--paper);
  --md-primary-fg-color--dark: var(--paper);
  --md-primary-bg-color: var(--ink);
  --md-accent-fg-color: var(--red);
  --md-typeset-a-color: var(--red);
  --md-code-bg-color: #fffdf9;
  --md-code-fg-color: var(--ink);
}

/* ─── Design Tokens: Dark ─── */
[data-md-color-scheme="slate"] {
  --ink: #ede4d4;
  --paper: #1a1510;
  --paper-rgb: 26,21,16;
  --red: #d44030;
  --red-dim: rgba(212,64,48,0.12);
  --red-fill: rgba(212,64,48,0.12);
  --muted: #b5a898;
  --rule: rgba(237,228,212,0.1);
  --rule-strong: rgba(237,228,212,0.18);
  --card-bg: rgba(34,28,20,0.6);
  --code-bg: rgba(237,228,212,0.06);
  --grain-blend: soft-light;
  --grain-opacity: 0.15;

  --md-default-bg-color: var(--paper);
  --md-default-fg-color: var(--ink);
  --md-default-fg-color--light: var(--muted);
  --md-primary-fg-color: var(--paper);
  --md-primary-fg-color--light: var(--paper);
  --md-primary-fg-color--dark: var(--paper);
  --md-primary-bg-color: var(--ink);
  --md-accent-fg-color: var(--red);
  --md-typeset-a-color: var(--red);
  --md-code-bg-color: var(--code-bg);
  --md-code-fg-color: var(--ink);
  /* Material slate sets its own --md-default-bg-color--light; override to
     keep the warm dark paper instead of slate's cool grey. */
  --md-default-bg-color--light: rgba(var(--paper-rgb),0.7);
}

/* ─── Paper grain texture ─── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  mix-blend-mode: var(--grain-blend);
}

/* ─── Header & Tabs ─── */
.md-header,
.md-tabs {
  background-color: var(--paper);
  border-bottom: 1px solid var(--rule);
}

/* ─── gb* nav mark ─── */
.gb-mark {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--muted);
  text-decoration: none;
  margin-left: 0.8rem;
}

.gb-star {
  color: var(--red);
}

@media screen and (max-width: 76.234375em) {
  .gb-mark--desktop { display: none; }
}

@media screen and (min-width: 76.25em) {
  .md-header__title { visibility: hidden; flex: 1; }
}

/* ─── Mobile drawer logo ─── */
.gb-nav-logo {
  display: inline-flex;
  align-items: center;
  padding: 0;
}

.md-nav__title .md-logo.gb-nav-logo img {
  height: 1.2rem;
  width: auto;
}

[data-md-color-scheme="slate"] .gb-nav-logo img {
  filter: brightness(0) invert(0.85) sepia(0.15) saturate(0.5);
}

/* ─── Search ─── */
.md-search__form {
  background-color: var(--card-bg);
  border: 1px solid var(--rule);
  box-shadow: none;
}

.md-search__input {
  color: var(--ink);
}

.md-search__input::placeholder {
  color: var(--muted);
}

/* ─── Typography ─── */
.md-typeset h1,
.md-typeset h2,
.md-typeset h3 {
  color: var(--ink);
}

.md-typeset code {
  border: 1px solid var(--rule);
  border-radius: 2px;
}

/* ─── Homepage hero ─── */
.homepage-identity {
  margin: 0 0 2rem;
  max-width: 38rem;
}

.homepage-identity h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--red);
  font-size: clamp(2rem, 6vw, 2.8rem);
  line-height: 1.2;
  margin: 0;
}

.identity-tagline {
  max-width: 38rem;
  margin: 0.75rem 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

/* ─── Sidebar ─── */
/* Keep the navigation and TOC panels scrollable without persistent scrollbar chrome. */
.md-sidebar__scrollwrap {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.md-sidebar__scrollwrap::-webkit-scrollbar {
  display: none;
}

/* ─── Navigation hover ─── */
.md-nav__link:hover {
  color: var(--red);
}

/* ─── Repo metadata: show only the release tag ─── */
.md-source__fact--stars,
.md-source__fact--forks {
  display: none;
}

/* ─── Responsive ─── */
@media screen and (max-width: 44.984375em) {
  .homepage-identity h1 {
    font-size: clamp(1.6rem, 8vw, 2.2rem);
  }
}
