/* ================================================================
   Reading-aids tab + compact colour panel.
   The panel is colour-only: typeface, size, spacing and interline are
   all owned by the Dyslexie Font plugin (when active), so we deliberately
   keep our control scoped to the one thing Dyslexie's panel doesn't do —
   site-level background colour palettes.

   Form-factor mirrors the Dyslexie panel: a small floating box rather
   than a full-height side drawer, sized so it sits comfortably alongside
   site content without feeling like a takeover. Trigger is a deep-blue tab
   on the left edge (orange is reserved for the Nominate CTA), or a round
   floating action button bottom-right on phones.
   ================================================================ */


/* ----- The trigger: left-edge tab on desktop, FAB on mobile ----- */
.aa-tab {
  position: fixed;
  top: 50%;
  left: 0;
  z-index: 55;

  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 12px;

  /* Deep brand blue (matches the ReachDeck / BrowseAloud launch button
     family and the site's section panels) so the tab reads as the
     accessibility control rather than competing with the bright
     `--ember` Nominate CTA — Eli wants orange reserved for Nominate.
     White text on #0E5A75 = 6.6:1 — clears AA 4.5:1. */
  background: #0E5A75;
  color: var(--always-light);
  border: 0;
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);

  font-family: var(--font-stack);
  font-weight: 700;
  font-size: 15px;
  /* Vertical-rl rotates each Latin glyph 90° clockwise, then the
     `rotate(180deg)` flips the whole column. Lowercase reads poorly in
     this orientation because ascenders/descenders break the vertical
     rhythm, so we set uppercase + generous tracking so each letter has
     room to register as a discrete shape. */
  text-transform: uppercase;
  letter-spacing: 0.18em;
  cursor: pointer;
  writing-mode: vertical-rl;
  transform-origin: center;
  transform: translateY(-50%) rotate(180deg);
}
.aa-tab .aa-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  writing-mode: horizontal-tb;
  transform: rotate(180deg);
  margin-bottom: 4px;
}
.aa-tab:hover { background: #0A4658; }  /* slightly deeper brand blue; preserves AA */
/* Two-tone focus ring: a paper (cream) inner band reads against the tab and
   any dark page bg, an ink outer band reads against any light page bg.
   `outline` can't carry two colours, so we use stacked box-shadows. */
.aa-tab:focus-visible {
  outline: none;
  box-shadow:
    0 6px 18px rgba(0,0,0,0.25),
    0 0 0 3px var(--always-light),
    0 0 0 6px var(--always-ink);
}

/* When the panel is open, hide the tab so it doesn't sit over the panel edge */
.aa-tab[aria-expanded="true"] { visibility: hidden; }


/* ----- The overlay: invisible click-catcher.
   Transparent (rather than dim) so the colour change is visible against the
   real page content. Click anywhere outside the panel to close. ----- */
.aa-panel-overlay {
  position: fixed; inset: 0;
  background: transparent;
  display: none;
  z-index: 60;
}
.aa-panel-overlay[aria-hidden="false"] { display: block; }


/* ----- The panel: small floating box on the left, near the tab ----- */
.aa-panel {
  position: fixed;
  top: 50%;
  left: 60px;                          /* clear of the tab (~36px wide + breathing room) */
  transform: translate(-12px, -50%) scale(0.96);
  width: 360px;
  max-width: calc(100vw - 80px);

  background: var(--surface-card);
  color: var(--text-card);
  border: 1px solid var(--border-medium);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,0.25);

  z-index: 65;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease-out, transform 180ms ease-out;
}
.aa-panel[aria-hidden="false"] {
  transform: translate(0, -50%) scale(1);
  opacity: 1;
  pointer-events: auto;
}
@media (prefers-reduced-motion: reduce) {
  .aa-panel { transition: none; }
}

.aa-panel-body {
  padding: 18px 20px 16px;
}
.aa-panel-row-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-card);
  margin-bottom: 10px;
}


