/* ====================================================================
   ACCESSIBILITY WIDGET
   ==================================================================== */
:root{
  --a11y-green: #1f7a3d;
  --a11y-yellow: #f5b301;
  --a11y-blue: #0d6efd;
  --a11y-shadow: 0 20px 50px -20px rgba(0,0,0,.35);
}

/* ---------- Floating Button ---------- */
.a11y-fab{
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.4);
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1040;
  box-shadow:
    0 8px 24px rgba(13,110,253,.4),
    0 4px 12px rgba(0,0,0,.15);
  transition: transform .25s ease, box-shadow .25s ease;
}
.a11y-fab:hover{
  transform: scale(1.08);
  box-shadow:
    0 12px 30px rgba(13,110,253,.55),
    0 6px 16px rgba(0,0,0,.2);
}
.a11y-fab:active{ transform: scale(.96); }
.a11y-fab:focus-visible{
  outline: 3px solid var(--a11y-yellow);
  outline-offset: 3px;
}

/* Icon hover effect — tidak berputar, hanya scale halus */
.a11y-fab i{
  transition: transform .3s cubic-bezier(.22, 1, .36, 1);
}
.a11y-fab:hover i{
  transform: scale(1.12);
}
.a11y-fab:active i{
  transform: scale(.95);
}

.a11y-fab-pulse{
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(13,110,253,.5);
  animation: a11yPulse 2.5s ease-out infinite;
  pointer-events: none;
}
@keyframes a11yPulse{
  0%   { transform: scale(1);   opacity: .85; }
  70%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ---------- Backdrop ---------- */
.a11y-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity .3s ease, visibility .3s ease;
  z-index: 1041;
}
.a11y-backdrop.show{
  opacity: 1;
  visibility: visible;
}

