/*
  WCAG / Accessibility helpers (v3)
  - UI toolbar buttons
  - skip link
  - robust focus indicator (WCAG 2.2: 2.4.11)
  - font scaling (zoom)
  - high contrast
  - underline links
  - grayscale
  - increased spacing

  Keep this file loaded AFTER the main theme stylesheet.
*/

:root {
  /* A stable, high-contrast focus color for the default theme */
  --a11y-focus-color: #0b5fff; /* blue; typically >= 3:1 on light bg */
  --a11y-skip-bg: #ffffff;
  --a11y-skip-fg: #000000;
}

/* Visually hidden but accessible to screen readers */
.sr-only {
    position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ------------------------
   Skip link (WCAG 2.4.1)
------------------------- */
.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--a11y-skip-bg);
  color: var(--a11y-skip-fg);
  border: 2px solid currentColor;
  text-decoration: none;
  font-weight: 800;
  z-index: 99999;

  transform: translateY(-200%);
  transition: transform 150ms ease;
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
}

/* If you have a sticky header, prevent focus/targets from being hidden under it */
#main,
:target {
  scroll-margin-top: 140px;
}

/* ------------------------
   Robust focus ring (WCAG 2.4.7 + 2.4.11)
------------------------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--a11y-focus-color);
  outline-offset: 3px;
}

/* Ensure focus is still visible on dark/contrast mode backgrounds */
body.a11y-contrast {
  --a11y-focus-color: #ffd800; /* yellow on black */
  --a11y-skip-bg: #000000;
  --a11y-skip-fg: #ffffff;
}

/* ------------------------
   Accessibility toolbar UI
------------------------- */
.a11y-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.a11y-btn {
  height: 40px;
  min-width: 40px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  border: 1px solid var(--th-border-color);
  border-radius: 0px;
  background: var(--white-color);
  color: var(--title-color);

  font-size: 14px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.02em;

  
}

.a11y-btn:hover {
  
  border-color: var(--theme-color);
}

.a11y-btn[aria-pressed="true"] {
  background: var(--theme-color);
  border-color: var(--theme-color);
  color: var(--white-color);
}

/* Icons + labels inside accessibility buttons */
.a11y-btn > i.fa-solid {
  font-size: 14px;
  line-height: 1;
  display: inline-block;
}

.a11y-btn__label {
  white-space: nowrap;
  display: none;
}

/* On very small screens, keep only icons (labels are redundant thanks to aria-label) */
@media (max-width: 575px) {
  .a11y-btn__label {
    display: none;
  }
  .a11y-btn {
    padding: 0 10px;
  }
}

/* Make toolbar fit better in header */
.th-header .header-button {
  display: flex;
  align-items: center;
  gap: 10px;
}

@media (max-width: 1199px) {
  .a11y-btn {
    height: 36px;
    min-width: 36px;
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .a11y-btn {
    transition: none;
  }
  .a11y-btn:hover {
    transform: none;
  }
  .skip-link {
    transition: none;
  }
}

/* ------------------------
   Font scaling / zoom
   Note: CSS zoom is non-standard; browser zoom still recommended.
------------------------- */
body.a11y-zoom-1 { zoom: 1; }
body.a11y-zoom-2 { zoom: 1.12; }
body.a11y-zoom-3 { zoom: 1.25; }

/* Fallback for browsers without CSS zoom */
@supports not (zoom: 1) {
  body.a11y-zoom-1 { font-size: 18px; line-height: 32px; }
  body.a11y-zoom-2 { font-size: calc(18px * 1.12); line-height: calc(32px * 1.12); }
  body.a11y-zoom-3 { font-size: calc(18px * 1.25); line-height: calc(32px * 1.25); }
}

/* ------------------------
   Underline links
------------------------- */
body.a11y-underline a {
  text-decoration: underline !important;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 2px;
}

/* ------------------------
   High contrast theme
------------------------- */
body.a11y-contrast {
  --th-body-background: #000000;
  --smoke-color: #000000;
  --smoke-color2: #000000;
  --smoke-color3: #000000;

  --title-color: #ffffff;
  --title-color2: #ffffff;
  --title-color3: #ffffff;
  --title-color4: #ffffff;

  --body-color: #ffffff;

  --th-border-color: #ffffff;
  --th-border-color2: #ffffff;
  --th-border-color3: rgba(255, 255, 255, 0.7);
  --th-border-color4: rgba(255, 255, 255, 0.7);
  --th-border-color7: #ffffff;

  --light-color: #ffffff;
  --gray-color: #000000;
  --gray-color2: #000000;
  --gray-color3: #ffffff;

  --theme-color: #ffd800;  /* yellow highlight */
  --theme-color2: #00e5ff; /* cyan highlight */
}

body.a11y-contrast,
body.a11y-contrast .th-header .menu-area,
body.a11y-contrast .header-top {
  background-color: var(--th-body-background) !important;
}

body.a11y-contrast a {
  color: var(--theme-color);
}

body.a11y-contrast .a11y-btn {
  background: #000;
  color: #fff;
  border-color: #fff;
}

body.a11y-contrast .a11y-btn[aria-pressed="true"] {
  background: var(--theme-color);
  border-color: var(--theme-color);
  color: #000;
}

/* Ensure form controls are visible */
body.a11y-contrast :where(input, select, textarea) {
  background: #000;
  color: #fff;
  border-color: #fff;
}

/* ------------------------
   Grayscale (desaturated)
------------------------- */
body.a11y-grayscale {
  -webkit-filter: grayscale(100%);
  filter: grayscale(100%);
}

/* ------------------------
   Increased spacing (line/paragraph)
   Supports WCAG 1.4.12 testing.
------------------------- */
body.a11y-spacing {
  line-height: 1.8 !important;
}

body.a11y-spacing :where(p, li, td, th, blockquote, .text, .content) {
  line-height: 1.8 !important;
}

body.a11y-spacing p {
  margin-bottom: 1.25em !important;
}

body.a11y-spacing :where(ul, ol) {
  margin-bottom: 1.25em !important;
}

body.a11y-spacing :where(h1, h2, h3, h4, h5, h6) {
  margin-bottom: 0.9em !important;
}
