/* ==========================================================================
   a11y.css: accessibility preferences and widget UI (Tal Barbibay site)

   Loaded after main.css on every page. Uses the semantic tokens that
   main.css defines on :root, and overrides them for the colour modes.

   1. Token fallbacks (zero specificity, main.css always wins)
   2. Preference modes on <html>
      data-a11y-text, a11y-contrast, a11y-light, a11y-grayscale,
      a11y-links, a11y-headings, a11y-readable, a11y-spacing,
      a11y-cursor, a11y-focus, no-motion
   3. Widget: trigger, tooltip, dialog panel, controls
   4. Reading guide
   5. Small screens, forced colours, print
   ========================================================================== */


/* 1. Token fallbacks
   Only used if main.css fails to load, so the widget stays legible. */
:where(:root) {
  --bg: #0B0A08;
  --bg-elev: #12100D;
  --bg-elev-2: #1A1713;
  --text: #F3EEE6;
  --text-muted: #B9B0A3;
  --accent: #C9A36A;
  --accent-strong: #E3C99A;
  --accent-ink: #0B0A08;
  --champagne: #E8D5B0;
  --line: rgba(232, 213, 176, .12);
  --line-strong: rgba(232, 213, 176, .28);
  --glass-bg: rgba(26, 23, 19, .55);
  --glass-border: rgba(227, 201, 154, .18);
  --focus: #F5D08A;
  --success: #7FD1A8;
  --danger: #FF9C8A;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 14px 36px -12px rgba(0, 0, 0, .55);
  --font-display: "IBM Plex Sans Hebrew", "Heebo", system-ui, sans-serif;
  --font-body: "Heebo", system-ui, "Segoe UI", Arial, sans-serif;
}


/* ==========================================================================
   2. Preference modes
   ========================================================================== */

/* 2.1 Text size: the site sizes type and most spacing in rem. */
html[data-a11y-text="-1"] { font-size: 90%; }
html[data-a11y-text="1"]  { font-size: 112.5%; }
html[data-a11y-text="2"]  { font-size: 125%; }
html[data-a11y-text="3"]  { font-size: 150%; }


/* 2.2 High contrast: strict black, white, yellow and cyan palette. */
html.a11y-contrast {
  --bg: #000000;
  --bg-elev: #000000;
  --bg-elev-2: #111111;
  --text: #FFFFFF;
  --text-muted: #FFFFFF;
  --accent: #FFD500;
  --accent-strong: #FFE866;
  --accent-ink: #000000;
  --champagne: #FFE866;
  --line: #FFFFFF;
  --line-strong: #FFFFFF;
  --glass-bg: #000000;
  --glass-border: #FFFFFF;
  --focus: #00E5FF;
  --success: #7CFFB2;
  --danger: #FF9C8A;
  --shadow: none;
  color-scheme: dark;
  background-color: #000000;
}

html.a11y-contrast .decor { display: none !important; }

html.a11y-contrast *,
html.a11y-contrast *::before,
html.a11y-contrast *::after {
  text-shadow: none !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
  -webkit-text-fill-color: currentColor !important;
}

/* Remove gradients, glows and textures; real images keep their content. */
html.a11y-contrast :not(img, picture, svg, video, canvas, iframe, [role="img"]),
html.a11y-contrast *::before,
html.a11y-contrast *::after {
  background-image: none !important;
}

html.a11y-contrast a {
  text-decoration-line: underline !important;
  text-underline-offset: .2em;
}

html.a11y-contrast :is(input, select, textarea) {
  border-color: var(--line) !important;
}

html.a11y-contrast :focus-visible {
  outline: 3px solid var(--focus) !important;
  outline-offset: 2px !important;
}

html.a11y-contrast ::selection {
  background: #FFD500;
  color: #000000;
}


/* 2.3 Light background: warm paper palette, every text pair at least 4.5:1. */
html.a11y-light {
  --bg: #FAF7F2;
  --bg-elev: #FFFFFF;
  --bg-elev-2: #F1EBE1;
  --text: #1A1714;
  --text-muted: #4A433A;
  --accent: #7A5A1E;
  --accent-strong: #5E4414;
  --accent-ink: #FFFFFF;
  --champagne: #5E4414;
  --line: rgba(26, 23, 20, .14);
  --line-strong: rgba(26, 23, 20, .32);
  --glass-bg: rgba(255, 255, 255, .8);
  --glass-border: rgba(26, 23, 20, .16);
  --focus: #0B57D0;
  --success: #1B6B45;
  --danger: #B3261E;
  --shadow: 0 1px 2px rgba(26, 23, 20, .06), 0 14px 36px -14px rgba(26, 23, 20, .22);
  color-scheme: light;
  background-color: #FAF7F2;
}

