/*!
 * Accessibility Widget — frontend styles
 * Applied via classes on <html>. The widget's own UI lives under .aw-root.
 */

@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/AtkinsonHyperlegible-Regular.ttf') format('truetype');
}
@font-face {
  font-family: 'Atkinson Hyperlegible';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/AtkinsonHyperlegible-Bold.ttf') format('truetype');
}

/* ---------- 1. Widget chrome (button + panel) ---------- */

.aw-root,
.aw-root * {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.aw-root {
  --aw-color: #1a73e8;
  --aw-color-dark: #1557b0;
  --aw-color-soft: rgba(26, 115, 232, 0.08);
  --aw-color-ring: rgba(26, 115, 232, 0.22);
  --aw-color-contrast: #ffffff;

  --aw-bg: #ffffff;
  --aw-bg-soft: #f7f8fa;
  --aw-text: #0b1220;
  --aw-text-soft: #475467;
  --aw-muted: #6b7588;
  --aw-border: #e6e8ef;
  --aw-border-strong: #d2d6e0;
  --aw-hover: #f1f3f8;
  --aw-focus: #0b3d91;             /* high-contrast focus (≥3:1 on white) */

  --aw-radius-lg: 18px;
  --aw-radius: 14px;
  --aw-radius-sm: 10px;

  --aw-shadow-lg: 0 24px 60px -16px rgba(15, 23, 42, 0.28), 0 6px 18px rgba(15, 23, 42, 0.06);
  --aw-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.03);

  --aw-z: 2147483000;

  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--aw-text);
}

/* Visually-hidden helper (for the aria-live region). */
.aw-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* ---- Trigger button ---- */
.aw-trigger {
  position: fixed;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--aw-color);
  color: var(--aw-color-contrast);
  border: 0;
  cursor: pointer;
  box-shadow: 0 12px 30px -8px rgba(26, 115, 232, 0.55), 0 4px 10px rgba(15, 23, 42, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--aw-z);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.aw-trigger::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35);
  pointer-events: none;
}
.aw-trigger:hover {
  transform: translateY(-2px);
  background: var(--aw-color-dark);
  box-shadow: 0 16px 36px -8px rgba(26, 115, 232, 0.6), 0 6px 14px rgba(15, 23, 42, 0.14);
}
.aw-trigger:focus-visible {
  outline: 3px solid var(--aw-focus);
  outline-offset: 3px;
}
.aw-trigger svg { width: 28px; height: 28px; }

.aw-pos-bottom-right { bottom: 24px; right: 24px; }
.aw-pos-bottom-left  { bottom: 24px; left: 24px; }
.aw-pos-top-right    { top: 24px; right: 24px; }
.aw-pos-top-left     { top: 24px; left: 24px; }

/* ---- Panel ---- */
.aw-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh;
  width: 420px;
  max-width: 100vw;
  background: var(--aw-bg);
  box-shadow: var(--aw-shadow-lg);
  z-index: var(--aw-z);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
}
.aw-panel.aw-left {
  right: auto;
  left: 0;
  transform: translateX(-100%);
}
.aw-panel.aw-open { transform: translateX(0); }

