/* SaxDocs — quiet dark docs. No loud accents. */

:root,
[data-md-color-scheme="slate"] {
  --saxdocs-accent: #6e7681;
  --saxdocs-accent-soft: #484f58;
  --saxdocs-sidebar-active: rgba(255, 255, 255, 0.06);
  --saxdocs-border: rgba(255, 255, 255, 0.08);
}

[data-md-color-scheme="default"] {
  --saxdocs-accent: #57606a;
  --saxdocs-accent-soft: #d0d7de;
  --saxdocs-sidebar-active: rgba(0, 0, 0, 0.04);
  --saxdocs-border: rgba(0, 0, 0, 0.08);
}

/* Header = same surface as body (no purple stripe) */
.md-header {
  background-color: var(--md-default-bg-color);
  box-shadow: none;
  border-bottom: 1px solid var(--saxdocs-border);
}

/* Legacy tabs styles (tabs feature off) — harmless if unused */
.md-tabs {
  background-color: var(--md-default-bg-color);
  box-shadow: none;
  border-bottom: 1px solid var(--saxdocs-border);
}

.md-tabs__link--active {
  border-bottom: 2px solid var(--saxdocs-accent);
  opacity: 1;
}

/* ── Desktop sidebar ── */
@media screen and (min-width: 76.25em) {
  .md-sidebar--primary {
    width: 16.5rem;
    border-right: 1px solid var(--saxdocs-border);
  }

  .md-sidebar--secondary {
    border-left: 1px solid var(--saxdocs-border);
  }

  .md-sidebar--primary .md-nav__link {
    font-size: 0.8125rem;
    opacity: 0.88;
  }

  .md-sidebar--primary .md-nav__link:hover {
    opacity: 1;
  }
}

/* Shared nav styling (desktop + mobile drawer) */
.md-nav__link--active {
  font-weight: 500;
  opacity: 1;
  background: var(--saxdocs-sidebar-active);
  border-radius: 4px;
  box-shadow: inset 2px 0 0 var(--saxdocs-accent);
}

.md-nav__title {
  font-size: 0.6875rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  opacity: 0.5;
  font-weight: 600;
}

.md-nav__item--section > .md-nav__link {
  opacity: 0.65;
  font-size: 0.75rem;
  margin-top: 0.35rem;
}

/* ── Mobile / tablet drawer (< 1220px) ── */
@media screen and (max-width: 76.234375em) {
  /*
   * Material hardcodes drawer geometry at 12.1rem (left offset + translateX).
   * If we change width alone, ~6rem stays on screen when the drawer is "closed".
   * Keep all three in sync via one variable.
   */
  :root {
    --saxdocs-drawer-width: 16rem;
  }

  [dir="ltr"] .md-sidebar--primary {
    left: calc(-1 * var(--saxdocs-drawer-width));
    width: var(--saxdocs-drawer-width);
    max-width: min(var(--saxdocs-drawer-width), 92vw);
    border-right: none;
  }

  [dir="rtl"] .md-sidebar--primary {
    right: calc(-1 * var(--saxdocs-drawer-width));
    width: var(--saxdocs-drawer-width);
    max-width: min(var(--saxdocs-drawer-width), 92vw);
    border-right: none;
  }

  [dir="ltr"] [data-md-toggle="drawer"]:checked ~ .md-container .md-sidebar--primary {
    transform: translateX(var(--saxdocs-drawer-width));
    pointer-events: auto;
  }

  [dir="rtl"] [data-md-toggle="drawer"]:checked ~ .md-container .md-sidebar--primary {
    transform: translateX(calc(-1 * var(--saxdocs-drawer-width)));
    pointer-events: auto;
  }

  /* Closed drawer must not capture taps on the page underneath */
  [data-md-toggle="drawer"]:not(:checked) ~ .md-container .md-sidebar--primary {
    pointer-events: none;
  }

  .md-sidebar--secondary {
    display: none;
  }

  .md-nav--primary > .md-nav__list {
    overflow: hidden;
    width: 100%;
  }

  .md-nav--primary .md-nav {
    width: 100%;
  }

  .md-nav__link .md-ellipsis {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .md-nav--primary .md-nav__link {
    font-size: 0.875rem;
    line-height: 1.35;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    opacity: 1;
  }

  .md-nav__item--section > .md-nav__link {
    font-size: 0.8125rem;
    margin-top: 0.5rem;
    opacity: 0.75;
  }

  .md-nav__link--active {
    margin-inline: 0.35rem;
    padding-inline: 0.55rem;
  }

  .md-nav__title {
    font-size: 0.75rem;
    opacity: 0.55;
    padding-block: 0.65rem;
  }

  .md-sidebar__scrollwrap {
    -webkit-overflow-scrolling: touch;
  }

  .md-nav--primary .md-nav__item .md-nav__title {
    font-size: 0.8125rem;
    letter-spacing: normal;
    text-transform: none;
    font-weight: 600;
    opacity: 0.9;
  }

  .md-nav__icon.md-icon {
    min-width: 1.5rem;
    min-height: 1.5rem;
    flex-shrink: 0;
  }

  /* Content is full width — drawer is fixed overlay, not a column */
  .md-main,
  .md-main__inner {
    width: 100%;
    max-width: 100%;
  }

  .md-content {
    margin-inline: 0 !important;
    width: 100%;
    max-width: 100%;
  }

  .md-content__inner {
    max-width: 100%;
    padding-inline: 1rem;
  }

  .md-overlay {
    z-index: 3;
  }

  .md-sidebar--primary {
    z-index: 4;
  }
}

/* Content — readable width */
.md-content__inner {
  max-width: 48rem;
}

.md-typeset a {
  color: var(--saxdocs-accent);
  text-decoration: underline;
  text-decoration-color: var(--saxdocs-accent-soft);
  text-underline-offset: 2px;
}

.md-typeset a:hover {
  text-decoration-color: var(--saxdocs-accent);
}

/* Tables */
.md-typeset table:not([class]) {
  font-size: 0.875rem;
}

.md-typeset table:not([class]) tbody tr:nth-child(even) {
  background-color: var(--md-default-fg-color--lightest);
}

/* Home — compact section list */
.saxdocs-sections {
  display: grid;
  gap: 0.5rem;
  margin: 1.5rem 0 2rem;
  padding: 0;
  list-style: none;
}

.saxdocs-sections li {
  margin: 0;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--saxdocs-border);
  border-radius: 6px;
  transition: background 0.15s ease;
}

.saxdocs-sections li:hover {
  background: var(--saxdocs-sidebar-active);
}

.saxdocs-sections a {
  font-weight: 500;
  text-decoration: none;
}

.saxdocs-sections a:hover {
  text-decoration: underline;
}

.saxdocs-sections span {
  display: block;
  font-size: 0.8125rem;
  opacity: 0.65;
  margin-top: 0.15rem;
}

/* Mermaid */
.mermaid {
  margin: 1.25rem 0;
}

/* Mobile home section cards — full width tap targets */
@media screen and (max-width: 76.234375em) {
  .saxdocs-sections li {
    padding: 0.85rem 1rem;
  }
}
