/*
 * Keyboard and layout accessibility fixes for the staff, referee, sign-in and older student pages.
 * Loaded after the Hyper theme from core/header.html and core/student_header.html.
 * Pages built on core/student_base.html have their own rules in student.css and do not load this file.
 * It sets no text, background or brand colours. Colours belong to the theme and the tenant; the contrast fixes
 * for the theme's palette are in contrast.css, which every layout loads.
 */

/* Skip link: visible only when it has keyboard focus. */
.skip-to-content {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 2000;
  background: #0b1a2b;
  color: #fff;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 600;
}
.skip-to-content:focus {
  left: 8px;
  color: #fff;
}
#main-content:focus { outline: none; }

/* A visible focus ring on every theme background. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible,
.btn:focus-visible {
  /* The theme sets "a, button { outline: 0 !important }", so this has to be important too. */
  outline: 3px solid #1d68d6 !important;
  outline-offset: 2px !important;
}
/* Light ring on the dark bars only. */
html[data-menu-color=dark] .topnav a:focus-visible,
html[data-topbar-color=dark] .navbar-custom a:focus-visible,
html[data-topbar-color=dark] .navbar-custom button:focus-visible,
.skip-to-content:focus-visible {
  outline-color: #7cc4ff !important;
}

/* Selection cards built from a div or a label with a visually hidden radio: show focus on the card. */
.pathway-card:has(input:focus-visible),
[data-a11y-toggle]:focus-visible {
  outline: 3px solid #1d68d6 !important;
  outline-offset: 2px !important;
}

/* Disabled-looking cards must not rely on opacity alone to be understood; aria-disabled carries the state. */
[data-a11y-toggle][aria-disabled=true] { cursor: not-allowed; }

/* Respect reduced motion. Spinners keep turning so loading is still visible. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/*
 * Reflow at 320px (WCAG 1.4.10). Floating labels never wrap, so long questions pushed the page wider than
 * the screen. On narrow screens the label is drawn above the control instead. The DOM order is unchanged.
 */
@media (max-width: 575.98px) {
  .form-floating {
    display: flex;
    flex-direction: column-reverse;
  }
  .form-floating > label {
    position: static;
    height: auto;
    padding: 0 0 0.25rem;
    white-space: normal;
    overflow: visible;
    transform: none !important;
    opacity: 1 !important;
    border: 0;
    pointer-events: auto;
  }
  .form-floating > .form-control,
  .form-floating > .form-select {
    height: auto;
    min-height: calc(1.5em + 1rem + 2px);
    padding: 0.5rem 0.75rem;
  }
  .form-floating > .form-control:not(:placeholder-shown),
  .form-floating > .form-control:focus,
  .form-floating > .form-select {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
}

/* The footer has a fixed height in the theme. With the accessibility link added it needs room to wrap on phones. */
@media (max-width: 767.98px) {
  .footer {
    height: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
  .content-page {
    padding-bottom: 130px !important;
  }
}

/* Footer links are 19px tall in the theme. WCAG 2.5.8 asks for 24px. */
.footer .footer-links a {
  display: inline-block;
  min-height: 24px;
  line-height: 24px;
}
