/* ============================================================
   DISARPUS WONOGIRI — Widget Aksesibilitas
   ------------------------------------------------------------
   Trigger icon di utility bar + panel pengaturan (ukuran teks,
   kontras tinggi, font mudah dibaca, kurangi animasi).
   Preferensi disimpan di localStorage, diterapkan lewat atribut
   data-a11y-* di elemen <html>.
   ============================================================ */

/* -- Trigger button (nempel di utility bar) -- */
.a11y-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.08);
    color: var(--c-text-on-dark, #fff);
    cursor: pointer;
    transition: background var(--tx-fast, 0.15s), border-color var(--tx-fast, 0.15s);
    flex-shrink: 0;
}
.a11y-trigger:hover,
.a11y-trigger[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.55);
}
.a11y-trigger i { font-size: 13px; line-height: 1; }

/* -- Overlay + panel -- */
.a11y-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 14, 8, 0.45);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease;
}
.a11y-overlay.is-open { opacity: 1; visibility: visible; }

.a11y-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%);
    width: min(420px, calc(100% - 32px));
    max-height: min(600px, calc(100vh - 48px));
    overflow-y: auto;
    background: var(--c-cream-surface, #FAF6EB);
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(20, 14, 8, 0.28);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.18s ease, transform 0.18s ease;
    font-family: var(--font-serif, 'Lora', serif);
    color: var(--c-text-primary, #2B1810);
}
.a11y-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%);
}

.a11y-panel__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 22px 4px;
}
.a11y-panel__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display, 'Cormorant Garamond', serif);
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--c-green-deep, #0F4226);
    margin: 0;
}
.a11y-panel__title i { font-size: 20px; }
.a11y-panel__sub {
    font-size: 0.85rem;
    color: var(--c-text-secondary, #5C3A1F);
    margin: 4px 0 0 30px;
}
.a11y-panel__close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--c-text-secondary, #5C3A1F);
    font-size: 18px;
    line-height: 1;
    padding: 4px;
    flex-shrink: 0;
}
.a11y-panel__close:hover { color: var(--c-text-primary, #2B1810); }

.a11y-panel__body { padding: 14px 22px 8px; }

.a11y-group { margin-bottom: 18px; }
.a11y-group__label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.82rem;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--c-brown-ink, #2B1810);
}
.a11y-group__label i { font-size: 16px; color: var(--c-green, #1B5E3F); }

.a11y-choices {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.a11y-choices--2 { grid-template-columns: repeat(2, 1fr); }
.a11y-choice {
    padding: 10px 8px;
    border-radius: 10px;
    border: 1px solid var(--c-cream-border, #C8B79A);
    background: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--c-text-primary, #2B1810);
    cursor: pointer;
    text-align: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.a11y-choice:hover { border-color: var(--c-green, #1B5E3F); }
.a11y-choice[aria-pressed="true"] {
    background: var(--c-green-deep, #0F4226);
    border-color: var(--c-green-deep, #0F4226);
    color: #fff;
}

.a11y-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.03);
    margin-bottom: 10px;
}
.a11y-toggle-row__label {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    font-size: 0.85rem;
    font-weight: 700;
}
.a11y-toggle-row__label i { font-size: 16px; margin-top: 2px; color: var(--c-green, #1B5E3F); }
.a11y-toggle-row__desc {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--c-text-secondary, #5C3A1F);
    margin-top: 2px;
}

.a11y-switch {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: #d8cdb8;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s;
}
.a11y-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.15s;
}
.a11y-switch[aria-checked="true"] { background: var(--c-green-deep, #0F4226); }
.a11y-switch[aria-checked="true"]::after { transform: translateX(18px); }

.a11y-panel__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 22px 18px;
    border-top: 1px solid var(--c-cream-border, #C8B79A);
    margin-top: 6px;
}
.a11y-reset {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    color: var(--c-text-secondary, #5C3A1F);
    font-family: inherit;
}
.a11y-reset:hover { color: var(--c-text-primary, #2B1810); }
.a11y-wcag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--c-blue-mid, #1B4FA3);
}
.a11y-wcag i { color: var(--c-green-bright, #34A853); font-size: 14px; }

/* ============================================================
   EFEK — diterapkan lewat atribut data-a11y-* di <html>
   ============================================================ */

/* Ukuran teks */
html[data-a11y-size="kecil"]         { font-size: 14px; }
html[data-a11y-size="besar"]         { font-size: 18px; }
html[data-a11y-size="sangat-besar"]  { font-size: 20px; }

/* Kontras tinggi — override token warna teks/background secara global */
html[data-a11y-contrast="tinggi"] {
    --c-text-primary: #000000;
    --c-text-secondary: #000000;
    --c-text-muted: #1a1a1a;
    --c-cream-surface: #ffffff;
    --c-cream: #ffffff;
    --c-cream-shade: #ffffff;
    --c-blue-mid: #0033cc;
    --c-blue-electric: #0033cc;
    --c-green: #006633;
    --c-green-mid: #006633;
}
html[data-a11y-contrast="tinggi"] body { background: #fff; }
html[data-a11y-contrast="tinggi"] a { text-decoration: underline; }

/* Font mudah dibaca — Atkinson Hyperlegible */
html[data-a11y-font="mudah"] body,
html[data-a11y-font="mudah"] h1,
html[data-a11y-font="mudah"] h2,
html[data-a11y-font="mudah"] h3,
html[data-a11y-font="mudah"] h4,
html[data-a11y-font="mudah"] p,
html[data-a11y-font="mudah"] a,
html[data-a11y-font="mudah"] span,
html[data-a11y-font="mudah"] li,
html[data-a11y-font="mudah"] button {
    font-family: 'Atkinson Hyperlegible', Arial, sans-serif !important;
}

/* Kurangi animasi */
html[data-a11y-motion="kurangi"] *,
html[data-a11y-motion="kurangi"] *::before,
html[data-a11y-motion="kurangi"] *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

@media (max-width: 480px) {
    .a11y-choices { grid-template-columns: repeat(2, 1fr); }
}