/* ---- Header ---- */
.aw-header {
  position: relative;
  background: var(--aw-bg);
  color: var(--aw-text);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--aw-border);
}
.aw-header-icon {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: var(--aw-color);
  color: #fff;
  border-radius: 9px;
  flex-shrink: 0;
}
.aw-header-icon svg { width: 20px; height: 20px; }
.aw-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--aw-text);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aw-icon-btn {
  background: transparent;
  color: var(--aw-text-soft);
  border: 1px solid var(--aw-border);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.aw-icon-btn:hover {
  background: var(--aw-hover);
  color: var(--aw-text);
  border-color: var(--aw-border-strong);
}
.aw-icon-btn:focus-visible {
  outline: 3px solid var(--aw-focus);
  outline-offset: 2px;
}
.aw-icon-btn svg { width: 16px; height: 16px; }

.aw-reset {
  background: transparent;
  border: 1px solid var(--aw-border);
  color: var(--aw-text-soft);
  border-radius: 9px;
  padding: 6px 10px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  height: 32px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.aw-reset:hover {
  background: var(--aw-hover);
  color: var(--aw-text);
  border-color: var(--aw-border-strong);
}
.aw-reset:focus-visible {
  outline: 3px solid var(--aw-focus);
  outline-offset: 2px;
}

/* ---- Body ---- */
.aw-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: var(--aw-bg);
  scrollbar-gutter: stable;
}

/* Custom scrollbar (WebKit) so it doesn't look like a server dashboard */
.aw-body::-webkit-scrollbar { width: 10px; }
.aw-body::-webkit-scrollbar-track { background: transparent; }
.aw-body::-webkit-scrollbar-thumb {
  background: var(--aw-border-strong);
  border-radius: 10px;
  border: 2px solid var(--aw-bg);
}
.aw-body::-webkit-scrollbar-thumb:hover { background: var(--aw-muted); }

.aw-section { margin-bottom: 22px; }
.aw-section:last-child { margin-bottom: 8px; }
.aw-section h3 {
  font-size: 13px;
  text-transform: none;
  letter-spacing: -0.005em;
  color: var(--aw-text);
  margin: 0 0 12px;
  font-weight: 700;
}

.aw-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

/* ---- Tile ---- */
.aw-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  background: var(--aw-bg);
  border: 1px solid var(--aw-border);
  border-radius: var(--aw-radius);
  cursor: pointer;
  font: inherit;
  color: var(--aw-text);
  text-align: left;
  min-height: 56px;
  box-shadow: var(--aw-shadow-sm);
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease, color 0.12s ease;
}
.aw-tile:hover {
  background: var(--aw-hover);
  border-color: var(--aw-border-strong);
}
.aw-tile:active { transform: scale(0.985); }
.aw-tile:focus-visible {
  outline: 3px solid var(--aw-focus);
  outline-offset: 2px;
}
.aw-tile.aw-on {
  background: var(--aw-color);
  border-color: var(--aw-color);
  color: var(--aw-color-contrast);
  box-shadow: 0 6px 16px -6px var(--aw-color-ring), 0 0 0 4px var(--aw-color-soft);
}
.aw-tile.aw-on:hover {
  background: var(--aw-color-dark);
  border-color: var(--aw-color-dark);
}
.aw-tile-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--aw-bg-soft);
  border-radius: 10px;
  color: var(--aw-text);
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease;
}
.aw-tile-icon svg { width: 20px; height: 20px; }
.aw-tile.aw-on .aw-tile-icon {
  background: rgba(255, 255, 255, 0.2);
  color: var(--aw-color-contrast);
}
.aw-tile-label {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.005em;
  flex: 1;
  min-width: 0;
}
/* Active-state checkmark badge — visual indicator beyond color. */
.aw-tile-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--aw-color);
  display: none;
  align-items: center;
  justify-content: center;
}
.aw-tile-check svg { width: 12px; height: 12px; }
.aw-tile.aw-on .aw-tile-check { display: inline-flex; }

/* ---- Steppers ---- */
.aw-steppers {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}
.aw-stepper {
  display: flex;
  align-items: center;
  border: 1px solid var(--aw-border);
  border-radius: var(--aw-radius);
  overflow: hidden;
  background: var(--aw-bg);
  box-shadow: var(--aw-shadow-sm);
}
.aw-stepper-btn {
  flex: 0 0 48px;
  height: 48px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: var(--aw-text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.aw-stepper-btn:hover { background: var(--aw-hover); color: var(--aw-color-dark); }
.aw-stepper-btn:focus-visible {
  outline: 3px solid var(--aw-focus);
  outline-offset: -3px;
}
.aw-stepper-btn svg { width: 18px; height: 18px; }
.aw-stepper-label {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--aw-text);
  border-left: 1px solid var(--aw-border);
  border-right: 1px solid var(--aw-border);
  padding: 0 8px;
  letter-spacing: -0.005em;
}

/* ---- Footer ---- */
.aw-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--aw-border);
  background: var(--aw-bg-soft);
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--aw-muted);
}
.aw-footer span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--aw-bg);
  border: 1px solid var(--aw-border);
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--aw-text-soft);
}
.aw-footer a { color: var(--aw-color-dark); text-decoration: none; font-weight: 600; }
.aw-footer a:hover { text-decoration: underline; }
.aw-footer a:focus-visible { outline: 2px solid var(--aw-focus); outline-offset: 2px; border-radius: 2px; }

