/* ==========================================================================
   Okivoria — Accessibility Widget Stylesheet
   Self-contained. Namespaced with "a11y-" to avoid collisions with site CSS.
   Include this file on every page, after the page's own <style>/CSS.
   ========================================================================== */

/* -------------------- Dyslexia-friendly font -------------------- */
@font-face {
  font-family: 'OpenDyslexic';
  src: url('./fonts/open-dyslexic/OpenDyslexic-Regular.woff') format('woff');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   1. TOGGLE BUTTON — fixed, right edge, vertically centered
   (kept clear of the .scroll-top button, which lives bottom-right)
   ========================================================================== */
.a11y-toggle {
  position: fixed;
  top: 50%;
  right: 1.5rem;
  transform: translateY(-50%);
  z-index: 2147483000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: linear-gradient(135deg, #3c6e8f, #1f4b63);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 40, 60, 0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.a11y-toggle:hover {
  transform: translateY(-50%) scale(1.07);
  box-shadow: 0 14px 34px rgba(0, 40, 60, 0.45);
}

.a11y-toggle:focus-visible {
  outline: 3px solid #ffb703;
  outline-offset: 3px;
}

.a11y-toggle[aria-expanded="true"] {
  background: linear-gradient(135deg, #1f4b63, #0f2838);
}

@media (max-width: 640px) {
  .a11y-toggle {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
    right: 1rem;
  }
}

/* ==========================================================================
   2. OVERLAY
   ========================================================================== */
.a11y-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 30, 0.35);
  z-index: 2147483001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.a11y-overlay.a11y-visible {
  opacity: 1;
  visibility: visible;
}

/* ==========================================================================
   3. PANEL
   ========================================================================== */
.a11y-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  height: 100dvh;
  width: min(400px, 100vw);
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: -20px 0 60px -20px rgba(0, 40, 60, 0.4);
  z-index: 2147483002;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #1a2e3f;
}

.a11y-panel.a11y-open {
  transform: translateX(0);
}

.a11y-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid rgba(60, 110, 143, 0.15);
  flex-shrink: 0;
}

.a11y-panel-header h2 {
  font-size: 0.98rem;
  font-weight: 600;
  color: #0f2838;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  flex-shrink: 1;
  min-width: 0;
  overflow: hidden;
}

.a11y-panel-header h2 span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.a11y-panel-header h2 i {
  color: #3c6e8f;
}

.a11y-header-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.a11y-icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(60, 110, 143, 0.2);
  background: rgba(255, 255, 255, 0.6);
  color: #1f4b63;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.a11y-icon-btn:hover {
  background: rgba(60, 110, 143, 0.15);
}

.a11y-icon-btn:focus-visible {
  outline: 2px solid #3c6e8f;
  outline-offset: 2px;
}

.a11y-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.4rem 1.4rem;
}

.a11y-panel-footer {
  flex-shrink: 0;
  padding: 1rem 1.4rem;
  border-top: 1px solid rgba(60, 110, 143, 0.15);
}

.a11y-panel-footer a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #1f4b63;
  text-decoration: none;
  border-bottom: 1px dotted;
  width: fit-content;
}

.a11y-panel-footer a:hover {
  opacity: 0.75;
}

@media (max-width: 480px) {
  .a11y-panel {
    width: 100vw;
  }
}

/* ==========================================================================
   4. SECTIONS / ROWS
   ========================================================================== */
.a11y-section {
  padding: 0.9rem 0;
  border-bottom: 1px solid rgba(60, 110, 143, 0.1);
}

.a11y-section:last-child {
  border-bottom: none;
}

.a11y-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #3c6e8f;
  margin-bottom: 0.7rem;
}

.a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.15rem;
  cursor: pointer;
  border-radius: 10px;
}

.a11y-switch-row:hover {
  background: rgba(60, 110, 143, 0.06);
}

.a11y-row-label {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.88rem;
  color: #1a2e3f;
}

.a11y-row-label i {
  width: 20px;
  text-align: center;
  color: #3c6e8f;
  font-size: 1rem;
  flex-shrink: 0;
}

/* -------------------- Toggle switch -------------------- */
.a11y-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.a11y-switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

.a11y-slider {
  position: absolute;
  inset: 0;
  background: rgba(60, 110, 143, 0.25);
  border-radius: 30px;
  transition: background 0.2s;
  pointer-events: none;
}

.a11y-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s;
}

.a11y-switch input:checked+.a11y-slider {
  background: #3c6e8f;
}

.a11y-switch input:checked+.a11y-slider::before {
  transform: translateX(18px);
}

.a11y-switch input:focus-visible+.a11y-slider {
  outline: 2px solid #ffb703;
  outline-offset: 2px;
}

/* -------------------- Font-size stepper -------------------- */
.a11y-stepper-row {
  cursor: default;
}

.a11y-stepper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(60, 110, 143, 0.08);
  border-radius: 30px;
  padding: 0.25rem;
}

