/*
 * Display options. Two halves in one file:
 *  1. Page-wide choices: a class on <html>, set by /js/a11y-early.js before the page draws.
 *  2. The button and panel, which live in a shadow root (every class starts with a11y-, and the
 *     whole thing sits under .a11y-root, so nothing here can leak into the page).
 * It is a display aid. It does not make a page compliant with anything.
 */

/* ===== 1. Page-wide choices ===== */

/* Text size. The site sizes its text in rem, so one percentage on the root scales it all. */
html.a11y-text-1 { font-size: 125%; }
html.a11y-text-2 { font-size: 150%; }
html.a11y-text-3 { font-size: 175%; }
html.a11y-text-4 { font-size: 200%; }
/* Big text on a small screen: long words and addresses wrap instead of pushing the page sideways. */
html[class*="a11y-text-"] body { overflow-wrap: break-word; hyphens: auto; }
/* The site keeps some labels on one line (the top menu, the cookie buttons). At big text they wrap or stack instead. */
html[class*="a11y-text-"] body *:not(#a11y-host):not(pre):not(code):not(.sr-only):not(.visually-hidden) { white-space: normal; }
/* Headings and the truck phone's grid let long words break rather than push the page sideways. */
html[class*="a11y-text-"] :is(h1, h2, h3, h4, .dkicker) { overflow-wrap: anywhere; }
html[class*="a11y-text-"] .drive > * { min-width: 0; }
/* Page titles stop growing once they'd be wider than a phone. */
html[class*="a11y-text-"] h1 { font-size: min(2.25rem, 11vw); }
/* The skip link hides above the page; bigger text makes it taller, so hide it further. */
html[class*="a11y-text-"] .skip-link:not(:focus),
html.a11y-spacing .skip-link:not(:focus) { top: -500px; }
html[class*="a11y-text-"] :is(.site-menu, .site-nav, .site-actions) { flex-wrap: wrap; margin-left: 0; }
/* The cookie banner at big text. Its buttons sit side by side where they fit and wrap where they don't.
   On a phone, either way up, its text stops at 150% (24px), so the banner covers about half the screen
   instead of most of it until it's answered. The rest of the page keeps the full size. */
html[class*="a11y-text-"] .consent-banner .consent-actions { flex-direction: row; flex-wrap: wrap; width: 100%; }
html[class*="a11y-text-"] .consent-banner .consent-btn { flex: 1 1 auto; width: auto; min-width: min-content; padding: 8px 14px; }
@media (max-width: 599px), (max-height: 599px) {
  html[class*="a11y-text-"] .consent-banner {
    font-size: min(1rem, 24px); gap: 10px;
    padding-top: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
}

/* More spacing: the WCAG 1.4.12 values. */
html.a11y-spacing body *:not(#a11y-host):not(svg):not(svg *):not(canvas) {
  line-height: 1.5 !important;
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
}
html.a11y-spacing body p:not(#a11y-host) { margin-bottom: 2em !important; }
/* The cookie banner's single paragraph needs no gap under it: the banner's own gap spaces it from the buttons. */
html.a11y-spacing .consent-banner p.consent-text:not(#a11y-host) { margin-bottom: 0 !important; }

/* Less motion. */
html.a11y-motion *:not(#a11y-host),
html.a11y-motion *:not(#a11y-host)::before,
html.a11y-motion *:not(#a11y-host)::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* Higher contrast: black and white, yellow links. The map, images, colour swatches and the toolbar keep their own colours. */
html.a11y-contrast body,
html.a11y-contrast body *:not(#a11y-host):not(img):not(video):not(svg):not(svg *):not(canvas):not(iframe):not(.maplibregl-map):not(.maplibregl-map *):not([class*="swatch"]):not(.dot) {
  background-color: #000 !important;
  background-image: none !important;
  color: #fff !important;
  border-color: #fff !important;
  text-shadow: none !important;
  box-shadow: none !important;
}
html.a11y-contrast a:not(#a11y-host):not(.maplibregl-map *),
html.a11y-contrast a:not(#a11y-host):not(.maplibregl-map *) * {
  color: #ff0 !important;
  text-decoration: underline !important;
}
html.a11y-contrast :focus-visible {
  outline: 3px solid #ff0 !important;
  outline-offset: 2px !important;
}

/* Room at the bottom so the floating button never sits on the last line of a page. */
html.a11y-floating body,
html.a11y-floating body.has-consent-banner { padding-bottom: calc(72px + var(--a11y-lift, 0px)); }

/* ===== 2. The button and panel (inside the shadow root) ===== */

.a11y-root, .a11y-root * { box-sizing: border-box; }

.a11y-root {
  --panel-bg: #ffffff;
  --panel-fg: #1b1f27;
  --muted: #4a5260;
  --line: #c9ced8;
  --tile: #f2f4f8;
  --accent: var(--accent-light);
  --on-accent: #ffffff;
  /* Above the cookie banner, but never off the top of a short screen. */
  --bottom: min(calc(12px + var(--a11y-lift, 0px) + env(safe-area-inset-bottom, 0px)), calc(100vh - 72px));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  /* Follows the page's text size a little, so the panel stays readable at the largest step. */
  font-size: calc(10px + 0.4rem);
  line-height: 1.4;
  color: var(--panel-fg);
  hyphens: manual;
  overflow-wrap: normal;
}
@media (prefers-color-scheme: dark) {
  .a11y-root {
    --panel-bg: #1b1f27;
    --panel-fg: #f2f4f8;
    --muted: #b7bfcc;
    --line: #3a4150;
    --tile: #272d38;
    --accent: var(--accent-dark);
    --on-accent: #111111;
  }
}

.a11y-launcher {
  position: fixed;
  left: 12px;
  bottom: var(--bottom);
  z-index: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0;
  padding: 0;
  border: 2px solid var(--on-brand);
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}
.a11y-launcher svg { width: 60%; height: 60%; flex: none; }
.a11y-launcher:hover { filter: brightness(1.1); }
/* On the truck phone it sits in the page, after the footer, instead of over the big buttons. */
.a11y-inline { padding: 16px; }
.a11y-inline .a11y-launcher { position: static; }

.a11y-panel {
  position: fixed;
  left: 12px;
  bottom: calc(var(--bottom) + 62px);
  z-index: 2147483000;
  width: min(24em, calc(100vw - 24px));
  max-height: calc(100vh - var(--bottom) - 86px);
  max-height: calc(100dvh - var(--bottom) - 86px);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  color: var(--panel-fg);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  overflow: hidden;
}
.a11y-inline .a11y-panel { bottom: 12px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); }
.a11y-panel[hidden] { display: none; }

.a11y-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.a11y-title { flex: 1; margin: 0; font-size: 1.15em; font-weight: 700; line-height: 1.2; color: inherit; }
.a11y-close {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent;
  color: var(--panel-fg); font: inherit; font-size: 1.7em; line-height: 1; cursor: pointer;
}
.a11y-close:hover { background: var(--tile); }

.a11y-body { padding: 12px 16px 4px; overflow-y: auto; flex: 1; }
.a11y-group { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
.a11y-group legend { padding: 0; margin: 0 0 6px; font-size: 0.82em; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.a11y-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.a11y-chip {
  min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--tile); color: var(--panel-fg); font: inherit; font-size: 0.95em; cursor: pointer;
}
.a11y-chip:hover:not(:disabled) { border-color: var(--panel-fg); }
.a11y-chip:disabled { opacity: 0.45; cursor: default; }

.a11y-stepper { display: flex; align-items: center; gap: 8px; }
.a11y-stepper .a11y-chip { min-width: 56px; font-weight: 700; }
.a11y-out { flex: 1; text-align: center; font-weight: 700; }

.a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.a11y-tile {
  min-height: 52px; padding: 8px 10px; border: 2px solid var(--line); border-radius: 10px;
  background: var(--tile); color: var(--panel-fg); font: inherit; font-size: 0.95em; line-height: 1.25;
  text-align: left; cursor: pointer;
}
.a11y-tile:hover { border-color: var(--panel-fg); }
.a11y-tile[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.a11y-state { display: block; font-size: 0.85em; font-weight: 700; }

.a11y-foot {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  padding: 10px 16px 12px; border-top: 1px solid var(--line); font-size: 0.85em; color: var(--muted);
}
.a11y-foot a { color: var(--panel-fg); }
.a11y-foot span { flex: 1 1 12em; }
.a11y-reset {
  min-height: 44px; padding: 8px 14px; border: 1px solid var(--panel-fg); border-radius: 8px;
  background: transparent; color: var(--panel-fg); font: inherit; font-size: 1.05em; cursor: pointer;
}
.a11y-credit { display: inline-block; padding: 6px 0; }

.a11y-launcher:focus-visible,
.a11y-chip:focus-visible,
.a11y-tile:focus-visible,
.a11y-close:focus-visible,
.a11y-reset:focus-visible,
.a11y-foot a:focus-visible { outline: 3px solid #ffbf00; outline-offset: 2px; box-shadow: 0 0 0 5px #000; }

.a11y-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 480px) {
  .a11y-panel { left: 12px; right: 12px; width: auto; }
  .a11y-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: no-preference) {
  .a11y-launcher { transition: transform 0.12s ease; }
  .a11y-launcher:hover { transform: scale(1.06); }
}
