/* ========================================
   ACCESSIBILITY WIDGET
   ======================================== */

@font-face {
  font-family: "OpenDyslexic";
  src: url("../webfonts/OpenDyslexic-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("../webfonts/OpenDyslexic-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

.accessibility-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 10000;
  font-family: Arial, sans-serif;
}

.widget-toggle {
  width: 52px;
  height: 52px;
  border: 0;
  border-radius: 50%;
  background: #19599c;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.widget-toggle:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.widget-toggle:focus-visible,
.widget-btn:focus-visible,
.widget-reset:focus-visible,
.widget-checkbox input:focus-visible + span {
  outline: 3px solid #f1d90d;
  outline-offset: 3px;
}

.widget-panel {
  position: absolute;
  right: 0;
  bottom: 64px;
  width: 300px;
  padding: 18px;
  border-radius: 14px;
  background: #fff;
  color: #222;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.22);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.98);
  transform-origin: bottom right;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease,
    visibility 0.2s ease;
}

.widget-panel.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  .widget-toggle,
  .widget-btn,
  .widget-panel {
    transition: none;
  }
}

.widget-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 700;
  color: #19599c;
}

.widget-icon {
  flex-shrink: 0;
}

.widget-section {
  padding: 12px 0;
  border-top: 1px solid #e6e6e6;
}

.widget-section:first-of-type {
  border-top: 0;
}

.widget-label {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}

.widget-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.widget-btn,
.widget-reset {
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s ease, transform 0.2s ease;
}

.widget-btn {
  background: #eef4fa;
  color: #19599c;
}

.widget-btn:hover {
  background: #dce9f6;
  transform: translateY(-1px);
}

.widget-checkbox {
  display: block;
  margin: 0;
  cursor: pointer;
}

.widget-checkbox input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.widget-checkbox span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #f7f7f7;
  color: #333;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.2s ease, color 0.2s ease;
}

.widget-checkbox input:checked + span {
  background: #19599c;
  color: #fff;
}

.widget-reset {
  width: 100%;
  margin-top: 12px;
  background: #333;
  color: #fff;
}

.widget-reset:hover {
  background: #555;
}

/* ========================================
   ACCESSIBILITY STATES
   ======================================== */

#main-content {
  isolation: isolate;
}

/* High Contrast */
#main-content.a11y-high-contrast,
#main-content.a11y-high-contrast * {
  background-color: #000 !important;
  color: #ffff00 !important;
  border-color: #ffff00 !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

#main-content.a11y-high-contrast a {
  color: #00ffff !important;
}

#main-content.a11y-high-contrast img,
#main-content.a11y-high-contrast video,
#main-content.a11y-high-contrast svg {
  filter: none !important;
}

/* Invert Colors */
#main-content.a11y-invert-colors {
  filter: invert(1) hue-rotate(180deg);
}

/* Prevent images/media looking completely wrong when inverted */
#main-content.a11y-invert-colors img,
#main-content.a11y-invert-colors video,
#main-content.a11y-invert-colors svg {
  filter: invert(1) hue-rotate(180deg);
}

/* Dyslexia-friendly font */
#main-content.a11y-dyslexia-font,
#main-content.a11y-dyslexia-font * {
  font-family: "OpenDyslexic", Arial, sans-serif !important;
  letter-spacing: 0.04em;
  word-spacing: 0.08em;
  line-height: 1.6;
}

/* Mobile */
@media (max-width: 480px) {
  .accessibility-widget {
    right: 12px;
    bottom: 12px;
  }

  .widget-panel {
    width: min(300px, calc(100vw - 24px));
    right: 0;
  }

  .widget-toggle {
    width: 48px;
    height: 48px;
  }
}
