/* ════════════════════════════════════════════
   ROOT — identik PTSP Kemenag Kab. Madiun
════════════════════════════════════════════ */
:root {
  /* Aksesibilitas runtime variables */
  --a11y-font-size: 1rem;
  --a11y-line-height: 1.65;
  --a11y-letter-spacing: 0em;
  --a11y-word-spacing: 0em;
  --a11y-font-family: "Plus Jakarta Sans", sans-serif;
  --a11y-bg: var(--putih);
  --a11y-text: var(--teks);
  --a11y-link: var(--hijau);
  --a11y-border: var(--border);
  --a11y-saturation: 100%;
  --a11y-brightness: 100%;
  --a11y-cursor: auto;
}

/* High contrast mode */
body.hc-dark {
  --a11y-bg: #000000;
  --a11y-text: #ffffff;
  --a11y-link: #ffff00;
  --a11y-border: #ffffff;
}
body.hc-light {
  --a11y-bg: #ffffff;
  --a11y-text: #000000;
  --a11y-link: #0000cc;
  --a11y-border: #000000;
}
body.hc-yellow {
  --a11y-bg: #ffff00;
  --a11y-text: #000000;
  --a11y-link: #000099;
  --a11y-border: #000000;
}
body.grayscale {
  filter: grayscale(100%);
}
body.invert {
  filter: invert(90%) hue-rotate(180deg);
}
body.dyslexia {
  --a11y-font-family: "OpenDyslexic", sans-serif;
  --a11y-letter-spacing: 0.08em;
  --a11y-word-spacing: 0.18em;
  --a11y-line-height: 1.9;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--a11y-font-family);
  font-size: var(--a11y-font-size);
  line-height: var(--a11y-line-height);
  letter-spacing: var(--a11y-letter-spacing);
  word-spacing: var(--a11y-word-spacing);
  color: var(--a11y-text);
  background: var(--a11y-bg);
  cursor: var(--a11y-cursor);
  overflow-x: hidden;
  transition:
    background 0.3s,
    color 0.3s,
    filter 0.3s;
}
a {
  color: var(--a11y-link);
}

/* ── READING BAR ── */
.reading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--hijau), var(--emas));
  z-index: 9999;
  width: 0%;
  transition: width 0.1s linear;
}

/* ════════════════════════════════════════════
   WIDGET AKSESIBILITAS — FLOATING PANEL
════════════════════════════════════════════ */

/* Trigger button */
.a11y-trigger {
  position: fixed;
  bottom: 88px;
  left: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--hijau);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 20px rgba(15, 68, 35, 0.45);
  z-index: 9998;
  transition: all 0.25s;
  animation: pulse-a11y 2.5s infinite;
}
.a11y-trigger:hover {
  background: var(--hijau-muda);
  transform: scale(1.08);
}
@keyframes pulse-a11y {
  0%,
  100% {
    box-shadow: 0 4px 20px rgba(26, 107, 58, 0.45);
  }
  50% {
    box-shadow:
      0 4px 28px rgba(26, 107, 58, 0.7),
      0 0 0 8px rgba(26, 107, 58, 0.1);
  }
}

/* Panel */
.a11y-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 340px;
  max-width: 100vw;
  background: #fff;
  border-radius: 0 20px 0 0;
  box-shadow: 4px -4px 40px rgba(0, 0, 0, 0.18);
  z-index: 9997;
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 90vh;
  overflow-y: auto;
  border-top: 3px solid var(--hijau);
  border-right: 1.5px solid var(--border);
}
.a11y-panel.open {
  transform: translateY(0);
}

/* Panel header */
.a11y-header {
  background: linear-gradient(135deg, var(--hijau-gelap), var(--hijau));
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 2;
}
.a11y-header h2 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}
.a11y-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: background 0.2s;
}
.a11y-close:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* Panel body */
.a11y-body {
  padding: 16px;
}

