/* INFALABS — Widget aksesibilitas (gaya UserWay).
   Diadaptasi dari widget JDIH BPOM, disesuaikan ke design system INFALABS.

   Dua kelompok aturan:
   1) EFEK — kelas pada <html> yang mengubah tampilan seluruh halaman.
      Banyak elemen situs memakai inline style / utilitas Tailwind, jadi override
      butuh !important. File ini sengaja TIDAK memakai @layer supaya selalu
      menang atas reset Tailwind yang berada di @layer base.
   2) UI WIDGET — tombol pengapung + panel pengaturan (#a11y-widget).
   Widget diletakkan di luar .ifl-root dan dinormalkan kembali (unzoom /
   un-invert) supaya panel tetap terbaca saat efek aktif. */

/* ============================================================
   1) EFEK
   ============================================================ */

/* Skala halaman — zoom pada root meniru zoom browser sehingga elemen
   position:fixed tetap benar; widget dikembalikan ke 1x agar tak ikut membesar. */
html.a11y-zoomed { zoom: var(--a11y-zoom, 1); }
/* Widget & lapisan pembantu dinormalkan kembali: posisinya dihitung dari
   koordinat kursor (clientY) yang tidak mengikuti zoom root. */
html.a11y-zoomed #a11y-widget,
html.a11y-zoomed #a11y-guide,
html.a11y-zoomed .a11y-mask { zoom: var(--a11y-unzoom, 1); }

/* Palet warna (kontras tinggi / mode gelap / monokrom) */
html.a11y-fx { filter: var(--a11y-fx); }
/* Mode gelap memakai invert: media & widget di-invert balik agar tetap wajar */
html.a11y-dark img,
html.a11y-dark video,
html.a11y-dark iframe,
html.a11y-dark #a11y-widget { filter: invert(1) hue-rotate(180deg); }

/* Sorot tautan */
html.a11y-links .ifl-root a {
  text-decoration: underline !important;
  text-underline-offset: 3px;
  outline: 2px solid #C9A227 !important;
  outline-offset: 2px;
  border-radius: 3px;
}

/* Font mudah dibaca (fallback bertingkat bila OpenDyslexic tak tersedia) */
html.a11y-font .ifl-root,
html.a11y-font .ifl-root * {
  font-family: 'OpenDyslexic', 'Atkinson Hyperlegible', 'Comic Sans MS', Verdana, Tahoma, sans-serif !important;
  letter-spacing: .012em;
}

/* Jarak teks lebih lega */
html.a11y-spacing .ifl-root,
html.a11y-spacing .ifl-root * {
  line-height: 1.9 !important;
  letter-spacing: .05em !important;
  word-spacing: .14em !important;
}

/* Teks rata kiri (menghilangkan justify / center yang menyulitkan disleksia).
   Hanya elemen teks — tidak div/flex agar tata letak tombol tak bergeser. */
html.a11y-left .ifl-root :is(p, h1, h2, h3, h4, h5, h6, li, dt, dd, td, th, blockquote, label) {
  text-align: left !important;
}

/* Hentikan animasi */
html.a11y-noanim .ifl-root *,
html.a11y-noanim .ifl-root *::before,
html.a11y-noanim .ifl-root *::after {
  animation: none !important;
  transition: none !important;
}
html.a11y-noanim { scroll-behavior: auto !important; }
/* Elemen reveal-on-scroll (app.js) mulai dari opacity:0 — tanpa transisi ia bisa
   tertahan tak terlihat, jadi dipaksa tampil saat animasi dimatikan. */
html.a11y-noanim .ifl-root .reveal { opacity: 1 !important; transform: none !important; }

/* Sembunyikan gambar — hanya media, gradien latar (background-image) dibiarkan
   agar tata letak & identitas visual tidak rusak. Ruangnya tetap dipakai. */
html.a11y-noimg .ifl-root :is(img, video, iframe, picture) { visibility: hidden !important; }

/* Kursor besar */
html.a11y-cursor .ifl-root,
html.a11y-cursor .ifl-root * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M8 3l0 32 8-8 6 13 6-3-6-13 12 0z' fill='%23ffffff' stroke='%230E2A5C' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 6 3, auto !important;
}
html.a11y-cursor .ifl-root :is(a, button, [role="button"], summary),
html.a11y-cursor .ifl-root :is(a, button) * {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M17 4a3 3 0 0 1 3 3v13l4-1a4 4 0 0 1 5 4v9a8 8 0 0 1-8 8h-6a9 9 0 0 1-8-5l-4-8a3 3 0 0 1 5-4l3 3V7a3 3 0 0 1 3-3z' fill='%23ffffff' stroke='%230FB5A6' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 14 3, pointer !important;
}

/* Mode bacakan teks yang disorot kursor — kursor tanya + penanda elemen aktif.
   Penanda memakai outline & background-color saja agar gradien kartu tetap utuh. */
