/**
 * Accessibility Widget Styles
 * Israeli Standard 5568 / WCAG 2.0 Level AA Compliant
 */

/* Widget Button */
.a11y-widget-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #2563eb;
  color: white;
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  font-size: 32px;
  line-height: 1;
}

.a11y-widget-button:hover {
  background: #1d4ed8;
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.6);
}

.a11y-widget-button:focus {
  outline: 3px solid #fbbf24;
  outline-offset: 2px;
}


/* Widget Panel */
.a11y-widget-panel {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 120px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
}

.a11y-widget-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.a11y-header {
  background: #2563eb;
  color: white;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.a11y-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.a11y-close {
  background: none;
  border: none;
  color: white;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.a11y-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.a11y-close:focus {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

/* Content */
.a11y-content {
  padding: 20px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
}

.a11y-section {
  margin-bottom: 24px;
}

.a11y-section:last-child {
  margin-bottom: 0;
}

.a11y-section h3 {
  margin: 0 0 12px 0;
  font-size: 14px;
  font-weight: 600;
  color: #1f2937;
}

/* Controls */
.a11y-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.a11y-btn {
  flex: 1;
  padding: 10px;
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.a11y-btn:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.a11y-btn:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.a11y-value {
  flex: 1;
  text-align: center;
  font-weight: 600;
  color: #2563eb;
}

.a11y-btn-block {
  width: 100%;
  padding: 10px;
  margin-bottom: 8px;
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.a11y-btn-block:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
}

.a11y-btn-block.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.a11y-btn-block:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Toggles */
.a11y-toggles {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.a11y-toggle {
  display: flex;
  align-items: center;
  padding: 8px;
  background: #f9fafb;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

.a11y-toggle:hover {
  background: #f3f4f6;
}

.a11y-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  cursor: pointer;
  accent-color: #2563eb;
}

.a11y-toggle span {
  font-size: 14px;
  color: #374151;
}

/* Reset Button */
.a11y-btn-reset {
  width: 100%;
  padding: 12px;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.a11y-btn-reset:hover {
  background: #dc2626;
}

.a11y-btn-reset:focus {
  outline: 2px solid #fbbf24;
  outline-offset: 2px;
}

/* Footer */
.a11y-footer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
  text-align: center;
  color: #6b7280;
}

/* Reading Guide */
.a11y-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(37, 99, 235, 0.6);
  pointer-events: none;
  z-index: 9997;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.5);
}

/* Accessibility Enhancements */

/* High Contrast */
html.a11y-contrast-high {
  filter: contrast(120%);
}

html.a11y-contrast-high body {
  background: white;
  color: #000;
}

/* Dark Mode */
html.a11y-contrast-dark {
  filter: invert(1) hue-rotate(180deg);
}

html.a11y-contrast-dark img,
html.a11y-contrast-dark video,
html.a11y-contrast-dark [style*="background-image"] {
  filter: invert(1) hue-rotate(180deg);
}

/* Readable Font */
html.a11y-readable-font,
html.a11y-readable-font * {
  font-family: 'Arial', 'Helvetica', sans-serif !important;
}

/* Text Spacing */
html.a11y-text-spacing * {
  line-height: 1.8 !important;
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
}

html.a11y-text-spacing p {
  margin-bottom: 1.5em !important;
}

/* Highlight Links */
html.a11y-highlight-links a {
  background: #fef3c7 !important;
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  padding: 2px 4px !important;
  border-radius: 3px !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 {
  background: #dbeafe !important;
  padding: 8px !important;
  border-left: 4px solid #2563eb !important;
  border-radius: 4px !important;
}

/* Invert Colors */
html.a11y-invert-colors {
  filter: invert(1);
}

html.a11y-invert-colors img,
html.a11y-invert-colors video {
  filter: invert(1);
}

/* Grayscale */
html.a11y-grayscale {
  filter: grayscale(1);
}

/* Hide Images */
html.a11y-hide-images img {
  opacity: 0 !important;
}

html.a11y-hide-images [style*="background-image"] {
  background-image: none !important;
}

/* RTL Support for Hebrew */
html[dir="rtl"] .a11y-widget-button {
  left: 20px;
  right: auto;
}

html[dir="rtl"] .a11y-widget-panel {
  left: 20px;
  right: auto;
}

html[dir="rtl"] .a11y-toggle input[type="checkbox"] {
  margin-right: 0;
  margin-left: 10px;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .a11y-widget-button {
    width: 52px;
    height: 52px;
    bottom: 16px;
    right: 16px;
  }
  
  .a11y-widget-button {
    font-size: 28px;
  }
  
  .a11y-widget-panel {
    bottom: 80px;
    right: 16px;
    width: calc(100vw - 32px);
  }
  
  html[dir="rtl"] .a11y-widget-button {
    left: 16px;
    right: auto;
  }
  
  html[dir="rtl"] .a11y-widget-panel {
    left: 16px;
    right: auto;
  }
}

/* Focus Styles for Better Keyboard Navigation */
*:focus {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

button:focus,
a:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 3px solid #2563eb;
  outline-offset: 3px;
}

/* Prevent outline from affecting layout of puzzle elements */
.puzzle-tile:focus,
.puzzle-board:focus,
.puzzle-board-wrapper:focus {
  outline-offset: 0;
}

/* Skip to Main Content Link */
.skip-to-main {
  position: absolute;
  top: -100px;
  left: 0;
  background: #2563eb;
  color: white;
  padding: 12px 20px;
  text-decoration: none;
  font-weight: 600;
  z-index: 10000;
  border-radius: 0 0 8px 0;
}

.skip-to-main:focus {
  top: 0;
  outline: 3px solid #fbbf24;
}

/* Screen Reader Only Content */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