/* Section group */
.a11y-group {
  margin-bottom: 18px;
}
.a11y-group-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--abu);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.a11y-group-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── TTS PLAYER ── */
.tts-player {
  background: var(--hijau-terang);
  border-radius: 12px;
  padding: 16px;
  border: 1.5px solid var(--border);
  margin-bottom: 6px;
}
.tts-status {
  font-size: 0.76rem;
  color: var(--abu);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 18px;
}
.tts-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ccc;
  flex-shrink: 0;
  transition: background 0.3s;
}
.tts-status .dot.speaking {
  background: #22c55e;
  animation: blink 0.8s infinite;
}
.tts-status .dot.paused {
  background: var(--emas);
}
.tts-status .dot.idle {
  background: #ccc;
}
@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* TTS Controls */
.tts-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.tts-btn {
  flex: 1;
  border: none;
  border-radius: 9px;
  padding: 10px 8px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.2s;
}
.tts-btn.primary {
  background: var(--hijau);
  color: #fff;
}
.tts-btn.primary:hover {
  background: var(--hijau-muda);
}
.tts-btn.secondary {
  background: #fff;
  color: var(--hijau);
  border: 1.5px solid var(--border);
}
.tts-btn.secondary:hover {
  background: var(--hijau-terang);
}
.tts-btn.danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1.5px solid #fdc3bb;
}
.tts-btn.danger:hover {
  background: #dc2626;
  color: #fff;
}
.tts-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* TTS Select area */
.tts-input-wrap {
  position: relative;
  margin-bottom: 10px;
}
.tts-select-btn {
  width: 100%;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--hijau);
  cursor: pointer;
  text-align: left;
  transition: border 0.2s;
  font-family: inherit;
  display: flex;
  align-items: center;
  gap: 7px;
}
.tts-select-btn:hover {
  border-color: var(--hijau);
}

/* Speed + Voice sliders */
.tts-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.79rem;
  color: var(--abu);
}
.slider-row label {
  min-width: 52px;
  font-weight: 600;
  color: var(--teks);
}
.slider-row input[type="range"] {
  flex: 1;
  accent-color: var(--hijau);
  height: 4px;
  cursor: pointer;
}
.slider-row .val {
  min-width: 32px;
  text-align: right;
  font-weight: 700;
  color: var(--hijau);
  font-size: 0.78rem;
}

/* Voice select */
.voice-select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--teks);
  background: #fff;
  outline: none;
  transition: border 0.2s;
  cursor: pointer;
}
.voice-select:focus {
  border-color: var(--hijau);
}

/* Highlight text progress */
.tts-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.tts-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--hijau), var(--hijau-muda));
  width: 0%;
  transition: width 0.2s;
}

/* ── FONT SIZE ── */
.font-size-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fs-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 800;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.fs-btn:hover {
  background: var(--hijau);
  border-color: var(--hijau);
  color: #fff;
}
.fs-display {
  flex: 1;
  text-align: center;
  font-weight: 800;
  color: var(--hijau);
  font-size: 0.92rem;
  background: var(--hijau-terang);
  border-radius: 8px;
  padding: 7px;
  border: 1px solid var(--border);
}
.fs-presets {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.fs-preset {
  flex: 1;
  padding: 6px;
  border-radius: 7px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  font-family: inherit;
}
.fs-preset:hover,
.fs-preset.active {
  background: var(--hijau);
  border-color: var(--hijau);
  color: #fff;
}

/* ── TOGGLE SWITCH ── */
.a11y-toggles {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--abu-bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  transition: background 0.2s;
}
.toggle-row:hover {
  background: var(--hijau-terang);
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--teks);
}
.toggle-label i {
  width: 18px;
  text-align: center;
  color: var(--hijau);
}
.toggle-label small {
  display: block;
  font-size: 0.71rem;
  font-weight: 400;
  color: var(--abu);
  margin-top: 1px;
}
.toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: #d1d5db;
  cursor: pointer;
  transition: background 0.3s;
}
.toggle-switch input:checked + .toggle-track {
  background: var(--hijau);
}
.toggle-track::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.3s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.toggle-switch input:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* ── CONTRAST BUTTONS ── */
.contrast-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.contrast-btn {
  padding: 10px 8px;
  border-radius: 10px;
  border: 2px solid var(--border);
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-family: inherit;
}
.contrast-btn .cb-preview {
  width: 32px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}
