/* ============================================
   ACCESSIBILITY WIDGET - Standalone (legal pages)
   Wood & Gold theme to match main game
   ============================================ */

/* Floating button */
.a11y-widget-btn {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 99990;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--accent-lo);
  background: linear-gradient(135deg, var(--bg-2), var(--bg-1));
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 10px color-mix(in srgb, var(--accent) 15%, transparent);
  transition: transform 0.2s, box-shadow 0.2s;
}
.a11y-widget-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5), 0 0 15px color-mix(in srgb, var(--accent) 25%, transparent);
}
.a11y-widget-btn:focus-visible {
  outline: 3px solid var(--accent-hi);
  outline-offset: 3px;
}
.a11y-widget-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--status-success);
  border: 2px solid var(--bg-1);
}

/* Panel */
.a11y-widget-panel {
  position: fixed;
  bottom: 82px;
  left: 20px;
  z-index: 99991;
  width: 300px;
  max-height: 80vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--bg-4), var(--bg-3), var(--bg-2));
  border: 2px solid var(--accent-lo);
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 20px color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text-1);
  animation: a11y-slide-up 0.2s ease-out;
}
@keyframes a11y-slide-up {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.a11y-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--accent-lo) 40%, transparent);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-accent);
}
.a11y-widget-header i {
  margin-left: 8px;
}
.a11y-widget-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  line-height: 1;
}
.a11y-widget-close:hover {
  color: var(--text-1);
  background: color-mix(in srgb, var(--accent-lo) 15%, transparent);
}
.a11y-widget-body {
  padding: 12px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Font size section */
.a11y-widget-section {
  margin-bottom: 4px;
}
.a11y-widget-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}
.a11y-widget-row {
  display: flex;
  gap: 6px;
}
.a11y-widget-size-btn {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid color-mix(in srgb, var(--accent-lo) 30%, transparent);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-1);
  cursor: pointer;
  font-weight: 700;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.a11y-widget-size-btn:hover {
  background: color-mix(in srgb, var(--accent-lo) 15%, transparent);
}
.a11y-widget-size-btn.active {
  background: color-mix(in srgb, var(--accent-lo) 25%, transparent);
  border-color: var(--accent);
  color: var(--text-accent);
}

/* Toggle buttons */
.a11y-widget-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent-lo) 20%, transparent);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-1);
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  text-align: right;
  transition: background 0.15s, border-color 0.15s;
}
.a11y-widget-toggle:hover {
  background: color-mix(in srgb, var(--accent-lo) 12%, transparent);
}
.a11y-widget-toggle.active {
  background: color-mix(in srgb, var(--accent-lo) 20%, transparent);
  border-color: color-mix(in srgb, var(--accent-lo) 50%, transparent);
}
.a11y-widget-toggle i {
  width: 20px;
  text-align: center;
  color: var(--text-accent);
  font-size: 0.95rem;
}
.a11y-widget-toggle span:first-of-type {
  flex: 1;
}
.a11y-widget-toggle-indicator {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-muted);
}
.a11y-widget-toggle.active .a11y-widget-toggle-indicator {
  background: color-mix(in srgb, var(--status-success) 20%, transparent);
  color: var(--status-success-dim);
}

/* Reset button */
.a11y-widget-reset {
  margin-top: 6px;
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--status-danger) 30%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--status-danger) 8%, transparent);
  color: var(--status-danger);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  text-align: center;
  transition: background 0.15s;
}
.a11y-widget-reset:hover {
  background: color-mix(in srgb, var(--status-danger) 15%, transparent);
}
.a11y-widget-reset i {
  margin-left: 6px;
}

/* ============================================
   ACCESSIBILITY MODES - Applied to <html>
   ============================================ */

/* Font size levels */
.a11y-font-1 { font-size: 110% !important; }
.a11y-font-2 { font-size: 120% !important; }
.a11y-font-3 { font-size: 135% !important; }

/* High contrast */
.a11y-high-contrast {
  --theme-text: #ffffff !important;
  --theme-text-muted: #d4d4d4 !important;
  --theme-bg: #000000 !important;
  --theme-surface: #111111 !important;
  --glass-bg: rgba(0, 0, 0, 0.9) !important;
  --glass-border: rgba(255, 255, 255, 0.5) !important;
}
.a11y-high-contrast * {
  text-shadow: none !important;
}
.a11y-high-contrast img {
  contrast: 1.1;
}

/* Grayscale */
.a11y-grayscale {
  filter: grayscale(100%);
}
.a11y-grayscale .a11y-widget-btn,
.a11y-grayscale .a11y-widget-panel {
  filter: grayscale(0);
}

/* Highlight links */
.a11y-highlight-links a,
.a11y-highlight-links button {
  outline: 2px solid var(--accent) !important;
  outline-offset: 2px !important;
}
.a11y-highlight-links a {
  text-decoration: underline !important;
  text-decoration-color: var(--accent) !important;
  text-underline-offset: 3px !important;
}
.a11y-highlight-links .a11y-widget-panel button,
.a11y-highlight-links .a11y-widget-btn {
  text-decoration: none !important;
}

/* Large cursor */
.a11y-large-cursor,
.a11y-large-cursor * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M5 2l22 18-10 2 6 14-5 2-6-14-7 8z' fill='%23000' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 5 2, auto !important;
}

/* Text spacing */
.a11y-text-spacing {
  letter-spacing: 0.08em !important;
  word-spacing: 0.16em !important;
}
.a11y-text-spacing p,
.a11y-text-spacing li,
.a11y-text-spacing span,
.a11y-text-spacing div {
  line-height: 2 !important;
}

/* Reduce motion */
.a11y-reduce-motion,
.a11y-reduce-motion * {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}
.a11y-reduce-motion .a11y-widget-panel {
  animation: none !important;
}

/* TTS active cursor */
.a11y-tts-active p,
.a11y-tts-active span,
.a11y-tts-active div,
.a11y-tts-active li,
.a11y-tts-active h1,
.a11y-tts-active h2,
.a11y-tts-active h3,
.a11y-tts-active h4,
.a11y-tts-active td,
.a11y-tts-active label {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3A4.5 4.5 0 0012 8.5v7a4.49 4.49 0 004.5-3.5zM14 3.23v2.06a7 7 0 010 13.42v2.06A9 9 0 0014 3.23z' fill='%236B9080'/%3E%3C/svg%3E") 12 12, pointer !important;
}

[data-a11y-tts-pending] {
  outline: 2px solid color-mix(in srgb, var(--accent) 70%, transparent) !important;
  outline-offset: 2px !important;
  animation: a11y-tts-pulse 1s ease-in-out infinite !important;
}

@keyframes a11y-tts-pulse {
  0%, 100% { outline-color: color-mix(in srgb, var(--accent) 70%, transparent); }
  50% { outline-color: color-mix(in srgb, var(--accent) 30%, transparent); }
}

/* Mobile responsive */
@media (max-width: 480px) {
  .a11y-widget-panel {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: 78px;
  }
  .a11y-widget-btn {
    bottom: 14px;
    left: 14px;
    width: 46px;
    height: 46px;
  }
}
