/* ALGOR accessibility widget — shared by the Next.js app and the FastAPI-served
   pager pages (/one-pager, /bond-pager, /convertible-pager), which are same-origin
   via Next rewrites. Preference classes are toggled on <html> by /a11y/widget.js
   and persisted in localStorage (key: algor-a11y-prefs). */

/* ── preference classes ──────────────────────────────────────────────────── */

/* text size — zoom scales px-based inline styles too, which rem-scaling misses */
html.a11y-zoom-1 body { zoom: 1.1; }
html.a11y-zoom-2 body { zoom: 1.25; }
html.a11y-zoom--1 body { zoom: 0.9; }
html.a11y-zoom--2 body { zoom: 0.8; }

/* high contrast — must beat the !important navy background in globals.css */
html.a11y-contrast body {
  background: #000 !important;
  background-image: none !important;
  color: #fff !important;
}
html.a11y-contrast .app-shell,
html.a11y-contrast .page-content {
  background: #000 !important;
}
html.a11y-contrast a { color: #ffe14d !important; }
html.a11y-contrast button { outline: 1px solid #fff; }

/* grayscale */
html.a11y-grayscale { filter: grayscale(1); }

/* highlight links */
html.a11y-links a {
  text-decoration: underline !important;
  outline: 1px solid currentColor;
  outline-offset: 1px;
}

/* readable font */
html.a11y-font body,
html.a11y-font body * {
  font-family: Arial, Helvetica, sans-serif !important;
}

/* stop animations */
html.a11y-no-motion *,
html.a11y-no-motion *::before,
html.a11y-no-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

/* ── widget button + panel ───────────────────────────────────────────────── */

#algor-a11y-btn {
  position: fixed;
  bottom: 48px;
  left: 12px;
  z-index: 2147482000;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #1e6fd9;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  padding: 0;
}
#algor-a11y-btn:hover { background: #1857ab; }
#algor-a11y-btn:focus-visible { outline: 3px solid #ffe14d; outline-offset: 2px; }
#algor-a11y-btn svg { width: 28px; height: 28px; }

#algor-a11y-panel {
  position: fixed;
  bottom: 104px;
  left: 12px;
  z-index: 2147482001;
  width: 280px;
  max-height: 70vh;
  overflow-y: auto;
  border-radius: 14px;
  background: #0d1a2d;
  border: 1px solid rgba(212, 175, 55, 0.4);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  padding: 14px;
  direction: rtl;
  font-family: inherit;
  color: #e5e7eb;
  display: none;
}
#algor-a11y-panel.open { display: block; }
#algor-a11y-panel h2 {
  color: #d4af37;
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px;
}
.algor-a11y-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 10px;
  margin-bottom: 7px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #e5e7eb;
  font-size: 13px;
  cursor: pointer;
  text-align: right;
}
.algor-a11y-row:hover { background: rgba(255, 255, 255, 0.1); }
.algor-a11y-row:focus-visible { outline: 2px solid #ffe14d; outline-offset: 1px; }
.algor-a11y-row[aria-pressed="true"] {
  background: #d4af37;
  color: #0a0f1e;
  font-weight: 700;
}
.algor-a11y-foot {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  text-align: center;
}
.algor-a11y-foot a { color: #d4af37; text-decoration: underline; }

/* ── phones / app mode: keep clear of the bottom tab bar + home indicator ── */
@media (max-width: 640px) {
  #algor-a11y-btn { bottom: calc(48px + env(safe-area-inset-bottom, 0px)); width: 44px; height: 44px; }
  #algor-a11y-panel { bottom: calc(100px + env(safe-area-inset-bottom, 0px)); width: min(280px, calc(100vw - 24px)); }
}
html.app-mode #algor-a11y-btn { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
html.app-mode #algor-a11y-panel { bottom: calc(128px + env(safe-area-inset-bottom, 0px)); }
