/* ---------------------------------------------------------------------------
   Ternary VertexCache — documentation theme.

   Material for MkDocs ships blue-tinted greys (its "slate" scheme is a desaturated
   navy). Everything below re-points those variables at NEUTRAL greys, plus a warm
   off-white in light mode, so the site reads as monochrome rather than blueish.
   --------------------------------------------------------------------------- */

/* ---- Light scheme --------------------------------------------------------- */
[data-md-color-scheme="default"] {
  --tl-bg:        #faf9f7;   /* warm off-white, not pure white */
  --tl-bg-raised: #ffffff;
  --tl-fg:        #26251f;
  --tl-fg-muted:  #5f5d55;
  --tl-border:    #e3e1dc;
  --tl-accent:    #3d3b35;

  --md-default-bg-color:              var(--tl-bg);
  --md-default-fg-color:              var(--tl-fg);
  --md-default-fg-color--light:       var(--tl-fg-muted);
  --md-default-fg-color--lighter:     #8d8a80;
  --md-default-fg-color--lightest:    var(--tl-border);

  --md-primary-fg-color:              #1f1e19;
  --md-primary-bg-color:              #f5f4f1;
  --md-accent-fg-color:               var(--tl-accent);

  --md-typeset-color:                 var(--tl-fg);
  --md-typeset-a-color:               #4a4842;
  --md-code-bg-color:                 #f1efeb;
  --md-code-fg-color:                 #33322c;
  --md-footer-bg-color:               #1f1e19;
  --md-footer-bg-color--dark:         #171613;
}

/* ---- Dark scheme ---------------------------------------------------------- */
[data-md-color-scheme="slate"] {
  --tl-bg:        #1c1b18;   /* neutral warm charcoal, no blue cast */
  --tl-bg-raised: #24231f;
  --tl-fg:        #e8e6e1;
  --tl-fg-muted:  #a6a39b;
  --tl-border:    #35332e;
  --tl-accent:    #cfccc4;

  --md-hue: 40;              /* Material derives some greys from this; 40 = warm */

  --md-default-bg-color:              var(--tl-bg);
  --md-default-fg-color:              var(--tl-fg);
  --md-default-fg-color--light:       var(--tl-fg-muted);
  --md-default-fg-color--lighter:     #7c7972;
  --md-default-fg-color--lightest:    var(--tl-border);

  --md-primary-fg-color:              #171613;
  --md-primary-bg-color:              var(--tl-fg);
  --md-accent-fg-color:               var(--tl-accent);

  --md-typeset-color:                 var(--tl-fg);
  --md-typeset-a-color:               #cbc8c0;
  --md-code-bg-color:                 #26251f;
  --md-code-fg-color:                 #ddd9d1;
  --md-footer-bg-color:               #171613;
  --md-footer-bg-color--dark:         #121110;
}

/* Header and sidebars follow the same neutral surface as the page. */
.md-header,
.md-tabs                     { background-color: var(--md-primary-fg-color); }
[data-md-color-scheme="slate"] .md-header { border-bottom: 1px solid var(--tl-border); }

/* Search field: neutral, not tinted. */
.md-search__form             { background-color: rgba(255,255,255,.08); }
.md-search__form:hover       { background-color: rgba(255,255,255,.14); }

/* ---- Typography ----------------------------------------------------------- */
.md-typeset h1,
.md-typeset h2,
.md-typeset h3               { font-weight: 600; letter-spacing: -.01em; }
.md-typeset h2               { margin-top: 2.2em; border-top: 1px solid var(--tl-border); padding-top: 1.2em; }
.md-typeset h1               { color: var(--md-default-fg-color); }

