/* Accessibility preferences for the public site.
   Counterpart to frontend/src/style.css in the application: same settings, same
   storage key, same <html> attributes. The two surfaces share an origin, so a
   preference set on the landing page is already in effect inside /app/.

   The token names differ from the app's (--bg/--card/--ink here against
   --bg-main/--bg-card/--color-main there), which is why this file exists rather
   than being shared outright. */

.a11y-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.a11y-widget {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9000;
}

.a11y-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  border: 2px solid var(--lime, #bed41a);
  background: var(--green-700, #1f6f00);
  color: #ffffff;
  cursor: pointer;
  box-shadow: var(--shadow, 0 10px 30px rgba(16, 53, 20, 0.18));
}
.a11y-fab:hover { background: var(--green-800, #14530a); }

.a11y-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  width: 19rem;
  max-width: calc(100vw - 2.5rem);
  max-height: 75vh;
  overflow-y: auto;
  padding: 1rem;
  background: var(--card, #ffffff);
  color: var(--ink, #10231a);
  border: 2px solid var(--green-700, #1f6f00);
  border-radius: 12px;
  box-shadow: var(--shadow-lg, 0 24px 60px rgba(16, 53, 20, 0.18));
  text-align: left;
}

.a11y-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.a11y-panel-title { margin: 0; font-size: 1.05rem; }
.a11y-close {
  width: 2rem;
  height: 2rem;
  font-size: 1.4rem;
  line-height: 1;
  background: transparent;
  color: inherit;
  border: 1px solid var(--line, #e3ece1);
  border-radius: 6px;
  cursor: pointer;
}

.a11y-field {
  border: 1px solid var(--line, #e3ece1);
  border-radius: 8px;
  padding: 0.6rem 0.75rem 0.75rem;
  margin: 0 0 0.85rem 0;
}
.a11y-legend { padding: 0 0.35rem; font-weight: 600; font-size: 0.9rem; }
.a11y-sizes { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.a11y-size {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--line, #e3ece1);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}
.a11y-size:has(input:checked) {
  background: var(--green-700, #1f6f00);
  color: #ffffff;
  border-color: var(--green-700, #1f6f00);
}

.a11y-toggles { display: flex; flex-direction: column; gap: 0.4rem; }
.a11y-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 0.65rem;
  background: transparent;
  color: inherit;
  border: 1px solid var(--line, #e3ece1);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font: inherit;
  font-size: 0.92rem;
}
.a11y-toggle-label { flex: 1; }
.a11y-toggle-track {
  flex: none;
  position: relative;
  width: 2.5rem;
  height: 1.4rem;
  border-radius: 1rem;
  background: var(--bg, #f5f9f3);
  border: 2px solid var(--muted, #5d6f64);
}
.a11y-toggle-thumb {
  position: absolute;
  top: 0.1rem;
  left: 0.1rem;
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--muted, #5d6f64);
  transition: transform 0.15s ease, background 0.15s ease;
}
/* State shows in the knob position and the border too, never fill alone. */
.a11y-toggle[aria-pressed="true"] { border-color: var(--green-700, #1f6f00); }
.a11y-toggle[aria-pressed="true"] .a11y-toggle-track {
  background: var(--green-700, #1f6f00);
  border-color: var(--green-700, #1f6f00);
}
.a11y-toggle[aria-pressed="true"] .a11y-toggle-thumb {
  background: #ffffff;
  transform: translateX(1.1rem);
}

.a11y-reset {
  width: 100%;
  margin-top: 0.85rem;
  padding: 0.6rem;
  min-height: 2.75rem;
  background: transparent;
  color: inherit;
  border: 1px solid var(--muted, #5d6f64);
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.a11y-hint { margin: 0.6rem 0 0 0; font-size: 0.8rem; color: var(--muted, #5d6f64); }

/* --- Preference effects --------------------------------------------------
   The site has one (light) theme, so there is a single high-contrast ramp. */
:root[data-a11y-contrast="high"] {
  --bg: #ffffff;
  --card: #ffffff;
  --ink: #000000;
  --muted: #243029;
  --line: #000000;
  --green-700: #0b4a08;   /* white text on this is ~10:1 */
  --green-800: #06240b;
  --green-900: #04170a;
  --lime: #d6ee1f;
}
:root[data-a11y-contrast="high"] body { background: #ffffff; color: #000000; }

:root[data-a11y-spacing="true"] body {
  line-height: 1.8 !important;
  letter-spacing: 0.12em;
  word-spacing: 0.16em;
}
:root[data-a11y-spacing="true"] p { margin-bottom: 2em; }
:root[data-a11y-spacing="true"] .leaflet-container {
  letter-spacing: normal;
  word-spacing: normal;
}

:root[data-a11y-underline="true"] a { text-decoration: underline !important; }

:root[data-a11y-focus="true"] :focus-visible {
  outline: 4px solid var(--lime, #bed41a) !important;
  outline-offset: 2px !important;
  box-shadow: 0 0 0 7px rgba(0, 0, 0, 0.85) !important;
}

/* Also cancels the html{scroll-behavior:smooth} the landing page sets. */
:root[data-a11y-motion="true"],
:root[data-a11y-motion="true"] *,
:root[data-a11y-motion="true"] *::before,
:root[data-a11y-motion="true"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
  scroll-behavior: auto !important;
}
/* The landing page reveals sections on scroll via .reveal/.show. With motion
   reduced, show them outright rather than leaving content invisible. */
:root[data-a11y-motion="true"] .reveal { opacity: 1 !important; transform: none !important; }
