/* Phase 15 — technical, mobile and accessibility optimisation */

/* Keyboard users should always have a visible focus indicator. */
:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

/* Keep the existing skip link usable without affecting the visual layout. */
.skip-link:focus {
  left: var(--gutter, 1rem);
  top: 1rem;
}

/* Mobile navigation: allow long menus to scroll instead of being clipped. */
@media (max-width: 900px) {
  .main-nav.open {
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .main-nav a {
    min-height: 48px;
    display: flex;
    align-items: center;
  }

  .nav-toggle {
    min-width: 48px;
    min-height: 44px;
  }
}

/* Comfortable touch targets for common controls. */
button,
.button,
.text-link,
.site-nav a,
.main-nav a {
  -webkit-tap-highlight-color: transparent;
}

@media (max-width: 640px) {
  input,
  select,
  textarea,
  button {
    font-size: 16px;
  }

  .button {
    min-height: 44px;
  }
}

/* Respect visitors who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Prevent accidental horizontal overflow from long legal text or controls. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
video,
iframe {
  max-width: 100%;
}

table {
  max-width: 100%;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Improve readability of long legal-resource pages. */
@media (max-width: 640px) {
  .wrap,
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  h1 {
    overflow-wrap: anywhere;
  }

  p,
  li,
  td,
  th {
    overflow-wrap: anywhere;
  }
}