/* Tables read as data, so keep them quiet and monochrome. */
.md-typeset table:not([class]) {
  border: 1px solid var(--tl-border);
  border-radius: 4px;
  font-size: .74rem;
}
.md-typeset table:not([class]) th {
  background-color: var(--tl-bg-raised);
  font-weight: 600;
}
[data-md-color-scheme="slate"] .md-typeset table:not([class]) th { background-color: #2b2a25; }

/* Screenshots: a hairline keeps dark UI captures from bleeding into the page. */
.md-typeset img              { border-radius: 4px; }
.md-typeset a > img,
.md-typeset p > img          { border: 1px solid var(--tl-border); }

/* Admonitions in greyscale — Material colours these blue/orange by default. */
.md-typeset .admonition,
.md-typeset details          { border-color: var(--tl-border); font-size: .72rem; }
.md-typeset .admonition.note   > .admonition-title,
.md-typeset .admonition.warning > .admonition-title,
.md-typeset .admonition.danger  > .admonition-title { background-color: rgba(125,122,114,.12); }
.md-typeset .note   > .admonition-title::before,
.md-typeset .warning > .admonition-title::before,
.md-typeset .danger  > .admonition-title::before { background-color: var(--md-default-fg-color--light); }
.md-typeset .admonition.note    { border-left: 3px solid var(--md-default-fg-color--lighter); }
.md-typeset .admonition.warning { border-left: 3px solid var(--md-default-fg-color--light); }
.md-typeset .admonition.danger  { border-left: 3px solid var(--md-default-fg-color); }

/* Header logo sizing. */
.md-header__button.md-logo img { height: 1.5rem; width: auto; }

/* ---------------------------------------------------------------------------
   Header title: always the SITE NAME, never the page title.

   Material renders two stacked "topics" in the header — the site name and the
   current page title — and cross-fades to the page title once the page's H1
   scrolls out of view (it adds .md-header__title--active). Two reasons to pin it:
   the site name belongs beside the logo as a stable brand element, and because the
   home page's H1 is visually hidden it counts as immediately out of view, so the
   header would otherwise read "Home" at scroll position zero.
   --------------------------------------------------------------------------- */
.md-header__title .md-header__topic:first-child {
  opacity: 1 !important;
  z-index: 0 !important;
  transform: none !important;
  pointer-events: auto !important;
}
.md-header__title .md-header__topic + .md-header__topic { display: none !important; }
.md-header__title .md-header__topic > .md-ellipsis { font-weight: 600; }

/* The primary nav repeats the site name above the page list, which now duplicates
   the header. Desktop only — on mobile that element is the drawer's header and
   carries the close affordance, so it has to stay. */
@media screen and (min-width: 76.25em) {
  .md-nav--primary > .md-nav__title { display: none; }
  .md-sidebar--primary .md-nav__list { padding-top: .4rem; }
}

/* The home page's H1 repeats the site name already shown in the header, so it is hidden from
   sighted readers. Kept in the DOM rather than deleted: without an H1 Material synthesises one
   from the nav title ("Home"), and screen readers / search engines still want a real heading.
   Clip rather than display:none, which would drop it from the accessibility tree too. */
.md-typeset .tl-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Opening line of a page — slightly larger and quieter than body copy. */
.md-typeset .tl-lead {
  font-size: .85rem;
  line-height: 1.7;
  color: var(--md-default-fg-color--light);
  margin-top: .4em;
}

/* ---------------------------------------------------------------------------
   Background watermarks.

   Several copies of the mark at large scale, at different heights and alternating
   sides, so a faint logo drifts past as you scroll rather than sitting fixed.
   Very low opacity and pointer-events:none — decorative only, never in the way.
   --------------------------------------------------------------------------- */
.md-main                     { position: relative; }
.md-main__inner              { position: relative; z-index: 1; }

.md-main::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    url("../assets/watermark.png"),
    url("../assets/watermark.png"),
    url("../assets/watermark.png"),
    url("../assets/watermark.png"),
    url("../assets/watermark.png");
  background-repeat: no-repeat;
  background-size: 460px, 320px, 400px, 300px, 360px;
  background-position:
    right -110px top 260px,
    left  -80px  top 1500px,
    right -90px  top 2750px,
    left  -70px  top 4100px,
    right -100px top 5400px;
  opacity: .05;
}
[data-md-color-scheme="slate"] .md-main::before { opacity: .07; }

/* Below the content breakpoint the sidebars collapse and the text runs full
   width — a watermark under body copy hurts legibility, so drop it. */
@media screen and (max-width: 76.1875em) {
  .md-main::before { display: none; }
}

/* Respect reduced-motion / low-vision preferences. */
@media (prefers-contrast: more) {
  .md-main::before { display: none; }
}
