/* SAT Header Accessibility Toggle - v1.4.0 */
:root{
  --sat-a11y-z: 99999;
  --sat-a11y-radius: 14px;
  --sat-a11y-shadow: 0 10px 30px rgba(0,0,0,.18);
  --sat-a11y-bg: #ffffff;
  --sat-a11y-text: #111827;
  --sat-a11y-muted: #6b7280;
  --sat-a11y-border: rgba(0,0,0,.12);
  --sat-a11y-accent: #c41e3a; /* your red */
  --sat-a11y-accent2: #7f1d1d;

  /* readability tweaks */
  --sat-a11y-letter-spacing: 0.10em; /* requested */
  --sat-a11y-ruler-height: 54px;

}

/* ===== deterministic, non-compounding text scaling =====
   The JS stores one immutable native baseline on each real text owner.
   A-/A+ only changes plugin-owned rendered values calculated from that baseline.
   Existing elements are never re-measured while scaling is active. */
html.sat-a11y--text-scale {
  font-size: var(--sat-a11y-render-root-font-size) !important;
}

/*
 * Homepage/theme styles contain many highly-specific font-size rules with
 * !important.  A normal utility selector can therefore lose the cascade even
 * when it also uses !important.  The harmless :not(#...) specificity boosters
 * below give the accessibility rule three ID levels of specificity without
 * requiring IDs on page elements.  This keeps the class-based rendering model
 * (so native measurement remains non-compounding) while reliably overriding
 * fixed px/rem/em sizes in cards, menus, buttons, forms and widgets.
 */
html.sat-a11y--text-scale
  .sat-a11y-text-target:not(#sat-a11y-font-boost-1):not(#sat-a11y-font-boost-2):not(#sat-a11y-font-boost-3) {
  font-size: var(--sat-a11y-render-font-size) !important;
}

html.sat-a11y--text-scale
  .sat-a11y-text-target.sat-a11y-line-target:not(#sat-a11y-line-boost-1):not(#sat-a11y-line-boost-2):not(#sat-a11y-line-boost-3) {
  line-height: var(--sat-a11y-render-line-height) !important;
}

/* ===== non-font accessibility features =====
   These rules intentionally use a few harmless :not(#...) specificity boosters.
   The USTARCH theme contains many deeply nested !important declarations, so
   low-specificity accessibility utilities can otherwise appear to do nothing. */

/* ----- Increased letter spacing ----- */
html.sat-a11y--spacing:not(#sat-spacing-boost-1):not(#sat-spacing-boost-2):not(#sat-spacing-boost-3) body {
  letter-spacing: var(--sat-a11y-letter-spacing) !important;
}

html.sat-a11y--spacing:not(#sat-spacing-boost-1):not(#sat-spacing-boost-2):not(#sat-spacing-boost-3) body :where(
  p, li, dt, dd, blockquote, a, span, em, strong, small,
  h1, h2, h3, h4, h5, h6, label, legend,
  button, input, textarea, select, option, optgroup,
  th, td, caption, figcaption, summary, time, code, pre,
  [role="button"], [role="menuitem"], [role="tab"], [role="option"]
) {
  letter-spacing: var(--sat-a11y-letter-spacing) !important;
}

/* Keep the accessibility toolbar itself compact and predictable. */
html.sat-a11y--spacing [data-sat-a11y],
html.sat-a11y--spacing [data-sat-a11y] * {
  letter-spacing: normal !important;
}
html.sat-a11y--spacing [data-sat-a11y] .sat-a11y__letter,
html.sat-a11y--spacing [data-sat-a11y] .sat-a11y__title {
  letter-spacing: .02em !important;
}

/* ----- Reading ruler ----- */
.sat-a11y-ruler {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  width: 100vw !important;
  height: var(--sat-a11y-ruler-height) !important;
  margin: 0 !important;
  padding: 0 !important;
  background: rgba(255, 235, 59, .28) !important;
  border-top: 2px solid rgba(196, 30, 58, .65) !important;
  border-bottom: 2px solid rgba(196, 30, 58, .65) !important;
  box-shadow: 0 5px 18px rgba(0,0,0,.18) !important;
  pointer-events: none !important;
  z-index: 2147483647 !important;
  transform: translate3d(0,-200px,0);
  display: none;
}

/* ----- Grayscale / invert -----
   Apply the page filter on the root element rather than on body. This keeps
   fixed-position UI/ruler geometry stable while still filtering the page. */
html.sat-a11y--grayscale:not(.sat-a11y--invert) {
  filter: grayscale(1) !important;
}
html.sat-a11y--invert:not(.sat-a11y--grayscale) {
  filter: invert(1) hue-rotate(180deg) !important;
}
html.sat-a11y--grayscale.sat-a11y--invert {
  filter: grayscale(1) invert(1) hue-rotate(180deg) !important;
}

/* Re-invert visual media so photographs/videos keep their natural polarity. */
html.sat-a11y--invert body :where(img, picture, video, iframe, canvas, svg) {
  filter: invert(1) hue-rotate(180deg) !important;
}

