/* ============================================================
   Shop4Specials — Accessibility Features & Toolbar Styles
   ============================================================ */

/* ---- Visually Hidden Screen Reader Helper ---- */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ---- Accessibility Toolbar Floating Widget ---- */
.a11y-toolbar {
  position: fixed;
  bottom: var(--space-4, 20px);
  right: var(--space-4, 20px);
  z-index: 999990;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2, 8px);
}

.a11y-toolbar__toggle {
  background-color: var(--color-primary, #1a3c6e);
  color: var(--color-primary-text, #ffffff);
  border: 2px solid transparent;
  border-radius: 50%;
  width: 58px;
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  padding: 0;
}

.a11y-toolbar__toggle:hover {
  background-color: var(--color-primary-hover, #122b52);
  transform: scale(1.05);
}

.a11y-toolbar__toggle:focus-visible {
  outline: 3px solid var(--color-primary, #1a3c6e);
  outline-offset: 3px;
}

.a11y-toolbar__toggle svg {
  width: 30px;
  height: 30px;
  fill: currentColor;
}

.a11y-toolbar__panel {
  background-color: var(--color-surface, #ffffff);
  border: 1px solid var(--color-border, #e2e8f0);
  border-radius: var(--radius-lg, 12px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  padding: 1.25rem;
  width: min(92vw, 360px);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  display: none;
  flex-direction: column;
  gap: 1.25rem;
}

.a11y-toolbar__panel[aria-hidden="false"],
.a11y-toolbar__panel.is-open {
  display: flex;
  animation: slideUp 0.25s ease-out forwards;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.a11y-toolbar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-divider, #e2e8f0);
  padding-bottom: 0.75rem;
}

.a11y-toolbar__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
  color: var(--color-heading, #0f172a);
}

.a11y-toolbar__close {
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text, #334155);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.a11y-toolbar__close:hover {
  background-color: var(--color-surface-hover, #f1f5f9);
}

.a11y-toolbar__close:focus-visible {
  outline: 2px solid var(--color-primary, #1a3c6e);
  outline-offset: 2px;
}

.a11y-toolbar__section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.a11y-toolbar__label {
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--color-text-secondary, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.a11y-toolbar__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.a11y-btn {
  background-color: var(--color-bg-alt, #f8fafc);
  border: 1px solid var(--color-border, #cbd5e1);
  color: var(--color-text, #0f172a);
  padding: 0.65rem 0.5rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.825rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  min-height: 52px;
}

.a11y-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.a11y-btn:hover {
  background-color: var(--color-border, #cbd5e1);
}

.a11y-btn:focus-visible {
  outline: 2px solid var(--color-primary, #1a3c6e);
  outline-offset: 2px;
}

.a11y-btn[aria-pressed="true"],
.a11y-btn.is-active {
  background-color: #1a3c6e !important;
  border-color: #1a3c6e !important;
  color: #ffffff !important;
}

/* Dark theme panel styles */
[data-theme="dark"] .a11y-toolbar__panel {
  background-color: #1e293b;
  border-color: #334155;
}
[data-theme="dark"] .a11y-toolbar__title {
  color: #f8fafc;
}
[data-theme="dark"] .a11y-btn {
  background-color: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}
[data-theme="dark"] .a11y-btn:hover {
  background-color: #334155;
}
[data-theme="dark"] .a11y-btn[aria-pressed="true"],
[data-theme="dark"] .a11y-btn.is-active {
  background-color: #3b82f6 !important;
  border-color: #60a5fa !important;
  color: #ffffff !important;
}

/* High Contrast theme panel styles */
[data-theme="high-contrast"] .a11y-toolbar__panel {
  background-color: #000000;
  border: 2px solid #ffffff;
}
[data-theme="high-contrast"] .a11y-toolbar__title {
  color: #ffffff;
}
[data-theme="high-contrast"] .a11y-toolbar__toggle {
  background-color: #ffff00;
  color: #000000;
  border: 3px solid #ffffff;
}
[data-theme="high-contrast"] .a11y-btn {
  background-color: #000000;
  border: 2px solid #ffffff;
  color: #ffffff;
}
[data-theme="high-contrast"] .a11y-btn:hover {
  background-color: #222222;
}
[data-theme="high-contrast"] .a11y-btn[aria-pressed="true"],
[data-theme="high-contrast"] .a11y-btn.is-active {
  background-color: #ffff00 !important;
  border-color: #ffffff !important;
  color: #000000 !important;
}
[data-theme="high-contrast"] .a11y-toolbar__toggle:focus-visible,
[data-theme="high-contrast"] .a11y-btn:focus-visible,
[data-theme="high-contrast"] .a11y-toolbar__close:focus-visible {
  outline: 3px solid #ffff00 !important;
  outline-offset: 3px !important;
}

/* ---- Reading Guide ---- */
#reading-guide {
  position: fixed;
  left: 0;
  width: 100vw;
  height: 8px;
  background-color: #f59e0b;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.7);
  z-index: 999999;
  pointer-events: none;
  display: none;
  transform: translateY(-50%);
}
body[data-reading-guide="true"] #reading-guide {
  display: block;
}

/* ---- Cursor Enlargement ---- */
body[data-large-cursor="true"],
body[data-large-cursor="true"] * {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24"><path fill="%23000000" stroke="%23ffffff" stroke-width="2" d="M4 4l16 16-6 1-4 6-6-23z"/></svg>'), auto !important;
}
body[data-large-cursor="true"] a,
body[data-large-cursor="true"] button,
body[data-large-cursor="true"] [role="button"],
body[data-large-cursor="true"] input,
body[data-large-cursor="true"] select {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="36" height="36" viewBox="0 0 24 24"><path fill="%23000000" stroke="%23ffffff" stroke-width="2" d="M9 11l-4 4-4-4m4-4v8m11-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm-4-9a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm8 4a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm-11 5a2 2 0 1 1-4 0 2 2 0 0 1 4 0z"/></svg>'), pointer !important;
}

/* ---- Highlight Links ---- */
body[data-highlight-links="true"] a {
  background-color: #fef08a !important;
  color: #0f172a !important;
  text-decoration: underline !important;
  text-decoration-thickness: 3px !important;
  text-underline-offset: 3px !important;
  font-weight: 700 !important;
}

[data-theme="dark"] body[data-highlight-links="true"] a {
  background-color: #fef08a !important;
  color: #0f172a !important;
}

[data-theme="high-contrast"] body[data-highlight-links="true"] a {
  background-color: #ffff00 !important;
  color: #000000 !important;
  outline: 2px solid #ffffff !important;
}

/* ---- Dyslexia Font ---- */
body[data-dyslexia="true"],
body[data-dyslexia="true"] * {
  font-family: "OpenDyslexic", "Comic Sans MS", Arial, sans-serif !important;
}

/* ---- Reduce Motion ---- */
body[data-reduce-motion="true"] *,
body[data-reduce-motion="true"] *::before,
body[data-reduce-motion="true"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* ---- Mobile Responsiveness ---- */
@media (max-width: 640px) {
  .a11y-toolbar {
    bottom: 16px;
    right: 16px;
  }
  .a11y-toolbar__panel {
    width: calc(100vw - 32px);
    max-height: 82vh;
    padding: 1rem;
  }
  .a11y-toolbar__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .a11y-btn {
    padding: 8px 4px;
    font-size: 0.775rem;
    min-height: 48px;
  }
}
