/* ============================================
   Site-wide accessibility (under version badge)
   Trigger + phone-like panel. Loaded on main pages + warning gate.
   ============================================ */

/* Font scale via root — rem-based UI grows with this */
html[data-font-scale="sm"] {
  font-size: 87.5%;
}

html[data-font-scale="md"] {
  font-size: 100%;
}

html[data-font-scale="lg"] {
  font-size: 112.5%;
}

html[data-font-scale="xl"] {
  font-size: 125%;
}

/* Higher contrast — forced black / white / yellow (obvious site-wide) */
html[data-a11y-contrast="1"] body {
  --bg-deep: #000000 !important;
  --bg-moss: #000000 !important;
  --panel: #000000 !important;
  --panel-2: #0a0a0a !important;
  --mud: #222222 !important;
  --bark: #ffffff !important;
  --slime: #ffff00 !important;
  --hot-pink: #ffff00 !important;
  --acid-yellow: #ffff00 !important;
  --cotton-candy: #00ffff !important;
  --fog: #ffffff !important;
  --mist: #ffff00 !important;
  --border-ghost: #ffffff !important;
  --purple-glitch: #ffff00 !important;
  --accent-soft: rgba(255, 255, 0, 0.45) !important;
  --accent-glow: rgba(255, 255, 0, 0.55) !important;
  color: #ffffff !important;
  background-color: #000000 !important;
  background-image: none !important;
}

html[data-a11y-contrast="1"] body::before,
html[data-a11y-contrast="1"] body.theme-clown::before {
  content: none !important;
  display: none !important;
  background: none !important;
  filter: none !important;
}

html[data-a11y-contrast="1"] .site-header,
html[data-a11y-contrast="1"] .site-footer,
html[data-a11y-contrast="1"] .widget,
html[data-a11y-contrast="1"] .box,
html[data-a11y-contrast="1"] .panel,
html[data-a11y-contrast="1"] .site-panel,
html[data-a11y-contrast="1"] .card,
html[data-a11y-contrast="1"] .member-card,
html[data-a11y-contrast="1"] .main,
html[data-a11y-contrast="1"] .speech-bubble,
html[data-a11y-contrast="1"] .motd-strip,
html[data-a11y-contrast="1"] .stepin-widget,
html[data-a11y-contrast="1"] .nav-list a {
  background: #000000 !important;
  background-image: none !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

html[data-a11y-contrast="1"] h1,
html[data-a11y-contrast="1"] h2,
html[data-a11y-contrast="1"] h3,
html[data-a11y-contrast="1"] .logo,
html[data-a11y-contrast="1"] .logo-text,
html[data-a11y-contrast="1"] .widget h2,
html[data-a11y-contrast="1"] .site-footer .footer-note {
  color: #ffffff !important;
}

html[data-a11y-contrast="1"] a {
  color: #ffff00 !important;
  text-decoration: underline !important;
  text-underline-offset: 0.12em;
  text-decoration-thickness: 0.1em;
  font-weight: 700;
}

html[data-a11y-contrast="1"] a:hover,
html[data-a11y-contrast="1"] a:focus-visible,
html[data-a11y-contrast="1"] .nav-list a:hover,
html[data-a11y-contrast="1"] .nav-list a.active {
  color: #ffffff !important;
  background: #000080 !important;
  outline: 2px solid #ffff00;
}

html[data-a11y-contrast="1"] input,
html[data-a11y-contrast="1"] textarea,
html[data-a11y-contrast="1"] select,
html[data-a11y-contrast="1"] button:not(.site-a11y__trigger):not(.site-a11y__close):not(.site-a11y__circle):not(.site-a11y__tile) {
  color: #ffffff !important;
  background: #000000 !important;
  border-color: #ffffff !important;
}

/* Warning gate — black / yellow / white (beats teal Win98 paint) */
html[data-a11y-contrast="1"] body.splash-page.warning-gate {
  color: #ffffff !important;
  background: #000000 !important;
}

html[data-a11y-contrast="1"] .splash-card,
html[data-a11y-contrast="1"] .win98-window,
html[data-a11y-contrast="1"] .win98-body,
html[data-a11y-contrast="1"] .win98-titlebar {
  background: #000000 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
  box-shadow: none !important;
}

html[data-a11y-contrast="1"] .splash-warning {
  color: #000000 !important;
  background: #ffff00 !important;
  outline: 3px solid #ffffff;
  padding: 0.2em 0.4em;
  font-weight: 800;
}

html[data-a11y-contrast="1"] .splash-lead,
html[data-a11y-contrast="1"] .splash-tw,
html[data-a11y-contrast="1"] .splash-brand .logo-text {
  color: #ffffff !important;
  background: #000000 !important;
  border-color: #ffffff !important;
}

html[data-a11y-contrast="1"] .splash-tw {
  border: 2px solid #ffffff !important;
}

html[data-a11y-contrast="1"] body.splash-page.warning-gate a {
  color: #ffff00 !important;
  font-weight: 700;
}

/* Zephyr — same forced palette (vars already flipped on body) */
html[data-a11y-contrast="1"] body.zephyr-page,
html[data-a11y-contrast="1"] body.zephyr-realm {
  color: #ffffff !important;
  background-color: #000000 !important;
  background-image: none !important;
}

/* Always-underline links */
html[data-a11y-underline="1"] a {
  text-decoration: underline !important;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 0.08em;
}

/* --- Shell: trigger under version badge --- */
.site-a11y {
  position: fixed;
  top: calc(max(0.65rem, env(safe-area-inset-top)) + 2.05rem);
  left: max(0.65rem, env(safe-area-inset-left));
  z-index: 61;
  pointer-events: auto;
}

.site-a11y__trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.4rem 0.75rem;
  margin: 0;
  border: 2px solid #1a1220;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffe566, #ffc94a);
  color: #1a1220;
  font-family: var(--font-bubble, "Sniglet", "Comic Sans MS", cursive);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.28);
  cursor: pointer;
  touch-action: manipulation;
  appearance: none;
  -webkit-appearance: none;
}

