/*
 * Accessibility Tools (public website): the floating button, its panel, and the page modes it switches on.
 * A site can restyle the tool with --a11y-accent, --a11y-accent-ink, --a11y-panel-bg, --a11y-panel-ink, --a11y-focus.
 * The page modes are classes on <html> set by a11y.js: a11y-zoomed (+ --a11y-zoom), a11y-gray, a11y-hc, a11y-neg,
 * a11y-light, a11y-underline, a11y-font.
 */

/* ---------------------------------------------------------------- the tool */
.dwb-a11y {
  --a11y-accent: #3b5bdb;
  --a11y-accent-ink: #fff;
  --a11y-panel-bg: #fff;
  --a11y-panel-ink: #1b1f2a;
  --a11y-focus: #111;
  position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 99990;
  display: flex; align-items: center; margin: 0; padding: 0;
  font: 400 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  letter-spacing: normal; text-transform: none; text-align: left;
}
.dwb-a11y:not(.is-ready) { display: none; }
.dwb-a11y, .dwb-a11y * { box-sizing: border-box; }

.dwb-a11y .dwb-a11y-toggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 46px; height: 46px; margin: 0; padding: 0; cursor: pointer;
  background: var(--a11y-accent); color: var(--a11y-accent-ink);
  border: 2px solid var(--a11y-panel-bg); border-left: 0; border-radius: 0 10px 10px 0;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .3); font: inherit;
}
.dwb-a11y .dwb-a11y-toggle:hover { filter: brightness(1.12); }
.dwb-a11y .dwb-a11y-toggle svg { display: block; width: 28px; height: 28px; }

.dwb-a11y .dwb-a11y-panel {
  width: 250px; max-width: calc(100vw - 56px); max-height: 80vh; max-height: min(80dvh, 520px); overflow-y: auto;
  margin: 0 0 0 8px; padding: 12px; background: var(--a11y-panel-bg); color: var(--a11y-panel-ink);
  border: 1px solid rgba(0, 0, 0, .15); border-radius: 12px; box-shadow: 0 10px 32px rgba(0, 0, 0, .28);
  overscroll-behavior: contain;
}
.dwb-a11y .dwb-a11y-panel[hidden] { display: none; }

.dwb-a11y .dwb-a11y-title {
  margin: 0 0 8px; padding: 0 4px 8px; border-bottom: 2px solid var(--a11y-accent);
  font: 700 16px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; color: var(--a11y-panel-ink);
  letter-spacing: normal; text-transform: none;
}
.dwb-a11y .dwb-a11y-list { list-style: none; margin: 0; padding: 0; }
.dwb-a11y .dwb-a11y-list li { margin: 0; padding: 0; list-style: none; }
.dwb-a11y .dwb-a11y-list li::before { content: none; }

.dwb-a11y .dwb-a11y-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 42px; margin: 2px 0; padding: 8px 10px;
  background: transparent; color: var(--a11y-panel-ink); border: 1px solid transparent; border-radius: 8px;
  font: 500 15px/1.3 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; letter-spacing: normal; text-transform: none;
  text-align: left; cursor: pointer; box-shadow: none;
}
.dwb-a11y .dwb-a11y-btn svg { flex: none; display: block; width: 20px; height: 20px; color: var(--a11y-accent); }
.dwb-a11y .dwb-a11y-btn:hover { background: rgba(59, 91, 219, .1); border-color: var(--a11y-accent); }
.dwb-a11y .dwb-a11y-btn[aria-pressed="true"] { background: var(--a11y-accent); color: var(--a11y-accent-ink); border-color: var(--a11y-accent); }
.dwb-a11y .dwb-a11y-btn[aria-pressed="true"] svg { color: var(--a11y-accent-ink); }

.dwb-a11y .dwb-a11y-toggle:focus-visible,
.dwb-a11y .dwb-a11y-btn:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; box-shadow: 0 0 0 6px #fff; }

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

