/*
 * Floating Accessibility widget — user-facing display/reading/motion controls, separate from
 * pto-a11y.js (which auto-wires label/input associations at render time; a developer-facing
 * markup fix, not a visitor-facing tool). Every effect here is opt-in and OFF by default; nothing
 * in this file changes how the site looks until a visitor turns something on from the panel.
 *
 * Filter-based Display modes (High/Dark contrast, Grayscale, Invert, Saturation, Dim images) are
 * computed and written into #pto-a11y-dynamic-style by pto-a11y-widget.js rather than as static
 * rules here, since more than one of them can combine into a single `filter` value at once (CSS
 * can't merge two independently-toggled classes' own `filter` declarations — the later one just
 * replaces the earlier one) — see that file's updateDynamicStyle().
 */

/* ---- Floating toggle button ---- */
.pto-a11y-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99998;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--pto-navy, #0f1b33);
  color: #fff;
  border: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  cursor: pointer;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.pto-a11y-toggle:hover,
.pto-a11y-toggle:focus-visible {
  background: var(--pto-navy-light, #17274a);
}
html[data-pto-a11y-pos="left"] .pto-a11y-toggle {
  right: auto;
  left: 20px;
}

/* ---- Panel ---- */
.pto-a11y-panel {
  position: fixed;
  bottom: 84px;
  right: 20px;
  z-index: 99999;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  background: #fff;
  color: #1f2937;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .32);
  padding: 0;
  display: none;
  font-family: var(--bws-font-sans, system-ui, sans-serif);
}
html[data-pto-a11y-pos="left"] .pto-a11y-panel {
  right: auto;
  left: 20px;
}
.pto-a11y-panel.pto-a11y-open {
  display: block;
}
.pto-a11y-panel-header {
  position: sticky;
  top: 0;
  background: var(--pto-navy, #0f1b33);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 14px 14px 0 0;
  z-index: 1;
}
.pto-a11y-panel-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}
.pto-a11y-panel-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.pto-a11y-panel-body {
  padding: 14px 16px 18px;
}

/* ---- Quick presets ---- */
.pto-a11y-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.pto-a11y-preset-btn {
  text-align: left;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  cursor: pointer;
  font-size: .8rem;
}
.pto-a11y-preset-btn strong {
  display: block;
  font-size: .85rem;
  margin-bottom: 2px;
  color: #1f2937;
}
.pto-a11y-preset-btn span {
  color: #6b7280;
}
.pto-a11y-preset-btn:hover,
.pto-a11y-preset-btn:focus-visible {
  border-color: var(--bws-primary, #b8860b);
  background: #fff;
}

/* ---- Section groups ---- */
.pto-a11y-section {
  margin-bottom: 16px;
}
.pto-a11y-section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6b7280;
  margin: 0 0 8px;
}
.pto-a11y-row {
  margin-bottom: 10px;
}
.pto-a11y-row-label {
  font-size: .85rem;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 5px;
  display: block;
}

/* Segmented (mutually-exclusive) choice groups: Size, Spacing, Display contrast mode. */
.pto-a11y-segmented {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.pto-a11y-segmented button {
  flex: 1 1 auto;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: .8rem;
  cursor: pointer;
  color: #1f2937;
}
.pto-a11y-segmented button.pto-a11y-active {
  background: var(--pto-navy, #0f1b33);
  border-color: var(--pto-navy, #0f1b33);
  color: #fff;
}

/* Plain on/off toggle rows (checkboxes styled as pill switches). */
.pto-a11y-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  font-size: .85rem;
  color: #1f2937;
  cursor: pointer;
}
.pto-a11y-switch {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
}
.pto-a11y-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.pto-a11y-switch-track {
  position: absolute;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: background .15s;
}
.pto-a11y-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .15s;
}
.pto-a11y-switch input:checked + .pto-a11y-switch-track {
  background: var(--bws-primary, #b8860b);
}
.pto-a11y-switch input:checked + .pto-a11y-switch-track::after {
  transform: translateX(16px);
}
.pto-a11y-switch input:focus-visible + .pto-a11y-switch-track {
  outline: 2px solid var(--pto-navy, #0f1b33);
  outline-offset: 2px;
}

.pto-a11y-slider-row input[type="range"] {
  width: 100%;
}

.pto-a11y-reset {
  width: 100%;
  margin-top: 4px;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #b91c1c;
  border-radius: 8px;
  padding: 8px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
}
.pto-a11y-note {
  font-size: .72rem;
  color: #9ca3af;
  text-align: center;
  margin: 10px 0 0;
}

/* ==========================================================================
   Effects applied to the whole page once a visitor turns them on.
   ========================================================================== */

/* --- Text size --- */
html[data-pto-a11y-size="large"] { font-size: 112.5%; }
html[data-pto-a11y-size="larger"] { font-size: 130%; }

/* --- Spacing --- */
html[data-pto-a11y-spacing="wide"] body { letter-spacing: .02em; line-height: 1.7; }
html[data-pto-a11y-spacing="wide"] p, html[data-pto-a11y-spacing="wide"] li { word-spacing: .08em; }
html[data-pto-a11y-spacing="wider"] body { letter-spacing: .04em; line-height: 1.9; }
html[data-pto-a11y-spacing="wider"] p, html[data-pto-a11y-spacing="wider"] li { word-spacing: .18em; }

/* --- Readable font: a plain, highly-legible sans stack in place of the site's display fonts. --- */
html[data-pto-a11y-readable-font="1"] body,
html[data-pto-a11y-readable-font="1"] h1,
html[data-pto-a11y-readable-font="1"] h2,
html[data-pto-a11y-readable-font="1"] h3,
html[data-pto-a11y-readable-font="1"] h4,
html[data-pto-a11y-readable-font="1"] .pto-serif {
  font-family: Verdana, Arial, "Segoe UI", sans-serif !important;
}

/* --- Dyslexia-friendly approximation: no OpenDyslexic font is bundled with this install (would
   need a licensed/self-hosted font file), so this uses the well-documented fallback recipe —
   a plain rounded sans with extra letter/word spacing — rather than pretending to load a font
   that isn't actually there. */
html[data-pto-a11y-dyslexia-font="1"] body,
html[data-pto-a11y-dyslexia-font="1"] h1,
html[data-pto-a11y-dyslexia-font="1"] h2,
html[data-pto-a11y-dyslexia-font="1"] h3,
html[data-pto-a11y-dyslexia-font="1"] h4,
html[data-pto-a11y-dyslexia-font="1"] .pto-serif {
  font-family: Verdana, "Comic Sans MS", Arial, sans-serif !important;
  letter-spacing: .035em !important;
  word-spacing: .12em !important;
}

/* --- Highlight headings --- */
html[data-pto-a11y-highlight-headings="1"] h1,
html[data-pto-a11y-highlight-headings="1"] h2,
html[data-pto-a11y-highlight-headings="1"] h3 {
  background: #fff6d8;
  outline: 2px solid #f2b84b;
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Highlight links --- */
html[data-pto-a11y-highlight-links="1"] a:not(.pto-a11y-toggle):not(.pto-a11y-panel a) {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  background: rgba(255, 230, 0, .28) !important;
  outline: 1px solid rgba(0, 0, 0, .25);
  border-radius: 2px;
}

/* --- Larger tap targets --- */
html[data-pto-a11y-larger-tap="1"] a,
html[data-pto-a11y-larger-tap="1"] button,
html[data-pto-a11y-larger-tap="1"] .bws-btn,
html[data-pto-a11y-larger-tap="1"] input,
html[data-pto-a11y-larger-tap="1"] select,
html[data-pto-a11y-larger-tap="1"] textarea,
html[data-pto-a11y-larger-tap="1"] .pto-check-row {
  min-height: 44px;
}
html[data-pto-a11y-larger-tap="1"] .bws-btn,
html[data-pto-a11y-larger-tap="1"] button {
  padding-top: 10px !important;
  padding-bottom: 10px !important;
}

/* --- Reduce motion: an explicit opt-in version of the site's existing prefers-reduced-motion
   media query (see pto-theme.css) — this one applies regardless of the visitor's OS setting. --- */
html[data-pto-a11y-reduce-motion="1"] *,
html[data-pto-a11y-reduce-motion="1"] *::before,
html[data-pto-a11y-reduce-motion="1"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  scroll-behavior: auto !important;
}

/* --- Pause animations: freezes CSS animations in place rather than cutting them short/removing
   them (autoplaying <video> is paused via JS instead — CSS can't pause a raster like an animated
   GIF). --- */
html[data-pto-a11y-pause-animations="1"] *,
html[data-pto-a11y-pause-animations="1"] *::before,
html[data-pto-a11y-pause-animations="1"] *::after {
  animation-play-state: paused !important;
}

/* --- Focus mode: dims everything on the page except the main content landmark (and this widget
   itself), so header/footer/sidebar chrome stops competing for attention while reading. --- */
html[data-pto-a11y-focus-mode="1"] body > *:not(#main-content):not(.pto-a11y-root) {
  opacity: .3;
  filter: grayscale(.4);
  transition: opacity .2s;
}
html[data-pto-a11y-focus-mode="1"] body > *:not(#main-content):not(.pto-a11y-root):hover {
  opacity: .7;
}

/* --- Reading guide / reading mask / cursor marker: plain fixed elements the JS moves on
   mousemove; hidden entirely (not just invisible) when their feature is off so they cost
   nothing and can never intercept a click. --- */
.pto-a11y-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(242, 184, 75, .85);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0); /* no-op placeholder so the box-shadow property is cheap to toggle if ever needed */
  pointer-events: none;
  z-index: 99990;
  display: none;
  top: -100px;
}
html[data-pto-a11y-reading-guide="1"] .pto-a11y-reading-guide {
  display: block;
}

.pto-a11y-reading-mask-band {
  position: fixed;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, .55);
  pointer-events: none;
  z-index: 99989;
  display: none;
}
html[data-pto-a11y-reading-mask="1"] .pto-a11y-reading-mask-band {
  display: block;
}

.pto-a11y-cursor-marker {
  position: fixed;
  width: 38px;
  height: 38px;
  margin-left: -19px;
  margin-top: -19px;
  border: 3px solid #f2b84b;
  border-radius: 50%;
  pointer-events: none;
  z-index: 99991;
  display: none;
  mix-blend-mode: difference;
  top: -100px;
  left: -100px;
}
html[data-pto-a11y-cursor-marker="1"] .pto-a11y-cursor-marker {
  display: block;
}

@media (max-width: 480px) {
  .pto-a11y-panel {
    bottom: 78px;
    width: calc(100vw - 20px);
  }
}
