/* ==========================================================================
   goy-algorithms — "islands on night water"
   --------------------------------------------------------------------------
   The page ground is the water: a lighter navy-charcoal. Floating surfaces —
   the header island, the nav rail, code blocks, theorem panels — are DARKER
   than the water, like landmasses at night. This inverts the usual dark-theme
   convention (cards lighter than the ground) and is what stops the palette
   reading as a stock dark mode.

   Flat fills and hairlines only. No gradients anywhere.
   ========================================================================== */

[data-md-color-scheme="slate"] {
  /* --- the water: page ground, the lighter tone --- */
  --water:        #1B2534;

  /* --- the islands: darker than the water --- */
  --island:       #121A27;   /* header, nav rail, admonitions */
  --island-deep:  #0D141E;   /* code blocks — the deepest surface */

  /* --- hairlines --- */
  --water-line:   #2A344A;
  --line:         #26324A;
  --line-soft:    #212B3B;

  /* --- ink --- */
  --ink:          #E3E9F2;
  --ink-muted:    #8EA0B7;

  /* --- the one accent: warm harbour light on cold water ---
     Used only for links, the active nav item, and mathematical statements.
     Nothing else gets to be amber. */
  --lamp:         #E9B872;
  --lamp-dim:     #B98F4E;

  /* Material plumbing */
  --md-hue: 214;
  --md-default-bg-color:      var(--water);
  --md-default-fg-color:      var(--ink);
  --md-default-fg-color--light:  var(--ink-muted);
  --md-typeset-color:         var(--ink);
  --md-typeset-a-color:       var(--lamp);
  --md-accent-fg-color:       var(--lamp);
  --md-footer-bg-color:       transparent;
  --md-footer-bg-color--dark: transparent;
  --md-code-bg-color:         var(--island-deep);
  --md-code-fg-color:         #D6DEEA;
}

/* --------------------------------------------------------------------------
   THE HEADER ISLAND
   Inset from the sides, flush against the very top, rounded only along the
   bottom edge — so it reads as a separate landmass that is still joined to
   the top of the page rather than hovering free.
   -------------------------------------------------------------------------- */
[data-md-color-scheme="slate"] .md-header {
  background-color: var(--island);
  box-shadow: none;
  border: 1px solid var(--line-soft);
  border-top: none;
  border-radius: 0 0 18px 18px;
  /* inset from the page edges so the water shows on both sides */
  width: calc(100% - 1.6rem);
  margin: 0 0.8rem;
  overflow: hidden;
}

[data-md-color-scheme="slate"] .md-header__title {
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Search field as a small inset pool inside the island */
[data-md-color-scheme="slate"] .md-search__form {
  background-color: var(--island-deep);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}
[data-md-color-scheme="slate"] .md-search__form:hover {
  background-color: var(--island-deep);
  border-color: var(--water-line);
}

/* --------------------------------------------------------------------------
   THE NAV RAIL — a second island
   -------------------------------------------------------------------------- */
.md-sidebar--primary .md-sidebar__scrollwrap {
  background-color: var(--island);
  border: 1px solid var(--line-soft);
  border-radius: 16px;
  margin: 0.8rem 0 0.8rem 0.6rem;
  padding: 0.9rem 0.75rem;
}

.md-nav {
  font-size: 0.72rem;
}
.md-nav__link {
  border-radius: 7px;
  padding: 0.24rem 0.45rem;
  transition: background-color 120ms ease, color 120ms ease;
}
.md-nav__link:hover {
  background-color: rgba(255, 255, 255, 0.045);
  color: var(--ink);
}
/* The active page: the lit one */
.md-nav__link--active,
.md-nav__link[aria-current="page"] {
  color: var(--lamp) !important;
  background-color: rgba(233, 184, 114, 0.09);
  font-weight: 500;
}
/* Section labels in the rail read as labels, not links */
.md-nav__item--section > .md-nav__link {
  color: var(--ink-muted);
  font-size: 0.66rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 600;
}

/* Hide the redundant site-name label above the rail */
.md-nav__title[for="__drawer"] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   READING SURFACE
   Prose sits directly on the water — no panel. A constrained measure keeps
   Cyrillic technical prose comfortable over long articles.
   -------------------------------------------------------------------------- */
.md-typeset {
  font-size: 0.79rem;
  line-height: 1.78;
  letter-spacing: 0.001em;
}
.md-content__inner {
  max-width: 46rem;   /* ~72–78 characters of Cyrillic body text */
  margin-inline: auto;
  padding-top: 0.4rem;
}

.md-typeset h1 {
  font-size: 1.85rem;
  line-height: 1.18;
  font-weight: 600;
  letter-spacing: -0.022em;
  color: var(--ink);
  margin-bottom: 1.4rem;
}
.md-typeset h2 {
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -0.014em;
  margin-top: 2.6rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
}
.md-typeset h3 {
  font-size: 1.0rem;
  font-weight: 600;
  letter-spacing: -0.008em;
  margin-top: 1.8rem;
}
.md-typeset h4 {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-muted);
}

.md-typeset a {
  text-decoration-color: var(--lamp-dim);
  text-underline-offset: 0.18em;
  transition: color 120ms ease;
}
.md-typeset a:hover {
  color: var(--lamp);
  text-decoration-color: var(--lamp);
}

/* --------------------------------------------------------------------------
   CODE — the deepest island
   -------------------------------------------------------------------------- */
.md-typeset pre > code,
.md-typeset .highlight pre {
  background-color: var(--island-deep);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}
