/**
 * Widget Aksesibilitas Disabilitas (Self-Hosted)
 * Khusus Website Satpol PP / Pemerintah Daerah
 * 100% Bebas Blokir Firewall & Mandiri
 */

/* ==========================================================================
   1. TRIGGER BUTTON (TOMBOL MENGAMBANG)
   ========================================================================== */
.a11y-trigger-btn {
    position: fixed;
    bottom: 25px;
    left: 25px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
    color: #ffffff;
    border: 2px solid #ffffff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
    padding: 0;
}

.a11y-trigger-btn:hover {
    transform: scale(1.1);
    background: linear-gradient(135deg, #0b5ed7, #084298);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.5);
}

.a11y-trigger-btn svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
}

/* Tooltip */
.a11y-trigger-btn::after {
    content: "Fitur Disabilitas";
    position: absolute;
    left: 62px;
    background: rgba(33, 37, 41, 0.95);
    color: #ffffff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.2s ease;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.a11y-trigger-btn:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* ==========================================================================
   2. PANEL / MODAL MENU AKSEBILITAS
   ========================================================================== */
.a11y-panel {
    position: fixed;
    bottom: 85px;
    left: 25px;
    width: 360px;
    max-width: calc(100vw - 40px);
    max-height: 80vh;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    z-index: 999999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border: 1px solid rgba(0, 0, 0, 0.1);
    animation: a11yFadeIn 0.25s ease-out forwards;
}

.a11y-panel.a11y-active {
    display: flex;
}

@keyframes a11yFadeIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.a11y-header {
    background: linear-gradient(135deg, #0d6efd, #0b5ed7);
    color: #ffffff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.a11y-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.a11y-header svg {
    width: 20px;
    height: 20px;
    fill: #ffffff;
}

.a11y-close-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.a11y-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Body */
.a11y-body {
    padding: 15px;
    overflow-y: auto;
    max-height: calc(80vh - 120px);
}

.a11y-section {
    margin-bottom: 16px;
}

.a11y-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    margin-bottom: 8px;
}

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

.a11y-btn {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 10px 8px;
    cursor: pointer;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #333333;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    width: 100%;
}

.a11y-btn:hover {
    background: #e9ecef;
    border-color: #ced4da;
    color: #0b5ed7;
}

.a11y-btn.a11y-btn-active {
    background: #e7f1ff;
    border-color: #0d6efd;
    color: #0d6efd;
    font-weight: 700;
    box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25);
}

.a11y-btn svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* Highlight elemen yang sedang dibacakan saat kursor hover */
.a11y-speaking-highlight {
    outline: 2px solid #0d6efd !important;
    outline-offset: 2px !important;
    background-color: rgba(13, 110, 253, 0.12) !important;
    border-radius: 4px !important;
    transition: outline 0.15s ease, background-color 0.15s ease !important;
}

/* Footer / Reset Button */
.a11y-footer {
    padding: 10px 15px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 8px;
}

.a11y-reset-btn {
    width: 100%;
    background: #dc3545;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s;
}

.a11y-reset-btn:hover {
    background: #bb2d3b;
}

/* ==========================================================================
   3. EFEK-EFEK AKSEBILITAS PADA HALAMAN (CLASSES PADA HTML / BODY)
   ========================================================================== */

/* A. Ukuran Font & Zoom */
html.a11y-font-neg-1 body {
    zoom: 0.88;
}
html.a11y-font-1 body {
    zoom: 1.15;
}
html.a11y-font-2 body {
    zoom: 1.30;
}
html.a11y-font-3 body {
    zoom: 1.50;
}

/* Fallback teks */
html.a11y-font-neg-1 p, html.a11y-font-neg-1 a, html.a11y-font-neg-1 li, html.a11y-font-neg-1 td, html.a11y-font-neg-1 th {
    font-size: 0.9em !important;
}
html.a11y-font-1 p, html.a11y-font-1 a, html.a11y-font-1 li, html.a11y-font-1 td, html.a11y-font-1 th {
    font-size: 1.15em !important;
}
html.a11y-font-2 p, html.a11y-font-2 a, html.a11y-font-2 li, html.a11y-font-2 td, html.a11y-font-2 th {
    font-size: 1.3em !important;
}
html.a11y-font-3 p, html.a11y-font-3 a, html.a11y-font-3 li, html.a11y-font-3 td, html.a11y-font-3 th {
    font-size: 1.5em !important;
}