html.a11y-light .decor { opacity: .35 !important; }

html.a11y-light ::selection {
  background: #7A5A1E;
  color: #FFFFFF;
}


/* 2.4 Grayscale.
   A fixed backdrop-filter layer on the root greys out everything beneath it
   without putting a filter on any ancestor, so position:fixed and sticky
   elements keep working. Browsers without backdrop-filter fall back to a
   filter on the top-level page blocks (never on <html> or the widget). */
html.a11y-grayscale::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  pointer-events: none;
  -webkit-backdrop-filter: grayscale(1);
  backdrop-filter: grayscale(1);
}

@supports not ((backdrop-filter: grayscale(1)) or (-webkit-backdrop-filter: grayscale(1))) {
  html.a11y-grayscale::before { content: none; }
  html.a11y-grayscale body > :not(.a11y-root) { filter: grayscale(1); }
}


/* 2.5 Link highlighting */
html.a11y-links a {
  text-decoration-line: underline !important;
  text-decoration-thickness: max(2px, .08em) !important;
  text-underline-offset: .22em !important;
}

html.a11y-links a:not(:focus-visible) {
  outline: 2px dashed currentColor !important;
  outline-offset: 3px !important;
}


/* 2.6 Heading highlighting (page content only, not the widget) */
html.a11y-headings body > :not(.a11y-root) :is(h1, h2, h3, h4, h5, h6) {
  outline: 2px solid var(--accent) !important;
  outline-offset: .3em !important;
  border-radius: 2px;
}


/* 2.7 Readable font */
html.a11y-readable {
  --font-display: Arial, "Segoe UI", system-ui, sans-serif;
  --font-body: Arial, "Segoe UI", system-ui, sans-serif;
}

html.a11y-readable body,
html.a11y-readable body * {
  font-family: Arial, "Segoe UI", system-ui, sans-serif !important;
  letter-spacing: normal !important;
}


/* 2.8 Text spacing (WCAG 1.4.12 values), page content only.
   More specific than 2.7, so it wins when both are on. */
html.a11y-spacing body > :not(.a11y-root),
html.a11y-spacing body > :not(.a11y-root) * {
  line-height: 1.5 !important;
  letter-spacing: .12em !important;
  word-spacing: .16em !important;
}

html.a11y-spacing body > :not(.a11y-root) p {
  margin-block-end: 2em !important;
}


/* 2.9 Large cursor (48px arrow and pointing hand, black with a white edge) */
html.a11y-cursor,
html.a11y-cursor * {
  cursor: url("../img/cursor-arrow.svg") 6 3, auto !important;
}

html.a11y-cursor :is(a[href], button:not(:disabled), [role="button"], summary, label, select,
  input[type="checkbox"], input[type="radio"], input[type="submit"], input[type="button"]),
html.a11y-cursor :is(a[href], button:not(:disabled), [role="button"], summary, label) * {
  cursor: url("../img/cursor-hand.svg") 17 4, pointer !important;
}

html.a11y-cursor :is(input:not([type="checkbox"], [type="radio"], [type="submit"], [type="button"], [type="range"], [type="color"]), textarea, [contenteditable="true"]) {
  cursor: text !important;
}


/* 2.10 Stronger focus indicator */
html.a11y-focus :focus-visible,
html.a11y-focus :is(input, select, textarea):focus {
  outline: 4px solid var(--focus) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 8px rgba(245, 208, 138, .35) !important;
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--focus) 35%, transparent) !important;
}


/* 2.11 Stop animations: set by the boot script (saved choice or OS setting)
   or by the widget. main.js also stops GSAP, Lenis and the marquee. */
html.no-motion {
  scroll-behavior: auto !important;
}

