/* Accessibility Widget Base Variables */
:root {
  --a11y-primary: #1d4ed8;
  --a11y-bg: #ffffff;
  --a11y-text: #1f2937;
  --a11y-border: #e5e7eb;
  --a11y-hover: #f3f4f6;
  --a11y-zindex: 999999;
}

/* Floating Button */
#a11y-toggle-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  background-color: var(--a11y-primary);
  color: #fff;
  border: 2px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: var(--a11y-zindex);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: transform 0.3s ease, background 0.3s ease;
  outline: none;
}
#a11y-toggle-btn:hover, #a11y-toggle-btn:focus-visible {
  transform: scale(1.1);
  background-color: #2563eb;
  box-shadow: 0 0 0 4px rgba(37,99,235,0.3);
}

/* Panel Structure */
#a11y-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 320px;
  max-height: 80vh;
  background: var(--a11y-bg);
  color: var(--a11y-text);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  z-index: var(--a11y-zindex);
  overflow-y: auto;
  transform: translateY(20px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
  display: flex;
  flex-direction: column;
}

#a11y-panel.a11y-open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

#a11y-panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--a11y-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--a11y-bg);
  z-index: 2;
}

#a11y-panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

#a11y-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--a11y-text);
  padding: 4px;
}

#a11y-panel-content {
  padding: 16px;
}

.a11y-section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 700;
  margin: 16px 0 8px 0;
  letter-spacing: 0.5px;
}
.a11y-section-title:first-child {
  margin-top: 0;
}

.a11y-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.a11y-btn {
  background: #f9fafb;
  border: 1px solid var(--a11y-border);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  color: var(--a11y-text);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.a11y-btn svg {
  width: 20px;
  height: 20px;
}

.a11y-btn:hover {
  background: var(--a11y-hover);
}

.a11y-btn.a11y-active {
  background: var(--a11y-primary);
  color: #fff;
  border-color: var(--a11y-primary);
}
.a11y-btn.a11y-active svg {
    color: #fff;
}

#a11y-reset-btn {
  margin-top: 16px;
  width: 100%;
  padding: 12px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

/* Modifiers */

/* Dyslexia Font */
html.a11y-dyslexia * {
  font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif !important;
}

/* High Contrast Mode */
html.a11y-high-contrast {
  filter: contrast(150%) saturate(150%);
}

/* Dark Mode Overrides */
html.a11y-dark-mode {
  filter: invert(1) hue-rotate(180deg);
}
html.a11y-dark-mode img, 
html.a11y-dark-mode video,
html.a11y-dark-mode svg,
html.a11y-dark-mode iframe {
  filter: invert(1) hue-rotate(180deg);
}

/* Light Mode (wash out dark backgrounds) */
html.a11y-light-mode {
  background-color: #ffffff !important;
  color: #000000 !important;
}
html.a11y-light-mode * {
  background-color: #ffffff !important;
  color: #000000 !important;
  border-color: #cccccc !important;
}

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

/* Invert */
html.a11y-invert {
  filter: invert(100%);
}
html.a11y-invert img,
html.a11y-invert video,
html.a11y-invert iframe {
  filter: invert(100%);
}

/* Highlight Links */
html.a11y-highlight-links a, html.a11y-highlight-links button {
  background-color: #ffeb3b !important;
  color: #000000 !important;
  text-decoration: underline !important;
  border: 2px solid #000000 !important;
}

/* Highlight Headings */
html.a11y-highlight-headings h1,
html.a11y-highlight-headings h2,
html.a11y-highlight-headings h3,
html.a11y-highlight-headings h4,
html.a11y-highlight-headings h5,
html.a11y-highlight-headings h6 {
  border: 2px dashed #d97706 !important;
  background-color: #fef3c7 !important;
  color: #000000 !important;
}

/* Pause Animations */
html.a11y-pause-animations * {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* Bigger Cursor */
html.a11y-big-cursor * {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="black" stroke="white" stroke-width="2" d="M4 2v20l6-6h10z"/></svg>') 0 0, auto !important;
}

/* Text Scaling */
html.a11y-text-1 { font-size: 105% !important; }
html.a11y-text-2 { font-size: 110% !important; }
html.a11y-text-3 { font-size: 115% !important; }
html.a11y-text-4 { font-size: 120% !important; }

/* Line Height */
html.a11y-line-height-1 * { line-height: 1.7 !important; }
html.a11y-line-height-2 * { line-height: 1.9 !important; }
html.a11y-line-height-3 * { line-height: 2.1 !important; }

/* Letter Spacing */
html.a11y-letter-spacing-1 * { letter-spacing: 0.05em !important; }
html.a11y-letter-spacing-2 * { letter-spacing: 0.1em !important; }
