/* Accessibility options toolbar. Loaded after site.css and uses its colour tokens.
   Reused from the sister site, adapted to this site's dark header and footer.
   Without any saved choice nothing below changes how the site looks, except the toolbar button itself.
   Choices are classes on <html>: a11y-text-1, a11y-text-2, a11y-dark, a11y-light, a11y-gray, a11y-underline, a11y-focus.
   Rules about colour use !important on purpose: they must win over the normal styles of every component. */

/* ---------- the button (needs JavaScript, so it is hidden without it) ---------- */
.a11y-toggle {
  display: none; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; padding: 0; margin: 0;
  background: none; color: var(--limestone); border: 1.5px solid rgba(197, 208, 211, .6); border-radius: 3px; cursor: pointer;
}
.js .a11y-toggle { display: inline-flex; }
.a11y-toggle svg { display: block; width: 24px; height: 24px; }
.a11y-toggle:hover, .a11y-toggle[aria-expanded="true"] { background: var(--limestone); color: var(--ink); border-color: var(--limestone); }

/* ---------- the panel ---------- */
.a11y-panel {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 5;
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px var(--gutter) 20px; max-height: calc(100vh - 70px); overflow-y: auto;
  background: var(--chalk); color: var(--ink); border-bottom: 1px solid var(--ink);
  box-shadow: 0 18px 24px -14px rgba(0, 0, 0, .3);
  --focus: var(--ochre-deep);
}
.a11y-panel[hidden] { display: none; }
@media (min-width: 760px) {
  .a11y-panel {
    left: auto; width: 340px; padding: 16px; border: 1px solid var(--ink);
    right: max(var(--gutter), calc((100% - 1120px) / 2));
  }
}
.a11y-title { font-family: var(--serif); font-size: 1.1875rem; font-weight: 600; line-height: 1.3; }
.a11y-group { display: flex; flex-direction: column; gap: 8px; }
.a11y-group-label { font-size: .875rem; font-weight: 600; color: var(--slate); }
.a11y-readout { font-variant-numeric: tabular-nums; font-weight: 400; }
.a11y-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.a11y-wide { grid-column: 1 / -1; }
.a11y-btn {
  min-height: 44px; padding: 8px 10px; background: #fff; color: var(--ink);
  border: 1.5px solid var(--ink); border-radius: 3px; cursor: pointer;
  font: 500 .875rem/1.25 var(--sans); text-align: center;
}
.a11y-btn:hover { background: var(--limestone); }
.a11y-btn[aria-pressed="true"] { background: var(--ink); color: var(--chalk); }
.a11y-btn[aria-pressed="true"]::before { content: "\2713\00a0"; content: "\2713\00a0" / ""; }   /* a tick as well as the colour, so the state does not rely on colour alone */
.a11y-btn[aria-disabled="true"] { opacity: .55; cursor: default; }
.a11y-btn[aria-disabled="true"]:hover { background: #fff; }
.a11y-reset { width: 100%; }

/* ---------- text size: CSS zoom on the page content ---------- */
html.a11y-text-1 :is(main, .site-footer) { zoom: 1.15; }
html.a11y-text-2 :is(main, .site-footer) { zoom: 1.3; }
html:is(.a11y-text-1, .a11y-text-2) :is(main, .site-footer) { overflow-wrap: break-word; }

/* ---------- grayscale: never on body or any ancestor of a fixed element ---------- */
html.a11y-gray :is(.site-header, main, .site-footer, .skip-link) { filter: grayscale(1); }
html.a11y-gray body { background: #ececec; }   /* the page colour cannot be filtered (no filter on body), so it is set to the gray of Limestone */

/* ---------- high contrast: dark and light share one set of rules, the colours come from variables ---------- */
html.a11y-dark {
  --a11y-bg: #171717; --a11y-fg: #fff; --a11y-link: #ffee00; --a11y-line: #bdbdbd;
  --a11y-btn-bg: #ffee00; --a11y-btn-fg: #000; --a11y-field-bg: #000; --a11y-focus: #ffee00;
}
html.a11y-light {
  --a11y-bg: #fff; --a11y-fg: #111; --a11y-link: #0033cc; --a11y-line: #595959;
  --a11y-btn-bg: #111; --a11y-btn-fg: #fff; --a11y-field-bg: #fff; --a11y-focus: #000;
}
html:is(.a11y-dark, .a11y-light) body { background: var(--a11y-bg); color: var(--a11y-fg); }
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer),
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) :not(img) {
  background-color: var(--a11y-bg) !important; color: var(--a11y-fg) !important;
  border-color: var(--a11y-line) !important; text-shadow: none !important; box-shadow: none !important;
}
html:is(.a11y-dark, .a11y-light) .sun { visibility: hidden; }
html:is(.a11y-dark, .a11y-light) :is(.hero, .page-head)::after { opacity: .15; background-color: transparent; }
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) a:not(.btn) {
  color: var(--a11y-link) !important; text-decoration: underline !important; text-decoration-thickness: 2px !important; text-underline-offset: 3px !important;
}
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) a:not(.btn):hover { text-decoration-thickness: 4px !important; }
html:is(.a11y-dark, .a11y-light) .site-nav a[aria-current="page"] { border-bottom-color: currentColor !important; }
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) .btn {
  background-color: var(--a11y-btn-bg) !important; color: var(--a11y-btn-fg) !important; border-color: var(--a11y-btn-bg) !important;
}
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) .btn:hover {
  background-color: var(--a11y-bg) !important; color: var(--a11y-fg) !important; border-color: var(--a11y-fg) !important;
}
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) :is(input:not([type="checkbox"]), textarea) {
  background-color: var(--a11y-field-bg) !important; color: var(--a11y-fg) !important; border: 2px solid var(--a11y-fg) !important;
}
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) input[type="checkbox"] { accent-color: var(--a11y-link); }
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) :is(.a11y-toggle[aria-expanded="true"], .a11y-btn[aria-pressed="true"]) {
  background-color: var(--a11y-btn-bg) !important; color: var(--a11y-btn-fg) !important;
}
html:is(.a11y-dark, .a11y-light) :is(.site-header, main, .site-footer) :focus { outline-color: var(--a11y-focus) !important; }
html:is(.a11y-dark, .a11y-light) :is(.contact-aside, .details, .form-panel) { border: 2px solid var(--a11y-line); }
/* Logos are drawn for one background only: put each on the colour it was made for.
   The header and footer use the reversed (light) logo, made for a dark ground. The contact page symbol is dark, made for a light ground. */
html.a11y-light :is(.brand img, .footer-logo) { background-color: #1B2A33; box-shadow: 0 0 0 6px #1B2A33 !important; }
html:is(.a11y-dark, .a11y-light) .contact-aside img { background-color: #fff; box-shadow: 0 0 0 4px #fff !important; }

/* ---------- underline links ---------- */
html.a11y-underline a { text-decoration-line: underline !important; text-decoration-thickness: 2px !important; text-underline-offset: 3px !important; }

/* ---------- highlight focus: black ring with a yellow halo, so it shows on light and dark backgrounds alike ---------- */
html.a11y-focus :is(a[href], button, input, select, textarea, summary, [tabindex]:not([tabindex="-1"])) { outline: 1px dotted currentColor; outline-offset: 2px; }
html.a11y-focus :focus-visible { outline: 3px solid #000 !important; outline-offset: 2px !important; box-shadow: 0 0 0 2px #ffee00 !important; }
