/* ============================================================
   Accessibility Menu
   Bottom-left floating button. Slide-out panel with 12 controls.
   Persists user preferences to localStorage.
   Brand: --agency-red #EE2128, --ink #111, --cream #FAF8F4
   Targets: WCAG 2.1 AA, prefers-reduced-motion, prefers-color-scheme.
   ============================================================ */

/* -----------------------------------------------------------
   1. Trigger button (bottom-left, always visible)
   ----------------------------------------------------------- */
.rc-a11y-trigger {
  position: fixed;
  left: 1.25rem;
  bottom: 1.25rem;
  z-index: 9100; /* above floating-contact (9000) so both can coexist */
  width: 3rem;
  height: 3rem;
  border-radius: 999px;
  background: #0067B1; /* ISA accessibility blue */
  color: #FFFFFF;
  border: 2px solid #0067B1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.rc-a11y-trigger:hover,
.rc-a11y-trigger:focus-visible {
  transform: translateY(-2px);
  background: #00558F; /* darker ISA blue on hover */
  border-color: #00558F;
  color: #FFFFFF;
  outline: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22), 0 3px 8px rgba(0, 0, 0, 0.12);
}

.rc-a11y-trigger svg {
  width: 1.5rem;
  height: 1.5rem;
  fill: currentColor;
}

/* -----------------------------------------------------------
   2. Panel
   ----------------------------------------------------------- */
