/*
 * "Maxsus imkoniyatlar sozlamalari" paneli va uning sahifaga ta'sirlari.
 *
 * Markup — `views/layouts/_a11y-panel.php`, mantiq — `web/js/a11y.js`
 * (`app\assets\A11yAsset`).
 *
 * Sahifaga ta'sir qiluvchi qoidalar `<html>` dagi `a11y-*` klasslariga
 * bog'langan va `.page-wrapper` bilan cheklangan — panelning o'zi (u
 * `.page-wrapper` dan tashqarida) o'zgarmay qoladi. Istisno: "Yuqori
 * kontrast" filtri `<html>` ga qo'yiladi — `.page-wrapper` ga qo'yilgan
 * filtr uning ichidagi `position: fixed` elementlarni (header, o'ng panel)
 * sahifa bilan birga siljitib yuborardi.
 */

/* ============================================================
   Panel
   ============================================================ */

.a11y {
    --a11y-navy: #0b2a6f;
    --a11y-blue: #2962ff;
    --a11y-ink: #111827;
    --a11y-tile: #eef3fa;
    --a11y-line: #d3dae6;
    --a11y-fs: 15px;
    --a11y-icon: 26px;

    position: fixed;
    top: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    width: 400px;
    max-width: calc(100vw - 24px);
    overflow: hidden;
    color: var(--a11y-ink);
    font-family: Montserrat, Arial, sans-serif;
    font-size: var(--a11y-fs);
    line-height: 1.35;
    background: #f2f5fa;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(4, 12, 40, .45);
    animation: a11y-in .22s ease;
}

.a11y[hidden] {
    display: none;
}

@keyframes a11y-in {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: none; }
}

.a11y *,
.a11y *::before,
.a11y *::after {
    box-sizing: border-box;
}

.a11y svg {
    flex: none;
}

.a11y button {
    font: inherit;
    cursor: pointer;
}

.a11y :focus-visible {
    outline: 3px solid #ffb400;
    outline-offset: 2px;
}

/* "Katta o'lchamli vidjet" */
.a11y.is-large {
    --a11y-fs: 18px;
    --a11y-icon: 32px;

    width: 480px;
}

/* --- Sarlavha ---------------------------------------------------- */

.a11y__head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: #fff;
    background: var(--a11y-navy);
}

.a11y__close {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    color: var(--a11y-navy);
    background: #fff;
    border: 0;
    border-radius: 50%;
    transition: transform .2s;
}

.a11y__close svg {
    stroke-width: 2.6;
}

.a11y__close:hover {
    transform: rotate(90deg);
}

.a11y__title {
    flex: 1;
    margin: 0;
    color: #fff;
    font-size: calc(var(--a11y-fs) + 3px);
    font-weight: 700;
    line-height: 1.25;
}

.a11y__hotkey {
    display: block;
    font-size: calc(var(--a11y-fs) - 2px);
    font-weight: 500;
    opacity: .85;
}

.a11y__lang {
    position: relative;
    flex: none;
}

.a11y__lang summary {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 10px 7px 14px;
    color: var(--a11y-navy);
    font-size: 14px;
    font-weight: 700;
    list-style: none;
    background: #fff;
    border-radius: 20px;
    cursor: pointer;
}

.a11y__lang summary::-webkit-details-marker {
    display: none;
}

.a11y__lang ul {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 2;
    min-width: 84px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}

.a11y__lang a {
    display: block;
    padding: 7px 10px;
    color: var(--a11y-ink);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
}

.a11y__lang a:hover,
.a11y__lang a[aria-current] {
    color: #fff;
    background: var(--a11y-blue);
}

/* --- Tana -------------------------------------------------------- */

.a11y__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
}

.a11y__large {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 12px;
}

.a11y__large-label {
    display: flex;
    align-items: center;
    gap: 14px;
    font-weight: 500;
}

.a11y__large-label svg,
.a11y__tile svg {
    width: var(--a11y-icon);
    height: var(--a11y-icon);
}

.a11y__switch {
    position: relative;
    flex: none;
    width: 48px;
    height: 26px;
    padding: 0;
    background: #b9c2cf;
    border: 0;
    border-radius: 13px;
    transition: background-color .2s;
}

.a11y__switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
    transition: transform .2s;
}

.a11y__switch[aria-checked="true"] {
    background: var(--a11y-blue);
}

.a11y__switch[aria-checked="true"]::after {
    transform: translateX(22px);
}

.a11y__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--a11y-line);
    border-radius: 12px;
}