/* ---- Backdrop ---- */
.aw-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: calc(var(--aw-z) - 1);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.aw-backdrop.aw-open { opacity: 1; pointer-events: auto; }

/* ---- Headings popover ---- */
.aw-headings {
  position: fixed;
  top: 80px;
  right: 80px;
  width: 360px;
  max-height: 70vh;
  overflow-y: auto;
  background: var(--aw-bg);
  color: var(--aw-text);
  border: 1px solid var(--aw-border);
  border-radius: var(--aw-radius-lg);
  box-shadow: var(--aw-shadow-lg);
  padding: 20px;
  z-index: var(--aw-z);
}
.aw-headings-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--aw-text);
  letter-spacing: -0.005em;
}
.aw-headings ul { list-style: none; padding: 0; margin: 0; }
.aw-headings li { margin: 2px 0; font-size: 13px; }
.aw-headings a {
  color: var(--aw-text);
  text-decoration: none;
  display: block;
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.12s, color 0.12s;
}
.aw-headings a:hover { background: var(--aw-color-soft); color: var(--aw-color-dark); }
.aw-headings a:focus-visible { outline: 2px solid var(--aw-focus); outline-offset: 1px; }
.aw-headings-close {
  position: absolute; top: 12px; right: 12px;
}

/* ---- Skip link ---- */
.aw-skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: #000;
  color: #fff;
  padding: 10px 14px;
  z-index: var(--aw-z);
  text-decoration: none;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}
.aw-skip-link:focus {
  left: 8px;
  top: 8px;
  border-radius: 8px;
}

/* ---- Reading guide & mask overlays ---- */
.aw-reading-guide {
  position: fixed;
  left: 0;
  right: 0;
  height: 40px;
  pointer-events: none;
  border-top: 2px solid var(--aw-color);
  border-bottom: 2px solid var(--aw-color);
  z-index: calc(var(--aw-z) - 2);
  background: transparent;
}
.aw-reading-mask-top,
.aw-reading-mask-bottom {
  position: fixed;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: calc(var(--aw-z) - 2);
}

/* Lock background scroll while modal is open */
html.aw-panel-open,
html.aw-panel-open body { overflow: hidden !important; }

/* ---- Mobile: bottom sheet ---- */
@media (max-width: 600px) {
  .aw-panel {
    width: 100vw;
    height: 92vh;
    height: 92dvh;
    max-height: 92vh;
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
  }
  .aw-panel.aw-left { transform: translateY(100%); }
  .aw-panel.aw-open,
  .aw-panel.aw-left.aw-open { transform: translateY(0); }
  /* Drag-handle affordance */
  .aw-panel::before {
    content: '';
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    border-radius: 2px;
    background: var(--aw-border-strong);
    z-index: 1;
  }
  .aw-header { padding-top: 22px; }
  .aw-trigger { width: 52px; height: 52px; }
  .aw-trigger svg { width: 26px; height: 26px; }
  .aw-pos-bottom-right { bottom: 16px; right: 16px; }
  .aw-pos-bottom-left  { bottom: 16px; left: 16px; }
}

/* Reduced motion: respect user preference */
@media (prefers-reduced-motion: reduce) {
  .aw-trigger,
  .aw-panel,
  .aw-backdrop,
  .aw-tile,
  .aw-tile-icon,
  .aw-stepper-btn,
  .aw-icon-btn,
  .aw-reset { transition: none !important; }
}

/* ---------- 2. Page-level transformations (applied to <html>) ---------- */

html.aw-font-scale {
  font-size: calc(16px * var(--aw-font-scale, 1)) !important;
}

html.aw-line-height * {
  line-height: var(--aw-line-height, 1.5) !important;
}

html.aw-letter-spacing * {
  letter-spacing: var(--aw-letter-spacing, 0) !important;
}

