/* ================================================================
   KMFRI Accessibility Widget – Styles
   ================================================================ */

/* DSpace: each theme's own primary colour (KMFRI navy on the main site, Blue Carbon's on /bluecarbon) */
:root {
  --a11y-ink: var(--bs-primary, #001D3D);
  --a11y-ink-hover: var(--bs-link-color, #0A5EAD);
}

/* ── Floating Action Button ──────────────────────────────────── */
.a11y-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 10000;
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--a11y-ink);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  border: 2px solid #fff;   /* DSpace: visible over the navy footer */
  transition: background .2s, transform .2s;
}
.a11y-fab:hover,
.a11y-fab:focus-visible {
  background: var(--a11y-ink-hover);
  transform: scale(1.08);
}
.a11y-fab.open {
  background: var(--a11y-ink-hover);
}
.a11y-fab svg { pointer-events: none; }

/* ── Panel ───────────────────────────────────────────────────── */
.a11y-panel {
  position: fixed;
  bottom: 88px;
  left: 24px;
  z-index: 10001;
  width: 320px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(.95);
  opacity: 0;
  visibility: hidden;
  transition: transform .25s ease, opacity .25s ease, visibility .25s;
}
.a11y-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
}

/* Header */
.a11y-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .875rem 1.25rem;
  background: var(--a11y-ink);
  color: #fff;
}
.a11y-panel__title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.a11y-panel__close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 .15rem;
  border-radius: 0;
}
.a11y-panel__close:hover,
.a11y-panel__close:focus-visible { opacity: .7; }

/* Body */
.a11y-panel__body {
  overflow-y: auto;
  padding: .75rem 1.25rem 1rem;
  flex: 1;
}

/* Font size section */
.a11y-panel__section {
  margin-bottom: .75rem;
}
.a11y-panel__label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #555;
  margin-bottom: .4rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.a11y-panel__font-controls {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.a11y-panel__font-controls button {
  width: 38px;
  height: 34px;
  border: 1.5px solid #ccc;
  border-radius: 0;
  background: #f7f9fc;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.a11y-panel__font-controls button:hover {
  background: var(--a11y-ink-hover);
  color: #fff;
  border-color: var(--a11y-ink-hover);
}
.a11y-panel__font-value {
  min-width: 48px;
  text-align: center;
  font-weight: 700;
  font-size: .95rem;
  color: var(--a11y-ink);
}

/* ── Toggle rows ─────────────────────────────────────────────── */
.a11y-panel__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: .65rem 0;
  border: none;
  border-bottom: 1px solid #eee;
  background: none;
  cursor: pointer;
  text-align: left;
  gap: .75rem;
}
.a11y-panel__toggle:last-child { border-bottom: none; }
.a11y-panel__toggle-info { flex: 1; }
.a11y-panel__toggle-label {
  display: block;
  font-size: .88rem;
  font-weight: 600;
  color: #222;
}
.a11y-panel__toggle-desc {
  display: block;
  font-size: .72rem;
  color: #666;   /* DSpace: #888 was 3.5:1 on white */
  margin-top: 1px;
}

/* Switch */
.a11y-panel__toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  background: #ccc;
  border-radius: 0;
  flex-shrink: 0;
  transition: background .2s;
}
.a11y-panel__toggle.active .a11y-panel__toggle-switch {
  background: var(--a11y-ink-hover);
}
.a11y-panel__toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.a11y-panel__toggle.active .a11y-panel__toggle-knob {
  transform: translateX(18px);
}

/* Footer */
.a11y-panel__footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid #eee;
}
.a11y-panel__reset {
  width: 100%;
  padding: .55rem;
  border: 1.5px solid var(--a11y-ink);
  border-radius: 0;
  background: transparent;
  color: var(--a11y-ink);
  font-weight: 600;
  font-size: .85rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.a11y-panel__reset:hover {
  background: var(--a11y-ink);
  color: #fff;
}

/* ── Keyboard focus, hover & disabled states (widget polish) ──── */
/* Visible focus ring on every control — the widget must itself be a11y. */
.a11y-fab:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}
.a11y-panel__toggle:focus-visible,
.a11y-panel__close:focus-visible,
.a11y-panel__reset:focus-visible,
.a11y-panel__font-controls button:focus-visible {
  outline: 3px solid var(--a11y-ink-hover);
  outline-offset: 2px;
}
/* Hover affordance on the toggle rows */
.a11y-panel__toggle {
  border-radius: 0;
  padding-left: .5rem;
  padding-right: .5rem;
  transition: background .15s;
}
.a11y-panel__toggle:hover { background: #f3f7fb; }
.a11y-panel__toggle.active .a11y-panel__toggle-label {
  color: var(--a11y-ink);
}
/* Font +/- buttons disabled at their limits */
.a11y-panel__font-controls button:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.a11y-panel__font-controls button:disabled:hover {
  background: #f7f9fc;
  color: inherit;
  border-color: #ccc;
}
/* Respect OS-level reduced-motion for the panel itself */
@media (prefers-reduced-motion: reduce) {
  .a11y-panel { transition: opacity .25s ease, visibility .25s; transform: none; }
  .a11y-panel.open { transform: none; }
  .a11y-fab { transition: background .2s; }
}

/* ── Reading guide bar ───────────────────────────────────────── */
.a11y-reading-guide {
  position: fixed;
  left: 0;
  width: 100%;
  height: 36px;
  background: rgba(255, 255, 0, .18);
  border-top: 2px solid rgba(255, 200, 0, .5);
  border-bottom: 2px solid rgba(255, 200, 0, .5);
  pointer-events: none;
  z-index: 99999;
  transition: top .05s linear;
}

/* ── Body-level accessibility classes ────────────────────────── */

/* High Contrast */
.a11y-contrast {
  filter: contrast(1.35);
}
.a11y-contrast img { filter: contrast(1); }

/* Dyslexia Font */
.a11y-dyslexia,
.a11y-dyslexia *:not(.fa, .fas, .far, .fab, .fa-solid, .fa-regular, .fa-brands) {   /* icons keep their icon font */
  font-family: "OpenDyslexic", "Comic Sans MS", "Arial", sans-serif !important;
}

/* Highlight Links */
.a11y-links a {
  text-decoration: underline !important;
  text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important;
  /* no forced colour: blue links would vanish on the navy header and footer */
}

/* Large Cursor */
.a11y-cursor,
.a11y-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M4 4l12 28 5-11 11-5z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 4 4, auto !important;
}

/* Text Spacing */
.a11y-spacing {
  letter-spacing: .08em !important;
  word-spacing: .16em !important;
}
.a11y-spacing p,
.a11y-spacing li,
.a11y-spacing dd,
.a11y-spacing td,
.a11y-spacing th {
  line-height: 1.9 !important;
}

/* Pause Animations */
.a11y-no-animations,
.a11y-no-animations *,
.a11y-no-animations *::before,
.a11y-no-animations *::after {
  animation-duration: 0s !important;
  animation-delay: 0s !important;
  transition-duration: 0s !important;
  scroll-behavior: auto !important;
}

/* DSpace: room under the last footer line (main and Blue Carbon footers) so the button never covers it */
.kmfri-footer-bar,
.pr-footer__bar {
  padding-bottom: 88px !important;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  .a11y-fab {
    bottom: 16px;
    left: 16px;
    width: 46px;
    height: 46px;
  }
  .a11y-panel {
    left: 8px;
    right: 8px;
    width: auto;
    bottom: 74px;
  }
}
