/**
 * Accessibility Widget Styles for NARBE Foundation
 * Provides styling for the accessibility panel and all accessibility modes
 */

/* ============================================
   ACCESSIBILITY WIDGET BUTTON & PANEL
   ============================================ */

/* Widget Button */
.a11y-widget-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.a11y-widget-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
}

.a11y-widget-btn:focus {
  outline: 3px solid #1e293b;
  outline-offset: 3px;
}

.a11y-widget-btn svg {
  width: 28px;
  height: 28px;
  color: white;
}

/* Panel */
.a11y-panel {
  position: fixed;
  bottom: 90px;
  left: 20px;
  z-index: 9998;
  width: 320px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0.3s ease;
}

.a11y-panel.open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

/* Panel Header */
.a11y-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white;
}

.a11y-panel-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.a11y-panel-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.a11y-panel-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.a11y-panel-close:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

.a11y-panel-close svg {
  width: 18px;
  height: 18px;
  color: white;
}

/* Panel Content */
.a11y-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Sections */
.a11y-section {
  margin-bottom: 24px;
}

.a11y-section:last-child {
  margin-bottom: 0;
}

.a11y-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 12px 0;
}

/* Font Size Controls */
.a11y-font-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #f1f5f9;
  padding: 12px 16px;
  border-radius: 12px;
}

.a11y-font-btn {
  width: 40px;
  height: 40px;
  border: 2px solid #e2e8f0;
  background: white;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.a11y-font-btn:hover:not(:disabled) {
  border-color: #6366f1;
  background: #f0f0ff;
}

.a11y-font-btn:focus {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.a11y-font-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.a11y-font-btn svg {
  width: 20px;
  height: 20px;
  color: #1e293b;
}

.a11y-font-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
  min-width: 60px;
  text-align: center;
}

/* Toggle Buttons */
.a11y-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.a11y-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.a11y-toggle:hover {
  border-color: #6366f1;
  background: #f0f0ff;
}

.a11y-toggle:focus {
  outline: 2px solid #6366f1;
  outline-offset: 2px;
}

.a11y-toggle.active {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border-color: transparent;
  color: white;
}

.a11y-toggle-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.a11y-toggle-icon svg {
  width: 24px;
  height: 24px;
  color: #64748b;
}

.a11y-toggle.active .a11y-toggle-icon svg {
  color: white;
}

.a11y-toggle-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
  color: #1e293b;
}

.a11y-toggle.active .a11y-toggle-label {
  color: white;
}

/* Reset Button */
.a11y-reset-section {
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.a11y-reset-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: #fee2e2;
  color: #dc2626;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.a11y-reset-btn:hover {
  background: #fecaca;
}

.a11y-reset-btn:focus {
  outline: 2px solid #dc2626;
  outline-offset: 2px;
}

.a11y-reset-btn svg {
  width: 18px;
  height: 18px;
}

/* Panel Footer */
.a11y-panel-footer {
  padding: 12px 20px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.a11y-panel-footer p {
  margin: 0;
  font-size: 0.75rem;
  color: #64748b;
  text-align: center;
}

/* Reading Guide Element */
#a11y-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  height: 30px;
  background: rgba(255, 255, 0, 0.3);
  border-top: 2px solid rgba(255, 200, 0, 0.6);
  border-bottom: 2px solid rgba(255, 200, 0, 0.6);
  pointer-events: none;
  z-index: 9995;
  display: none;
}

/* Screen Reader Only (utility class) */
.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;
}

/* ============================================
   HIGH CONTRAST MODE
   ============================================ */

.a11y-high-contrast {
  --bg-color: #000000;
  --text-color: #ffffff;
  --link-color: #ffff00;
  --border-color: #ffffff;
}

.a11y-high-contrast,
.a11y-high-contrast * {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

.a11y-high-contrast a,
.a11y-high-contrast a * {
  color: #ffff00 !important;
  text-decoration: underline !important;
}

.a11y-high-contrast button,
.a11y-high-contrast .btn,
.a11y-high-contrast .donate-btn,
.a11y-high-contrast .cta-btn,
.a11y-high-contrast [class*="btn"] {
  background: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #ffffff !important;
}

.a11y-high-contrast img {
  filter: contrast(1.2) !important;
}

.a11y-high-contrast .a11y-panel,
.a11y-high-contrast .a11y-panel * {
  background-color: #1a1a1a !important;
}

.a11y-high-contrast .a11y-toggle.active {
  background: #ffffff !important;
  color: #000000 !important;
}

.a11y-high-contrast .a11y-toggle.active * {
  color: #000000 !important;
}

/* ============================================
   DYSLEXIA-FRIENDLY FONT
   ============================================ */

.a11y-dyslexia-font,
.a11y-dyslexia-font * {
  font-family: 'OpenDyslexic', 'Comic Sans MS', 'Arial', sans-serif !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.1em !important;
}

/* ============================================
   LARGE SPACING MODE
   ============================================ */

.a11y-large-spacing {
  line-height: 2 !important;
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
}

.a11y-large-spacing p,
.a11y-large-spacing li,
.a11y-large-spacing span,
.a11y-large-spacing div {
  line-height: 2 !important;
  margin-bottom: 1.5em !important;
}

.a11y-large-spacing h1,
.a11y-large-spacing h2,
.a11y-large-spacing h3,
.a11y-large-spacing h4,
.a11y-large-spacing h5,
.a11y-large-spacing h6 {
  margin-bottom: 1em !important;
  line-height: 1.5 !important;
}

/* ============================================
   HIGHLIGHT LINKS MODE
   ============================================ */

.a11y-highlight-links a:not(.a11y-toggle):not(.a11y-font-btn):not(.a11y-reset-btn):not(.a11y-panel-close):not(.a11y-widget-btn) {
  background-color: #ffff00 !important;
  color: #000000 !important;
  padding: 2px 4px !important;
  text-decoration: underline !important;
  border-radius: 3px !important;
  box-shadow: 0 0 0 2px #ffff00 !important;
}

.a11y-highlight-links a:not(.a11y-toggle):not(.a11y-font-btn):not(.a11y-reset-btn):not(.a11y-panel-close):not(.a11y-widget-btn):hover {
  background-color: #ffd700 !important;
}

.a11y-highlight-links a:not(.a11y-toggle):not(.a11y-font-btn):not(.a11y-reset-btn):not(.a11y-panel-close):not(.a11y-widget-btn):focus {
  outline: 3px solid #ff6600 !important;
  outline-offset: 2px !important;
}

/* ============================================
   LARGER CURSOR MODE
   ============================================ */

.a11y-larger-cursor,
.a11y-larger-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='2' d='M8 8l28 12-12 4-4 12z'/%3E%3C/svg%3E") 4 4, auto !important;
}

