/*
 * Accessibility tools panel (partials/accessibility.blade.php) and the
 * page adjustments it switches on through data-a11y-* attributes on <html>.
 * Adjustments target the page's own top-level blocks (body > :not(.a11y)),
 * so the panel itself never gets zoomed, filtered or hidden.
 */

/* ---------- Floating button ---------- */
.a11y__toggle {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1060;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 0;
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--site-theme, #2460b9);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform 200ms ease-in-out;
}

.a11y__toggle:hover,
.a11y__toggle:focus-visible {
    transform: scale(1.08);
}

/* ---------- Panel ---------- */
.a11y__panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1070;
    display: flex;
    flex-direction: column;
    width: 320px;
    max-width: 100vw;
    background: #f3f4f6;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
    font-family: "Mukta", "Kalimati", sans-serif;
}

.a11y__panel[hidden] {
    display: none;
}

.a11y__head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 14px;
    background: var(--site-theme, #2460b9);
    color: #fff;
}

.a11y__title {
    flex: 1;
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.a11y__icon-btn {
    display: inline-flex;
    padding: 4px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.a11y__icon-btn:hover,
.a11y__icon-btn:focus-visible {
    background: rgba(255, 255, 255, 0.15);
}

.a11y__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 14px;
    overflow-y: auto;
}

.a11y__tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px 10px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: border-color 150ms ease-in-out;
}

.a11y__tool:hover,
.a11y__tool:focus-visible {
    border-color: #bfd3f2;
}

.a11y__tool[aria-pressed="true"] {
    border-color: var(--site-theme, #2460b9);
    color: var(--site-theme, #2460b9);
}

.a11y__label {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
}

.a11y__levels {
    display: flex;
    gap: 4px;
}

.a11y__levels span {
    width: 18px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
}

.a11y__levels span.is-on {
    background: var(--site-theme, #2460b9);
}

/* ---------- Page adjustments ---------- */
html[data-a11y-text-size="1"] body > :not(.a11y) { zoom: 1.1; }
html[data-a11y-text-size="2"] body > :not(.a11y) { zoom: 1.2; }
html[data-a11y-text-size="3"] body > :not(.a11y) { zoom: 1.35; }

/* Contrast, colour filter and saturation are combined into --a11y-filter by the script */
html[data-a11y-filter] body > :not(.a11y) {
    filter: var(--a11y-filter);
}

/* Dark contrast inverts the page; invert photos back so they look normal */
html[data-a11y-contrast="2"],
html[data-a11y-contrast="2"] body {
    background: #000 !important;
}

html[data-a11y-contrast="2"] body > :not(.a11y) :is(img, video, iframe, picture) {
    filter: invert(1) hue-rotate(180deg);
}

html[data-a11y-align="1"] body > :not(.a11y) :is(p, li, h1, h2, h3, h4, h5, h6, td, th, dd, dt, label, blockquote) { text-align: left !important; }
html[data-a11y-align="2"] body > :not(.a11y) :is(p, li, h1, h2, h3, h4, h5, h6, td, th, dd, dt, label, blockquote) { text-align: center !important; }
html[data-a11y-align="3"] body > :not(.a11y) :is(p, li, h1, h2, h3, h4, h5, h6, td, th, dd, dt, label, blockquote) { text-align: right !important; }

html[data-a11y-spacing="1"] body > :not(.a11y) * { letter-spacing: 0.05em !important; word-spacing: 0.1em !important; }
html[data-a11y-spacing="2"] body > :not(.a11y) * { letter-spacing: 0.1em !important; word-spacing: 0.2em !important; }
html[data-a11y-spacing="3"] body > :not(.a11y) * { letter-spacing: 0.15em !important; word-spacing: 0.3em !important; }

html[data-a11y-line-height="1"] body > :not(.a11y) * { line-height: 1.75 !important; }
html[data-a11y-line-height="2"] body > :not(.a11y) * { line-height: 2 !important; }
html[data-a11y-line-height="3"] body > :not(.a11y) * { line-height: 2.5 !important; }

/* Latin text changes font; Nepali text falls back to Mukta */
html[data-a11y-font="1"] body > :not(.a11y) :not(i, .fa) { font-family: Arial, Helvetica, "Mukta", sans-serif !important; }
html[data-a11y-font="2"] body > :not(.a11y) :not(i, .fa) { font-family: Georgia, "Times New Roman", "Mukta", serif !important; }
html[data-a11y-font="3"] body > :not(.a11y) :not(i, .fa) { font-family: Verdana, Tahoma, "Mukta", sans-serif !important; }

html[data-a11y-dyslexia="1"] body > :not(.a11y) :not(i, .fa) {
    font-family: Verdana, Tahoma, "Mukta", sans-serif !important;
    font-style: normal !important;
    letter-spacing: 0.06em !important;
    word-spacing: 0.16em !important;
    line-height: 1.8 !important;
}

html[data-a11y-cursor="1"],
html[data-a11y-cursor="1"] * {
    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 d='M4 2l15 9-6.5 1.7L9.5 20z' fill='%23000' stroke='%23fff' stroke-width='1.4' stroke-linejoin='round'/%3E%3C/svg%3E") 8 4, auto !important;
}

html[data-a11y-hide-images="1"] body > :not(.a11y) :is(img, video, picture, svg image) {
    visibility: hidden !important;
}

html[data-a11y-hide-images="1"] body > :not(.a11y) [style*="background-image"] {
    background-image: none !important;
}

html[data-a11y-pause="1"] body > :not(.a11y),
html[data-a11y-pause="1"] body > :not(.a11y) * {
    animation-play-state: paused !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

@media (max-width: 575.98px) {
    .a11y__toggle {
        left: 12px;
        bottom: 12px;
        width: 46px;
        height: 46px;
    }
}

@media print {
    .a11y {
        display: none !important;
    }
}