.a11y-stepper button {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #1f4b63;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 40, 60, 0.15);
}

.a11y-stepper button:hover {
  background: #3c6e8f;
  color: #fff;
}

.a11y-stepper button:focus-visible {
  outline: 2px solid #ffb703;
  outline-offset: 2px;
}

.a11y-stepper span {
  min-width: 38px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #1f4b63;
}

/* -------------------- Profiles -------------------- */
.a11y-profiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.a11y-profile-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0.4rem;
  border-radius: 14px;
  border: 1px solid rgba(60, 110, 143, 0.2);
  background: rgba(60, 110, 143, 0.05);
  color: #1f4b63;
  font-size: 0.7rem;
  font-weight: 500;
  line-height: 1.25;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, border-color 0.2s;
}

.a11y-profile-btn i {
  font-size: 1.15rem;
  color: #3c6e8f;
}

.a11y-profile-btn:hover {
  background: rgba(60, 110, 143, 0.15);
}

.a11y-profile-btn.a11y-active {
  background: #3c6e8f;
  border-color: #3c6e8f;
  color: #fff;
}

.a11y-profile-btn.a11y-active i {
  color: #fff;
}

.a11y-profile-btn:focus-visible {
  outline: 2px solid #ffb703;
  outline-offset: 2px;
}

/* -------------------- Language switcher (in panel header, site pattern) -------------------- */
.a11y-lang-switcher {
  position: relative;
}

.a11y-lang-trigger {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  height: 36px;
  padding: 0 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(60, 110, 143, 0.2);
  background: rgba(255, 255, 255, 0.6);
  color: #1f4b63;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
}

.a11y-lang-trigger:hover {
  background: rgba(60, 110, 143, 0.15);
}

.a11y-lang-trigger:focus-visible {
  outline: 2px solid #ffb703;
  outline-offset: 2px;
}

.a11y-lang-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  min-width: 130px;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 14px;
  box-shadow: 0 20px 40px -20px rgba(0, 40, 60, 0.35);
  overflow: hidden;
  display: none;
  z-index: 1;
}

.a11y-lang-dropdown.a11y-show {
  display: block;
}

.a11y-lang-option {
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #1f4b63;
  transition: background 0.2s;
}

.a11y-lang-option:hover {
  background: rgba(60, 110, 143, 0.1);
}

.a11y-lang-option i {
  margin-right: 0.5rem;
  width: 0.9rem;
  color: #3c6e8f;
}

/* -------------------- Text alignment segmented group -------------------- */
.a11y-align-group,
.a11y-speed-group {
  display: flex;
  gap: 0.25rem;
  background: rgba(60, 110, 143, 0.08);
  border-radius: 12px;
  padding: 0.25rem;
}

.a11y-align-btn {
  width: 32px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #1f4b63;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.a11y-align-btn:hover {
  background: rgba(255, 255, 255, 0.7);
}

.a11y-align-btn.a11y-active {
  background: #3c6e8f;
  color: #fff;
}

.a11y-align-btn:focus-visible {
  outline: 2px solid #ffb703;
  outline-offset: 2px;
}

/* -------------------- Screen-reader / read-aloud -------------------- */
.a11y-speed-btn {
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #1f4b63;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
}

.a11y-speed-btn:hover {
  background: rgba(255, 255, 255, 0.7);
}

.a11y-speed-btn.a11y-active {
  background: #3c6e8f;
  color: #fff;
}

.a11y-speed-btn:focus-visible {
  outline: 2px solid #ffb703;
  outline-offset: 2px;
}

.a11y-read-btn {
  width: 100%;
  margin-top: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: none;
  background: #3c6e8f;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.a11y-read-btn:hover {
  background: #1f4b63;
}

.a11y-read-btn:focus-visible {
  outline: 2px solid #ffb703;
  outline-offset: 3px;
}

.a11y-read-btn.a11y-reading {
  background: #ff6b00;
}

.a11y-read-btn.a11y-reading:hover {
  background: #e05f00;
}

/* ==========================================================================
   5. READING GUIDE BAR (created dynamically by accessibility.js)
   ========================================================================== */
.a11y-reading-guide-bar {
  position: fixed;
  left: 0;
  width: 100%;
  height: 40px;
  background: rgba(255, 214, 0, 0.22);
  border-top: 2px solid rgba(200, 150, 0, 0.7);
  border-bottom: 2px solid rgba(200, 150, 0, 0.7);
  pointer-events: none;
  z-index: 2147482999;
  transform: translateY(-50%);
}

/* ==========================================================================
   6. APPLIED ACCESSIBILITY STATES
   These classes are toggled on <html> by accessibility.js and affect the
   whole page. All rules use !important because they must win over each
   page's own inline <style> and any inline element styles.
   ========================================================================== */

/* ---- Line height ---- */
html.a11y-line-height body,
html.a11y-line-height p,
html.a11y-line-height li {
  line-height: 2 !important;
}

