/*
 * Aksesibilitas Ekosistem Data Sulawesi Barat — stylesheet bersama.
 * Dipakai identik oleh DATA, SATU DATA, Open Data, Satu Peta, dan Satu Dashboard.
 * Semua kelas berawalan .akses- dan mode tampilan dipasang sebagai kelas pada <html>,
 * sehingga tidak bertabrakan dengan CSS aplikasi.
 * Acuan: WCAG 2.2 AA (1.4.3, 1.4.4, 1.4.8, 1.4.10, 1.4.12, 2.3.3, 2.4.7, 2.4.11, 2.5.8).
 */

@font-face { font-family: 'SD Mudah Dibaca'; src: url(font/atkinson-hyperlegible-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'SD Mudah Dibaca'; src: url(font/atkinson-hyperlegible-latin-700-normal.woff2) format('woff2'); font-weight: 600 800; font-display: swap; }
@font-face { font-family: 'SD Disleksia'; src: url(font/opendyslexic-latin-400-normal.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'SD Disleksia'; src: url(font/opendyslexic-latin-700-normal.woff2) format('woff2'); font-weight: 600 800; font-display: swap; }

/* ---------- Utilitas ---------- */
.akses-sr { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0 0 0 0) !important; white-space: nowrap !important; border: 0 !important; }

/* Tautan lompat ke konten: tersembunyi sampai difokus (2.4.1). */
.akses-lompat { position: fixed; left: .75rem; top: -4rem; z-index: 2147483001; padding: .7rem 1.1rem; border-radius: .5rem; background: #0b3a82; color: #fff !important; font-weight: 600; text-decoration: underline; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); transition: top .15s; }
.akses-lompat:focus { top: .75rem; outline: 3px solid #ffd400; outline-offset: 2px; }

/* Indikator fokus dasar: selalu terlihat untuk pengguna keyboard (2.4.7, 2.4.11). */
:focus-visible { outline: 2px solid #1d4ed8; outline-offset: 2px; }
html[data-color-theme="dark"] :focus-visible { outline-color: #8ab4ff; }

/* Target fokus dari tautan lompat tidak perlu bingkai permanen. */
[data-akses-tujuan]:focus { outline: none; }

/* ---------- Tombol aksesibilitas (melayang) ---------- */
.akses-tombol {
  position: fixed; left: max(1rem, env(safe-area-inset-left)); bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 2147482000;
  width: 52px; height: 52px; border-radius: 50%; border: 3px solid #fff; padding: 0;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: #0b3a82; color: #fff; box-shadow: 0 6px 18px rgba(2, 18, 54, .35);
}
.akses-tombol:hover { background: #082c63; }
.akses-tombol:focus-visible { outline: 3px solid #ffd400; outline-offset: 3px; }
.akses-tombol svg { width: 30px; height: 30px; }
.akses-tombol[aria-expanded="true"] { background: #082c63; box-shadow: 0 0 0 4px rgba(11, 58, 130, .3), 0 6px 18px rgba(2, 18, 54, .35); }
.akses-tombol-tanda { position: absolute; top: -3px; right: -3px; width: 16px; height: 16px; border-radius: 50%; background: #16a34a; border: 2px solid #fff; display: none; }
html.akses-ada-ubah .akses-tombol-tanda { display: block; }
@media print { .akses-tombol, .akses-panel, .akses-pemutar, .akses-lompat { display: none !important; } }

/* ---------- Panel pengaturan ---------- */
.akses-panel {
  --ap-bg: #ffffff; --ap-teks: #0f172a; --ap-redup: #475569; --ap-garis: #cbd5e1; --ap-kartu: #f1f5f9; --ap-aktif: #0b3a82; --ap-aktif-bg: #e0eaff;
  position: fixed; left: max(1rem, env(safe-area-inset-left)); bottom: calc(52px + 1.75rem); z-index: 2147482001;
  width: min(390px, calc(100vw - 2rem)); max-height: min(78vh, calc(100vh - 6.5rem)); overflow: auto; overscroll-behavior: contain;
  background: var(--ap-bg); color: var(--ap-teks); border: 1px solid var(--ap-garis); border-radius: 1rem;
  box-shadow: 0 24px 60px rgba(2, 18, 54, .3); font: 400 15px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: normal; word-spacing: normal; text-align: left;
}
html[data-color-theme="dark"] .akses-panel { --ap-bg: #111827; --ap-teks: #f1f5f9; --ap-redup: #cbd5e1; --ap-garis: #374151; --ap-kartu: #1f2937; --ap-aktif: #8ab4ff; --ap-aktif-bg: #1e3a6e; }
.akses-panel[hidden] { display: none; }
/* Panel tetap bisa digulir (roda tetikus, sentuh, keyboard) tetapi batang gulirnya disembunyikan. */
.akses-panel { scrollbar-width: none; -ms-overflow-style: none; }
.akses-panel::-webkit-scrollbar { display: none; width: 0; height: 0; }
.akses-panel * { box-sizing: border-box; font-family: inherit; line-height: 1.4; letter-spacing: normal; word-spacing: normal; }
.akses-kepala { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; background: #0b3a82; color: #fff; border-radius: 1rem 1rem 0 0; }
.akses-kepala h2 { margin: 0; font-size: 1.05rem; font-weight: 700; color: #fff; flex: 1; }
.akses-kepala svg { width: 24px; height: 24px; flex: none; }
.akses-tutup { width: 40px; height: 40px; border-radius: .5rem; border: 0; background: rgba(255, 255, 255, .14); color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.akses-tutup:hover { background: rgba(255, 255, 255, .26); }
.akses-tutup:focus-visible { outline: 3px solid #ffd400; outline-offset: 1px; }
.akses-isi { padding: .4rem 1rem 1rem; }
.akses-bagian { border: 0; margin: .8rem 0 0; padding: 0; min-width: 0; }
.akses-bagian > h3, .akses-bagian > legend { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ap-redup); margin: 0 0 .45rem; padding: 0; }
.akses-baris-ukuran { display: grid; grid-template-columns: 1fr auto 1fr; gap: .4rem; align-items: stretch; }
.akses-nilai { display: flex; align-items: center; justify-content: center; min-width: 4.2rem; font-weight: 700; font-size: 1rem; }
.akses-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 44px; padding: .45rem .7rem;
  border-radius: .6rem; border: 1px solid var(--ap-garis); background: var(--ap-kartu); color: var(--ap-teks);
  font-size: .9rem; font-weight: 600; cursor: pointer; text-align: center;
}
.akses-btn:hover { border-color: var(--ap-aktif); }
.akses-btn:disabled { opacity: .5; cursor: not-allowed; }
.akses-btn svg { width: 18px; height: 18px; flex: none; }
.akses-btn-utama { background: #0b3a82; border-color: #0b3a82; color: #fff; }
html[data-color-theme="dark"] .akses-btn-utama { background: #8ab4ff; border-color: #8ab4ff; color: #0b1220; }
.akses-kisi { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; }
.akses-saklar { position: relative; display: flex; align-items: center; gap: .55rem; min-height: 48px; padding: .5rem .6rem; border-radius: .6rem; border: 1px solid var(--ap-garis); background: var(--ap-kartu); cursor: pointer; font-size: .88rem; font-weight: 600; }
.akses-saklar input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.akses-saklar .akses-indikator { flex: none; width: 34px; height: 20px; border-radius: 10px; background: #94a3b8; position: relative; transition: background .15s; }
.akses-saklar .akses-indikator::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.akses-saklar input:checked + .akses-indikator { background: #15803d; }
.akses-saklar input:checked + .akses-indikator::after { transform: translateX(14px); }
.akses-saklar:has(input:checked) { border-color: #15803d; background: var(--ap-aktif-bg); }
.akses-saklar:has(input:focus-visible) { outline: 3px solid #1d4ed8; outline-offset: 2px; }
html[data-color-theme="dark"] .akses-saklar:has(input:focus-visible) { outline-color: #ffd400; }
.akses-pilihan { display: flex; flex-wrap: wrap; gap: .35rem; }
.akses-pilihan label { position: relative; flex: 1 1 auto; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: .4rem .6rem; border-radius: .6rem; border: 1px solid var(--ap-garis); background: var(--ap-kartu); cursor: pointer; font-size: .85rem; font-weight: 600; text-align: center; }
.akses-pilihan input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.akses-pilihan label:has(input:checked) { border-color: var(--ap-aktif); background: var(--ap-aktif-bg); color: var(--ap-teks); box-shadow: inset 0 0 0 1px var(--ap-aktif); }
.akses-pilihan label:has(input:checked)::before { content: '✓'; margin-right: .3rem; font-weight: 700; }
.akses-pilihan label:has(input:focus-visible) { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.akses-sub { font-size: .82rem; font-weight: 600; margin: .55rem 0 .3rem; color: var(--ap-teks); }
.akses-ket { font-size: .8rem; color: var(--ap-redup); margin: .4rem 0 0; }
.akses-ket-peringatan { color: #92400e !important; background: #fef3c7; border-radius: .5rem; padding: .45rem .6rem; }
html[data-color-theme="dark"] .akses-ket-peringatan { color: #fde68a !important; background: #422006; }
.akses-ket kbd { display: inline-block; padding: 0 .3rem; border-radius: .3rem; border: 1px solid var(--ap-garis); background: var(--ap-kartu); color: var(--ap-teks); font: 600 .75rem/1.6 ui-monospace, monospace; }
.akses-lipat { margin-top: .45rem; border: 1px solid var(--ap-garis); border-radius: .6rem; }
.akses-lipat > summary { cursor: pointer; padding: .55rem .7rem; font-size: .88rem; font-weight: 600; min-height: 44px; display: flex; align-items: center; gap: .4rem; list-style: none; }
.akses-lipat > summary::-webkit-details-marker { display: none; }
.akses-lipat > summary::before { content: '▸'; transition: transform .15s; }
.akses-lipat[open] > summary::before { transform: rotate(90deg); }
.akses-lipat > summary:focus-visible { outline: 3px solid #1d4ed8; outline-offset: -3px; border-radius: .5rem; }
.akses-lipat-isi { padding: 0 .7rem .7rem; }
.akses-lipat-isi .akses-sub { margin-top: .55rem; }
.akses-ket[hidden] { display: none; }
.akses-aksi-baca { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .4rem; }
.akses-kaki { position: sticky; bottom: 0; padding: .75rem 1rem; background: var(--ap-bg); border-top: 1px solid var(--ap-garis); border-radius: 0 0 1rem 1rem; }
.akses-kaki .akses-btn { width: 100%; }
.akses-panel select { width: 100%; min-height: 44px; border-radius: .6rem; border: 1px solid var(--ap-garis); background: var(--ap-kartu); color: var(--ap-teks); padding: .35rem .6rem; font-size: .9rem; }

@media (max-width: 575.98px) {
  .akses-tombol { width: 48px; height: 48px; }
  .akses-panel { left: 0; right: 0; bottom: 0; width: 100%; max-height: 86vh; border-radius: 1rem 1rem 0 0; }
  .akses-kepala { border-radius: 1rem 1rem 0 0; }
  .akses-kaki { border-radius: 0; }
}

/* ---------- Pemutar bacaan (Text-to-Speech) ---------- */
.akses-pemutar { position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 2147482002; display: flex; align-items: center; gap: .5rem; padding: .5rem .6rem .5rem 1rem; max-width: calc(100vw - 7rem); border-radius: 999px; background: #0b3a82; color: #fff; box-shadow: 0 10px 30px rgba(2, 18, 54, .35); font: 600 14px/1.3 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.akses-pemutar[hidden] { display: none; }
.akses-pemutar span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.akses-pemutar button { min-width: 44px; min-height: 40px; border-radius: 999px; border: 0; background: rgba(255, 255, 255, .16); color: #fff; font: inherit; padding: 0 .8rem; cursor: pointer; }
.akses-pemutar button:hover { background: rgba(255, 255, 255, .28); }
.akses-pemutar button:focus-visible { outline: 3px solid #ffd400; outline-offset: 2px; }
.akses-dibaca { outline: 3px solid #f59e0b !important; outline-offset: 3px; background-color: rgba(253, 230, 138, .45) !important; border-radius: 4px; }
html[data-color-theme="dark"] .akses-dibaca { background-color: rgba(180, 120, 0, .35) !important; }
html.akses-klik-baca main *:not(a):not(button):not(input):not(select):not(textarea):not(label):hover { cursor: help; }

/* ---------- Alternatif grafik & peta ---------- */
.akses-alt { margin-top: .6rem; border: 1px solid var(--akses-garis, rgba(100, 116, 139, .35)); border-radius: .6rem; font-size: .875rem; }
.akses-alt > summary { cursor: pointer; padding: .5rem .75rem; font-weight: 600; list-style: none; display: flex; align-items: center; gap: .4rem; min-height: 40px; }
.akses-alt > summary::-webkit-details-marker { display: none; }
.akses-alt > summary::before { content: '▸'; display: inline-block; transition: transform .15s; }
.akses-alt[open] > summary::before { transform: rotate(90deg); }
.akses-alt > summary:focus-visible { outline: 3px solid #1d4ed8; outline-offset: -3px; border-radius: .5rem; }
.akses-alt-isi { padding: 0 .75rem .75rem; }
.akses-ringkasan { margin: 0 0 .5rem; }
.akses-tabel-gulir { max-height: 320px; overflow: auto; border-radius: .4rem; }
.akses-tabel { width: 100%; border-collapse: collapse; font-size: .82rem; }
.akses-tabel caption { caption-side: top; text-align: left; font-weight: 600; padding: 0 0 .35rem; color: inherit; }
.akses-tabel th, .akses-tabel td { padding: .3rem .5rem; border-bottom: 1px solid rgba(100, 116, 139, .25); text-align: left; vertical-align: top; }
.akses-tabel thead th { position: sticky; top: 0; background: var(--akses-kepala-tabel, #eef2f7); font-weight: 700; }
html[data-color-theme="dark"] .akses-tabel thead th { background: #1f2937; }
.akses-tabel td.akses-angka, .akses-tabel th.akses-angka { text-align: right; font-variant-numeric: tabular-nums; }
.akses-tabel button { min-height: 32px; padding: .15rem .5rem; border-radius: .4rem; border: 1px solid rgba(100, 116, 139, .5); background: transparent; color: inherit; cursor: pointer; font-size: .8rem; }
.akses-tabel button:hover { background: rgba(100, 116, 139, .12); }
.akses-tabel button:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 1px; }
.akses-lebih { margin-top: .5rem; }

/* Bidik di tengah peta saat peta difokus lewat keyboard: Enter = periksa objek di titik ini. */
.leaflet-container.akses-peta:focus-visible { outline: 3px solid #1d4ed8 !important; outline-offset: -3px; }
.leaflet-container.akses-peta:focus-visible::after { content: ''; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; z-index: 1000; pointer-events: none;
  background: linear-gradient(#0b3a82, #0b3a82) center/2px 100% no-repeat, linear-gradient(#0b3a82, #0b3a82) center/100% 2px no-repeat; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px #0b3a82; }

/* ======================================================================
 * MODE TAMPILAN (kelas pada <html>)
 * ====================================================================== */

/* Ukuran teks: aplikasi memakai rem (Bootstrap/Limitless), jadi cukup skala akar. */
html.akses-skala { font-size: calc(100% * var(--akses-skala, 1)); }
html.akses-skala .akses-panel, html.akses-skala .akses-pemutar { font-size: calc(15px * min(var(--akses-skala, 1), 1.35)); }
/* Teks diperbesar (1.4.4, 1.4.10): menu & baris alat boleh turun ke baris berikutnya agar tidak terpotong. */
html.akses-skala .navbar > :is(.container, .container-fluid), html.akses-skala .navbar-collapse, html.akses-skala .navbar-nav { flex-wrap: wrap; }
html.akses-skala .navbar-nav { row-gap: .15rem; }
html.akses-skala :is(dt, dd, th, td, .badge, .btn) { overflow-wrap: anywhere; }
html.akses-skala .btn { white-space: normal; }
/* Teks ≥130%: kepala halaman lengket tidak lagi menempel agar tidak menutupi konten (1.4.10). */
html.akses-skala-besar :is(.sticky-top, .navbar.fixed-top) { position: relative !important; }

/* Kontras tinggi: perkuat teks redup, garis, dan tautan; filter kontras ringan untuk grafis. */
html.akses-kontras body { color: #000; }
html.akses-kontras :is(.text-muted, .text-body-secondary, .od-meta, .form-text, small, .small, .page-header-desc, .breadcrumb-item, .text-secondary) { color: #1f2937 !important; opacity: 1 !important; }
html.akses-kontras[data-color-theme="dark"] body { color: #fff; }
html.akses-kontras[data-color-theme="dark"] :is(.text-muted, .text-body-secondary, .od-meta, .form-text, small, .small, .page-header-desc, .breadcrumb-item, .text-secondary) { color: #f1f5f9 !important; }
html.akses-kontras a:not(.btn):not(.nav-link):not(.dropdown-item):not(.navbar-brand) { text-decoration: underline !important; text-underline-offset: .15em; }
html.akses-kontras :is(.card, .od-card, .od-panel, .form-control, .form-select, .table, .btn-light, .sd-widget, .dropdown-menu) { border-color: #475569 !important; }
html.akses-kontras :is(.form-control, .form-select)::placeholder { color: #374151 !important; opacity: 1; }
html.akses-kontras[data-color-theme="dark"] :is(.form-control, .form-select)::placeholder { color: #d1d5db !important; }
html.akses-kontras :is(.btn, .badge) { text-shadow: none !important; }

/* Spasi teks (1.4.12): huruf, kata, paragraf. */
html.akses-spasi-1 body :not(i):not(svg):not(svg *):not(.leaflet-container *):not(code):not(pre) { letter-spacing: .05em !important; word-spacing: .1em !important; }
html.akses-spasi-2 body :not(i):not(svg):not(svg *):not(.leaflet-container *):not(code):not(pre) { letter-spacing: .12em !important; word-spacing: .16em !important; }
html.akses-spasi-2 main p { margin-bottom: 2em !important; }

/* Tinggi baris. */
html.akses-baris-1 body :is(p, li, dd, dt, td, th, label, blockquote, figcaption, summary, legend, .form-text, .od-meta, h1, h2, h3, h4, h5, h6, .small, small) { line-height: 1.6 !important; }
html.akses-baris-2 body :is(p, li, dd, dt, td, th, label, blockquote, figcaption, summary, legend, .form-text, .od-meta, h1, h2, h3, h4, h5, h6, .small, small) { line-height: 1.9 !important; }
html.akses-baris-3 body :is(p, li, dd, dt, td, th, label, blockquote, figcaption, summary, legend, .form-text, .od-meta, h1, h2, h3, h4, h5, h6, .small, small) { line-height: 2.2 !important; }

/* Huruf mudah dibaca / ramah disleksia (ikon Phosphor dan kode tetap memakai hurufnya sendiri). */
html.akses-font-baca body, html.akses-font-baca body :not(i):not([class^="ph-"]):not([class*=" ph-"]):not(code):not(pre):not(kbd):not(.leaflet-container *) { font-family: 'SD Mudah Dibaca', system-ui, sans-serif !important; }
html.akses-font-disleksia body, html.akses-font-disleksia body :not(i):not([class^="ph-"]):not([class*=" ph-"]):not(code):not(pre):not(kbd):not(.leaflet-container *) { font-family: 'SD Disleksia', 'Comic Sans MS', system-ui, sans-serif !important; }

/* Garis bawah tautan. */
html.akses-tautan a:not(.btn), html.akses-tautan .nav-link { text-decoration: underline !important; text-underline-offset: .18em; text-decoration-thickness: .08em; }

/* Penegasan fokus keyboard. */
html.akses-fokus :focus-visible { outline: 4px solid #111827 !important; outline-offset: 2px !important; box-shadow: 0 0 0 7px #ffd400 !important; border-radius: 4px; }
html.akses-fokus[data-color-theme="dark"] :focus-visible { outline-color: #ffd400 !important; box-shadow: 0 0 0 7px #111827 !important; }

/* Kurangi animasi (2.3.3). */
html.akses-gerak *, html.akses-gerak *::before, html.akses-gerak *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }

/* Sembunyikan gambar dekoratif (peta, grafik, logo bertanda informatif tetap tampil). */
html.akses-tanpa-gambar img:is([alt=""], [role="presentation"], [aria-hidden="true"]):not(.leaflet-tile):not(.leaflet-marker-icon):not(.leaflet-container img),
html.akses-tanpa-gambar [data-akses-dekoratif], html.akses-tanpa-gambar svg[data-akses-dekoratif] { visibility: hidden !important; }
html.akses-tanpa-gambar body :not(.leaflet-container):not(.leaflet-container *):not(.form-select):not(.form-check-input):not(.btn-close):not(.akses-tombol):not(.akses-panel *):not(.dropdown-toggle):not(select) { background-image: none !important; }

/* Tampilan sederhana: tanpa bayangan/gradien/elemen promosi, lebar baca nyaman. */
html.akses-sederhana [data-akses-opsional], html.akses-sederhana .sdsr, html.akses-sederhana .sdsr-tab { display: none !important; }
html.akses-sederhana body :not(.akses-tombol):not(.akses-panel):not(.akses-pemutar):not(.leaflet-container *) { box-shadow: none !important; text-shadow: none !important; }
html.akses-sederhana main :is(p, li) { max-width: 75ch; }

/* Pola pada grafik SVG bawaan aplikasi (garis putus-putus berbeda per seri). */
html.akses-pola .sd-g path[stroke]:nth-of-type(2n) { stroke-dasharray: 8 4; }
html.akses-pola .sd-g path[stroke]:nth-of-type(3n) { stroke-dasharray: 2 4; }

@media (prefers-reduced-motion: reduce) {
  .akses-tombol, .akses-saklar .akses-indikator, .akses-saklar .akses-indikator::after, .akses-alt > summary::before, .akses-lompat { transition: none; }
}
@media (forced-colors: active) {
  .akses-tombol, .akses-panel, .akses-pemutar, .akses-btn, .akses-saklar, .akses-pilihan label { border: 2px solid CanvasText; forced-color-adjust: auto; }
  .akses-saklar .akses-indikator { border: 1px solid CanvasText; }
}