.a11y__tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 88px;
    padding: 14px 8px;
    color: var(--a11y-ink);
    text-align: center;
    background: var(--a11y-tile);
    border: 2px solid transparent;
    border-radius: 10px;
    transition: background-color .2s, border-color .2s, color .2s;
}

button.a11y__tile:hover {
    border-color: var(--a11y-blue);
}

.a11y__tile[aria-pressed="true"],
.a11y__tile--stepper.is-changed {
    color: #fff;
    background: var(--a11y-blue);
}

.a11y__stepper {
    display: flex;
    align-items: center;
    gap: 14px;
}

.a11y__stepper button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    color: #fff;
    background: #0b0f1a;
    border: 0;
    border-radius: 50%;
}

.a11y__stepper button svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.6;
}

.a11y__stepper button:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.a11y__tile--stepper.is-changed .a11y__stepper button {
    color: var(--a11y-blue);
    background: #fff;
}

.a11y__stepper output {
    min-width: 44px;
    font-size: calc(var(--a11y-fs) - 2px);
    font-weight: 600;
}

.a11y__reset {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 16px;
    padding: 11px;
    color: #c4161c;
    font-weight: 700;
    background: #fff;
    border: 1.5px solid #c4161c;
    border-radius: 6px;
    transition: background-color .2s, color .2s;
}

.a11y__reset:hover {
    color: #fff;
    background: #c4161c;
}

.a11y__report {
    display: block;
    padding: 13px 16px;
    color: #fff;
    font-weight: 500;
    text-align: center;
    text-decoration: underline;
    background: var(--a11y-navy);
}

.a11y__report:hover {
    color: #fff;
    text-decoration: none;
}

@media (max-width: 575.98px) {
    .a11y,
    .a11y.is-large {
        top: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: none;
        border-radius: 0;
    }

    .a11y__body {
        padding: 12px;
    }

    .a11y__grid {
        gap: 8px;
        padding: 8px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .a11y {
        animation: none;
    }
}

/* ============================================================
   Sahifaga ta'sirlar
   ============================================================ */

html.a11y-contrast {
    filter: contrast(1.5) saturate(1.2);
}

html.a11y-readable-font .page-wrapper *:not(i):not(svg):not(svg *):not([class*="fa-"]):not([class^="flaticon"]) {
    font-family: Verdana, Tahoma, Arial, sans-serif !important;
}

html.a11y-align-left .page-wrapper * {
    text-align: left !important;
}

html.a11y-align-center .page-wrapper * {
    text-align: center !important;
}

html.a11y-align-right .page-wrapper * {
    text-align: right !important;
}

html.a11y-hide-images .page-wrapper img,
html.a11y-hide-images .page-wrapper video,
html.a11y-hide-images .page-wrapper picture {
    visibility: hidden !important;
}

html.a11y-hide-images .page-wrapper,
html.a11y-hide-images .page-wrapper * {
    background-image: none !important;
}

html.a11y-hide-images .page-wrapper .section {
    background-color: #0b1533 !important;
}

html.a11y-highlight-links .page-wrapper a {
    text-decoration: underline !important;
    outline: 2px solid #ffb400 !important;
    outline-offset: 2px;
}

html.a11y-highlight-headings .page-wrapper :is(h1, h2, h3, h4, h5, h6) {
    outline: 3px dashed #2962ff !important;
    outline-offset: 4px;
}

html.a11y-letter-spacing .page-wrapper * {
    letter-spacing: var(--a11y-letter-spacing) !important;
    word-spacing: calc(var(--a11y-letter-spacing) * 2) !important;
}

html.a11y-zoom .page-wrapper {
    zoom: var(--a11y-zoom);
}

/* --- O'qish maskasi ---------------------------------------------- */

.a11y-mask[hidden],
.a11y-magnifier[hidden] {
    display: none;
}

.a11y-mask__top,
.a11y-mask__bottom {
    position: fixed;
    left: 0;
    right: 0;
    z-index: 99990;
    background: rgba(3, 8, 24, .72);
    pointer-events: none;
}

.a11y-mask__top {
    top: 0;
    height: 40vh;
    border-bottom: 3px solid #ffb400;
}

.a11y-mask__bottom {
    top: calc(40vh + 140px);
    bottom: 0;
    border-top: 3px solid #ffb400;
}

/* --- Matn kattalashtirgich --------------------------------------- */

.a11y-magnifier {
    position: fixed;
    z-index: 99995;
    max-width: min(520px, calc(100vw - 32px));
    padding: 14px 18px;
    color: #fff;
    font-family: Verdana, Arial, sans-serif;
    font-size: 26px;
    font-weight: 600;
    line-height: 1.35;
    background: #0b1533;
    border: 2px solid #ffb400;
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
    pointer-events: none;
}