/* ---------- Panel ---------- */
.a11y-panel{
  position: fixed;
  top: 50%;
  left: 50%;
  width: 420px;
  max-width: calc(100vw - 32px);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--a11y-shadow);
  transform: translate(-50%, -50%) scale(.92);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity .3s ease,
    transform .35s cubic-bezier(.34, 1.4, .64, 1),
    visibility .3s ease;
  z-index: 1042;
  display: flex;
  flex-direction: column;
}
.a11y-panel.show{
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

/* Header */
.a11y-header{
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
  color: #fff;
  border-radius: 18px 18px 0 0;
  position: sticky;
  top: 0;
  z-index: 2;
}
.a11y-header-icon{
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.a11y-header-text{ flex: 1; min-width: 0; }
.a11y-header-text h5{
  margin: 0 0 2px;
  font-size: 1.05rem;
  font-weight: 700;
}
.a11y-header-text p{
  margin: 0;
  font-size: .75rem;
  opacity: .9;
}
.a11y-close{
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: rgba(255,255,255,.15);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  transition: background .2s, transform .2s;
}
.a11y-close:hover{
  background: rgba(255,255,255,.28);
  transform: rotate(90deg);
}

/* Body */
.a11y-body{
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Label grup */
.a11y-label{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  font-weight: 700;
  color: #4b5a51;
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 10px;
}
.a11y-label i{ color: var(--a11y-blue); font-size: 1rem; }

/* ---------- Font Size Controls ---------- */
.a11y-font-controls{
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.a11y-font-btn{
  padding: 12px 8px;
  border-radius: 10px;
  border: 1.5px solid #e2e9e4;
  background: #fff;
  color: #4b5a51;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  transition: all .2s ease;
  position: relative;
}
.a11y-font-btn sup{
  font-size: .6rem;
  font-weight: 800;
  color: var(--a11y-blue);
}
.a11y-font-btn:hover{
  border-color: var(--a11y-blue);
  color: var(--a11y-blue);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px -3px rgba(13,110,253,.3);
}
.a11y-font-btn.active{
  background: linear-gradient(135deg, var(--a11y-blue), #0a58ca);
  border-color: var(--a11y-blue);
  color: #fff;
}
.a11y-font-btn.active sup{ color: #fff; }

.a11y-font-indicator{
  text-align: center;
  margin-top: 8px;
  font-size: .75rem;
  color: #6b7a70;
  font-weight: 600;
}

/* ---------- Toggle Grid ---------- */
.a11y-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.a11y-tile{
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 12px;
  border-radius: 12px;
  border: 1.5px solid #e2e9e4;
  background: #fff;
  cursor: pointer;
  transition: all .25s ease;
  text-align: center;
}
.a11y-tile:hover{
  border-color: var(--a11y-blue);
  background: #f8fbff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px -6px rgba(13,110,253,.3);
}
.a11y-tile:focus-visible{
  outline: 3px solid var(--a11y-yellow);
  outline-offset: 2px;
}

.a11y-tile-icon{
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #e7f0ff;
  color: var(--a11y-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: background .25s, color .25s;
}
.a11y-tile-label{
  font-size: .78rem;
  font-weight: 700;
  color: #4b5a51;
  line-height: 1.3;
}

.a11y-tile-check{
  position: absolute;
  top: 8px;
  right: 8px;
  color: #1f7a3d;
  font-size: 1rem;
  opacity: 0;
  transform: scale(.5);
  transition: opacity .25s, transform .25s;
}

/* Active state */
.a11y-tile[aria-pressed="true"]{
  border-color: var(--a11y-blue);
  background: linear-gradient(135deg, #e7f0ff, #d6e6ff);
}
.a11y-tile[aria-pressed="true"] .a11y-tile-icon{
  background: linear-gradient(135deg, var(--a11y-blue), #0a58ca);
  color: #fff;
}
.a11y-tile[aria-pressed="true"] .a11y-tile-label{
  color: #0a58ca;
}
.a11y-tile[aria-pressed="true"] .a11y-tile-check{
  opacity: 1;
  transform: scale(1);
}

/* Reset tile */
.a11y-tile-reset{
  border-style: dashed;
  color: #b3261e;
}
.a11y-tile-reset .a11y-tile-icon{
  background: #fdecea;
  color: #b3261e;
}
.a11y-tile-reset:hover{
  border-color: #b3261e;
  background: #fdecea;
}
.a11y-tile-reset:hover .a11y-tile-icon{
  background: #b3261e;
  color: #fff;
}

/* Footer */
.a11y-footer{
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px dashed #eef2ef;
  font-size: .72rem;
  color: #8ba094;
}
.a11y-footer i{ color: var(--a11y-blue); }

/* ---------- Reading Guide ---------- */
.a11y-reading-guide{
  position: fixed;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(90deg, transparent 0%, var(--a11y-yellow) 50%, transparent 100%);
  box-shadow: 0 0 12px rgba(245,179,1,.8);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  top: 0;
  transition: opacity .25s ease;
}
.a11y-reading-guide.active{
  opacity: 1;
}

/* ====================================================================
   APPLIED EFFECTS (aktif ketika body punya class tertentu)
   ==================================================================== */

/* Font Size Scaling */
body.a11y-font-1 { zoom: 1.1; }
body.a11y-font-2 { zoom: 1.2; }
body.a11y-font-3 { zoom: 1.35; }
body.a11y-font-neg1 { zoom: .9; }

/* Firefox fallback */
@supports not (zoom: 1) {
  body.a11y-font-1 { font-size: 110%; }
  body.a11y-font-2 { font-size: 120%; }
  body.a11y-font-3 { font-size: 135%; }
}

/* High Contrast */
body.a11y-contrast,
body.a11y-contrast *{
  background-color: #000 !important;
  color: #fff !important;
  border-color: #fff !important;
  box-shadow: none !important;
  text-shadow: none !important;
}
body.a11y-contrast a,
body.a11y-contrast a *{
  color: #ffff00 !important;
  text-decoration: underline !important;
}
body.a11y-contrast button,
body.a11y-contrast .btn{
  background: #000 !important;
  color: #ffff00 !important;
  border: 2px solid #ffff00 !important;
}
body.a11y-contrast img{
  filter: contrast(1.2) brightness(1.1);
}

/* Dyslexia Font */
body.a11y-dyslexia,
body.a11y-dyslexia *{
  font-family: 'Comic Neue', 'Comic Sans MS', 'Segoe UI', cursive !important;
  letter-spacing: .5px;
  word-spacing: 2px;
}
body.a11y-dyslexia p,
body.a11y-dyslexia li,
body.a11y-dyslexia td{
  line-height: 1.8 !important;
}

/* Grayscale */
body.a11y-grayscale{
  filter: grayscale(1);
}

/* Highlight Links */
body.a11y-links a{
  background: rgba(245,179,1,.2) !important;
  outline: 2px solid var(--a11y-yellow) !important;
  outline-offset: 2px;
  border-radius: 4px;
  padding: 2px 4px;
  font-weight: 700 !important;
  text-decoration: underline !important;
}
body.a11y-links a:hover{
  background: var(--a11y-yellow) !important;
  color: #000 !important;
}

/* Big Cursor */
body.a11y-cursor,
body.a11y-cursor *{
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='1' d='M5 3l14 9-6 1 4 8-3 1-4-8-5 5z'/%3E%3C/svg%3E") 6 6, auto !important;
}

/* Text Spacing */
body.a11y-spacing p,
body.a11y-spacing li,
body.a11y-spacing div,
body.a11y-spacing td,
body.a11y-spacing th,
body.a11y-spacing span{
  line-height: 2 !important;
  letter-spacing: 1px !important;
  word-spacing: 4px !important;
}

@media (prefers-reduced-motion: reduce){
  .a11y-fab-pulse{
    animation: none !important;
  }
  .a11y-fab i{
    transition: none !important;
  }
}

/* Mobile */
@media (max-width: 576px){
  .a11y-fab{
    bottom: 18px;
    left: 18px;
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
  }
  .a11y-panel{
    width: calc(100vw - 24px);
    max-height: 85vh;
  }
  .a11y-header{ padding: 14px 16px; }
  .a11y-body{ padding: 16px; }
  .a11y-grid{ gap: 8px; }
  .a11y-tile{ padding: 12px 8px; }
  .a11y-tile-icon{ width: 34px; height: 34px; font-size: 1rem; }
  .a11y-tile-label{ font-size: .72rem; }
}

/* ====================================================================
   SCREEN READER (Text-to-Speech)
   ==================================================================== */
.a11y-tts-section{
  padding: 14px;
  background: linear-gradient(135deg, #f0f7ff 0%, #e7f0ff 100%);
  border: 1.5px solid #c8ddff;
  border-radius: 12px;
  margin-bottom: 4px;
}

/* Tombol utama */
.a11y-tts-main{
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.a11y-tts-btn{
  border: 0;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s, background .25s, opacity .25s;
}

.a11y-tts-play{
  flex: 1;
  background: linear-gradient(135deg, #0d6efd, #0a58ca);
  color: #fff;
  box-shadow: 0 6px 16px -6px rgba(13,110,253,.55);
}
.a11y-tts-play:hover:not(:disabled){
  transform: translateY(-2px);
  box-shadow: 0 10px 22px -8px rgba(13,110,253,.7);
}
.a11y-tts-play.reading{
  background: linear-gradient(135deg, #e53935, #c62828);
  box-shadow: 0 6px 16px -6px rgba(229,57,53,.55);
}

.a11y-tts-pause,
.a11y-tts-stop{
  width: 46px;
  padding: 12px;
  background: #fff;
  border: 1.5px solid #c8ddff;
  color: #0d6efd;
  font-size: 1rem;
}
.a11y-tts-pause:hover:not(:disabled),
.a11y-tts-stop:hover:not(:disabled){
  background: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}
.a11y-tts-stop:hover:not(:disabled){
  background: #e53935;
  border-color: #e53935;
}

.a11y-tts-btn:disabled{
  opacity: .45;
  cursor: not-allowed;
}

/* Tombol baca teks terpilih */
.a11y-tts-select{
  width: 100%;
  padding: 10px 14px;
  border: 1.5px dashed #0d6efd;
  border-radius: 10px;
  background: #fff;
  color: #0d6efd;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  transition: all .2s;
}
.a11y-tts-select small{
  font-weight: 400;
  opacity: .7;
  font-size: .7rem;
}
.a11y-tts-select:hover:not(:disabled){
  background: #0d6efd;
  color: #fff;
  border-style: solid;
}
.a11y-tts-select:disabled{
  opacity: .5;
  cursor: not-allowed;
  border-color: #b0beb6;
  color: #8ba094;
}

/* Pengaturan */
.a11y-tts-settings{
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed #c8ddff;
}

.a11y-tts-row{
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.a11y-tts-row-inline{
  flex-direction: row;
  align-items: center;
}

.a11y-tts-row label{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .75rem;
  font-weight: 700;
  color: #4b5a51;
}
.a11y-tts-row label i{
  color: #0d6efd;
  font-size: .9rem;
}

.a11y-tts-rate-value{
  margin-left: auto;
  padding: 2px 8px;
  background: #fff;
  border: 1px solid #c8ddff;
  border-radius: 6px;
  color: #0d6efd;
  font-weight: 800;
  font-size: .72rem;
  min-width: 42px;
  text-align: center;
}

.a11y-tts-select-input{
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #c8ddff;
  border-radius: 8px;
  background: #fff;
  font-size: .8rem;
  color: #4b5a51;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .2s;
}
.a11y-tts-select-input:focus{
  outline: 0;
  border-color: #0d6efd;
  box-shadow: 0 0 0 3px rgba(13,110,253,.15);
}

.a11y-tts-range{
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #0d6efd 0%, #0d6efd var(--fill, 50%), #d6e6ff var(--fill, 50%), #d6e6ff 100%);
  cursor: pointer;
  outline: none;
}
.a11y-tts-range::-webkit-slider-thumb{
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid #0d6efd;
  box-shadow: 0 2px 6px rgba(13,110,253,.35);
  cursor: pointer;
  transition: transform .15s;
}
.a11y-tts-range::-webkit-slider-thumb:hover{
  transform: scale(1.15);
}
.a11y-tts-range::-moz-range-thumb{
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid #0d6efd;
  box-shadow: 0 2px 6px rgba(13,110,253,.35);
  cursor: pointer;
}

.a11y-tts-checkbox{
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}
.a11y-tts-checkbox input[type="checkbox"]{
  width: 16px;
  height: 16px;
  accent-color: #0d6efd;
  cursor: pointer;
}
.a11y-tts-checkbox span{
  font-size: .78rem;
  color: #4b5a51;
}

/* Status indicator */
.a11y-tts-status{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #c8ddff;
  border-radius: 8px;
  font-size: .75rem;
  color: #0d6efd;
  font-weight: 600;
}
.a11y-tts-status-dot{
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0d6efd;
  flex-shrink: 0;
  transition: background .3s;
}
.a11y-tts-status.speaking .a11y-tts-status-dot{
  background: #e53935;
  animation: a11yTtsPulse 1.2s ease-in-out infinite;
}
.a11y-tts-status.paused .a11y-tts-status-dot{
  background: #f5b301;
}
.a11y-tts-status.error .a11y-tts-status-dot{
  background: #e53935;
}
.a11y-tts-status.speaking .a11y-tts-status-text{
  color: #e53935;
}

@keyframes a11yTtsPulse{
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.35); opacity: .6; }
}

.a11y-tts-tip{
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 10px;
  font-size: .7rem;
  color: #6b7a70;
  line-height: 1.5;
}
.a11y-tts-tip i{ color: #0d6efd; flex-shrink: 0; margin-top: 2px; }

/* ====================================================================
   HIGHLIGHT — Kalimat yang sedang dibaca
   ==================================================================== */
.a11y-tts-highlight{
  background: linear-gradient(180deg, transparent 55%, #f5b301 55%, #f5b301 100%) !important;
  color: inherit !important;
  border-radius: 2px;
  padding: 1px 2px;
  transition: background .3s ease;
  scroll-margin-top: 120px;
}

/* Untuk browser yang support CSS Highlight API */
::highlight(a11y-speak){
  background: linear-gradient(180deg, transparent 55%, #f5b301 55%, #f5b301 100%);
  color: inherit;
}

/* ====================================================================
   MOBILE
   ==================================================================== */
@media (max-width: 576px){
  .a11y-tts-play{ padding: 10px 12px; font-size: .78rem; }
  .a11y-tts-play span{ font-size: .72rem; }
  .a11y-tts-select{ font-size: .74rem; padding: 9px 10px; }
  .a11y-tts-select small{ display: block; width: 100%; text-align: center; }
}