/* DodecaGreen accessibility panel — reuses brand.css tokens */

.dg-a11y-toggle {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9998;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--green-800);
  background: var(--green-800);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.15s ease, background 0.15s ease;
}
.dg-a11y-toggle:hover { background: var(--green-700); transform: translateY(-1px); }
.dg-a11y-toggle svg { width: 26px; height: 26px; }

.dg-a11y-panel {
  position: fixed;
  right: 20px;
  bottom: 84px;
  z-index: 9998;
  width: 320px;
  max-width: calc(100vw - 40px);
  max-height: 74vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-family: var(--font-body);
  color: var(--ink);
  transform: translateY(8px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.dg-a11y-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.dg-a11y-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--green-50);
  border-radius: var(--radius) var(--radius) 0 0;
}
.dg-a11y-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0;
  color: var(--green-900);
}
.dg-a11y-close {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--stone);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
}
.dg-a11y-close:hover { color: var(--ink); }

.dg-a11y-body { padding: 14px 16px 18px; }

.dg-a11y-group { margin-bottom: 16px; }
.dg-a11y-group h3 {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--stone);
  margin: 0 0 8px;
}

.dg-a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.dg-a11y-row:last-child { margin-bottom: 0; }
.dg-a11y-row span { font-size: 14px; }

.dg-a11y-btnrow { display: flex; gap: 6px; }

.dg-a11y-mini {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  font-family: var(--font-body);
}
.dg-a11y-mini:hover { background: var(--green-50); border-color: var(--green-300); }
.dg-a11y-mini.active {
  background: var(--green-700);
  border-color: var(--green-700);
  color: #fff;
}

.dg-a11y-switch {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 12px;
  background: var(--line);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}
.dg-a11y-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.dg-a11y-switch.on { background: var(--green-700); }
.dg-a11y-switch.on::after { transform: translateX(18px); }

.dg-a11y-hint {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--stone);
}

.dg-a11y-reset {
  width: 100%;
  margin-top: 4px;
  padding: 9px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--parchment);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}
.dg-a11y-reset:hover { background: var(--green-100); border-color: var(--green-300); }

/* --- Applied states (html.dg-a11y-*) --- */

/* Most DodecaGreen pages hardcode px font-sizes rather than em/rem, so a
   font-size percentage on body would miss most text. zoom scales everything
   (text, spacing, icons) regardless of how sizes were declared. */
html.dg-a11y-text-lg body { zoom: 1.15; }
html.dg-a11y-text-xl body { zoom: 1.3; }
/* panel/toggle/guide are attached to <html>, a sibling of <body>, not a
   descendant — so body's zoom never touches them and no counter-zoom is
   needed to keep them (and the reading-guide's cursor tracking) accurate. */

html.dg-a11y-dyslexia body,
html.dg-a11y-dyslexia * {
  font-family: 'OpenDyslexic', 'Comic Sans MS', var(--font-body) !important;
  letter-spacing: 0.01em !important;
}

/* Line-height on body alone only reaches elements that don't set their own
   (most DodecaGreen text does), and the old letter/word-spacing selector
   covered only <p>/<li> — missing headings, divs, spans, table cells, dt/dd,
   labels, blockquotes, etc. Target every text-bearing element instead,
   carved out from anything that shouldn't reflow: code, form controls, SVG
   text, icons, and our own panel. */
html.dg-a11y-spacing
  body :not(
    pre, pre *, code, code *,
    svg, svg *,
    input, textarea, select, option,
    .dg-a11y-panel, .dg-a11y-panel *, .dg-a11y-toggle, .dg-a11y-toggle *
  ) {
  line-height: 1.9 !important;
  letter-spacing: 0.03em !important;
  word-spacing: 0.08em !important;
}

html.dg-a11y-contrast body {
  background: #ffffff !important;
  color: #000000 !important;
}
html.dg-a11y-contrast a:not(.dg-a11y-panel a, .dg-a11y-toggle) { color: #0000ee !important; }
html.dg-a11y-contrast body *:not(.dg-a11y-panel, .dg-a11y-panel *, .dg-a11y-toggle, .dg-a11y-toggle *) {
  background-color: transparent !important;
  color: inherit !important;
  border-color: #000 !important;
  box-shadow: none !important;
}

html.dg-a11y-grayscale { filter: grayscale(1); }

html.dg-a11y-links a { text-decoration: underline !important; outline: 1px dashed var(--green-700); }

html.dg-a11y-reduce-motion *,
html.dg-a11y-reduce-motion *::before,
html.dg-a11y-reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

html.dg-a11y-focus *:focus,
html.dg-a11y-focus *:focus-visible {
  outline: 3px solid var(--clay) !important;
  outline-offset: 2px !important;
  border-radius: 2px;
}

#dg-a11y-guide {
  position: fixed;
  left: 0;
  width: 100%;
  height: 36px;
  background: rgba(255, 214, 0, 0.28);
  border-top: 1px solid rgba(180, 140, 0, 0.4);
  border-bottom: 1px solid rgba(180, 140, 0, 0.4);
  pointer-events: none;
  z-index: 9997;
  display: none;
}
html.dg-a11y-guide-on #dg-a11y-guide { display: block; }
