/*
 * Floating accessibility pill for served lessons (Spec 0034). The control chrome
 * only: the lesson's own cs-design-system.css already responds to the body
 * classes the pill toggles (warm-tones, high-contrast, dyslexia, --fs), so no
 * response styles live here. Built by src/lib/lesson-chrome.ts, injected by the
 * /courses route. Namespaced under `csl-a11y-` so it never clashes with Craig's
 * lesson markup; mirrors AccessibilityBar.astro. Falls back to literal shades
 * when the platform tokens are absent.
 */

.csl-a11y-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(140deg, #00c49a 0%, #009e7c 100%);
  color: #fff;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 196, 154, 0.4), 0 2px 8px rgba(0, 196, 154, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.csl-a11y-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 12px 30px rgba(0, 196, 154, 0.5), 0 4px 10px rgba(0, 196, 154, 0.3);
}
.csl-a11y-fab:active {
  transform: translateY(0) scale(0.98);
}
.csl-a11y-fab:focus-visible {
  outline: 3px solid #f5a623;
  outline-offset: 3px;
}

.csl-a11y-panel {
  position: fixed;
  bottom: 92px;
  left: 20px;
  z-index: 1000;
  width: 262px;
  max-width: calc(100vw - 40px);
  background: #fff;
  border: 1px solid var(--rule, #dee2e6);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16);
  padding: 12px 16px 14px;
  font-family: var(--font, 'Plus Jakarta Sans', system-ui, sans-serif);
}
.csl-a11y-panel[hidden] {
  display: none;
}

.csl-a11y-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.csl-a11y-title {
  flex: 1;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink, #1a1e24);
}
.csl-a11y-x {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted, #6c757d);
  display: inline-flex;
  padding: 4px;
  border-radius: 6px;
}
.csl-a11y-x:hover {
  color: var(--ink, #1a1e24);
  background: var(--surface, #f8f9fa);
}

.csl-a11y-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--rule, #dee2e6);
}
.csl-a11y-row:first-of-type {
  margin-top: 4px;
}
.csl-a11y-ic {
  color: var(--muted, #6c757d);
  display: inline-flex;
  flex: none;
}
.csl-a11y-name {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink, #1a1e24);
}

.csl-a11y-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex: none;
  border: none;
  border-radius: 999px;
  background: var(--muted, #6c757d);
  cursor: pointer;
  padding: 0;
  transition: background 0.15s;
}
.csl-a11y-switch[aria-checked='true'] {
  background: var(--teal, #00c49a);
}
.csl-a11y-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: left 0.15s;
}
.csl-a11y-switch[aria-checked='true'] .csl-a11y-knob {
  left: 22px;
}

.csl-a11y-size {
  display: inline-flex;
  gap: 4px;
  flex: none;
}
.csl-a11y-size button {
  min-width: 36px;
  min-height: 30px;
  background: var(--surface, #f8f9fa);
  border: 1px solid var(--rule, #dee2e6);
  border-radius: 8px;
  color: var(--ink, #1a1e24);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.csl-a11y-size button:hover {
  background: var(--navy-lt, #e8f0f7);
}

@media (max-width: 520px) {
  .csl-a11y-fab {
    bottom: 16px;
    left: 16px;
  }
  .csl-a11y-panel {
    bottom: 86px;
    left: 16px;
  }
}

/*
 * Spec 0036 Phase 2 / Spec 0045: at mobile widths the floating accessibility
 * pill folds into the site-header drawer on ALL surfaces (platform pages and
 * lessons alike), so the floating control is hidden. Lessons used to be an
 * exception (they kept the pill); that carve-out is gone so lessons match the
 * rest of the site. On desktop the pill stays, since the drawer only exists on
 * mobile.
 */
@media (max-width: 768px) {
  .csl-a11y {
    display: none;
  }
}

/*
 * Spec 0055: some served pages (the M18 practice papers) carry their own fixed
 * bottom action bar (`.csx-bar`, at bottom:0). Lift the pill's FAB and panel
 * above it so they never overlap the paper's bar. Only takes effect on desktop
 * (the pill is hidden <=768px); the higher specificity keeps it above the base
 * positions without touching the general case.
 */
body.cs-sh-host:has(.csx-bar) .csl-a11y-fab {
  bottom: 78px;
}
body.cs-sh-host:has(.csx-bar) .csl-a11y-panel {
  bottom: 150px;
}

/* High-contrast treatment for the pill itself (the lesson body class). */
body.high-contrast .csl-a11y-fab {
  background: #000 !important;
  color: #fff !important;
  outline: 2px solid #fff;
}
body.high-contrast .csl-a11y-panel {
  background: #fff !important;
  border: 3px solid #000 !important;
}
body.high-contrast .csl-a11y-panel * {
  color: #000 !important;
}
body.high-contrast .csl-a11y-switch {
  background: #767676 !important;
  outline: 1px solid #000;
}
body.high-contrast .csl-a11y-switch[aria-checked='true'] {
  background: #000 !important;
}
body.high-contrast .csl-a11y-knob {
  background: #fff !important;
}

/* Reading guide band (Spec 0036 Phase 2 follow-up): a translucent strip that
   tracks the pointer while the reading-guide control is on. Positioned by
   cs-a11y.js; shown only when the body carries the reading-guide class. */
.csl-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 38px;
  z-index: 998;
  pointer-events: none;
  display: none;
  background: rgba(0, 196, 154, 0.12);
  border-top: 2px solid rgba(0, 196, 154, 0.5);
  border-bottom: 2px solid rgba(0, 196, 154, 0.5);
}
body.reading-guide .csl-reading-guide {
  display: block;
}

/*
 * Spec 0036 Phase 2 toggle responses. Kept in this shared stylesheet (loaded on
 * both platform pages and served lessons) so each toggle behaves identically on
 * every surface from one source. Each rule is opt-in: it does nothing until its
 * body class is set, so default rendering is untouched. Literal shades are used
 * (no token dependency) so they hold on the lesson surface too.
 */
body.line-spacing {
  line-height: 1.9 !important;
  letter-spacing: 0.06em;
  word-spacing: 0.16em;
}
body.line-spacing p,
body.line-spacing li {
  line-height: 1.9 !important;
}
body.link-highlight a {
  background: #fff3a8;
  box-shadow: 0 0 0 1px #e0c200;
  border-radius: 2px;
  text-decoration: underline;
  text-decoration-thickness: 2px;
}
body.enhanced-focus :focus-visible {
  outline: 3px solid #f5a623 !important;
  outline-offset: 3px !important;
  border-radius: 2px;
}
body.large-cursor,
body.large-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='38' height='38' viewBox='0 0 24 24'%3E%3Cpath d='M5 2l15 9-6.6 1.2L17 19l-2.4 1-3.4-6.6L6 18z' fill='%23111111' stroke='%23ffffff' stroke-width='1.2'/%3E%3C/svg%3E") 4 2, auto !important;
}
body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
