/* Accessibility toolbar (src/a11y.mjs + src/main.js), shared by every theme.
   Part 1: the button and panel. Part 2: what each setting does to the page (classes on <html>). */

/* ---------- 1. Button + panel ---------- */
.a11y-fab {
  position: fixed; left: 18px; bottom: var(--a11y-bottom, 18px); z-index: 95;
  display: grid; place-items: center; width: 58px; height: 58px; padding: 0;
  border: 3px solid #fffdf8; border-radius: 50%; background: #2a2c2b; color: #f0cf7e;
  box-shadow: 0 16px 32px -14px rgb(42 44 43 / .7), 0 0 0 1px rgb(42 44 43 / .12);
  cursor: pointer; transition: transform .25s cubic-bezier(.2, .7, .2, 1), background-color .2s, color .2s;
}
.a11y-fab svg { width: 34px; height: 34px; }
.a11y-fab:hover { transform: scale(1.07); }
.a11y-fab:focus-visible { outline: 3px solid #d9ad4e; outline-offset: 3px; }
.a11y-fab[aria-expanded="true"] { background: #d9ad4e; color: #2a2c2b; transform: none; }
/* gold dot = at least one setting is on */
.a11y-fab.is-active::after { content: ""; position: absolute; top: -2px; right: -2px; width: 16px; height: 16px; border-radius: 50%; background: #d9ad4e; border: 3px solid #fffdf8; }
.a11y-fab[aria-expanded="true"].is-active::after { background: #2a2c2b; }
.a11y-tip {
  position: absolute; left: calc(100% + 12px); top: 50%; translate: -6px -50%;
  padding: 7px 14px; border-radius: 999px; background: #2a2c2b; color: #fffdf8;
  font-size: 14px; font-weight: 600; line-height: 1.2; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: opacity .2s, translate .25s cubic-bezier(.2, .7, .2, 1);
}
.a11y-fab:hover .a11y-tip, .a11y-fab:focus-visible .a11y-tip { opacity: 1; translate: 0 -50%; }
.a11y-fab[aria-expanded="true"] .a11y-tip { opacity: 0; }

.a11y-panel {
  position: fixed; left: 18px; bottom: calc(var(--a11y-bottom, 18px) + 72px); z-index: 96;
  width: min(392px, calc(100vw - 36px)); max-height: calc(100dvh - var(--a11y-bottom, 18px) - 96px); overflow: auto;
  padding: 20px 20px 18px; border: 1px solid #e6e0d4; border-radius: 26px;
  background: #fffdf8; color: #2a2c2b; font-size: 15px; line-height: 1.45; text-align: left;
  box-shadow: 0 34px 80px -30px rgb(42 44 43 / .6);
  transform-origin: 0 100%; animation: a11y-in .3s cubic-bezier(.2, .7, .2, 1);
}
.a11y-panel[hidden] { display: none; }
@keyframes a11y-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.a11y-panel button { font: inherit; color: inherit; cursor: pointer; }
.a11y-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.a11y-panel .a11y-title { margin: 0; font-family: var(--serif, Georgia, serif); font-style: italic; font-weight: 500; font-size: 27px; line-height: 1.1; letter-spacing: -.01em; color: #2a2c2b; }
.a11y-close { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid #d6cec0; border-radius: 50%; background: transparent; }
.a11y-close svg { width: 22px; height: 22px; }
.a11y-close:hover { background: #2a2c2b; border-color: #2a2c2b; color: #fffdf8; }
.a11y-intro { margin: 6px 0 16px; color: #4a4d4b; font-size: 14.5px; }
.a11y-label { margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #4a4d4b; }
.a11y-seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 18px; background: #ebe5d9; }
.a11y-seg button { display: grid; justify-items: center; align-content: center; gap: 2px; min-height: 66px; padding: 6px 4px; border: 0; border-radius: 14px; background: transparent; }
.a11y-seg b { font-family: var(--serif, Georgia, serif); font-weight: 500; line-height: 1; }
.a11y-seg span { font-size: 13px; font-weight: 600; }
.a11y-seg button:hover { background: #fffdf8; }
.a11y-seg button[aria-pressed="true"] { background: #2a2c2b; color: #fffdf8; box-shadow: 0 8px 18px -10px rgb(42 44 43 / .7); }
.a11y-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.a11y-opt {
  position: relative; display: grid; justify-items: start; align-content: start; gap: 8px;
  min-height: 92px; padding: 14px 14px 12px; border: 1.5px solid #e6e0d4; border-radius: 18px; background: #fffdf8;
  text-align: left; font-weight: 600; font-size: 14.5px; line-height: 1.25;
  transition: border-color .2s, background-color .2s;
}
.a11y-opt svg { width: 28px; height: 28px; }
.a11y-opt:hover { border-color: #2a2c2b; }
.a11y-opt[aria-pressed="true"] { border-color: #2a2c2b; background: #f4e8c9; }
.a11y-state { position: absolute; top: 12px; right: 12px; min-width: 38px; padding: 2px 8px; border-radius: 999px; background: #ebe5d9; color: #4a4d4b; font-size: 12px; font-weight: 600; font-style: normal; line-height: 1.5; text-align: center; }
.a11y-state::after { content: "Off"; }
.a11y-opt[aria-pressed="true"] .a11y-state { background: #2a2c2b; color: #fffdf8; }
.a11y-opt[aria-pressed="true"] .a11y-state::after { content: "On"; }
.a11y-grid .a11y-opt:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 0; grid-template-columns: auto 1fr; align-items: center; }
.a11y-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid #e6e0d4; }
.a11y-reset { min-height: 44px; padding: 0 20px; border: 1px solid #d6cec0; border-radius: 999px; background: transparent; font-weight: 600 !important; font-size: 14px !important; }
.a11y-reset:hover { background: #2a2c2b; border-color: #2a2c2b; color: #fffdf8; }
.a11y-foot a { color: #2a2c2b; font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.a11y-panel :focus-visible { outline: 3px solid #d9ad4e; outline-offset: 2px; }
body.nav-open .a11y-fab, body.nav-open .a11y-panel { display: none; }
@media (max-width: 640px) {
  .a11y-fab { left: 14px; width: 54px; height: 54px; }
  .a11y-fab svg { width: 31px; height: 31px; }
  .a11y-tip { display: none; }
  .a11y-panel { left: 10px; right: 10px; width: auto; bottom: calc(var(--a11y-bottom, 18px) + 64px); padding: 18px 16px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .a11y-fab, .a11y-tip, .a11y-opt { transition: none; }
  .a11y-panel { animation: none; }
}
@media print { .a11y-fab, .a11y-panel { display: none !important; } }

/* ---------- 2. The settings ---------- */

/* Text size: scales the page content (works with the px-based type in every theme); the toolbar itself stays put */
html.a11y-text-1 :is(#main, .site-footer, .notice) { zoom: 1.15; }
html.a11y-text-2 :is(#main, .site-footer, .notice) { zoom: 1.3; }
/* the desktop menu bar has no room to grow; once it collapses into the menu button it scales too */
@media (max-width: 1099px) {
  html.a11y-text-1 .site-header { zoom: 1.15; }
  html.a11y-text-2 .site-header { zoom: 1.3; }
}
/* phones start with less room, so smaller steps */
@media (max-width: 640px) {
  html.a11y-text-1 :is(#main, .site-footer, .notice, .site-header) { zoom: 1.1; }
  html.a11y-text-2 :is(#main, .site-footer, .notice, .site-header) { zoom: 1.2; }
}
/* long button labels may wrap instead of running off the screen */
html:is(.a11y-text-1, .a11y-text-2) :is(#main, .site-footer) .btn { white-space: normal; max-width: 100%; padding-block: 8px; text-align: center; }
/* long web addresses in text may break onto the next line */
html:is(.a11y-text-1, .a11y-text-2) :is(#main, .site-footer) :is(p, li, dd, td) { overflow-wrap: anywhere; }

/* High contrast: darker text and borders, plain backgrounds (variables from both themes) */
html.a11y-contrast {
  --ink: #111; --ink-2: #111; --muted: #1f1f1f; --line: #8c857a; --line-2: #5f5a52;
  --amber: #6b4510; --amber-ink: #563708; --gold-ink: #5e4300;
  --bg: #fff; --paper: #fff; --soft: #f3f1ec; --grain: none;
}
html.a11y-contrast body { background-image: none; }
html.a11y-contrast :is(#main, .site-footer) :is(img, picture) { filter: contrast(1.08); }

/* Underline links */
html.a11y-links a:not(.btn, .skip-link, .a11y-panel a), html.a11y-links .linkish {
  text-decoration-line: underline !important; text-decoration-thickness: 2px !important;
  text-underline-offset: 3px !important; text-decoration-color: currentColor !important;
}
html.a11y-links .btn { outline: 2px solid currentColor; outline-offset: 2px; }

/* Easy-read font: Atkinson Hyperlegible (made by the Braille Institute for low-vision readers), no italics */
html.a11y-font body, html.a11y-font body * { font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif !important; }
html.a11y-font :is(em, i, cite, h1, h2, h3, h4, .display, blockquote) { font-style: normal !important; }

/* More spacing between lines, letters and words */
html.a11y-spacing :is(#main, .site-footer) :is(p, li, dd, dt, blockquote, figcaption, td):not(.display, .lede-xl) {
  line-height: 1.95 !important; letter-spacing: .03em !important; word-spacing: .14em !important;
}

/* Stop animations: no motion, no fades; scroll-in content shows straight away */
html.a11y-calm { scroll-behavior: auto !important; }
html.a11y-calm *, html.a11y-calm *::before, html.a11y-calm *::after { animation: none !important; transition: none !important; }
html.a11y-calm .reveal { opacity: 1 !important; transform: none !important; }

/* Room under the last footer line so the floating button never covers it */
.site-footer { padding-bottom: 96px; }
