/* ===== ACCESSIBILITY WIDGET - MirrorG ===== */

/* ===== WIDGET CONTAINER ===== */
.a11y-widget {
  position: fixed;
  bottom: var(--space-xl);
  left: var(--space-xl);
  z-index: var(--z-accessibility);
  font-family: var(--font-family-primary);
}

/* ===== TOGGLE BUTTON ===== */
.a11y-widget__toggle {
  width: 48px;
  height: 48px;
  border-radius: var(--border-radius-full);
  background: var(--color-primary);
  color: var(--color-white);
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-base), background-color var(--transition-base);
}

.a11y-widget__toggle:hover {
  background: var(--color-primary-dark);
  transform: scale(1.05);
}

.a11y-widget__toggle:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

.a11y-widget__icon {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* ===== PANEL ===== */
.a11y-widget__panel {
  position: absolute;
  bottom: 55px;
  left: 0;
  width: 320px;
  max-height: calc(100vh - 70px);
  background: var(--color-white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-xl);
  overflow-y: auto;
  transform-origin: bottom left;
  transition: transform var(--transition-base), opacity var(--transition-base);
}

.a11y-widget__panel[hidden] {
  display: block;
  transform: scale(0.95);
  opacity: 0;
  pointer-events: none;
}

.a11y-widget__panel:not([hidden]) {
  transform: scale(1);
  opacity: 1;
}

/* ===== HEADER ===== */
.a11y-widget__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-primary);
  color: var(--color-white);
}

.a11y-widget__title {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  margin: 0;
}

.a11y-widget__close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--color-white);
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.a11y-widget__close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.a11y-widget__close svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* ===== CONTENT ===== */
.a11y-widget__content {
  padding: var(--space-md);
}

/* ===== GROUPS ===== */
.a11y-widget__group {
  margin-bottom: var(--space-md);
}

.a11y-widget__group-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-sm);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ===== CONTROLS ===== */
.a11y-widget__controls {
  display: flex;
  gap: var(--space-sm);
}

.a11y-widget__controls--vertical {
  flex-direction: column;
}

/* ===== BUTTONS ===== */
.a11y-widget__btn {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  background: var(--color-white);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
}

.a11y-widget__btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.a11y-widget__btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.a11y-widget__btn--toggle[aria-pressed="true"] {
  background: var(--color-primary);
  color: var(--color-white);
  border-color: var(--color-primary);
}

.a11y-widget__btn--reset {
  width: 100%;
  background: #e74c3c;
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: var(--font-size-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: background 0.2s ease;
}

.a11y-widget__btn--reset:hover {
  background: #c0392b;
}

.a11y-widget__btn-icon {
  font-size: 1.2em;
}

/* ===== FOOTER ===== */
.a11y-widget__footer {
  padding: var(--space-md);
  border-top: 2px solid var(--color-border-light);
  background: var(--color-white);
  position: sticky;
  bottom: 0;
}

.a11y-widget__statement-link {
  display: block;
  text-align: center;
  margin-top: var(--space-sm);
  font-size: var(--font-size-xs);
  color: var(--color-primary);
  text-decoration: underline;
}

/* ===== ACCESSIBILITY STATES ===== */
/* IMPORTANT: filter-based features (contrast, invert, grayscale) are applied to
   body's DIRECT children, NOT to body itself. Applying filter to body creates a
   new containing block that breaks position:fixed on the a11y widget & WhatsApp button,
   making them disappear. The :not() selectors preserve those floating elements. */

/* High Contrast */
body.a11y-high-contrast > *:not(.a11y-widget):not(.whatsapp-btn):not(.a11y-reading-guide) {
  filter: contrast(1.4);
}

/* Invert Colors */
body.a11y-invert-colors > *:not(.a11y-widget):not(.whatsapp-btn):not(.a11y-reading-guide) {
  filter: invert(1) hue-rotate(180deg);
}

body.a11y-invert-colors > *:not(.a11y-widget):not(.whatsapp-btn):not(.a11y-reading-guide) img,
body.a11y-invert-colors > *:not(.a11y-widget):not(.whatsapp-btn):not(.a11y-reading-guide) video {
  filter: invert(1) hue-rotate(180deg);
}

/* Highlight Links */
body.a11y-highlight-links a:not(.btn) {
  outline: 2px solid var(--color-accent) !important;
  outline-offset: 2px;
  background-color: rgba(255, 203, 5, 0.2);
}

/* Readable Font */
body.a11y-readable-font,
body.a11y-readable-font * {
  font-family: Arial, Helvetica, sans-serif !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.1em !important;
}

/* Stop Animations */
body.a11y-stop-animations *,
body.a11y-stop-animations *::before,
body.a11y-stop-animations *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.01ms !important;
}

/* Grayscale */
body.a11y-grayscale > *:not(.a11y-widget):not(.whatsapp-btn):not(.a11y-reading-guide) {
  filter: grayscale(1);
}

/* Big Cursor */
body.a11y-big-cursor,
body.a11y-big-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 d='M8 4l28 20H20l-4 16L8 4z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* Text Spacing */
body.a11y-text-spacing p,
body.a11y-text-spacing li,
body.a11y-text-spacing span,
body.a11y-text-spacing div {
  letter-spacing: 0.12em !important;
  word-spacing: 0.16em !important;
  line-height: 2 !important;
}

/* Highlight Headings */
body.a11y-highlight-headings h1,
body.a11y-highlight-headings h2,
body.a11y-highlight-headings h3,
body.a11y-highlight-headings h4,
body.a11y-highlight-headings h5,
body.a11y-highlight-headings h6 {
  outline: 3px solid var(--color-primary) !important;
  outline-offset: 4px;
  padding: 4px !important;
}

/* Font Size Adjustments */
body.a11y-font-size-1 {
  font-size: 100%;
}

body.a11y-font-size-2 {
  font-size: 112.5%;
}

body.a11y-font-size-3 {
  font-size: 125%;
}

body.a11y-font-size-4 {
  font-size: 137.5%;
}

body.a11y-font-size-5 {
  font-size: 150%;
}

/* ===== READING GUIDE ===== */
.a11y-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  height: 40px;
  background: rgba(255, 203, 5, 0.25);
  pointer-events: none;
  z-index: 9998;
  border-top: 2px solid var(--color-accent);
  border-bottom: 2px solid var(--color-accent);
  display: none;
}

body.a11y-reading-guide-active .a11y-reading-guide {
  display: block;
}

/* ===== MOBILE ADJUSTMENTS ===== */
@media (max-width: 767px) {
  .a11y-widget {
    bottom: var(--space-md);
    left: var(--space-md);
  }

  .a11y-widget__toggle {
    width: 42px;
    height: 42px;
  }

  .a11y-widget__icon {
    width: 20px;
    height: 20px;
  }

  .a11y-widget__panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    max-height: 85vh;
  }

  .a11y-widget__content {
    max-height: calc(85vh - 60px);
  }
}