@media (prefers-reduced-motion: no-preference) {
  .dwb-a11y .dwb-a11y-toggle, .dwb-a11y .dwb-a11y-btn { transition: background-color .15s ease, border-color .15s ease, filter .15s ease; }
}
@media (max-width: 600px) {
  .dwb-a11y .dwb-a11y-toggle { width: 40px; height: 40px; }
  .dwb-a11y .dwb-a11y-toggle svg { width: 24px; height: 24px; }
  .dwb-a11y .dwb-a11y-panel { margin-left: 6px; padding: 10px; max-height: 70vh; max-height: 70dvh; }
}
@media print {
  .dwb-a11y, html::after { display: none !important; }
}

/* ---------------------------------------------------------------- text size */
/* Many site stylesheets use px, so the whole page body is scaled with CSS zoom (Chrome, Edge, Safari, Firefox 126+).
   Older browsers fall back to the root font size, which only affects rem/em based text. */
@supports (zoom: 1) {
  html.a11y-zoomed body { zoom: var(--a11y-zoom, 1); }
  html.a11y-zoomed .dwb-a11y { zoom: calc(1 / var(--a11y-zoom, 1)); }
}
@supports not (zoom: 1) {
  html.a11y-zoomed { font-size: calc(var(--a11y-zoom, 1) * 100%); }
}

/* ---------------------------------------------------------------- grayscale and negative contrast */
/* Done with a fixed, click-through layer that filters what is behind it. A filter on <html> or <body> would turn every
   position:fixed element of the site (and this tool) into something that scrolls with the page. */
html.a11y-gray::after,
html.a11y-neg::after { content: ""; position: fixed; inset: 0; z-index: 99980; pointer-events: none; }
html.a11y-gray::after { -webkit-backdrop-filter: grayscale(1); backdrop-filter: grayscale(1); }
html.a11y-neg::after { -webkit-backdrop-filter: invert(1) hue-rotate(180deg); backdrop-filter: invert(1) hue-rotate(180deg); }
html.a11y-gray.a11y-neg::after { -webkit-backdrop-filter: grayscale(1) invert(1) hue-rotate(180deg); backdrop-filter: grayscale(1) invert(1) hue-rotate(180deg); }
/* pictures are inverted once here and once by the layer above, so they keep their real colours */
html.a11y-neg img, html.a11y-neg video, html.a11y-neg picture, html.a11y-neg iframe, html.a11y-neg canvas {
  filter: invert(1) hue-rotate(180deg);
}

/* ---------------------------------------------------------------- high contrast and light background */
html.a11y-hc, html.a11y-hc body,
html.a11y-hc body *:not(.dwb-a11y):not(.dwb-a11y *) {
  background-color: #000 !important; background-image: none !important; color: #fff !important;
  border-color: #fff !important; box-shadow: none !important; text-shadow: none !important;
}
html.a11y-hc a:not(.dwb-a11y a), html.a11y-hc a:not(.dwb-a11y a) * { color: #ff0 !important; }
html.a11y-hc button:not(.dwb-a11y button), html.a11y-hc input:not(.dwb-a11y input), html.a11y-hc select, html.a11y-hc textarea {
  border: 2px solid #fff !important;
}
html.a11y-hc img:not(.dwb-a11y img) { outline: 1px solid #fff; }

html.a11y-light, html.a11y-light body,
html.a11y-light body *:not(.dwb-a11y):not(.dwb-a11y *) {
  background-color: #fff !important; background-image: none !important; color: #111 !important;
  text-shadow: none !important;
}
html.a11y-light a:not(.dwb-a11y a), html.a11y-light a:not(.dwb-a11y a) * { color: #0b3d91 !important; }
html.a11y-light button:not(.dwb-a11y button), html.a11y-light input:not(.dwb-a11y input), html.a11y-light select, html.a11y-light textarea {
  border: 1px solid #555 !important;
}

/* ---------------------------------------------------------------- links and font */
html.a11y-underline a:not(.dwb-a11y a) { text-decoration: underline !important; text-underline-offset: .15em; }
html.a11y-font body,
html.a11y-font body *:not(.dwb-a11y):not(.dwb-a11y *):not(i):not([class*="icon"]):not([class^="fa"]):not([class*=" fa"]) {
  font-family: Verdana, Tahoma, "Segoe UI", system-ui, -apple-system, Arial, sans-serif !important;
}