/* ---- Letter / word spacing ---- */
html.a11y-letter-spacing body,
html.a11y-letter-spacing p,
html.a11y-letter-spacing li,
html.a11y-letter-spacing a,
html.a11y-letter-spacing span {
  letter-spacing: 0.12em !important;
  word-spacing: 0.18em !important;
}

/* ---- Dyslexia-friendly font ---- */
html.a11y-dyslexia-font body,
html.a11y-dyslexia-font h1,
html.a11y-dyslexia-font h2,
html.a11y-dyslexia-font h3,
html.a11y-dyslexia-font p,
html.a11y-dyslexia-font a,
html.a11y-dyslexia-font span,
html.a11y-dyslexia-font li,
html.a11y-dyslexia-font button {
  font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif !important;
}

/* ---- Readable font (strip decorative type, plain sans everywhere) ---- */
html.a11y-readable-font body,
html.a11y-readable-font h1,
html.a11y-readable-font h2,
html.a11y-readable-font h3,
html.a11y-readable-font p,
html.a11y-readable-font a,
html.a11y-readable-font span,
html.a11y-readable-font li,
html.a11y-readable-font button {
  font-family: Arial, Helvetica, sans-serif !important;
  letter-spacing: normal !important;
}

/* ---- Text align ---- */
html.a11y-text-left p,
html.a11y-text-left li,
html.a11y-text-left .tagline,
html.a11y-text-left .description {
  text-align: left !important;
}

html.a11y-text-center p,
html.a11y-text-center li,
html.a11y-text-center .tagline,
html.a11y-text-center .description {
  text-align: center !important;
}

html.a11y-text-right p,
html.a11y-text-right li,
html.a11y-text-right .tagline,
html.a11y-text-right .description {
  text-align: right !important;
}

/* ---- High contrast ---- */
html.a11y-high-contrast body {
  background: #000 !important;
  color: #fff !important;
}

html.a11y-high-contrast .background {
  display: none !important;
}

html.a11y-high-contrast .topbar,
html.a11y-high-contrast .card,
html.a11y-high-contrast .footer,
html.a11y-high-contrast .site-menu nav,
html.a11y-high-contrast .lang-switcher,
html.a11y-high-contrast .lang-dropdown,
html.a11y-high-contrast .a11y-panel {
  background: #000 !important;
  border: 1px solid #fff !important;
  box-shadow: none !important;
  color: #fff !important;
}

html.a11y-high-contrast .a11y-panel {
  color: #fff !important;
}

html.a11y-high-contrast a,
html.a11y-high-contrast .brand,
html.a11y-high-contrast h1,
html.a11y-high-contrast h2,
html.a11y-high-contrast h3,
html.a11y-high-contrast p,
html.a11y-high-contrast span,
html.a11y-high-contrast li,
html.a11y-high-contrast .lang-btn,
html.a11y-high-contrast .menu-toggle,
html.a11y-high-contrast .badge,
html.a11y-high-contrast .a11y-row-label,
html.a11y-high-contrast .a11y-section-title {
  color: #fff !important;
  text-shadow: none !important;
}

html.a11y-high-contrast a {
  color: #ffd400 !important;
  text-decoration: underline !important;
}

html.a11y-high-contrast .footer-links a.current {
  color: #fff !important;
  border-bottom-color: #fff !important;
}

/* ---- Highlight links ---- */
html.a11y-highlight-links a:not(.a11y-toggle):not(.a11y-lang-btn):not(.a11y-profile-btn) {
  background: rgba(255, 214, 0, 0.35) !important;
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  color: #0f2838 !important;
  border-radius: 4px !important;
  padding: 0 0.15em !important;
}

/* ---- Highlight headings ---- */
html.a11y-highlight-headings h1,
html.a11y-highlight-headings h2,
html.a11y-highlight-headings h3 {
  outline: 2px dashed #3c6e8f !important;
  outline-offset: 4px;
  background: rgba(60, 110, 143, 0.08) !important;
}

/* ---- Stronger focus outline ---- */
html.a11y-focus-outline *:focus {
  outline: 3px solid #ff6b00 !important;
  outline-offset: 3px !important;
}

/* ---- Big cursor ---- */
html.a11y-big-cursor,
html.a11y-big-cursor * {
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path d="M4 2 L4 20 L9 15.5 L12.5 22 L15.5 20.5 L12 14 L19 14 Z" fill="black" stroke="white" stroke-width="1.2"/></svg>') 4 4, auto !important;
}

/* ---- Hide images ---- */
html.a11y-hide-images img,
html.a11y-hide-images picture,
html.a11y-hide-images svg:not(.a11y-panel svg):not(.a11y-toggle svg) {
  visibility: hidden !important;
}

/* ---- Pause animations ---- */
html.a11y-pause-animations *,
html.a11y-pause-animations *::before,
html.a11y-pause-animations *::after {
  animation-play-state: paused !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

@media (prefers-reduced-motion: reduce) {
  .a11y-panel {
    transition: none;
  }
}