.a11y-larger-cursor a,
.a11y-larger-cursor button,
.a11y-larger-cursor [role="button"],
.a11y-larger-cursor input[type="submit"],
.a11y-larger-cursor input[type="button"] {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='2' d='M14 4v32l8-8h16z'/%3E%3C/svg%3E") 14 4, pointer !important;
}

/* ============================================
   REDUCED MOTION MODE
   ============================================ */

.a11y-reduced-motion,
.a11y-reduced-motion * {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

.a11y-reduced-motion *::before,
.a11y-reduced-motion *::after {
  animation: none !important;
  transition: none !important;
}

/* ============================================
   FOCUS MODE (Enhanced Focus Indicators)
   ============================================ */

.a11y-focus-mode *:focus,
.a11y-focus-mode *:focus-visible {
  outline: 4px solid #ff6600 !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 8px rgba(255, 102, 0, 0.4), 0 0 20px rgba(255, 102, 0, 0.6) !important;
  position: relative;
  z-index: 100;
}

.a11y-focus-mode a:focus,
.a11y-focus-mode a:focus-visible,
.a11y-focus-mode button:focus,
.a11y-focus-mode button:focus-visible,
.a11y-focus-mode input:focus,
.a11y-focus-mode input:focus-visible,
.a11y-focus-mode select:focus,
.a11y-focus-mode select:focus-visible,
.a11y-focus-mode textarea:focus,
.a11y-focus-mode textarea:focus-visible,
.a11y-focus-mode [tabindex]:focus,
.a11y-focus-mode [tabindex]:focus-visible {
  outline: 4px solid #ff6600 !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 0 8px rgba(255, 102, 0, 0.4), 0 0 25px rgba(255, 102, 0, 0.7) !important;
  background-color: rgba(255, 102, 0, 0.1) !important;
}

/* Add a pulsing animation to make focus even more visible */
.a11y-focus-mode a:focus,
.a11y-focus-mode button:focus,
.a11y-focus-mode a:focus-visible,
.a11y-focus-mode button:focus-visible {
  animation: a11y-focus-pulse 1.5s ease-in-out infinite !important;
}

@keyframes a11y-focus-pulse {
  0%, 100% {
    box-shadow: 0 0 0 8px rgba(255, 102, 0, 0.4), 0 0 20px rgba(255, 102, 0, 0.6);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(255, 102, 0, 0.3), 0 0 35px rgba(255, 102, 0, 0.8);
  }
}

/* ============================================
   MOBILE RESPONSIVENESS
   ============================================ */

@media (max-width: 992px) {
  .a11y-widget-btn {
    bottom: calc(100px + env(safe-area-inset-bottom));
    width: 50px;
    height: 50px;
  }

  .a11y-widget-btn svg {
    width: 24px;
    height: 24px;
  }

  .a11y-panel {
    bottom: calc(160px + env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 200px);
  }

  .a11y-toggles {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .a11y-toggle {
    padding: 12px 8px;
  }

  .a11y-toggle-label {
    font-size: 0.7rem;
  }
}

@media (max-width: 380px) {
  .a11y-toggles {
    grid-template-columns: 1fr;
  }

  .a11y-toggle {
    flex-direction: row;
    justify-content: flex-start;
    padding: 12px 16px;
  }

  .a11y-toggle-icon {
    width: 28px;
    height: 28px;
  }
}

/* ============================================
   PRINT STYLES - Hide Widget
   ============================================ */

@media print {
  .a11y-widget-btn,
  .a11y-panel,
  .a11y-reading-guide {
    display: none !important;
  }
}

/* ============================================
   GLOBAL ENHANCED FOCUS STYLES (Always On)
   ============================================ */

/* Ensure focus is always visible */
*:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: 2px;
}

/* Skip link enhancements */
.skip-link {
  position: absolute;
  top: -100px;
  left: 10px;
  background: #1e293b;
  color: white;
  padding: 12px 24px;
  z-index: 10001;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.3s ease;
}

.skip-link:focus {
  top: 0;
  outline: 3px solid #ff6600;
  outline-offset: 2px;
}

/* Ensure interactive elements have visible focus */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #6366f1;
  outline-offset: 2px;
}
