/* Accessibility widget: the round button, the panel it opens, and the modes it switches on.
   Adapted from the widget in Care by Talia (talia-app: AccessibilityWidgetPanel.tsx and its globals.css rules).
   Shared by the deck and the accessibility statement. It reads the page's color tokens (--ground, --ink, ...)
   and falls back to Haley's daylight palette. */

.a11y-trigger, .a11y-wrap, .a11y-wrap * { box-sizing: border-box; }
.a11y-wrap[hidden], .a11y-guide[hidden] { display: none !important; }

/* The button: bottom left, level with the deck's own controls, which keep the middle (Haley's chat is on the right) */
.a11y-trigger {
  position: fixed; z-index: 20; width: 44px; height: 44px; border-radius: 50%;
  left: max(12px, env(safe-area-inset-left, 0px)); bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  display: grid; place-items: center; padding: 0; cursor: pointer;
  background: var(--raised, #ffffff); color: var(--button-bg, #3d4785);
  border: 1.5px solid var(--line-soft, #ede3dc);
  box-shadow: 0 2px 0 rgba(45,41,38,.04), 0 10px 24px rgba(45,41,38,.12);
}
.a11y-trigger svg { width: 26px; height: 26px; }
.a11y-trigger:focus-visible, .a11y-panel button:focus-visible, .a11y-panel a:focus-visible { outline: 3px solid var(--accent, #e8661a); outline-offset: 3px; }
.a11y-count {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--accent, #e8661a); color: #fff; font: 800 11px/20px Rubik, system-ui, sans-serif; text-align: center;
}

/* The panel: a sheet from the bottom on phones, a card in the middle on wide screens */
.a11y-wrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; font-family: Rubik, "Arial Hebrew", system-ui, sans-serif; }
.a11y-scrim { position: absolute; inset: 0; background: rgba(45,41,38,.45); animation: a11y-fade .3s ease both; }
.a11y-panel {
  position: relative; width: 100%; max-width: 480px; max-height: 92%; overflow-y: auto; overscroll-behavior: contain;
  background: var(--ground, #f9f4f2); color: var(--ink, #2d2926); border-radius: 28px 28px 0 0;
  padding: 14px max(20px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  box-shadow: 0 -10px 40px rgba(45,41,38,.2); animation: a11y-up .45s cubic-bezier(.2,.8,.2,1) both; outline: none;
}
.a11y-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.a11y-head h2 { margin: 0; font-size: 21px; font-weight: 800; }
.a11y-close { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--tint, #fcefe4); color: var(--ink, #2d2926); display: grid; place-items: center; cursor: pointer; }
.a11y-close svg { width: 18px; height: 18px; }
.a11y-label { margin: 0 0 8px; font-size: 14px; font-weight: 700; color: var(--ink-soft, #574e48); }
.a11y-sizes { display: flex; gap: 8px; }
.a11y-size, .a11y-opt, .a11y-reset {
  font: 700 14px/1.2 Rubik, "Arial Hebrew", system-ui, sans-serif; color: var(--ink-soft, #574e48); cursor: pointer;
  background: var(--raised, #fff); border: 1.5px solid var(--line-soft, #ede3dc); border-radius: 16px;
}
.a11y-size { flex: 1; min-height: 44px; padding: 6px; }
.a11y-rule { height: 1px; background: var(--line-soft, #ede3dc); margin: 12px 0; }
.a11y-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.a11y-opt { min-height: 58px; padding: 7px 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; }
.a11y-opt svg { width: 24px; height: 24px; flex: none; }
.a11y-opt span { font-size: 13px; font-weight: 700; line-height: 1.2; }
.a11y-size[aria-pressed="true"], .a11y-opt[aria-pressed="true"] { background: var(--accent-soft, #fcefe4); border-color: var(--accent, #e8661a); color: var(--ink, #2d2926); box-shadow: inset 0 0 0 1px var(--accent, #e8661a); }
.a11y-reset { width: 100%; min-height: 44px; margin-top: 8px; }
.a11y-link { display: block; text-align: center; margin: 4px 0 0; padding: 10px; font-size: 15px; font-weight: 700; color: var(--ink, #2d2926); text-underline-offset: 4px; }

@keyframes a11y-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes a11y-fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 340px) {
  .a11y-trigger { width: 40px; height: 40px; left: max(6px, env(safe-area-inset-left, 0px)); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .a11y-trigger svg { width: 23px; height: 23px; }
}
@media (min-width: 640px) {
  .a11y-wrap { align-items: center; }
  .a11y-panel { border-radius: 28px; }
}

/* Reading guide: a band that follows the pointer or the finger */
.a11y-guide { position: fixed; left: 0; right: 0; top: 40%; height: 14px; z-index: 99999; pointer-events: none; background: rgba(61,71,133,.14); border-top: 2px solid rgba(61,71,133,.55); border-bottom: 2px solid rgba(61,71,133,.55); }

/* ---- The modes ---- */

/* Text size: the page's own text is set in px, so the content is scaled as a whole */
html[data-a11y-zoom="1"] { --a11y-zoom: 1.15; }
html[data-a11y-zoom="2"] { --a11y-zoom: 1.3; }
html[data-a11y-zoom] :is(.wrap, .sheet, .doc, .hc-panel) { zoom: var(--a11y-zoom); }

/* High contrast: the page's tokens go to black on white, with a darker orange for text */
html.a11y-high-contrast {
  --ground: #ffffff; --raised: #ffffff; --tint: #ffffff; --line-soft: #000000;
  --ink: #000000; --ink-soft: #000000; --ink-faint: #1a1a1a;
  --accent: #a33800; --accent-ink: #a33800; --accent-soft: #ffffff;
  --button-bg: #000000; --button-ink: #ffffff;
  --pilot-bg: #000000; --pilot-ink: #ffffff; --pilot-soft: #ffffff; --pilot-accent: #ffd400; --pilot-tile: rgba(255,255,255,.16);
  --shadow: none;
}
html.a11y-high-contrast :is(.reasons li, .person, .contact, .says, .fact, .chips span, .a11y-opt, .a11y-size) { outline: 2px solid #000; outline-offset: -2px; }
html.a11y-high-contrast .pilot :is(.fact) { outline-color: #fff; }

/* Colors: grayscale and inversion (pictures keep their own colors when inverted) */
html.a11y-grayscale { filter: grayscale(1); }
html.a11y-invert { filter: invert(1) hue-rotate(180deg); }
html.a11y-invert.a11y-grayscale { filter: invert(1) hue-rotate(180deg) grayscale(1); }
html.a11y-invert :is(img, video, .scene, .sunrise, .garden, .pic, .mini, .badge, .hc-trigger svg, .hc-avatar svg, .hc-inline-art svg) { filter: invert(1) hue-rotate(180deg); }

/* Links: a frame on everything that acts like a link, and a link color on plain text links */
html.a11y-links :is(a, .badge, .join, [data-waitlist]) { outline: 3px solid #0057d9 !important; outline-offset: 2px; }
html.a11y-links a { text-decoration: underline !important; color: #0057d9 !important; }

/* Text: a plainer font, wider spacing, taller lines */
html.a11y-readable body, html.a11y-readable body :is(*, *::before, *::after) { font-family: Arial, "Helvetica Neue", Helvetica, "Arial Hebrew", sans-serif !important; letter-spacing: .02em; }
html.a11y-spacing body :is(*, *::before, *::after):not(svg *) { letter-spacing: .12em !important; word-spacing: .16em !important; }
html.a11y-lineheight body :is(*, *::before, *::after) { line-height: 1.9 !important; }

/* Pointer, motion, pictures, focus */
html.a11y-big-cursor, html.a11y-big-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M4 4l16 36 4-16 16-4z' fill='black' stroke='white' stroke-width='2'/%3E%3C/svg%3E") 4 4, auto !important;
}
html.a11y-no-motion, html.a11y-no-motion .deck { scroll-behavior: auto !important; }
html.a11y-no-motion *, html.a11y-no-motion *::before, html.a11y-no-motion *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
html.a11y-hide-images :is(img, video, [role="img"], .scene, .sunrise, .garden, .pic, .mini, .shot) { visibility: hidden !important; }
html.a11y-focus *:focus { outline: 3px solid #0057d9 !important; outline-offset: 3px !important; box-shadow: 0 0 0 6px rgba(0,87,217,.25) !important; }