.site-a11y__trigger:hover {
  filter: brightness(1.05);
}

.site-a11y__trigger:focus-visible {
  outline: 2px solid #ffe566;
  outline-offset: 3px;
}

.site-a11y.is-open .site-a11y__trigger {
  background: linear-gradient(180deg, #b8ff2e, #7ec82e);
}

.site-a11y__icon {
  display: block;
  flex-shrink: 0;
  width: 1.35rem;
  height: 1.35rem;
  object-fit: contain;
  border-radius: 999px;
  background: #fff;
}

.site-a11y__trigger-text {
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* --- Panel (phone-like a11y menu) --- */
.site-a11y__panel {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 0;
  width: min(18.5rem, calc(100vw - 1.3rem));
  padding: 0.75rem 0.8rem 0.9rem;
  border: 3px solid #1a1220;
  border-radius: 1.15rem;
  background: linear-gradient(165deg, #fff8e8 0%, #ffe9b8 45%, #ffd48a 100%);
  color: #1a1220;
  box-shadow: 4px 5px 0 rgba(0, 0, 0, 0.32);
  font-family: var(--font-bubble, "Sniglet", "Comic Sans MS", cursive);
}

.site-a11y__panel[hidden] {
  display: none !important;
}

.site-a11y__panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
}

.site-a11y__panel-title {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
  word-break: break-word;
}

.site-a11y__close {
  width: 2.4rem;
  height: 2.4rem;
  margin: 0;
  padding: 0;
  border: 2px solid #1a1220;
  border-radius: 999px;
  background: #fff;
  color: #1a1220;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  appearance: none;
  -webkit-appearance: none;
}

.site-a11y__close:focus-visible {
  outline: 2px solid #1a1220;
  outline-offset: 2px;
}

.site-a11y__section {
  margin-bottom: 0.75rem;
}

.site-a11y__section-label {
  margin: 0 0 0.45rem;
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.85;
}

.site-a11y__scale {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.45rem;
}

.site-a11y__circle {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  width: 4.25rem;
  min-height: 4.25rem;
  margin: 0;
  padding: 0.35rem 0.25rem;
  border: 3px solid #1a1220;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, #ffe566);
  color: #1a1220;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.22);
}

.site-a11y__circle:hover:not(:disabled) {
  filter: brightness(1.04);
}

.site-a11y__circle:focus-visible {
  outline: 2px solid #1a1220;
  outline-offset: 3px;
}

.site-a11y__circle:disabled {
  opacity: 0.4;
  cursor: default;
}

.site-a11y__circle-glyph {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
}

.site-a11y__circle-caption {
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
}

.site-a11y__scale-meter {
  display: flex;
  flex-flow: row wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem 0.4rem;
  padding: 0.2rem 0;
}

.site-a11y__dot {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 999px;
  border: 2px solid #1a1220;
  background: rgba(255, 255, 255, 0.55);
}

.site-a11y__dot.is-on {
  background: #ff8ec8;
}

.site-a11y__dot.is-current {
  background: #ff2a9a;
  transform: scale(1.2);
}

.site-a11y__scale-name {
  flex-basis: 100%;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.site-a11y__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.site-a11y__tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.35rem 0.25rem 0.45rem;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  appearance: none;
  -webkit-appearance: none;
}

.site-a11y__tile:focus-visible .site-a11y__tile-circle {
  outline: 2px solid #1a1220;
  outline-offset: 3px;
}

.site-a11y__tile-circle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4.5rem;
  height: 4.5rem;
  border: 3px solid #1a1220;
  border-radius: 999px;
  background: linear-gradient(180deg, #fff, #c9f0ff);
  font-size: 1.45rem;
  font-weight: 800;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.22);
}

.site-a11y__tile-circle--u {
  text-decoration: underline;
  text-underline-offset: 0.12em;
  background: linear-gradient(180deg, #fff, #e8d4ff);
}

.site-a11y__tile.is-on .site-a11y__tile-circle {
  background: linear-gradient(180deg, #d8ff8a, #7ec82e);
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.18);
}

.site-a11y__tile-label {
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  max-width: 6.5rem;
}

/* Zephyr */
body.zephyr-page .site-a11y__trigger {
  background: linear-gradient(180deg, #3a1018, #1a080c);
  border-color: #ff2a3a;
  color: #f2c8c8;
  font-family: "Share Tech Mono", ui-monospace, monospace;
  box-shadow: 0 0 10px rgba(255, 42, 58, 0.35);
}

body.zephyr-page .site-a11y.is-open .site-a11y__trigger {
  background: linear-gradient(180deg, #5a1820, #2a0c10);
  color: #ff6a6a;
}

body.zephyr-page .site-a11y__panel {
  background: linear-gradient(165deg, #2a0c10, #1a080c);
  border-color: #ff2a3a;
  color: #f2c8c8;
  box-shadow: 0 0 18px rgba(255, 42, 58, 0.35);
  font-family: "Share Tech Mono", ui-monospace, monospace;
}

body.zephyr-page .site-a11y__circle,
body.zephyr-page .site-a11y__close,
body.zephyr-page .site-a11y__tile-circle {
  background: linear-gradient(180deg, #3a1018, #1a080c);
  border-color: #ff2a3a;
  color: #f2c8c8;
  box-shadow: 0 0 8px rgba(255, 42, 58, 0.25);
}

body.zephyr-page .site-a11y__tile.is-on .site-a11y__tile-circle {
  background: linear-gradient(180deg, #5a1820, #2a0c10);
  color: #ff6a6a;
}

body.zephyr-page .site-a11y__dot {
  border-color: #ff2a3a;
  background: rgba(255, 42, 58, 0.2);
}

body.zephyr-page .site-a11y__dot.is-on,
body.zephyr-page .site-a11y__dot.is-current {
  background: #ff2a3a;
}

body.theme-enclave .site-a11y__trigger {
  background: linear-gradient(180deg, #e6e1d3, #c4b896);
  border-color: #2a2e22;
  color: #1a1e16;
}

body.theme-enclave .site-a11y__panel {
  background: linear-gradient(165deg, #f2eee2, #d4ccb0);
  border-color: #2a2e22;
  color: #1a1e16;
}

body.theme-cookie .site-a11y__trigger {
  background: linear-gradient(180deg, #f5d9a0, #c4894a);
  border-color: #3e2723;
  color: #2a1810;
}

body.theme-cookie .site-a11y__panel {
  background: linear-gradient(165deg, #fff3d6, #f0c27a);
  border-color: #3e2723;
  color: #2a1810;
}

/* Warning gate — Win98-flavored but still big & clear */
body.splash-page.warning-gate .site-a11y {
  top: calc(max(0.5rem, env(safe-area-inset-top)) + 1.7rem);
  left: max(0.5rem, env(safe-area-inset-left));
}

body.splash-page.warning-gate .site-a11y__trigger {
  min-height: 2.6rem;
  border-radius: 0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  background: #c0c0c0;
  color: #000;
  font-family: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, sans-serif;
  font-size: 0.9rem;
  box-shadow: inset 1px 1px 0 #dfdfdf;
}

body.splash-page.warning-gate .site-a11y.is-open .site-a11y__trigger {
  border-color: #000 #fff #fff #000;
  background: #dfdfdf;
  box-shadow: inset 1px 1px 0 #808080;
}

body.splash-page.warning-gate .site-a11y__trigger:focus-visible {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

body.splash-page.warning-gate .site-a11y__panel {
  border-radius: 0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  background: #c0c0c0;
  color: #000;
  box-shadow: 2px 2px 0 #000;
  font-family: "MS Sans Serif", "Microsoft Sans Serif", Tahoma, sans-serif;
}

body.splash-page.warning-gate .site-a11y__panel-title {
  font-size: 0.95rem;
}

body.splash-page.warning-gate .site-a11y__close,
body.splash-page.warning-gate .site-a11y__circle,
body.splash-page.warning-gate .site-a11y__tile-circle {
  border-radius: 0;
  border: 2px solid;
  border-color: #fff #000 #000 #fff;
  background: #c0c0c0;
  color: #000;
  box-shadow: inset 1px 1px 0 #dfdfdf;
  font-family: inherit;
}

body.splash-page.warning-gate .site-a11y__circle:active:not(:disabled),
body.splash-page.warning-gate .site-a11y__close:active,
body.splash-page.warning-gate .site-a11y__tile:active .site-a11y__tile-circle {
  border-color: #000 #fff #fff #000;
  box-shadow: inset 1px 1px 0 #808080;
}

body.splash-page.warning-gate .site-a11y__tile.is-on .site-a11y__tile-circle {
  background: #000080;
  color: #fff;
  border-color: #000 #fff #fff #000;
  box-shadow: inset 1px 1px 0 #808080;
}

body.splash-page.warning-gate .site-a11y__dot {
  border-radius: 0;
  border-color: #000;
  background: #fff;
}

body.splash-page.warning-gate .site-a11y__dot.is-on,
body.splash-page.warning-gate .site-a11y__dot.is-current {
  background: #000080;
}

@media (max-width: 640px) {
  /* Bottom-right FAB — keeps header / skins / page-hop clear on phones */
  .site-a11y {
    top: auto;
    left: auto;
    bottom: max(0.7rem, env(safe-area-inset-bottom));
    right: max(0.7rem, env(safe-area-inset-right));
  }

  body.splash-page.warning-gate .site-a11y {
    top: auto;
    left: auto;
    /* Clear Win98 taskbar + clock */
    bottom: max(2.6rem, calc(env(safe-area-inset-bottom) + 2.35rem));
    right: max(0.55rem, env(safe-area-inset-right));
  }

  .site-a11y__trigger {
    width: 2.85rem;
    height: 2.85rem;
    min-width: 2.85rem;
    min-height: 2.85rem;
    padding: 0.4rem;
    gap: 0;
    justify-content: center;
    font-size: 0;
  }

  .site-a11y__trigger-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .site-a11y__icon {
    width: 1.35rem;
    height: 1.35rem;
  }

  .site-a11y__panel {
    top: auto;
    bottom: calc(100% + 0.45rem);
    left: auto;
    right: 0;
    width: min(17.5rem, calc(100vw - 1.4rem));
  }
}
