/**
 * PastaBar Accessibility Widget - SAFE VERSION
 * Minimal styling that does NOT affect the rest of the page
 * NO universal selectors, NO !important (except on widget itself)
 */

/* ========================================
   Widget Container - Scoped to #a11y-widget only
   ======================================== */

#a11y-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Widget Toggle Button */
#a11y-widget .a11y-toggle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(55, 87, 60, 0.95);
  color: white;
  border: none;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  transition: transform 0.2s, box-shadow 0.2s;
}

#a11y-widget .a11y-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#a11y-widget .a11y-toggle:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(55, 87, 60, 0.4);
}

#a11y-widget .a11y-toggle svg {
  width: 22px;
  height: 22px;
}

#a11y-widget .a11y-toggle-text {
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Widget Panel */
#a11y-widget .a11y-panel {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: 280px;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s, visibility 0.3s;
}

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

/* Panel Header */
#a11y-widget .a11y-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #e0e0e0;
}

#a11y-widget .a11y-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #37573c;
}

#a11y-widget .a11y-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #666;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#a11y-widget .a11y-close:hover {
  color: #37573c;
}

/* Panel Content */
#a11y-widget .a11y-content {
  padding: 16px;
}

#a11y-widget .a11y-group {
  margin-bottom: 16px;
}

#a11y-widget .a11y-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
}

#a11y-widget .a11y-buttons {
  display: flex;
  gap: 8px;
}

#a11y-widget .a11y-btn {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  background: white;
  color: #333;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

#a11y-widget .a11y-btn:hover {
  background: #f5f5f5;
  border-color: #37573c;
}

#a11y-widget .a11y-btn:focus {
  outline: 2px solid #4d90fe;
  outline-offset: 2px;
}

#a11y-widget .a11y-btn.active {
  background: #37573c;
  color: white;
  border-color: #37573c;
}

#a11y-widget .a11y-value {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: #37573c;
  margin-top: 4px;
}

/* RTL Support */
body[dir="rtl"] #a11y-widget {
  right: auto;
  left: 20px;
}

body[dir="rtl"] #a11y-widget .a11y-panel {
  right: auto;
  left: 0;
}

/* Mobile */
@media (max-width: 767px) {
  #a11y-widget {
    bottom: 15px;
    right: 15px;
  }

  #a11y-widget .a11y-toggle {
    width: 44px;
    height: 44px;
  }

  #a11y-widget .a11y-toggle svg {
    width: 20px;
    height: 20px;
  }

  #a11y-widget .a11y-toggle-text {
    font-size: 7px;
  }

  #a11y-widget .a11y-panel {
    width: calc(100vw - 20px);
    max-width: 280px;
  }

  body[dir="rtl"] #a11y-widget {
    left: 15px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  #a11y-widget .a11y-toggle,
  #a11y-widget .a11y-panel,
  #a11y-widget .a11y-btn {
    transition: none;
  }
}

/* Print */
@media print {
  #a11y-widget {
    display: none;
  }
}

/* ========================================
   ZOOM EFFECT - Safe alternative to font-size
   Applied to body, not root element
   ======================================== */

body.a11y-zoom-110 {
  zoom: 1.1;
}

body.a11y-zoom-125 {
  zoom: 1.25;
}

/* ========================================
   HIGH CONTRAST MODE - SAFE VERSION
   Only affects content elements, not layout
   ======================================== */

body.a11y-high-contrast {
  background: #fff;
  color: #000;
}

body.a11y-high-contrast header,
body.a11y-high-contrast section,
body.a11y-high-contrast footer,
body.a11y-high-contrast div,
body.a11y-high-contrast nav {
  background: #fff;
  color: #000;
}

body.a11y-high-contrast a {
  color: #00f;
  text-decoration: underline;
}

body.a11y-high-contrast button,
body.a11y-high-contrast .btn {
  background: #000;
  color: #fff;
  border: 2px solid #000;
}

body.a11y-high-contrast button:hover,
body.a11y-high-contrast .btn:hover {
  background: #333;
}

/* Keep widget visible in high contrast */
body.a11y-high-contrast #a11y-widget .a11y-toggle {
  background: #000;
  color: #fff;
}

/* ========================================
   LINK HIGHLIGHTING
   ======================================== */

body.a11y-highlight-links a {
  background: #ffff00;
  color: #000;
  padding: 2px 4px;
  border-radius: 3px;
  text-decoration: underline;
  font-weight: 600;
}

body.a11y-highlight-links #a11y-widget a {
  background: transparent;
  font-weight: normal;
}

/* Skip Link - Safe positioning */
.a11y-skip-link {
  position: fixed;
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 12px 24px;
  text-decoration: none;
  border-radius: 0 0 8px 8px;
  z-index: 10000;
  font-weight: 600;
  transition: top 0.2s;
}

.a11y-skip-link:focus {
  top: 0;
}

/* ========================================
   KEYBOARD HELP MODAL
   ======================================== */

.a11y-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
}

.a11y-modal .a11y-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.a11y-modal .a11y-modal-content {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.a11y-modal .a11y-modal-content h2 {
  margin: 0 0 16px 0;
  color: #37573c;
  font-size: 20px;
}

.a11y-modal .a11y-modal-content ul {
  list-style: none;
  padding: 0;
  margin: 0 0 20px 0;
}

.a11y-modal .a11y-modal-content li {
  padding: 8px 0;
  border-bottom: 1px solid #e0e0e0;
}

.a11y-modal .a11y-modal-content li:last-child {
  border-bottom: none;
}

.a11y-modal .a11y-modal-content strong {
  display: inline-block;
  min-width: 120px;
  color: #37573c;
  font-family: monospace;
}

.a11y-modal .a11y-modal-content button {
  width: 100%;
}