.contrast-btn:hover,
.contrast-btn.active {
  border-color: var(--hijau);
  box-shadow: 0 0 0 2px rgba(26, 107, 58, 0.25);
}
.cb-normal .cb-preview {
  background: linear-gradient(90deg, #1c2a1e, #fff);
}
.cb-dark .cb-preview {
  background: #000;
  border-color: #fff;
}
.cb-light .cb-preview {
  background: #fff;
  border-color: #ccc;
}
.cb-yellow .cb-preview {
  background: #ffff00;
  border-color: #999;
}
.cb-grayscale .cb-preview {
  background: linear-gradient(90deg, #333, #ccc);
}
.cb-invert .cb-preview {
  background: linear-gradient(90deg, #ddd, #111);
}

/* ── CURSOR SIZE ── */
.cursor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.cursor-btn {
  padding: 10px 6px;
  border-radius: 10px;
  border: 2px solid var(--border);
  cursor: pointer;
  font-size: 0.74rem;
  font-weight: 700;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-family: inherit;
  background: #fff;
}
.cursor-btn:hover,
.cursor-btn.active {
  border-color: var(--hijau);
  background: var(--hijau-terang);
}
.cursor-btn .ci {
  font-size: 1.2rem;
}

/* ── READING GUIDE ── */
.reading-guide-line {
  position: fixed;
  left: 0;
  right: 0;
  height: 36px;
  background: rgba(26, 107, 58, 0.12);
  border-top: 2px solid rgba(26, 107, 58, 0.35);
  border-bottom: 2px solid rgba(26, 107, 58, 0.35);
  pointer-events: none;
  z-index: 8888;
  display: none;
  top: 50%;
  transform: translateY(-50%);
  transition: top 0.05s;
}
body.reading-guide .reading-guide-line {
  display: block;
}

/* ── FOCUS HIGHLIGHT ── */
body.focus-highlight *:focus {
  outline: 4px solid var(--emas) !important;
  outline-offset: 3px !important;
  border-radius: 4px !important;
}

/* ── LINK UNDERLINE ALWAYS ── */
body.always-underline a {
  text-decoration: underline !important;
  text-underline-offset: 3px;
}

/* ── RESET BTN ── */
.reset-btn {
  width: 100%;
  padding: 11px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: #fef2f2;
  color: #dc2626;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: all 0.2s;
  font-family: inherit;
  margin-top: 4px;
}
.reset-btn:hover {
  background: #dc2626;
  color: #fff;
  border-color: #dc2626;
}

/* ── DEMO CONTENT ── */
.demo-section {
  background: var(--a11y-bg);
  color: var(--a11y-text);
  border-radius: var(--r);
  border: 1.5px solid var(--a11y-border);
  padding: 32px;
  margin-bottom: 24px;
  transition: all 0.3s;
}
.demo-section h2 {
  font-size: clamp(1.3rem, 2.5vw, 1.8rem);
  font-weight: 800;
  color: var(--a11y-text);
  margin-bottom: 14px;
  line-height: 1.3;
}
.demo-section h2 span {
  color: var(--hijau);
}
.demo-section p {
  font-size: inherit;
  line-height: inherit;
  color: var(--a11y-text);
  opacity: 0.85;
  margin-bottom: 12px;
}
.demo-section a {
  color: var(--a11y-link);
  font-weight: 600;
}
.demo-section .tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--hijau-terang);
  color: var(--hijau);
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  margin-right: 6px;
  margin-bottom: 6px;
}

/* ── KATA HIGHLIGHT SAAT TTS ── */
.tts-highlight-word {
  background: rgba(26, 107, 58, 0.2);
  border-radius: 3px;
  transition: background 0.1s;
}

/* Overlay backdrop */
.a11y-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 9996;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.a11y-backdrop.open {
  opacity: 1;
  pointer-events: all;
}