html.a11y-speak .ifl-root,
html.a11y-speak .ifl-root * { cursor: help; }
.a11y-reading {
  outline: 3px solid #0FB5A6 !important;
  outline-offset: 3px;
  background-color: rgba(15, 181, 166, .12) !important;
  border-radius: 4px;
  box-shadow: 0 0 0 6px rgba(15, 181, 166, .14) !important;
}

/* Penanda fokus keyboard yang tegas */
html.a11y-focus .ifl-root :is(a, button, input, select, textarea, summary, [tabindex]):focus {
  outline: 3px solid #1B4FAE !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 6px rgba(27, 79, 174, .25) !important;
  border-radius: 4px;
}

/* Panduan baca (garis) & masker baca — dibuat oleh a11y.js */
#a11y-guide {
  position: fixed; left: 0; right: 0; height: 14px; z-index: 2147483000;
  pointer-events: none; background: rgba(27, 79, 174, .32);
  border-top: 2px solid #0FB5A6; border-bottom: 2px solid #0FB5A6;
}
.a11y-mask {
  position: fixed; left: 0; right: 0; z-index: 2147483000;
  pointer-events: none; background: rgba(14, 42, 92, .74);
}

/* Lewati ke konten utama — tampil saat difokuskan keyboard */
.a11y-skip {
  position: fixed; top: 8px; left: 8px; z-index: 2147483100;
  transform: translateY(-160%);
  background: #0E2A5C; color: #fff; font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px; font-weight: 700; padding: 11px 18px; border-radius: 12px;
  text-decoration: none; box-shadow: 0 16px 32px -12px rgba(14, 42, 92, .7);
  transition: transform .18s ease;
}
.a11y-skip:focus { transform: translateY(0); color: #fff; outline: 3px solid #0FB5A6; outline-offset: 2px; }
main:focus { outline: none; }

/* ============================================================
   2) UI WIDGET
   ============================================================ */
#a11y-widget {
  position: fixed; left: 22px; bottom: 22px; z-index: 2147483200;
  font-family: 'Inter', system-ui, sans-serif; color: #152540;
}