html.no-motion *,
html.no-motion *::before,
html.no-motion *::after {
  animation-duration: .001ms !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

/* Kept in its own rule: browsers without view transitions drop only this one. */
html.no-motion::view-transition-group(*),
html.no-motion::view-transition-old(*),
html.no-motion::view-transition-new(*) {
  animation: none !important;
}


/* ==========================================================================
   3. Widget
   Every rule is scoped to .a11y-root classes, so global element styles in
   main.css (h2, p, button, a) never leak in, and nothing leaks out.
   ========================================================================== */

.a11y-root {
  --a11y-fab: 56px;
  --a11y-edge: 16px;
  --a11y-bottom: max(16px, env(safe-area-inset-bottom));
  --a11y-ease: cubic-bezier(.2, .8, .2, 1);
  --a11y-radius: 1.25rem;
  --a11y-tile-radius: 1rem;
  font-family: var(--font-body);
  color: var(--text);
  line-height: 1.5;
  text-align: start;
}

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

.a11y-root .a11y-icon {
  display: block;
  flex: none;
  width: 1.5rem;
  height: 1.5rem;
}

.a11y-root .a11y-sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.a11y-root .a11y-kbd {
  display: inline-block;
  margin: 0;
  padding: .0625rem .375rem;
  border: 1px solid var(--line-strong);
  border-block-end-width: 2px;
  border-radius: .375rem;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
  letter-spacing: 0;
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
}


/* 3.1 Trigger: fixed on the inline-start side (the right edge in RTL),
   mirroring the WhatsApp button on the opposite corner. */
.a11y-root .a11y-trigger {
  position: fixed;
  z-index: 900;
  bottom: var(--a11y-bottom);
  inset-inline-start: var(--a11y-edge);
  display: grid;
  place-items: center;
  inline-size: var(--a11y-fab);
  block-size: var(--a11y-fab);
  margin: 0;
  padding: 0;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--bg-elev);
  color: var(--accent-strong);
  box-shadow: var(--shadow);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Fine inner hairline for the bronze medallion look */
.a11y-root .a11y-trigger::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  pointer-events: none;
}

.a11y-root .a11y-trigger .a11y-trigger__icon {
  width: 30px;
  height: 30px;
}

.a11y-root .a11y-trigger:hover,
.a11y-root .a11y-trigger[aria-expanded="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.a11y-root .a11y-trigger:hover::before,
.a11y-root .a11y-trigger[aria-expanded="true"]::before {
  border-color: var(--accent-ink);
  opacity: .25;
}

.a11y-root .a11y-trigger:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Small dot that shows custom preferences are active (visual hint only) */
.a11y-root .a11y-trigger.has-prefs::after {
  content: "";
  position: absolute;
  top: 1px;
  inset-inline-end: 1px;
  width: 14px;
  height: 14px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
}

.a11y-root .a11y-trigger.has-prefs:hover::after,
.a11y-root .a11y-trigger.has-prefs[aria-expanded="true"]::after {
  background: var(--accent-ink);
  border-color: var(--accent);
}

/* Tooltip: hover or keyboard focus only, dismissible with Esc, hoverable */
.a11y-root .a11y-trigger__tip {
  position: absolute;
  top: 50%;
  inset-inline-start: calc(100% + 12px);
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border: 1px solid var(--line-strong);
  border-radius: .75rem;
  background: var(--bg-elev-2);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  transform: translateY(-50%);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Bridge across the gap so the pointer can move onto the tooltip */
.a11y-root .a11y-trigger__tip::before {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: -14px;
  inline-size: 14px;
}

.a11y-root .a11y-trigger:hover .a11y-trigger__tip,
.a11y-root .a11y-trigger:focus-visible .a11y-trigger__tip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.a11y-root .a11y-trigger.is-tip-dismissed .a11y-trigger__tip,
.a11y-root .a11y-trigger[aria-expanded="true"] .a11y-trigger__tip {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

@media (hover: none) {
  .a11y-root .a11y-trigger:hover:not(:focus-visible) .a11y-trigger__tip {
    opacity: 0;
    visibility: hidden;
  }
}


/* 3.2 Backdrop and dialog panel */
.a11y-root .a11y-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(5, 4, 3, .32);
  opacity: 0;
}

.a11y-root.is-open .a11y-backdrop { opacity: 1; }

.a11y-root .a11y-backdrop[hidden],
.a11y-root .a11y-panel[hidden] {
  display: none !important;
}

.a11y-root .a11y-panel {
  position: fixed;
  z-index: 1000;
  bottom: calc(var(--a11y-bottom) + var(--a11y-fab) + 12px);
  inset-inline-start: var(--a11y-edge);
  display: block;
  inline-size: min(22.5rem, calc(100vw - 2 * var(--a11y-edge)));
  max-block-size: calc(100vh - var(--a11y-fab) - 3.5rem);
  max-block-size: calc(100dvh - var(--a11y-fab) - 3.5rem);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  border: 1px solid var(--line-strong);
  border-radius: var(--a11y-radius);
  background: var(--bg-elev);
  color: var(--text);
  box-shadow: var(--shadow), 0 32px 80px -24px rgba(0, 0, 0, .6);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.5;
  text-align: start;
  container: a11y-panel / inline-size;
  opacity: 0;
  transform: translateY(10px) scale(.98);
  transform-origin: 100% 100%;
}

[dir="ltr"] .a11y-root .a11y-panel { transform-origin: 0 100%; }

.a11y-root:not(.is-open) .a11y-panel { pointer-events: none; }

.a11y-root.is-open .a11y-panel {
  opacity: 1;
  transform: none;
}

html:not(.no-motion) .a11y-root .a11y-panel {
  transition: opacity .22s var(--a11y-ease), transform .34s var(--a11y-ease);
}

html:not(.no-motion) .a11y-root .a11y-backdrop {
  transition: opacity .22s ease;
}

html:not(.no-motion) .a11y-root :is(.a11y-trigger, .a11y-trigger__tip, .a11y-close, .a11y-step, .a11y-tile, .a11y-tile__icon, .a11y-tile__check, .a11y-reset, .a11y-link, .a11y-stepper__dot) {
  transition: background-color .18s ease, border-color .18s ease, color .18s ease, opacity .18s ease, visibility .18s ease;
}

.a11y-root .a11y-panel__grip { display: none; }

/* Sticky header keeps only the badge, title and close button, so it stays
   one compact row even at 150% text on a 320px screen. */
.a11y-root .a11y-panel__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.125rem .625rem;
  border-block-end: 1px solid transparent;
  background: var(--bg-elev);
}

.a11y-root .a11y-panel.is-scrolled .a11y-panel__head { border-block-end-color: var(--line); }

.a11y-root .a11y-panel__badge {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.5rem;
  block-size: 2.5rem;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent-strong);
}

