/*
 * Keyboard focus and mobile navigation for the BotBook MkDocs theme.
 *
 * --id-focus is a box-shadow token (DESIGN-SYSTEM.md §2.1): apply it with
 * box-shadow, never as an outline colour. All rings use the accent text
 * token, so they stay visible in both light and dark palettes.
 * Breakpoints follow MkDocs Material's own 76.1em / 60.1em / 44.9375em cuts;
 * the 390px rule covers a small phone viewport.
 */

/* == Keyboard focus visibility =========================================== */
.md-skip:focus,
.md-header__button:focus-visible,
.md-header__source a:focus-visible,
.md-search__input:focus-visible,
.md-search__result-link:focus-visible,
.md-nav__link:focus-visible,
.md-tabs__link:focus-visible,
.md-typeset a:focus-visible,
.md-typeset summary:focus-visible,
.md-typeset .button:focus-visible,
.md-content__button:focus-visible,
.md-footer-meta a:focus-visible,
.md-footer-nav a:focus-visible {
  box-shadow: var(--id-focus);
  border-radius: var(--id-radius-sm);
}

.md-search__form:focus-within {
  border-color: var(--id-accent);
  box-shadow: var(--id-focus);
}

.md-nav__toggle:focus-visible + .md-nav__link,
.md-nav__toggle:focus-visible ~ label {
  box-shadow: var(--id-focus);
}

/* Keep the skip link on-screen when focused, on the paper surface. */
.md-skip {
  background: var(--id-surface-solid);
  color: var(--id-accent-text);
  border: 1px solid var(--id-line);
}

/* == Wide tablets: keep the header and tab strip inside the viewport ===== */
@media screen and (max-width: 76.1em) {
  .md-header__inner {
    padding: 0 var(--id-space-4);
  }
  .md-tabs__list {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .md-tabs__list::-webkit-scrollbar {
    display: none;
  }
}

/* == Narrow tablets: drawer navigation stays on identity surfaces ======== */
@media screen and (max-width: 60.1em) {
  .md-header__topic:first-child {
    display: none;
  }
  .md-drawer {
    max-width: min(90vw, 320px);
    background: var(--id-paper);
    border-right: 1px solid var(--id-line);
    box-shadow: var(--id-shadow-card-hover);
  }
  .md-drawer .md-nav__title {
    position: sticky;
    top: 0;
    z-index: 1;
  }
  .md-nav--primary .md-nav__link {
    padding-top: var(--id-space-2);
    padding-bottom: var(--id-space-2);
  }
  .md-search__output {
    max-height: calc(100vh - 56px);
    overflow-y: auto;
  }
}

/* == Phones: no horizontal page scroll, readable chips and tables ======== */
@media screen and (max-width: 44.9375em) {
  .md-header__button.md-logo::after,
  .md-header__source {
    display: none;
  }
  .md-header__topic {
    font-size: var(--id-text-xs);
  }
  .md-typeset table:not([class]) {
    font-size: var(--id-text-sm);
  }
  .md-typeset__table {
    -webkit-overflow-scrolling: touch;
  }
  .md-footer-meta__inner {
    flex-wrap: wrap;
    gap: var(--id-space-3);
  }
  .md-footer-nav__link {
    min-width: 0;
  }
  .md-content__button {
    margin-right: var(--id-space-1);
  }
}

/* == 390px and below: tighten spacing without hiding navigation ========== */
@media screen and (max-width: 390px) {
  .md-header__inner {
    padding: 0 var(--id-space-2);
  }
  .md-typeset h1 {
    font-size: var(--id-text-3xl);
  }
  .md-typeset h2 {
    font-size: var(--id-text-2xl);
  }
  .md-typeset table:not([class]) th,
  .md-typeset table:not([class]) td {
    padding: var(--id-space-1) 6px;
  }
  .md-search__form {
    min-width: 0;
  }
}

/* == Reduced motion: identity durations collapse to zero ================= */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto !important;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