/* Kunci ukuran panel widget agar tetap proporsional dan tidak terdistorsi */
#a11y-panel, #a11y-trigger, #a11y-reading-line {
    zoom: 1 !important;
}

/* B. Kontras Tinggi (Latar Gelap Teks Terang) */
html.a11y-high-contrast {
    background-color: #000000 !important;
    color: #ffffff !important;
}
html.a11y-high-contrast body,
html.a11y-high-contrast .main,
html.a11y-high-contrast .bg-light,
html.a11y-high-contrast .bg-white,
html.a11y-high-contrast .header,
html.a11y-high-contrast .footer {
    background: #000000 !important;
    color: #ffffff !important;
}
html.a11y-high-contrast h1,
html.a11y-high-contrast h2,
html.a11y-high-contrast h3,
html.a11y-high-contrast h4,
html.a11y-high-contrast h5,
html.a11y-high-contrast h6,
html.a11y-high-contrast p,
html.a11y-high-contrast span,
html.a11y-high-contrast li {
    color: #ffffff !important;
}
html.a11y-high-contrast a {
    color: #ffeb3b !important;
    text-decoration: underline !important;
}
html.a11y-high-contrast .card,
html.a11y-high-contrast .entry__article,
html.a11y-high-contrast .widget {
    background: #111111 !important;
    border: 1px solid #444444 !important;
}

/* C. Mode Monokrom / Grayscale */
html.a11y-grayscale {
    filter: grayscale(100%) !important;
}

/* D. Balik Warna / Invert */
html.a11y-invert {
    filter: invert(100%) hue-rotate(180deg) !important;
}
html.a11y-invert img,
html.a11y-invert video,
html.a11y-invert .a11y-panel,
html.a11y-invert .a11y-trigger-btn {
    filter: invert(100%) hue-rotate(180deg) !important;
}

/* E. Sorot Tautan (Highlight Links) */
html.a11y-highlight-links a {
    background-color: #ffeb3b !important;
    color: #000000 !important;
    text-decoration: underline !important;
    font-weight: 700 !important;
    padding: 1px 3px !important;
    border-radius: 3px !important;
    box-shadow: 0 0 3px rgba(0,0,0,0.3) !important;
}

/* F. Font Ramah Disleksia */
html.a11y-dyslexic,
html.a11y-dyslexic * {
    font-family: "Comic Sans MS", "Arial Rounded MT Bold", sans-serif !important;
    letter-spacing: 0.05em !important;
    word-spacing: 0.1em !important;
    line-height: 1.8 !important;
}

/* G. Kursor Besar */
html.a11y-big-cursor,
html.a11y-big-cursor * {
    cursor: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewport='0 0 48 48' style='fill:black;stroke:white;stroke-width:2px;'><polygon points='0,0 0,36 10,26 20,44 26,41 16,23 30,23'/></svg>"), auto !important;
}

/* H. Garis Panduan Membaca (Reading Line) */
.a11y-reading-line {
    position: fixed;
    left: 0;
    width: 100vw;
    height: 4px;
    background: #0d6efd;
    box-shadow: 0 0 10px rgba(13, 110, 253, 0.8);
    pointer-events: none;
    z-index: 999997;
    display: none;
    transform: translateY(-50%);
}
html.a11y-reading-guide .a11y-reading-line {
    display: block;
}

/* Responsive Mobile */
@media (max-width: 576px) {
    .a11y-panel {
        bottom: 80px;
        left: 10px;
        width: calc(100vw - 20px);
    }
    .a11y-trigger-btn {
        bottom: 20px;
        left: 15px;
        width: 46px;
        height: 46px;
    }
}
