/**
 * The accessibility widget: the floating button, its panel, and every mode it
 * turns on.
 *
 * Lifted out of custom.css so that ONE copy serves both the nursery sites and
 * the platform's own pages. The platform front page is rendered outside the
 * view layer (renderStandalone) and carries its own shell, so it cannot inherit
 * the nursery layout's stylesheets -- and the alternative to a shared file was
 * a second copy of 270 lines that would drift the first time one of them was
 * touched.
 *
 * Paired with views/frontend/partials/accessibility-fab.ejs and
 * assets/js/backend/accessibility.js. All three belong together; moving one
 * without the others breaks the widget silently, since a missing stylesheet
 * leaves a working button with no visible panel.
 */

/* =============================================
   Accessibility FAB
   ============================================= */

/* FAB Button */
.accessibility-fab {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: 9998;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: #03a9f3;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(3, 169, 243, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  transition: background-color 0.2s, box-shadow 0.2s, transform 0.2s;
  outline-offset: 3px;
}

.accessibility-fab:hover,
.accessibility-fab:focus-visible {
  background-color: #0291d0;
  box-shadow: 0 6px 22px rgba(3, 169, 243, 0.6);
  transform: scale(1.08);
}

.accessibility-fab:focus-visible {
  outline: 3px solid #ffc107;
}

/* RTL: flip to right side */
[dir="rtl"] .accessibility-fab {
  left: auto;
  right: 28px;
}

/* Panel */
.accessibility-panel {
  position: fixed;
  bottom: 90px;
  left: 28px;
  z-index: 9999;
  width: 280px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  animation: acc-fade-in 0.2s ease;
}

[dir="rtl"] .accessibility-panel {
  left: auto;
  right: 28px;
}

@keyframes acc-fade-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Panel Header */
.accessibility-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #03a9f3;
  color: #fff;
  padding: 12px 16px;
}

.accessibility-panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
}

.accessibility-close-btn {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  transition: background-color 0.15s;
}

.accessibility-close-btn:hover,
.accessibility-close-btn:focus-visible {
  background-color: rgba(255, 255, 255, 0.25);
  outline: none;
}

/* Panel Body */
.accessibility-panel-body {
  padding: 8px 0;
  max-height: calc(100vh - 180px);
  overflow-y: auto;
}

/* Section */
.accessibility-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 16px;
  border-bottom: 1px solid #f0f0f0;
}

.accessibility-section-label {
  font-size: 13px;
  color: #444;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Button group */
.accessibility-btn-group {
  display: flex;
  gap: 6px;
}

.acc-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1.5px solid #dee2e6;
  background: #f8f9fa;
  color: #444;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  outline-offset: 2px;
}

.acc-btn:hover {
  background-color: #e3f6fd;
  border-color: #03a9f3;
  color: #03a9f3;
}

.acc-btn:focus-visible {
  outline: 2px solid #03a9f3;
}

.acc-btn.active,
.acc-btn[aria-pressed="true"] {
  background-color: #03a9f3;
  border-color: #03a9f3;
  color: #fff;
}

/* Reset All */
.acc-reset-all-btn {
  width: 100%;
  padding: 8px 16px;
  background: #f8f9fa;
  border: 1.5px solid #dee2e6;
  border-radius: 8px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 0.15s, color 0.15s;
}

.acc-reset-all-btn:hover,
.acc-reset-all-btn:focus-visible {
  background-color: #ffeaea;
  color: #dc3545;
  border-color: #dc3545;
  outline: none;
}

/* Reading guide line */
.acc-reading-line {
  position: fixed;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(3, 169, 243, 0.55);
  pointer-events: none;
  z-index: 99999;
  top: 0;
  transition: top 0.05s;
}

/* Accessibility body classes */
body.acc-high-contrast {
  filter: contrast(150%);
}

body.acc-invert {
  filter: invert(1) hue-rotate(180deg);
}

body.acc-high-contrast.acc-invert {
  filter: contrast(150%) invert(1) hue-rotate(180deg);
}

body.acc-grayscale {
  filter: grayscale(100%);
}

body.acc-saturate {
  filter: saturate(200%);
}

body.acc-highlight-links a {
  background-color: #fff176 !important;
  color: #000 !important;
  text-decoration: underline !important;
  outline: 1px solid #f9a825;
}

body.acc-focus-outline *:focus {
  outline: 3px solid #f9a825 !important;
  outline-offset: 3px !important;
}

body.acc-dyslexia,
body.acc-dyslexia * {
  font-family: 'Arial', 'Helvetica', sans-serif !important;
  letter-spacing: 0.05em !important;
  word-spacing: 0.15em !important;
  line-height: 1.7 !important;
}

/* Mobile responsive */
@media (max-width: 480px) {
  .accessibility-fab {
    bottom: 18px;
    left: 18px;
    width: 46px;
    height: 46px;
    font-size: 19px;
  }

  [dir="rtl"] .accessibility-fab {
    left: auto;
    right: 18px;
  }

  .accessibility-panel {
    bottom: 76px;
    left: 10px;
    right: 10px;
    width: auto;
  }

  [dir="rtl"] .accessibility-panel {
    left: 10px;
    right: 10px;
  }
}

/* Skip to content link (screen readers & keyboard users) */
.skip-to-content {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 100000;
  background: #03a9f3;
  color: #fff;
  padding: 10px 18px;
  border-radius: 0 0 8px 8px;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s;
}

.skip-to-content:focus {
  top: 0;
  color: #fff;
}

[dir="rtl"] .skip-to-content {
  left: auto;
  right: 16px;
}