/* --- Tombol pengapung --- */
.a11yw-fab {
  position: relative; width: 56px; height: 56px; padding: 0; border: none; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  background: linear-gradient(135deg, #1B4FAE, #0FB5A6);
  box-shadow: 0 16px 32px -12px rgba(27, 79, 174, .7), 0 4px 10px -4px rgba(14, 42, 92, .3),
              inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .22s cubic-bezier(.22, 1, .36, 1), box-shadow .28s ease;
}
.a11yw-fab svg { width: 32px; height: 32px; color: #fff; }
.a11yw-fab:hover { transform: translateY(-4px) scale(1.05); box-shadow: 0 24px 44px -14px rgba(15, 181, 166, .85); }
.a11yw-fab:active { transform: translateY(-1px) scale(1); }
.a11yw-fab:focus-visible { outline: 3px solid #0FB5A6; outline-offset: 3px; }
.a11yw-fab::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid rgba(15, 181, 166, .45); animation: a11ywPulse 2.6s ease-out infinite;
}
@keyframes a11ywPulse { 0% { opacity: .7; transform: scale(.9) } 70%, 100% { opacity: 0; transform: scale(1.25) } }
.a11yw-fab.is-open::after { display: none; }

/* --- Panel --- */
.a11yw-panel {
  position: absolute; left: 0; bottom: 70px; width: 356px;
  max-height: min(76vh, 660px); overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border: 1px solid #E1E8F4; border-radius: 18px;
  box-shadow: 0 40px 80px -24px rgba(14, 42, 92, .55), 0 8px 20px -12px rgba(14, 42, 92, .3);
  opacity: 0; visibility: hidden; transform: translateY(12px) scale(.98);
  transition: opacity .2s ease, transform .22s cubic-bezier(.22, 1, .36, 1), visibility .2s;
}
.a11yw-panel.is-open { opacity: 1; visibility: visible; transform: none; }
.a11yw-panel::-webkit-scrollbar { width: 8px }
.a11yw-panel::-webkit-scrollbar-thumb { background: #CBD8EC; border-radius: 999px }

.a11yw-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 11px;
  padding: 16px 16px 14px; background: linear-gradient(135deg, #0E2A5C, #1B4FAE);
  border-radius: 18px 18px 0 0; color: #fff;
}
.a11yw-head-ic {
  width: 38px; height: 38px; flex: none; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, .08));
  border: 1px solid rgba(255, 255, 255, .28);
}
.a11yw-head-ic svg { width: 22px; height: 22px; color: #fff }
.a11yw-head h2 { margin: 0; font-family: 'Sora', system-ui, sans-serif; font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; color: #fff }
.a11yw-head p { margin: 2px 0 0; font-size: 11.5px; color: #A9C6E8; font-weight: 500 }
.a11yw-close {
  margin-left: auto; width: 32px; height: 32px; flex: none; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 9px; color: #fff; cursor: pointer; transition: background .2s ease;
}
.a11yw-close:hover { background: rgba(255, 255, 255, .26) }
.a11yw-close svg { width: 16px; height: 16px }

.a11yw-body { padding: 14px 16px 16px }
.a11yw-sec + .a11yw-sec { margin-top: 16px; padding-top: 14px; border-top: 1px solid #EDF2FA }
.a11yw-sec > h3 {
  margin: 0 0 9px; font-family: 'Sora', system-ui, sans-serif; font-size: 11px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: #5C6B87;
}

/* Ukuran teks */
.a11yw-font { display: flex; align-items: center; gap: 8px }
.a11yw-fbtn {
  flex: 1; height: 42px; background: #F4F7FC; border: 1.5px solid #E1E8F4; border-radius: 12px;
  color: #0E2A5C; font-family: 'Sora', system-ui, sans-serif; font-weight: 700; cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .15s ease;
}
.a11yw-fbtn:hover:not(:disabled) { background: #EAF1FB; border-color: #9CC4F0; transform: translateY(-1px) }
.a11yw-fbtn:disabled { opacity: .4; cursor: default }
.a11yw-fval {
  min-width: 74px; text-align: center; font-family: 'Space Mono', ui-monospace, monospace; font-size: 13px;
  font-weight: 700; color: #0FB5A6;
}

/* Kisi tombol fitur */
.a11yw-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px }
.a11yw-tile {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 7px; text-align: left;
  padding: 11px 11px 10px; background: #fff; border: 1.5px solid #E1E8F4; border-radius: 13px;
  cursor: pointer; font-family: inherit; color: #152540;
  transition: background .18s ease, border-color .18s ease, box-shadow .2s ease, transform .15s ease;
}
.a11yw-tile:hover { border-color: #9CC4F0; background: #F7FBFF; transform: translateY(-1px) }
.a11yw-tile:focus-visible { outline: 2px solid #1B4FAE; outline-offset: 2px }
.a11yw-tile svg { width: 19px; height: 19px; color: #1B4FAE }
.a11yw-tile-lb { font-size: 12.5px; font-weight: 600; line-height: 1.3 }
.a11yw-tile[aria-pressed="true"] {
  background: linear-gradient(135deg, #E1F7F4, #EAF1FB); border-color: #0FB5A6;
  box-shadow: 0 10px 22px -14px rgba(15, 181, 166, .9), inset 0 0 0 1px rgba(15, 181, 166, .18);
}
.a11yw-tile[aria-pressed="true"] svg { color: #0FB5A6 }
.a11yw-tile[aria-pressed="true"] .a11yw-tile-lb { color: #0E2A5C; font-weight: 700 }
.a11yw-tile[aria-pressed="true"]::after {
  content: "✓"; position: absolute; top: 7px; right: 9px; font-size: 11px; font-weight: 800; color: #0FB5A6;
}

/* Aksi baris penuh */
.a11yw-row { display: flex; gap: 8px }
.a11yw-act {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 40px; padding: 0 12px; border-radius: 12px; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  background: #fff; border: 1.5px solid #E1E8F4; color: #0E2A5C;
  transition: background .18s ease, border-color .18s ease, transform .15s ease;
}
.a11yw-act svg { width: 16px; height: 16px; color: #0FB5A6 }
.a11yw-act:hover { border-color: #9CC4F0; background: #F7FBFF; transform: translateY(-1px) }
.a11yw-act.is-danger { color: #D64550 } .a11yw-act.is-danger svg { color: #D64550 }
.a11yw-act.is-danger:hover { border-color: #F0A9A2; background: #FEF5F4 }

.a11yw-hint { margin: 8px 0 0; font-size: 11px; color: #5C6B87; line-height: 1.5 }

.a11yw-foot {
  margin-top: 14px; padding-top: 12px; border-top: 1px solid #EDF2FA;
  font-size: 11px; color: #8A93A6; line-height: 1.55;
}
.a11yw-kbd {
  display: inline-block; padding: 1px 6px; margin: 0 1px; border: 1px solid #D9E1EF;
  border-bottom-width: 2px; border-radius: 5px; background: #F4F7FC;
  font-family: 'Space Mono', ui-monospace, monospace; font-size: 10.5px; color: #0E2A5C;
}

/* Responsif — panel jadi sheet bawah di layar kecil */
@media (max-width: 560px) {
  #a11y-widget { left: 16px; bottom: 16px }
  .a11yw-fab { width: 50px; height: 50px } .a11yw-fab svg { width: 29px; height: 29px }
  .a11yw-panel {
    position: fixed; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 84vh; border-radius: 18px 18px 0 0; border-left: none; border-right: none; border-bottom: none;
  }
  .a11yw-panel.is-open { transform: none }
}

@media (prefers-reduced-motion: reduce) {
  .a11yw-fab, .a11yw-panel, .a11yw-tile, .a11yw-act, .a11yw-fbtn, .a11y-skip { transition: none }
  .a11yw-fab::after { animation: none; display: none }
}