.a11y-root .a11y-panel__badge .a11y-icon {
  width: 1.375rem;
  height: 1.375rem;
}

.a11y-root .a11y-panel__title {
  flex: 0 1 auto;
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  max-inline-size: none;
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0;
  text-transform: none;
}

.a11y-root .a11y-panel__title:focus { outline: none; }

.a11y-root .a11y-panel__title:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 4px;
}

.a11y-root .a11y-panel__desc {
  margin: 0;
  padding-block: 0 .875rem;
  padding-inline: calc(1.125rem + 3.25rem) 1.125rem;
  max-inline-size: none;
  border-block-end: 1px solid var(--line);
  color: var(--text-muted);
  font-size: .875rem;
  line-height: 1.5;
}

/* Narrow panel for its text size: drop the badge, give the text full width */
@container a11y-panel (max-width: 19rem) {
  .a11y-root .a11y-panel__badge { display: none; }
  .a11y-root .a11y-panel__desc { padding-inline-start: 1.125rem; }
}

.a11y-root .a11y-close {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.75rem;
  block-size: 2.75rem;
  margin: 0;
  margin-inline-start: auto;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.a11y-root .a11y-close .a11y-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.a11y-root .a11y-close:hover {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}


/* 3.3 Panel body and groups */
.a11y-root .a11y-panel__body {
  display: grid;
  gap: 1.25rem;
  padding: 1rem 1.125rem .5rem;
  container-type: inline-size;
}

.a11y-root .a11y-group { margin: 0; }

.a11y-root .a11y-group__title {
  display: flex;
  align-items: center;
  gap: .625rem;
  margin: 0 0 .625rem;
  padding: 0;
  max-inline-size: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: .8125rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: .02em;
  text-transform: none;
}

.a11y-root .a11y-group__title::after {
  content: "";
  flex: 1 1 auto;
  block-size: 1px;
  background: var(--line);
}


/* 3.4 Text size stepper */
.a11y-root .a11y-stepper {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: .375rem;
  padding: .375rem;
  border: 1px solid var(--line);
  border-radius: var(--a11y-tile-radius);
  background: var(--bg-elev-2);
}

.a11y-root .a11y-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  min-block-size: 3.5rem;
  margin: 0;
  padding: .5rem .375rem;
  border: 1px solid transparent;
  border-radius: .75rem;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .8125rem;
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
  cursor: pointer;
}

