/* GitHub-like visual layer on top of MkDocs Material.
   Color tokens aligned to Primer (primer.style/foundations/color). */
:root {
  --gh-bg: #ffffff;
  --gh-subtle-bg: #f6f8fa;
  --gh-border: #d1d9e0;
  --gh-border-muted: #d1d9e0b3;
  --gh-text: #1f2328;
  --gh-muted-text: #59636e;
  --gh-link: #0969da;
  --gh-link-hover: #0550ae;
}

[data-md-color-scheme="default"] {
  --md-default-bg-color: var(--gh-bg);
  --md-default-fg-color: var(--gh-text);
  --md-default-fg-color--light: var(--gh-muted-text);
  --md-default-fg-color--lighter: #59636e;
  --md-default-fg-color--lightest: #6e7781;
  --md-code-bg-color: var(--gh-subtle-bg);
  --md-code-fg-color: #1f2328;
  --md-typeset-a-color: var(--gh-link);
  --md-accent-fg-color: var(--gh-link);
  --md-primary-fg-color: var(--gh-subtle-bg);
  --md-primary-fg-color--light: #ffffff;
  --md-primary-fg-color--dark: #eaeef2;
}

body,
input,
button {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

/* --- Focus indicators (WCAG 2.4.7) --- */

*:focus-visible {
  outline: 2px solid var(--gh-link);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

.md-nav__link:focus-visible {
  outline: 2px solid var(--gh-link);
  outline-offset: 2px;
  background: var(--gh-subtle-bg);
}

.md-search__input:focus-visible {
  outline: 2px solid var(--gh-link);
  outline-offset: 0;
  border-color: var(--gh-link);
}

/* Prevent sticky header from obscuring focused elements (WCAG 2.4.11) */
*:focus {
  scroll-margin-top: calc(var(--md-header-height, 3.5rem) + 1rem);
  scroll-margin-bottom: 1rem;
}

:target {
  scroll-margin-top: calc(var(--md-header-height, 3.5rem) + 1rem);
}

/* --- Skip link (WCAG 2.4.1) --- */

.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--gh-link);
  color: #ffffff;
  padding: 8px 16px;
  text-decoration: none;
  border-radius: 0 0 4px 0;
  z-index: 9999;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

/* --- Header --- */

.md-header {
  color: var(--gh-text);
  background: var(--gh-subtle-bg);
  border-bottom: 1px solid var(--gh-border);
  box-shadow: none;
}

.md-header__title,
.md-header__button {
  color: var(--gh-text);
}

.md-search__input {
  background: #ffffff;
  border: 1px solid var(--gh-border);
}

/* --- Layout --- */

.md-main {
  background: var(--gh-bg);
}

.md-sidebar--primary .md-sidebar__scrollwrap {
  border-right: 1px solid var(--gh-border-muted);
}

.md-sidebar--secondary .md-sidebar__scrollwrap {
  border-left: 1px solid var(--gh-border-muted);
}

/* --- Navigation --- */

.md-nav__link {
  color: var(--gh-text);
}

.md-nav__link:hover,
.md-nav__link:focus,
.md-nav__link--active {
  color: var(--gh-link);
}

/* Rename the primary drawer title without changing site_name globally. */
.md-nav--primary > .md-nav__title[for="__drawer"] {
  align-items: center;
  display: flex;
}

.md-nav--primary > .md-nav__title[for="__drawer"] > * {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.md-nav--primary > .md-nav__title[for="__drawer"]::after {
  color: var(--gh-muted-text);
  font-size: 0.95rem;
  font-weight: 600;
}

/* --- Typography (Primer markdown) --- */

.md-typeset {
  line-height: 1.5;
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4 {
  color: var(--gh-text);
  font-weight: 600;
  line-height: 1.25;
}

.md-typeset h1 {
  font-size: 2em;
  border-bottom: 1px solid var(--gh-border);
  margin-top: 0;
  margin-bottom: 16px;
  padding-bottom: 0.3em;
}

.md-typeset h2 {
  font-size: 1.5em;
  border-bottom: 1px solid var(--gh-border);
  margin-top: 24px;
  margin-bottom: 16px;
  padding-bottom: 0.3em;
}

.md-typeset h3 {
  font-size: 1.25em;
  margin-top: 24px;
  margin-bottom: 16px;
}

.md-typeset h4 {
  font-size: 1em;
  margin-top: 24px;
  margin-bottom: 16px;
}

.md-typeset p {
  color: var(--gh-text);
  margin-top: 0;
  margin-bottom: 16px;
}

.md-typeset ul,
.md-typeset ol {
  color: var(--gh-text);
  margin-bottom: 16px;
  padding-left: 2em;
}

.md-typeset li {
  margin-bottom: 0.25em;
}

.md-typeset li + li {
  margin-top: 0.25em;
}

/* Links: underline by default for color-blind users (WCAG 1.4.1) */
.md-typeset a {
  color: var(--gh-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.md-typeset a:hover {
  color: var(--gh-link-hover);
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

/* Navigation links don't need underline (obvious link context) */
.md-nav__link,
.md-header a,
.md-footer a,
.md-tabs a {
  text-decoration: none;
}

.md-nav__link:hover,
.md-header a:hover,
.md-footer a:hover {
  text-decoration: underline;
}

/* --- Code (Primer markdown) --- */

.md-typeset code {
  background: var(--gh-subtle-bg);
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  color: #1f2328;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 85%;
  padding: 0.2em 0.4em;
}

.md-typeset pre > code {
  border: 0;
  border-radius: 0;
  padding: 0;
}

.md-typeset pre {
  background: #f6f8fa;
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  font-size: 85%;
  line-height: 1.45;
}

/* --- Mermaid diagrams --- */

.md-typeset pre.mermaid,
.md-typeset .mermaid {
  background: #ffffff;
  border: 1px solid var(--gh-border);
  border-radius: 6px;
  padding: 16px;
}

.md-typeset pre.mermaid > code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 1rem;
}

.md-typeset .mermaid svg {
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: 100%;
}

/* --- Draw.io diagrams --- */

.md-typeset .mxgraph {
  margin: 16px auto;
  text-align: center;
}

/* --- Blockquotes --- */

.md-typeset blockquote {
  color: var(--gh-muted-text);
  border-left: 0.25em solid var(--gh-border);
  padding: 0 1em;
}

/* --- Tables (responsive for WCAG 1.4.10 Reflow) --- */

.md-typeset table:not([class]) {
  display: block;
  overflow-x: auto;
  border: 1px solid var(--gh-border);
  border-collapse: collapse;
  margin-top: 0;
  margin-bottom: 16px;
}

.md-typeset table:not([class]) th,
.md-typeset table:not([class]) td {
  border: 1px solid var(--gh-border);
  padding: 6px 13px;
}

.md-typeset table:not([class]) th {
  background: var(--gh-subtle-bg);
  font-weight: 600;
}

.md-typeset table:not([class]) tr:nth-child(2n) {
  background: var(--gh-subtle-bg);
}

/* --- Admonitions --- */

.md-typeset .admonition,
.md-typeset details {
  background: #f6f8fa;
  border: 1px solid var(--gh-border);
  box-shadow: none;
}

.md-typeset .admonition-title,
.md-typeset summary {
  background: #eaeef2;
}

/* --- Check lists (icon-based, no bullet) --- */

.md-typeset ul li > .twemoji:first-child,
.md-typeset ul li > .emojione:first-child,
.md-typeset ul li > .gemoji:first-child {
  margin-right: 0.4em;
}

.md-typeset ul:has(> li > .twemoji:first-child) {
  list-style: none;
  padding-left: 0.5em;
}

/* --- Horizontal rules --- */

.md-typeset hr {
  height: 0.25em;
  margin: 24px 0;
  padding: 0;
  background-color: var(--gh-border);
  border: 0;
}

/* --- Content area --- */

.md-content__inner {
  padding-top: 24px;
  padding-bottom: 32px;
}

.md-content__button {
  color: var(--gh-link);
}

/* --- Mobile layout --- */

@media screen and (max-width: 76.234375em) {
  .md-sidebar--primary .md-sidebar__scrollwrap,
  .md-sidebar--secondary .md-sidebar__scrollwrap {
    border: 0;
  }

  /* Remove end-gap in drawer rows so chevrons sit at the sidebar edge. */
  [dir="ltr"] .md-nav--primary .md-nav__item > .md-nav__link {
    margin-right: 0;
  }

  [dir="rtl"] .md-nav--primary .md-nav__item > .md-nav__link {
    margin-left: 0;
  }

  .md-nav--primary .md-nav__item--nested > .md-nav__link {
    padding-right: 0.2rem;
  }

  .md-nav--primary .md-nav__item--nested > .md-nav__link .md-nav__icon {
    margin-right: 0;
  }
}

/* --- Responsive tables at small viewports --- */

@media (max-width: 30em) {
  .md-typeset table:not([class]) {
    font-size: 0.85rem;
  }

  .md-typeset table:not([class]) th,
  .md-typeset table:not([class]) td {
    padding: 4px 8px;
  }
}

/* --- Desktop layout --- */

@media screen and (min-width: 76.25em) {
  .md-main__inner.md-grid {
    align-items: start;
    column-gap: 0;
    display: grid;
    grid-template-columns: clamp(11.5rem, 14vw, 14.5rem) minmax(0, 1fr) clamp(10.5rem, 12vw, 14rem);
    margin: 0;
    max-width: 100%;
    padding-inline: clamp(0.5rem, 1vw, 1rem);
  }

  .md-sidebar--primary,
  .md-sidebar--secondary {
    align-self: start;
    margin: 0;
    position: sticky;
    top: calc(var(--md-header-height) + 0.4rem);
    width: 100%;
  }

  .md-sidebar--primary {
    grid-column: 1;
  }

  [dir="ltr"] .md-sidebar--primary .md-sidebar__inner {
    padding-right: 0;
  }

  [dir="rtl"] .md-sidebar--primary .md-sidebar__inner {
    padding-left: 0;
  }

  .md-sidebar--primary .md-nav--primary {
    width: 100%;
  }

  /* Desktop: keep chevron close to label (not fixed at far-right). */
  .md-nav--primary .md-nav__item--nested > .md-nav__link {
    justify-content: flex-start;
  }

  [dir="ltr"] .md-nav--primary .md-nav__item--nested > .md-nav__link .md-icon:last-child {
    margin-left: 0.35rem;
  }

  [dir="rtl"] .md-nav--primary .md-nav__item--nested > .md-nav__link .md-icon:last-child {
    margin-right: 0.35rem;
  }

  .md-content {
    grid-column: 2;
    min-width: 0;
  }

  .md-content__inner {
    margin-inline: 0;
    max-width: 100%;
  }

  .md-content__inner .md-typeset {
    max-width: 100%;
  }

  .md-sidebar--secondary {
    grid-column: 3;
  }
}
