/*
 * Accessibility layer of the online quote tool (WCAG 2.1 AA). Loaded after styles.css.
 *
 * Someone using a mouse sees one difference: a text field now shows a ring while the cursor is
 * in it (it showed nothing before). Everything else here appears with the keyboard only.
 */

:root {
  --quote-focus-ring: #3071BF; /* Primary-700, the ring of the main website */
  --quote-focus-halo: #FFFFFF; /* keeps the ring visible on the blue landing panel */
  --quote-focus-width: 3px;
  --quote-focus-offset: 2px;
}

/* ── Skip link: out of sight until the first press of the Tab key ── */
.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2000;
  padding: 10px 16px;
  border-radius: 8px;
  background: #FFFFFF;
  color: #1F448D;
  font-family: Lato, sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 24px;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus {
  transform: none;
}

/* ── Keyboard focus indicator (WCAG 2.4.7) ──
   Bootstrap and the tool's own styles switch the outline off (.btn:focus, .form-control-custom),
   which is why these declarations carry !important. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: var(--quote-focus-width) solid var(--quote-focus-ring) !important;
  outline-offset: var(--quote-focus-offset) !important;
  box-shadow: 0 0 0 var(--quote-focus-offset) var(--quote-focus-halo) !important;
}

/* On the blue landing panel a blue ring disappears: there the ring is white, with a dark gap
   that separates it from the white zip field. */
#homePanel :focus-visible {
  outline-color: #FFFFFF !important;
  box-shadow: 0 0 0 var(--quote-focus-offset) #17356C !important; /* Primary-950 */
}

/* The rates button sets its own shadow with a heavier selector. */
#ratesContent .buttonInterested:focus-visible {
  box-shadow: 0 0 0 var(--quote-focus-offset) var(--quote-focus-halo) !important;
}

/* Small icon buttons: more air around the ring, rounded like the icon. */
.deleteCar:focus-visible,
[id="deleteDriver"]:focus-visible,
.review-edit:focus-visible {
  outline-offset: 4px !important;
  border-radius: 4px;
}

.languageSwitchContent .languageSwitch:focus-visible {
  outline-offset: 6px !important;
  border-radius: 12px;
}

/* The months field sits flush against its unit: keep the ring above it. */
.form-control-month:focus-visible {
  position: relative;
  z-index: 3;
}

/* Whole regions receive focus only so a screen reader starts reading there: no ring around them.
   The same goes for whatever a11y.js focused for someone who is not using the keyboard
   (the second selector outweighs the landing-panel rule above). */
#quoteMain:focus-visible,
#rates17:focus-visible,
#thankYou18:focus-visible,
.a11y-quiet-focus:focus-visible,
#quoteMain .a11y-quiet-focus:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* The VIN error starts on its own line, under the example. */
#inputVINumberError {
  display: block;
}

/* The step title receives focus when the step changes: the ring hugs the text, not the full row. */
#stepTitle {
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  border-radius: 8px;
}

#stepTitle:focus-visible,
#homePanel h1:focus-visible {
  outline-offset: 6px !important;
}

/* The titles of the rates and thank-you screens are drawn by main.js as full-width paragraphs:
   the ring hugs the text only while one of them has the keyboard focus. */
#rates17 [role="heading"]:focus-visible,
#thankYou18 [role="heading"]:focus-visible {
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
  border-radius: 8px;
  outline-offset: 6px !important;
}