/* ----- Colour swatches: 8 background options, laid out 4-per-row over
   two rows. Each button is a circle painted with its palette's
   surface-base colour. The active swatch gets a thicker accent ring + a
   tick overlay so the selected state is visible to colour-impaired users
   (AT users see it via `aria-pressed="true"`). Four columns keeps each
   swatch comfortably tappable rather than cramming eight into one row. ----- */
.aa-panel-swatches {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.aa-swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  /* Fixed ink-tinted border — the panel surface (--surface-card) is always
     cream/white regardless of the active palette, but `--border-strong`
     resolves to paper-tinted-transparent on dark themes, which disappears
     against a cream panel. Pinning the border to ink-tint guarantees the
     swatch edge is visible on every palette, including the lighter swatches
     (Paper, Pale Yellow, Pale Green) that otherwise blend into the panel. */
  border: 1px solid rgba(26, 24, 20, 0.35);
  background: var(--swatch);
  cursor: pointer;
  position: relative;
  padding: 0;
  transition: transform 160ms ease-out, border-color 160ms ease-out;
}
.aa-swatch:hover {
  transform: scale(1.06);
  border-color: var(--accent-primary);
}
.aa-swatch:focus-visible {
  outline: 3px solid var(--accent-primary);
  outline-offset: 2px;
}
.aa-swatch[aria-pressed="true"] {
  border-width: 3px;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--surface-card) inset;
}
.aa-swatch[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 22 22'%3E%3Cpath d='M5 11 L9 15 L17 7' stroke='%231A1814' stroke-width='3' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 60% 60%;
}
@media (prefers-reduced-motion: reduce) {
  .aa-swatch { transition: none; }
  .aa-swatch:hover { transform: none; }
}


/* ----- Footer: deep brand-blue strip with Reset + Close, matching
   the trigger tab so the panel reads as part of the same control.
   Blue (not orange) keeps the accessibility control distinct from the
   `--ember` Nominate CTA. AA: white text on #0E5A75 = 6.6:1. */
.aa-panel-footer {
  background: #0E5A75;
  color: var(--always-light);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.aa-panel-reset,
.aa-panel-close {
  background: transparent;
  border: 1px solid currentColor;
  color: inherit;
  border-radius: 6px;
  padding: 6px 12px;
  font-family: var(--font-stack);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.aa-panel-reset:hover,
.aa-panel-close:hover {
  background: var(--always-light);
  color: #0E5A75;
}
.aa-panel-reset:focus-visible,
.aa-panel-close:focus-visible {
  outline: 3px solid var(--always-light);
  outline-offset: 2px;
}


/* ================================================================
   Mobile (≤ 599px): swap left-edge tab for a round bottom-right FAB
   and let the panel float centred near the bottom — but still as a
   floating card, not a full-width drawer (the panel is small enough
   that a sheet treatment isn't needed).
   ================================================================ */
@media (max-width: 599px) {
  .aa-tab {
    top: auto;
    bottom: 20px;
    left: auto;
    right: 20px;
    transform: none;
    writing-mode: horizontal-tb;
    border-radius: 50%;
    width: 56px;
    height: 56px;
    padding: 0;
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
    justify-content: center;
  }
  .aa-tab .aa-tab-icon {
    margin: 0;
    transform: none;
  }
  .aa-tab .aa-tab-label {
    /* Visually hidden but kept for screen readers */
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
  }

  .aa-panel {
    top: auto;
    bottom: 90px;                       /* sit above the FAB */
    left: 50%;
    transform: translate(-50%, 8px) scale(0.96);
    max-width: calc(100vw - 32px);
  }
  .aa-panel[aria-hidden="false"] {
    transform: translate(-50%, 0) scale(1);
  }
}


/* ----- Tablet (600 – 899px): keep the tab on the left edge but
   drop the rotated label, leaving just the icon. Saves edge real
   estate while preserving the discoverable accent colour. ----- */
@media (min-width: 600px) and (max-width: 899px) {
  .aa-tab {
    writing-mode: horizontal-tb;
    transform: translateY(-50%);
    padding: 12px;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
  }
  .aa-tab .aa-tab-icon {
    transform: none;
    margin: 0;
  }
  .aa-tab .aa-tab-label {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
  }
}