.md-typeset code {
  background-color: rgba(13, 20, 30, 0.75);
  border: 1px solid var(--line-soft);
  border-radius: 5px;
  padding: 0.1em 0.34em;
  font-size: 0.86em;
}
.md-typeset pre > code {
  padding: 0.9rem 1rem;
}
/* tabbed code (=== "C++" / "Java") */
.md-typeset .tabbed-set > label {
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}
.md-typeset .tabbed-set > input:checked + label {
  color: var(--lamp);
  border-color: var(--lamp);
}

/* --------------------------------------------------------------------------
   SIGNATURE — mathematical statements
   This corpus is full of `!!! info "Теорем"` and `??? note "Баталгаа"`.
   They are set like a mathematics textbook, not like documentation callouts:
   no icon, no coloured fill, a single amber rule marking the claim, and the
   label in tracked monospace. The accent earns its place by meaning
   "this is a formal statement".
   -------------------------------------------------------------------------- */
/* Material assigns a per-type border colour (.admonition.info is cyan,
   .note is blue-grey, and so on) at a specificity that beats a plain
   `.md-typeset .admonition` rule. Every type is flattened back to the single
   amber rule here — the colour means "formal statement", not "callout genre". */
.md-typeset .admonition,
.md-typeset details,
.md-typeset .admonition.info,
.md-typeset .admonition.note,
.md-typeset .admonition.tip,
.md-typeset .admonition.warning,
.md-typeset .admonition.example,
.md-typeset .admonition.abstract,
.md-typeset details.info,
.md-typeset details.note,
.md-typeset details.tip,
.md-typeset details.warning,
.md-typeset details.example,
.md-typeset details.abstract {
  background-color: var(--island);
  border: 1px solid var(--line-soft);
  border-left: 2px solid var(--lamp);
  border-radius: 12px;
  box-shadow: none;
  font-size: 0.79rem;
}
.md-typeset .admonition-title,
.md-typeset summary {
  background-color: transparent !important;
  font-family: var(--md-code-font-family, monospace);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--lamp);
  padding-left: 0.9rem;
}
/* drop Material's admonition icons — a textbook doesn't use pictograms */
.md-typeset .admonition-title::before,
.md-typeset summary::before {
  display: none !important;
}
.md-typeset .admonition-title,
.md-typeset summary {
  padding-left: 0.9rem !important;
}
/* keep the details disclosure marker, tinted */
.md-typeset summary::after {
  color: var(--lamp);
}

/* Display math: the same amber vocabulary, so a formula is scannable while
   skimming a long article. Two selectors because the delimiters may be left
   as a pymdownx `div.arithmatex` wrapper or replaced outright by a MathJax
   block container, depending on the page. Both are scoped to the article so
   they cannot touch the nav, whose TOC links also carry `.arithmatex`. */
.md-typeset div.arithmatex,
.md-typeset mjx-container[display="true"] {
  display: block;
  border-left: 2px solid var(--lamp-dim);
  padding: 0.35rem 0 0.35rem 1rem;
  margin: 1.3rem 0;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: left;
}

/* --------------------------------------------------------------------------
   TABLES, QUOTES, FOOTER
   -------------------------------------------------------------------------- */
.md-typeset table:not([class]) {
  background-color: var(--island);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  font-size: 0.74rem;
}
.md-typeset table:not([class]) th {
  background-color: var(--island-deep);
  font-weight: 600;
}
.md-typeset blockquote {
  border-left: 2px solid var(--line);
  color: var(--ink-muted);
}
.md-footer,
.md-footer-meta {
  background-color: transparent;
}
/* The footer div carries `md-typeset` (see overrides/main.html), so the
   article font-size above was inflating it well past Material's own 0.64rem.
   Set it explicitly instead of relying on inheritance. */
.md-footer-meta.md-typeset,
.md-footer-copyright,
.md-footer-copyright__highlight {
  font-size: 0.48rem;
  line-height: 1.6;
}
.md-footer-meta.md-typeset a {
  font-size: inherit;
}
/* Material's footer row is a flex container with align-items: normal, so the
   copyright box gets stretched to match the taller social-icons box (32px
   icons + 12px padding either side = 56px) while its own text stays at the
   top of that box — which reads as the text sitting high. Centre both. */
.md-footer-meta__inner {
  align-items: center;
}
.md-footer-meta {
  border-top: 1px solid var(--line-soft);
  margin: 0 0.8rem;
}

/* Images keep a light plate — the diagrams are black line art on transparent */
[data-md-color-scheme="slate"] img {
  background-color: #E8EDF3;
  border-radius: 8px;
}

/* --------------------------------------------------------------------------
   ACCESSIBILITY FLOOR
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 2px;
  border-radius: 4px;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Narrow screens: the islands lose their side insets so no width is wasted */
@media screen and (max-width: 76.1875em) {
  [data-md-color-scheme="slate"] .md-header {
    width: 100%;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .md-content__inner { max-width: none; }
}

/* --------------------------------------------------------------------------
   PRESERVED: contribution metadata, MathJax plumbing
   -------------------------------------------------------------------------- */
.metadata {
  list-style: none;
  padding: 0;
  margin: 0 0 15px 0;
  color: var(--ink-muted);
  font-size: 0.85em;
}
.metadata.page-metadata .contributors-text { margin-right: 5px; }
body[dir=rtl] .metadata.page-metadata .contributors-text {
  margin-right: 0;
  margin-left: 5px;
}
.page-metadata .contributors {
  display: inline-block;
  list-style: none;
  margin: 0 !important;
  padding: 0 !important;
}
.page-metadata .contributors li {
  display: inline-block;
  vertical-align: top;
  margin: 0;
  padding: 0;
}

/* Visually hide the LaTeX source MathJax keeps for copying */
.mjx-copytext { font-size: 0; }
/* Scoped to the article: the TOC's links also carry .arithmatex, and an
   unscoped overflow rule there clipped the nav. */
.md-typeset .arithmatex { overflow-y: hidden; }
