/* a11y.css — styles for the shared accessibility layer (a11y.js). The same file in every
   Avalex app; an app tunes it with the custom properties below, never by editing it. */
:root {
  --a11y-focus: #1a56c4;            /* focus ring on light pages: 6.6:1 on white */
  --a11y-focus-dark: #ffcf5c;       /* focus ring on dark pages */
  --a11y-panel-bg: #11141a;
  --a11y-panel-fg: #f4f6fa;
  --a11y-panel-line: #5b6577;
  --a11y-accent: #ffcf5c;
  --a11y-offset-x: 1rem;            /* an app with its own fixed corner UI moves the button */
  --a11y-offset-y: 1rem;
}
html[data-a11y-surface="dark"] { --a11y-focus: var(--a11y-focus-dark); }

/* Skip link: first focusable element, off-screen until focused. */
.a11y-skip {
  position: fixed; left: 0; top: 0; z-index: 2147483000; transform: translateY(-120%);
  background: var(--a11y-panel-bg); color: var(--a11y-panel-fg);
  padding: .75rem 1.25rem; border-radius: 0 0 .5rem 0; font: 600 1rem/1.2 system-ui, sans-serif;
  text-decoration: underline;
}
.a11y-skip:focus { transform: none; outline: 3px solid var(--a11y-accent); outline-offset: -3px; }

/* Keyboard users always get a visible ring, whatever the page's own CSS removed.
   Pointer users keep the page's own focus styling. */
html[data-a11y-kbd] :focus-visible {
  outline: 3px solid var(--a11y-focus) !important; outline-offset: 2px !important;
}

/* ── Preferences button and panel ───────────────────────────────────────── */
.a11y-root { font: 400 1rem/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.a11y-fab {
  position: fixed; z-index: 2147482000;
  right: calc(var(--a11y-offset-x) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--a11y-offset-y) + env(safe-area-inset-bottom, 0px));
  width: 2.75rem; height: 2.75rem; padding: 0; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--a11y-panel-bg); color: var(--a11y-panel-fg);
  border: 2px solid var(--a11y-accent); box-shadow: 0 4px 16px rgba(0, 0, 0, .35);
}
.a11y-fab svg { width: 1.5rem; height: 1.5rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.a11y-fab svg circle { fill: currentColor; stroke: none; }
.a11y-fab:hover, .a11y-fab[aria-expanded="true"] { background: var(--a11y-accent); color: #11141a; }
.a11y-fab:focus-visible { outline: 3px solid var(--a11y-accent); outline-offset: 3px; }
.a11y-panel {
  position: fixed; z-index: 2147482000; box-sizing: border-box;
  right: calc(var(--a11y-offset-x) + env(safe-area-inset-right, 0px));
  bottom: calc(var(--a11y-offset-y) + 3.5rem + env(safe-area-inset-bottom, 0px));
  width: min(19rem, calc(100vw - 2rem)); max-height: calc(100vh - 6rem); overflow: auto;
  background: var(--a11y-panel-bg); color: var(--a11y-panel-fg);
  border: 1px solid var(--a11y-panel-line); border-radius: .75rem; padding: 1rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .5); text-align: left;
}
.a11y-panel[hidden] { display: none; }
.a11y-panel h2 {
  font: 700 .8rem/1.2 system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase;
  margin: 0 0 .75rem; color: #c3cad6; background: none; -webkit-text-fill-color: currentColor;
}
.a11y-panel label { display: flex; align-items: center; gap: .65rem; min-height: 2.5rem; cursor: pointer; color: inherit; font-size: 1rem; }
.a11y-panel input { width: 1.2rem; height: 1.2rem; margin: 0; flex: none; accent-color: var(--a11y-accent); }
.a11y-panel :focus-visible { outline: 3px solid var(--a11y-accent) !important; outline-offset: 2px !important; }
.a11y-hint { margin: -.35rem 0 .25rem 1.85rem; font-size: .8rem; color: #c3cad6; }
.a11y-sizes { border: 0; margin: 0 0 .5rem; padding: 0; display: flex; align-items: center; gap: .5rem; }
.a11y-sizes legend { float: left; width: auto; margin-right: auto; padding: 0; font-size: 1rem; color: inherit; }
.a11y-panel .a11y-size {
  position: relative; justify-content: center; gap: 0; width: 2.75rem; height: 2.75rem; min-height: 0;
  border: 1px solid var(--a11y-panel-line); border-radius: .5rem; font-weight: 700;
}
.a11y-size input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.a11y-size-0 span { font-size: .9rem; }
.a11y-size-1 span { font-size: 1.2rem; }
.a11y-size-2 span { font-size: 1.55rem; }
.a11y-size:has(input:checked) { background: var(--a11y-accent); border-color: var(--a11y-accent); color: #11141a; }
.a11y-size:has(input:focus-visible) { outline: 3px solid var(--a11y-accent); outline-offset: 2px; }
.a11y-reset {
  margin-top: .75rem; width: 100%; min-height: 2.5rem; padding: .5rem; border-radius: .5rem; cursor: pointer;
  background: transparent; color: var(--a11y-panel-fg); border: 1px solid var(--a11y-panel-line); font: inherit; font-size: .9rem;
}
.a11y-reset:hover { border-color: var(--a11y-accent); }
@media print { .a11y-root, .a11y-skip { display: none !important; } }
@media (forced-colors: active) {
  .a11y-fab, .a11y-panel, .a11y-size, .a11y-reset { border: 2px solid ButtonText; }
  .a11y-size:has(input:checked) { background: Highlight; color: HighlightText; forced-color-adjust: none; }
}

/* ── Preferences ────────────────────────────────────────────────────────── */
/* Higher contrast. The filter sits on the root element, which is the one place a filter
   does not re-anchor position:fixed descendants. Apps add their own token overrides
   under html[data-a11y-contrast="high"] for muted text and hairline borders. */
html[data-a11y-contrast="high"] { filter: contrast(1.3); }
html[data-a11y-contrast="high"] :is(input, select, textarea):not([type="checkbox"], [type="radio"], [type="range"]) { border-color: currentColor !important; }
html[data-a11y-contrast="high"] ::placeholder { color: inherit !important; opacity: .8 !important; }
/* Larger text: rem-based layouts scale with the root size. */
html[data-a11y-text="large"] { font-size: 118%; }
html[data-a11y-text="xlarge"] { font-size: 136%; }
/* Underlined links, so a link never depends on colour alone. */
html[data-a11y-links="underline"] a:not(.a11y-skip) { text-decoration: underline !important; text-underline-offset: .18em; }
/* Motion: the operating system's setting by default, an explicit choice either way. */
@media (prefers-reduced-motion: reduce) {
  html:not([data-a11y-motion="full"]) *, html:not([data-a11y-motion="full"]) *::before, html:not([data-a11y-motion="full"]) *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}
html[data-a11y-motion="reduced"] *, html[data-a11y-motion="reduced"] *::before, html[data-a11y-motion="reduced"] *::after {
  animation-duration: .001ms !important; animation-iteration-count: 1 !important;
  transition-duration: .001ms !important; scroll-behavior: auto !important;
}

/* ── Utilities ──────────────────────────────────────────────────────────── */
.a11y-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0; }
.a11y-media-note { font-size: .875rem; border-left: 3px solid var(--a11y-focus); padding-left: .6rem; margin: .5rem 0; }
.a11y-transcript { margin: .5rem 0; }
.a11y-transcript summary { cursor: pointer; min-height: 1.5rem; }
.a11y-transcript-text { white-space: pre-wrap; margin-top: .5rem; }