html.aw-align-left   *:not(.aw-root):not(.aw-root *) { text-align: left   !important; }
html.aw-align-center *:not(.aw-root):not(.aw-root *) { text-align: center !important; }
html.aw-align-right  *:not(.aw-root):not(.aw-root *) { text-align: right  !important; }

html.aw-readable-font *:not(.aw-root):not(.aw-root *) {
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, sans-serif !important;
}
html.aw-dyslexia-font *:not(.aw-root):not(.aw-root *) {
  font-family: "OpenDyslexic", "Comic Sans MS", system-ui, sans-serif !important;
}

html.aw-highlight-links a:not(.aw-root a) {
  text-decoration: underline !important;
  outline: 2px solid #ffbf47 !important;
  outline-offset: 2px !important;
  background: #fff8c4 !important;
  color: #0b3d91 !important;
}
html.aw-highlight-titles :is(h1, h2, h3, h4, h5, h6):not(.aw-root *) {
  outline: 2px dashed #1a73e8 !important;
  outline-offset: 4px !important;
}

html.aw-hide-images img:not(.aw-root img),
html.aw-hide-images picture:not(.aw-root picture),
html.aw-hide-images svg:not(.aw-root svg):not(.aw-skip-svg),
html.aw-hide-images video:not(.aw-root video) {
  visibility: hidden !important;
}
html.aw-hide-images *:not(.aw-root):not(.aw-root *) {
  background-image: none !important;
}

html.aw-stop-animations *:not(.aw-root):not(.aw-root *),
html.aw-stop-animations *::before,
html.aw-stop-animations *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

html.aw-big-cursor,
html.aw-big-cursor *:not(.aw-root):not(.aw-root *) {
  cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'><polygon points='6,2 6,38 16,30 22,44 28,42 22,28 36,28' fill='black' stroke='white' stroke-width='2'/></svg>") 4 4, auto !important;
}

html.aw-highlight-hover *:not(.aw-root):not(.aw-root *):hover {
  outline: 2px solid #1a73e8 !important;
  outline-offset: 2px !important;
}
html.aw-highlight-focus *:not(.aw-root):not(.aw-root *):focus {
  outline: 3px solid #0b3d91 !important;
  outline-offset: 2px !important;
}

/* Color modes */
html.aw-contrast-dark,
html.aw-contrast-dark body:not(.aw-root):not(.aw-root *) {
  background: #000 !important;
  color: #fff !important;
}
html.aw-contrast-dark *:not(.aw-root):not(.aw-root *) {
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
}
html.aw-contrast-dark a:not(.aw-root a) { color: #ffd84d !important; }

html.aw-contrast-light,
html.aw-contrast-light body:not(.aw-root):not(.aw-root *) {
  background: #fff !important;
  color: #000 !important;
}
html.aw-contrast-light *:not(.aw-root):not(.aw-root *) {
  background-color: #fff !important;
  color: #000 !important;
  border-color: #000 !important;
}
html.aw-contrast-light a:not(.aw-root a) { color: #0b3d91 !important; }

html.aw-contrast-high { filter: contrast(1.5) !important; }

html.aw-monochrome { filter: grayscale(1) !important; }
html.aw-saturation-high { filter: saturate(2) !important; }
html.aw-saturation-low  { filter: saturate(0.5) !important; }
html.aw-monochrome.aw-saturation-high,
html.aw-monochrome.aw-saturation-low { filter: grayscale(1) !important; }

/* Read mode strips chrome to prose */
html.aw-read-mode body:not(.aw-root):not(.aw-root *) {
  background: #fafaf7 !important;
  font-size: 18px !important;
}
html.aw-read-mode main,
html.aw-read-mode [role="main"],
html.aw-read-mode #main,
html.aw-read-mode article {
  max-width: 720px !important;
  margin: 40px auto !important;
  padding: 0 20px !important;
  line-height: 1.7 !important;
}

/* Issue highlights */
html.aw-show-issues [data-aw-issue] {
  position: relative;
}

/* Make sure the widget itself is never affected by page filters */
.aw-root { filter: none !important; }
.aw-root [data-aw-issue] { outline: none !important; }
