/* Ruscker brand — theme-aware logo swap.
 *
 * mdBook toggles the active theme via a class on <html> (light, rust,
 * coal, navy, ayu) rather than the OS prefers-color-scheme, so the
 * README's <picture> trick doesn't follow the in-book theme switcher.
 * We render both wordmark lockups and show the one that contrasts with
 * the current theme. */

.ruscker-logo {
  width: 320px;
  max-width: 80%;
  height: auto;
}

/* Default (light + rust): show the dark-text lockup. */
.ruscker-logo-dark {
  display: none;
}

/* Dark themes: hide the dark-text lockup, show the white-text one. */
html.coal .ruscker-logo-light,
html.navy .ruscker-logo-light,
html.ayu .ruscker-logo-light {
  display: none;
}
html.coal .ruscker-logo-dark,
html.navy .ruscker-logo-dark,
html.ayu .ruscker-logo-dark {
  display: inline-block;
}

/* Brand re-tint — paint mdBook's accents in the Ruscker teal palette
 * (#0F6E56 / #1D9E75 / #5DCAA5) instead of the stock theme colours. This
 * additional-css loads after the built-in theme CSS, so these override
 * the per-theme custom-property values. */

/* Light theme (the default): primary teal reads well on white. */
html.light {
  --links: #0f6e56;
  --sidebar-active: #0f6e56;
  --icons-hover: #0f6e56;
  --searchbar-border-color: #5dcaa5;
  --search-mark-bg: #b9e6d5;
  --searchresults-header-fg: #0f6e56;
  --inline-code-color: #0b5d49;
}

/* Dark themes: the lighter teal keeps contrast on dark backgrounds. */
html.coal,
html.navy,
html.ayu {
  --links: #5dcaa5;
  --sidebar-active: #5dcaa5;
  --icons-hover: #5dcaa5;
  --search-mark-bg: #1d9e75;
  --searchresults-header-fg: #5dcaa5;
}

/* The active page in the sidebar gets a subtle teal rail in every
 * theme — cheap wayfinding that reinforces the brand. */
.chapter li.chapter-item a.active {
  border-left: 3px solid var(--sidebar-active);
  padding-left: calc(1rem - 3px);
}

/* "Collapse sidebar" chevron (injected by theme/ruscker.js). It's a
 * <label for="mdbook-sidebar-toggle-anchor">, so clicking it toggles
 * mdBook's own sidebar checkbox — no custom state to keep in sync.
 *
 * Pinned with `position: fixed` to the sidebar's inner-right edge via
 * mdBook's `--sidebar-width` (so it tracks a resized sidebar and ignores
 * the TOC iframe's own layout), just below the menu bar. Shown only when
 * the sidebar is open; collapsing it hides the chevron — reopen with the
 * top-bar hamburger. */
.ruscker-sidebar-close {
  position: fixed;
  top: 3.4rem;
  left: calc(var(--sidebar-width) - 2.3rem);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 6px;
  cursor: pointer;
  color: var(--sidebar-fg);
  background: var(--theme-hover, rgba(0, 0, 0, 0.05));
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.ruscker-sidebar-close:hover {
  opacity: 1;
  color: #ffffff;
  background: var(--sidebar-active);
}
.ruscker-sidebar-close svg {
  width: 1.05rem;
  height: 1.05rem;
}
/* Gone when the sidebar is collapsed (the hamburger brings it back). */
html:not(.sidebar-visible) .ruscker-sidebar-close {
  display: none;
}
/* On narrow viewports the sidebar is a full overlay and the hamburger
 * sits right next to it — the extra chevron just clutters, so hide it. */
@media only screen and (max-width: 1080px) {
  .ruscker-sidebar-close {
    display: none;
  }
}