/* ===== toolbar UI ===== */
.sat-a11y{
  position: relative;
  display: inline-block;
  z-index: var(--sat-a11y-z);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  line-height: 1.2;
}

.sat-a11y__btnInline{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 1);
  background: var(--sat-a11y-accent);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,.12);
}
.sat-a11y__btnInline:hover{ filter: brightness(1.05); }
.sat-a11y__btnInline:focus-visible{
  outline: 3px solid rgba(196, 30, 58, .25);
  outline-offset: 2px;
}
.sat-a11y__letter{
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: .02em;
  transform: translateY(-.5px);
}

.sat-a11y__panel{
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(340px, calc(100vw - 24px));
  background: var(--sat-a11y-bg);
  color: var(--sat-a11y-text);
  border: 1px solid var(--sat-a11y-border);
  border-radius: var(--sat-a11y-radius);
  box-shadow: var(--sat-a11y-shadow);
  overflow: hidden;
}

.sat-a11y__header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--sat-a11y-accent), var(--sat-a11y-accent2));
  color: #fff;
}
.sat-a11y__title{ font-size: 13px; font-weight: 800; letter-spacing: .02em; }
.sat-a11y__close{
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
}
.sat-a11y__close:focus-visible{
  outline: 3px solid rgba(255,255,255,.45);
  outline-offset: 2px;
}

.sat-a11y__body{ padding: 12px; }
.sat-a11y__group + .sat-a11y__group{ margin-top: 12px; }
.sat-a11y__label{
  font-size: 12px;
  font-weight: 800;
  color: var(--sat-a11y-muted);
  margin-bottom: 8px;
}
.sat-a11y__row{ display: flex; gap: 8px; }

.sat-a11y__pill{
  appearance: none;
  border: 1px solid var(--sat-a11y-border);
  background: #fff;
  color: var(--sat-a11y-text);
  border-radius: 12px;
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  flex: 1;
}
.sat-a11y__pill:hover{ border-color: rgba(196, 30, 58, .35); }
.sat-a11y__pill:disabled{
  opacity: .45;
  cursor: not-allowed;
  filter: none;
}
.sat-a11y__pill:focus-visible{
  outline: 3px solid rgba(196, 30, 58, .22);
  outline-offset: 2px;
}
.sat-a11y__pill--ghost{
  background: #fff;
  color: var(--sat-a11y-accent);
  border-color: rgba(196, 30, 58, .25);
  width: 100%;
}

.sat-a11y__toggles{ display: grid; gap: 10px; }
.sat-a11y__toggle{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--sat-a11y-border);
  border-radius: 12px;
  background: #fff;
}
.sat-a11y__toggle--warn{ border-left: 3px solid rgba(196, 30, 58, .45); }
.sat-a11y__toggle input{ width: 18px; height: 18px; }
.sat-a11y__toggle span{ font-size: 14px; font-weight: 650; }

.sat-a11y__hint{
  margin-top: -4px;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--sat-a11y-muted);
}


/* ===== Read aloud controls ===== */
.sat-a11y__reader-row{
  gap: 6px;
}
.sat-a11y__reader-row .sat-a11y__pill{
  min-width: 0;
  padding-left: 7px;
  padding-right: 7px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.sat-a11y__reader-icon{
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  display: block;
}
.sat-a11y__reader-auto-row{
  margin-top: 7px;
}
.sat-a11y__reader-auto[aria-pressed="true"]{
  border-color: rgba(196, 30, 58, .55);
  background: rgba(196, 30, 58, .09);
  color: var(--sat-a11y-accent2);
  box-shadow: inset 0 0 0 1px rgba(196, 30, 58, .08);
}
.sat-a11y__reader-setting{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  color: var(--sat-a11y-muted);
  font-size: 12px;
  font-weight: 800;
}
.sat-a11y__reader-settings-row{
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.sat-a11y__reader-settings-row .sat-a11y__reader-setting{
  margin-top: 0;
  gap: 6px;
  min-width: 0;
}
.sat-a11y__reader-setting--compact .sat-a11y__reader-select{
  width: 78px;
  min-width: 72px;
  max-width: 78px;
}
.sat-a11y__reader-select{
  appearance: auto;
  width: 190px;
  max-width: 62%;
  min-width: 88px;
  border: 1px solid var(--sat-a11y-border);
  border-radius: 9px;
  background: #fff;
  color: var(--sat-a11y-text);
  padding: 6px 8px;
  font: inherit;
  line-height: 1.2;
}
.sat-a11y__reader-rate{
  width: 110px;
}
.sat-a11y__reader-select:focus-visible{
  outline: 3px solid rgba(196, 30, 58, .22);
  outline-offset: 2px;
}
.sat-a11y__reader-status{
  min-height: 1.3em;
  margin-top: 7px;
  color: var(--sat-a11y-muted);
  font-size: 11px;
  line-height: 1.3;
}

.sat-a11y__footer{ margin-top: 12px; }

.sat-a11y__sr{
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