.rc-a11y-panel {
  position: fixed;
  left: 1.25rem;
  bottom: 5rem;
  z-index: 9101;
  width: 22rem;
  max-width: calc(100vw - 2.5rem);
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  background: var(--cream, #FAF8F4);
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 6px 16px rgba(0, 0, 0, 0.1);
  padding: 1.25rem 1.25rem 1rem;
  font-family: 'Inter', system-ui, sans-serif;
  color: var(--ink, #111);
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.rc-a11y-panel[aria-hidden="false"] {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.rc-a11y-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.rc-a11y-panel__title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  color: var(--agency-red, #EE2128);
  line-height: 1.15;
}

.rc-a11y-panel__subtitle {
  font-size: 0.78rem;
  margin: 0.25rem 0 0;
  color: rgba(17, 17, 17, 0.72);
}

.rc-a11y-panel__close {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.25rem 0.4rem;
  color: rgba(17, 17, 17, 0.72);
  border-radius: 6px;
}

.rc-a11y-panel__close:hover,
.rc-a11y-panel__close:focus-visible {
  background: rgba(0, 0, 0, 0.06);
  color: var(--agency-red, #EE2128);
  outline: none;
}

/* -----------------------------------------------------------
   3. Control rows
   ----------------------------------------------------------- */
.rc-a11y-group {
  margin: 0.85rem 0 0;
}

.rc-a11y-group__label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(17, 17, 17, 0.55);
  margin: 0 0 0.45rem;
}

.rc-a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.rc-a11y-row:last-child {
  border-bottom: none;
}

.rc-a11y-row__label {
  flex: 1;
  font-size: 0.92rem;
  color: var(--ink, #111);
}

.rc-a11y-row__hint {
  display: block;
  font-size: 0.72rem;
  color: rgba(17, 17, 17, 0.55);
  margin-top: 0.15rem;
}

/* Toggle switch (boolean controls) */
.rc-a11y-toggle {
  position: relative;
  width: 2.6rem;
  height: 1.45rem;
  flex-shrink: 0;
  background: rgba(17, 17, 17, 0.18);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease;
  border: none;
  padding: 0;
}

.rc-a11y-toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  background: #FFFFFF;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}

.rc-a11y-toggle[aria-pressed="true"] {
  background: var(--agency-red, #EE2128);
}

.rc-a11y-toggle[aria-pressed="true"]::after {
  transform: translateX(1.15rem);
}

.rc-a11y-toggle:focus-visible {
  outline: 2px solid var(--agency-red, #EE2128);
  outline-offset: 2px;
}

/* Stepper (text size, line spacing, letter spacing) */
.rc-a11y-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(17, 17, 17, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: #FFFFFF;
  flex-shrink: 0;
}

.rc-a11y-stepper button {
  background: transparent;
  border: none;
  width: 1.85rem;
  height: 1.85rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--ink, #111);
}

.rc-a11y-stepper button:hover:not(:disabled),
.rc-a11y-stepper button:focus-visible {
  background: rgba(238, 33, 40, 0.1);
  color: var(--agency-red, #EE2128);
  outline: none;
}

.rc-a11y-stepper button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.rc-a11y-stepper__value {
  min-width: 2.2rem;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  border-left: 1px solid rgba(17, 17, 17, 0.12);
  border-right: 1px solid rgba(17, 17, 17, 0.12);
  padding: 0 0.25rem;
  line-height: 1.85rem;
}

/* Segmented selector (text alignment) */
.rc-a11y-segments {
  display: inline-flex;
  border: 1px solid rgba(17, 17, 17, 0.2);
  border-radius: 8px;
  overflow: hidden;
  background: #FFFFFF;
  flex-shrink: 0;
}

.rc-a11y-segments button {
  background: transparent;
  border: none;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
  cursor: pointer;
  color: var(--ink, #111);
  border-right: 1px solid rgba(17, 17, 17, 0.12);
}

.rc-a11y-segments button:last-child {
  border-right: none;
}

.rc-a11y-segments button[aria-pressed="true"] {
  background: var(--agency-red, #EE2128);
  color: #FFFFFF;
}

.rc-a11y-segments button:focus-visible {
  outline: 2px solid var(--agency-red, #EE2128);
  outline-offset: -2px;
}

/* Reset / footer */
.rc-a11y-panel__footer {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.rc-a11y-reset {
  background: transparent;
  border: 1px solid var(--agency-red, #EE2128);
  color: var(--agency-red, #EE2128);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.rc-a11y-reset:hover,
.rc-a11y-reset:focus-visible {
  background: var(--agency-red, #EE2128);
  color: #FFFFFF;
  outline: none;
}

.rc-a11y-panel__link {
  font-size: 0.74rem;
  color: var(--agency-red, #EE2128);
  text-decoration: none;
  letter-spacing: 0.06em;
}

.rc-a11y-panel__link:hover,
.rc-a11y-panel__link:focus-visible {
  text-decoration: underline;
  outline: none;
}

/* -----------------------------------------------------------
   4. Body-level visual effects
   These attach to <body data-a11y-...> and cascade everywhere.
   ----------------------------------------------------------- */

/* 4a. Text size (root font scale) */
body[data-a11y-text-size="larger"]   { font-size: 1.125rem; }
body[data-a11y-text-size="largest"]  { font-size: 1.25rem; }
body[data-a11y-text-size="xlarge"]   { font-size: 1.4rem; }

body[data-a11y-text-size="larger"]   h1,
body[data-a11y-text-size="largest"]  h1,
body[data-a11y-text-size="xlarge"]   h1,
body[data-a11y-text-size="larger"]   h2,
body[data-a11y-text-size="largest"]  h2,
body[data-a11y-text-size="xlarge"]   h2 { line-height: 1.2; }

/* 4b. Line spacing */
body[data-a11y-line-spacing="loose"]   *:not(svg):not(path) { line-height: 1.7 !important; }
body[data-a11y-line-spacing="looser"]  *:not(svg):not(path) { line-height: 2 !important; }

/* 4c. Letter spacing */
body[data-a11y-letter-spacing="wide"]   *:not(svg):not(path) { letter-spacing: 0.05em !important; }
body[data-a11y-letter-spacing="wider"]  *:not(svg):not(path) { letter-spacing: 0.1em !important; }

/* 4d. Text alignment override (force left when readable mode on) */
body[data-a11y-align="left"] p,
body[data-a11y-align="left"] li,
body[data-a11y-align="left"] h1,
body[data-a11y-align="left"] h2,
body[data-a11y-align="left"] h3,
body[data-a11y-align="left"] h4,
body[data-a11y-align="left"] .lede,
body[data-a11y-align="left"] [class*="hero"] { text-align: left !important; }

/* 4e. High contrast */
body[data-a11y-contrast="high"] {
  background: #000000 !important;
  color: #FFFFFF !important;
}

body[data-a11y-contrast="high"] *:not(.rc-a11y-trigger):not(.rc-a11y-trigger *):not(.rc-a11y-panel):not(.rc-a11y-panel *) {
  background-color: #000000 !important;
  color: #FFFFFF !important;
  border-color: #FFFFFF !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

body[data-a11y-contrast="high"] a:not(.rc-a11y-trigger):not(.rc-a11y-panel *) {
  color: #FFD400 !important;
  text-decoration: underline !important;
}

body[data-a11y-contrast="high"] button:not(.rc-a11y-trigger):not(.rc-a11y-panel button),
body[data-a11y-contrast="high"] .btn,
body[data-a11y-contrast="high"] [class*="cta"] {
  background-color: #FFD400 !important;
  color: #000000 !important;
  border: 2px solid #FFFFFF !important;
}

/* 4f. Dark mode (user-selected, distinct from high contrast) */
body[data-a11y-theme="dark"] {
  background: #181818 !important;
  color: #EDEDED !important;
}

body[data-a11y-theme="dark"] header,
body[data-a11y-theme="dark"] footer,
body[data-a11y-theme="dark"] section,
body[data-a11y-theme="dark"] main,
body[data-a11y-theme="dark"] article,
body[data-a11y-theme="dark"] .card,
body[data-a11y-theme="dark"] [class*="hero"],
body[data-a11y-theme="dark"] [class*="section"] {
  background-color: #181818 !important;
  color: #EDEDED !important;
}

body[data-a11y-theme="dark"] a:not(.rc-a11y-trigger):not(.rc-a11y-panel *) {
  color: #FF8A8E !important;
}

/* 4g. Reduce motion */
body[data-a11y-motion="reduce"] *,
body[data-a11y-motion="reduce"] *::before,
body[data-a11y-motion="reduce"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* 4h. Underline all links */
body[data-a11y-links="underline"] a:not(.rc-a11y-trigger):not(.rc-a11y-panel *) {
  text-decoration: underline !important;
}

/* 4i. Larger cursor */
body[data-a11y-cursor="large"],
body[data-a11y-cursor="large"] * {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'><polygon points='2,2 2,40 14,30 22,42 28,38 20,28 36,28' fill='black' stroke='white' stroke-width='2.5'/></svg>") 2 2, auto !important;
}

body[data-a11y-cursor="large"] a,
body[data-a11y-cursor="large"] button,
body[data-a11y-cursor="large"] [role="button"],
body[data-a11y-cursor="large"] input,
body[data-a11y-cursor="large"] select,
body[data-a11y-cursor="large"] textarea {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'><polygon points='2,2 2,40 14,30 22,42 28,38 20,28 36,28' fill='%23EE2128' stroke='white' stroke-width='2.5'/></svg>") 2 2, pointer !important;
}

/* 4j. Readable (dyslexia-friendly) font */
body[data-a11y-font="readable"],
body[data-a11y-font="readable"] *:not(.rc-a11y-trigger):not(.rc-a11y-trigger *):not(.rc-a11y-panel):not(.rc-a11y-panel *):not(i):not([class*="icon"]) {
  font-family: 'Atkinson Hyperlegible', 'Verdana', 'Tahoma', sans-serif !important;
  font-weight: 400 !important;
}

body[data-a11y-font="readable"] h1,
body[data-a11y-font="readable"] h2,
body[data-a11y-font="readable"] h3,
body[data-a11y-font="readable"] h4,
body[data-a11y-font="readable"] strong,
body[data-a11y-font="readable"] b {
  font-weight: 700 !important;
}

/* 4k. Saturation: grayscale */
body[data-a11y-saturation="grayscale"] {
  filter: grayscale(100%);
}

body[data-a11y-saturation="low"] {
  filter: saturate(50%);
}

/* 4l. Hide images (still allow logos in nav/footer for orientation) */
body[data-a11y-images="hide"] img:not([data-a11y-keep]),
body[data-a11y-images="hide"] picture:not([data-a11y-keep]),
body[data-a11y-images="hide"] video {
  visibility: hidden !important;
  position: relative;
}

body[data-a11y-images="hide"] img:not([data-a11y-keep])::after,
body[data-a11y-images="hide"] picture:not([data-a11y-keep])::after {
  content: attr(alt);
  visibility: visible;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0.5rem;
  background: rgba(17, 17, 17, 0.08);
  color: var(--ink, #111);
  font-size: 0.85rem;
  font-style: italic;
}

/* 4m. Keyboard focus highlight */
body[data-a11y-focus="visible"] *:focus {
  outline: 3px solid var(--agency-red, #EE2128) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(238, 33, 40, 0.25) !important;
}

/* -----------------------------------------------------------
   5. Mobile adjustments
   ----------------------------------------------------------- */
@media (max-width: 480px) {
  .rc-a11y-trigger {
    left: 0.85rem;
    bottom: 0.85rem;
    width: 2.65rem;
    height: 2.65rem;
  }

  .rc-a11y-panel {
    left: 0.85rem;
    right: 0.85rem;
    bottom: 4.4rem;
    width: auto;
    max-width: none;
  }
}

/* -----------------------------------------------------------
   6. Respect system prefers-reduced-motion on first paint
   ----------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .rc-a11y-panel,
  .rc-a11y-trigger,
  .rc-a11y-toggle::after {
    transition: none !important;
  }
}