.a11y-root .a11y-step .a11y-icon { color: var(--accent-strong); }

.a11y-root .a11y-step:hover {
  border-color: var(--line-strong);
  background: var(--bg-elev);
}

.a11y-root .a11y-step[aria-disabled="true"] {
  opacity: .5;
  cursor: not-allowed;
}

.a11y-root .a11y-step[aria-disabled="true"]:hover {
  border-color: transparent;
  background: transparent;
}

.a11y-root .a11y-stepper__value {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  min-inline-size: 4.75rem;
  margin: 0;
  padding: 0 .25rem;
  max-inline-size: none;
}

.a11y-root .a11y-stepper__num {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

.a11y-root .a11y-stepper__dots {
  display: flex;
  gap: .25rem;
}

.a11y-root .a11y-stepper__dot {
  inline-size: .4375rem;
  block-size: .4375rem;
  border-radius: 50%;
  background: var(--line-strong);
}

.a11y-root .a11y-stepper__dot.is-on { background: var(--accent); }


/* 3.5 Toggle tiles */
.a11y-root .a11y-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .5rem;
}

.a11y-root .a11y-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: .625rem;
  min-block-size: 5.5rem;
  margin: 0;
  padding: .75rem .875rem;
  border: 1px solid var(--line);
  border-radius: var(--a11y-tile-radius);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: start;
  cursor: pointer;
}

.a11y-root .a11y-tile:hover { border-color: var(--line-strong); }

.a11y-root .a11y-tile__icon {
  display: grid;
  place-items: center;
  flex: none;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  border: 1px solid var(--line-strong);
  border-radius: .75rem;
  color: var(--accent-strong);
}

.a11y-root .a11y-tile__icon .a11y-icon {
  width: 1.25rem;
  height: 1.25rem;
}

.a11y-root .a11y-tile__text {
  display: flex;
  flex-direction: column;
  gap: .125rem;
  min-inline-size: 0;
}

.a11y-root .a11y-tile__label { display: block; }

.a11y-root .a11y-tile__note {
  display: block;
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 400;
  line-height: 1.3;
}

.a11y-root .a11y-tile__note[hidden] { display: none; }

.a11y-root .a11y-tile__check {
  position: absolute;
  top: .625rem;
  inset-inline-end: .625rem;
  display: grid;
  place-items: center;
  inline-size: 1.25rem;
  block-size: 1.25rem;
  border: 1.5px solid var(--text-muted);
  border-radius: 50%;
  color: transparent;
}

.a11y-root .a11y-tile__check .a11y-icon {
  width: .8125rem;
  height: .8125rem;
}

.a11y-root .a11y-tile[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--bg-elev-2);
  background: color-mix(in srgb, var(--accent) 14%, var(--bg-elev-2));
}

.a11y-root .a11y-tile[aria-pressed="true"] .a11y-tile__icon,
.a11y-root .a11y-tile[aria-pressed="true"] .a11y-tile__check {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
}

/* An odd last tile spans the row and lays out horizontally */
.a11y-root .a11y-grid > .a11y-tile:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  min-block-size: 3.75rem;
}

.a11y-root .a11y-grid > .a11y-tile:last-child:nth-child(odd) .a11y-tile__check {
  top: 50%;
  transform: translateY(-50%);
}

.a11y-root .a11y-grid > .a11y-tile:last-child:nth-child(odd) .a11y-tile__text { padding-inline-end: 2rem; }

/* One column when the panel is narrow for its text size (reflow at 150%) */
@container (max-width: 17rem) {
  .a11y-root .a11y-grid { grid-template-columns: minmax(0, 1fr); }
  .a11y-root .a11y-grid > .a11y-tile {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    min-block-size: 3.75rem;
  }
  .a11y-root .a11y-grid > .a11y-tile .a11y-tile__check {
    top: 50%;
    transform: translateY(-50%);
  }
  .a11y-root .a11y-grid > .a11y-tile .a11y-tile__text { padding-inline-end: 2rem; }
  .a11y-root .a11y-stepper {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .a11y-root .a11y-stepper__value {
    grid-column: 1 / -1;
    grid-row: 1;
    flex-direction: row;
    gap: .625rem;
    padding: .25rem 0;
  }
}


/* 3.6 Footer: reset, links, shortcut hint */
.a11y-root .a11y-panel__foot {
  display: grid;
  gap: .75rem;
  margin-block-start: .75rem;
  padding: .875rem 1.125rem 1.125rem;
  border-block-start: 1px solid var(--line);
}

.a11y-root .a11y-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  inline-size: 100%;
  min-block-size: 2.875rem;
  margin: 0;
  padding: .625rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .9375rem;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
}

