:root {
  --a11y-bg: #ffffff;
  --a11y-text: #333333;
  --a11y-accent: #6b7c5e;
  --a11y-border: #dddddd;
}

/* Screen reader only */
#my-a11y-plugin-root .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;
}

/* Toolbar Container - in footer at bottom of page, not sticky */
#my-a11y-plugin-root {
  position: relative;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 6px 10px;
  min-height: 36px;
  background: rgba(0,0,0,0.04);
  border-top: 1px solid var(--a11y-border);
  font-family: Arial, sans-serif;
  font-size: 14px;
  direction: rtl;
  z-index: 99999;
}

/* Toggle Button - small, in footer */
#my-a11y-plugin-toggle {
  position: relative;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 6px;
  background: #2e3052;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: background 0.2s;
  filter: none !important;
  -webkit-tap-highlight-color: transparent;
}

#my-a11y-plugin-toggle .my-a11y-plugin-toggle-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

#my-a11y-plugin-toggle:hover,
#my-a11y-plugin-toggle:focus {
  background: #ca8d42;
  outline: 2px solid rgba(255,255,255,0.5);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  #my-a11y-plugin-root {
    padding: 8px 12px;
    min-height: 40px;
  }
  #my-a11y-plugin-toggle {
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 8px;
  }
  #my-a11y-plugin-toggle .my-a11y-plugin-toggle-icon {
    width: 20px;
    height: 20px;
  }
}

/* Panel - opens above the toggle, anchored to footer */
#my-a11y-plugin-panel {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 6px;
  width: 280px;
  max-width: calc(100vw - 24px);
  max-height: 70vh;
  overflow-y: auto;
  background: var(--a11y-bg);
  border: 1px solid var(--a11y-border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
  padding: 15px;
  border-radius: 8px 8px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 480px) {
  #my-a11y-plugin-panel {
    right: 0;
    left: 0;
    width: auto;
    max-width: none;
    max-height: 65vh;
  }
  .my-a11y-plugin-controls {
    grid-template-columns: 1fr;
  }
  .my-a11y-plugin-btn {
    padding: 12px;
  }
  .my-a11y-plugin-reset {
    grid-column: 1;
  }
}

#my-a11y-plugin-panel[hidden] {
  display: none;
}

#my-a11y-plugin-panel:not([hidden]) {
  transform-origin: bottom right;
  animation: my-a11y-panel-open 220ms ease-out;
}

@keyframes my-a11y-panel-open {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  #my-a11y-plugin-panel:not([hidden]) {
    animation: none;
  }
}

.my-a11y-plugin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--a11y-border);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.my-a11y-plugin-header h2 {
  margin: 0;
  font-size: 18px;
  color: var(--a11y-text);
}

#my-a11y-plugin-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--a11y-text);
}

.my-a11y-plugin-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.my-a11y-plugin-btn {
  background: #ca8d42;
  border: 1px solid #ccc;
  padding: 10px;
  cursor: pointer;
  font-size: 14px;
  color: #333;
  border-radius: 4px;
  transition: all 0.2s;
}

.my-a11y-plugin-btn:hover {
  background: #e0e0e0;
}

.my-a11y-plugin-btn:focus {
  outline: 2px solid var(--a11y-accent);
}

.my-a11y-plugin-active {
  background: var(--a11y-accent);
  color: white;
  border-color: #005177;
}

.my-a11y-plugin-reset {
  grid-column: span 2;
  background: #b3884d;
  color: white;
  border-color: #b3884d;
}

.my-a11y-plugin-reset:hover {
  background:rgb(123, 90, 45);
}

/* --- Accessibility Modes (Global overrides) --- */

/* Font Sizes - toolbar has font-size:16px so it stays fixed */
html.my-a11y-plugin-font-large {
  font-size: 1.2em !important;
}
html.my-a11y-plugin-font-xlarge {
  font-size: 1.5em !important;
}

/* Grayscale - on body only; toolbar is in html so not affected by filter containing block */
body.my-a11y-plugin-grayscale {
  filter: grayscale(100%) !important;
}

/* High Contrast */
body.my-a11y-plugin-high-contrast {
  background-color: #000000 !important;
  color: #ffff00 !important;
}
body.my-a11y-plugin-high-contrast * {
  background-color: #000000 !important;
  color: #ffff00 !important;
  border-color: #ffff00 !important;
}
body.my-a11y-plugin-high-contrast #my-a11y-plugin-root * {
  background-color: revert !important;
  color: revert !important;
  border-color: revert !important;
}

/* Light Background */
body.my-a11y-plugin-light-background {
  background-color: #ffffff !important;
  color: #000000 !important;
}
body.my-a11y-plugin-light-background * {
  background-color: #ffffff !important;
  color: #000000 !important;
}
body.my-a11y-plugin-light-background #my-a11y-plugin-root * {
  background-color: revert !important;
  color: revert !important;
}

/* Highlight Links */
body.my-a11y-plugin-highlight-links a {
  text-decoration: underline !important;
  background-color: yellow !important;
  color: black !important;
}

/* Readable Font */
body.my-a11y-plugin-readable-font * {
  font-family: Arial, Helvetica, sans-serif !important;
}

/* Stop Animations */
body.my-a11y-plugin-stop-animations * {
  animation: none !important;
  transition: none !important;
}