.a11y-root .a11y-reset .a11y-icon {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--accent-strong);
}

.a11y-root .a11y-reset:hover {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}

.a11y-root .a11y-panel__links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9.5rem, 100%), 1fr));
  gap: .5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.a11y-root .a11y-panel__links > li {
  margin: 0;
  padding: 0;
}

.a11y-root .a11y-panel__links > li::before,
.a11y-root .a11y-panel__links > li::marker {
  content: none;
}

.a11y-root .a11y-link {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-block-size: 2.75rem;
  padding: .5rem .75rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  color: var(--accent-strong);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: .2em;
}

.a11y-root .a11y-link .a11y-icon {
  width: 1.125rem;
  height: 1.125rem;
}

.a11y-root .a11y-link:hover {
  border-color: var(--accent);
  background: var(--bg-elev-2);
  text-decoration-thickness: 2px;
}

.a11y-root .a11y-hint {
  margin: 0;
  padding: 0;
  max-inline-size: none;
  color: var(--text-muted);
  font-size: .8125rem;
  line-height: 1.5;
  text-align: center;
}


/* 3.7 Focus rings inside the widget */
.a11y-root :is(button, a):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.a11y-root :is(button, a):focus:not(:focus-visible) { outline: none; }


/* ==========================================================================
   4. Reading guide: a band that follows the pointer (and keyboard focus)
   ========================================================================== */
.a11y-root .a11y-reading-guide {
  position: fixed;
  top: 0;
  inset-inline: 0;
  z-index: 1100;
  block-size: 12px;
  border-block: 2px solid var(--accent);
  background: rgba(201, 163, 106, .22);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  pointer-events: none;
  transform: translate3d(0, -100px, 0);
  will-change: transform;
}


/* ==========================================================================
   5. Small screens, forced colours, print
   ========================================================================== */

/* Phones and short landscape screens: full-width bottom sheet */
@media (max-width: 767.98px), (max-height: 540px) {
  .a11y-root .a11y-backdrop { background: rgba(5, 4, 3, .6); }

  .a11y-root .a11y-panel {
    bottom: 0;
    inset-inline: 0;
    inline-size: 100%;
    max-inline-size: 40rem;
    max-block-size: 85vh;
    max-block-size: 85dvh;
    margin-inline: auto;
    padding-block-end: env(safe-area-inset-bottom);
    border-block-end: 0;
    border-radius: 1.375rem 1.375rem 0 0;
    transform: translateY(40px);
    transform-origin: 50% 100%;
  }

  [dir="ltr"] .a11y-root .a11y-panel { transform-origin: 50% 100%; }

  .a11y-root .a11y-panel__grip {
    display: block;
    inline-size: 2.5rem;
    block-size: .25rem;
    margin: .5rem auto 0;
    border-radius: 999px;
    background: var(--line-strong);
  }

  .a11y-root .a11y-panel__head { padding-block-start: .75rem; }
}

@media (max-width: 480px) {
  .a11y-root { --a11y-fab: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .a11y-root .a11y-panel,
  .a11y-root .a11y-backdrop {
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .a11y-root :is(.a11y-trigger, .a11y-panel, .a11y-tile, .a11y-step, .a11y-close, .a11y-reset, .a11y-link, .a11y-trigger__tip, .a11y-stepper) {
    border: 1px solid CanvasText;
  }

  .a11y-root .a11y-tile[aria-pressed="true"] {
    outline: 3px solid Highlight;
    outline-offset: -4px;
  }

  .a11y-root .a11y-tile[aria-pressed="true"] .a11y-tile__check {
    forced-color-adjust: none;
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }

  .a11y-root .a11y-stepper__dot { forced-color-adjust: none; background: GrayText; }
  .a11y-root .a11y-stepper__dot.is-on { background: Highlight; }

  .a11y-root .a11y-reading-guide {
    forced-color-adjust: none;
    border-color: Highlight;
    background: transparent;
  }

  html.a11y-grayscale::before { content: none; }
}

@media print {
  .a11y-root { display: none !important; }
  html.a11y-grayscale::before { content: none; }
}
