/*
 * Erişilebilirlik menüsü — tüm sayfalarda sağ alt köşede.
 * database-connect.php → kaInjectA11yMenu her tam HTML sayfasına ekler; panel
 * ka-a11y-menu.js tarafından kurulur. Seçenekler <html>'e ka-a11y-<seçenek>
 * sınıfı olarak yazılır. Panelin kendisi (.ka-a11y) sayfa etkilerinin
 * (büyük metin, satır aralığı, disleksi yazısı…) dışında tutulur.
 * Vurgu rengi kurum paletini (--ka-primary) izler; tema yüklü olmayan
 * sayfalarda (tanıtım sayfası) UAB lacivertine düşer.
 */

.ka-a11y {
    --a11y-accent: var(--ka-primary, #073f82);
    --a11y-accent-ink: var(--ka-primary-strong, #073f82);
    --a11y-on-accent: var(--ka-on-primary, #ffffff);
    --a11y-accent-soft: color-mix(in srgb, var(--a11y-accent) 10%, var(--a11y-surface));
    --a11y-accent-line: color-mix(in srgb, var(--a11y-accent) 45%, var(--a11y-surface));
    --a11y-surface: #ffffff;
    --a11y-tile: #f6f7fb;
    --a11y-tile-hover: #eef1f8;
    --a11y-line: #e3e6ef;
    --a11y-ink: #141a2e;
    --a11y-muted: #5d6478;
    --a11y-switch: #c9cedb;
    --a11y-backdrop: transparent;
    font-family: var(--ka-font-family, "Overpass", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
    font-size: 14px;
    line-height: 1.35;
    letter-spacing: normal;
    word-spacing: normal;
    text-align: left;
    color: var(--a11y-ink);
}
html.dark .ka-a11y {
    --a11y-surface: #171c2b;
    --a11y-tile: #1f2537;
    --a11y-tile-hover: #262d42;
    --a11y-line: #2e3550;
    --a11y-ink: #eef0f7;
    --a11y-muted: #a2a9bd;
    --a11y-switch: #4a5270;
    --a11y-accent-soft: color-mix(in srgb, var(--a11y-accent) 22%, var(--a11y-surface));
}
.ka-a11y *, .ka-a11y *::before, .ka-a11y *::after { box-sizing: border-box; }
.ka-a11y button { font: inherit; letter-spacing: normal; text-transform: none; margin: 0; }
.ka-a11y svg { display: block; flex: none; }

/* ---------- Açma düğmesi ---------- */
.ka-a11y-toggle {
    position: fixed; right: 20px; bottom: 20px; z-index: var(--ka-z-navbar, 1020);
    width: 48px; height: 48px; padding: 0;
    display: grid; place-items: center;
    border: 3px solid var(--a11y-surface); border-radius: 50%;
    background: var(--a11y-accent); color: var(--a11y-on-accent);
    outline: 1px solid var(--a11y-accent-line);
    cursor: pointer;
    transition: transform .2s ease, background-color .2s ease;
}
.ka-a11y-toggle svg { width: 26px; height: 26px; }
.ka-a11y-toggle:hover { transform: translateY(-2px) scale(1.05); }
.ka-a11y-toggle[aria-expanded="true"] { transform: scale(.94); }
.ka-a11y-count {
    position: absolute; top: -4px; right: -4px;
    min-width: 20px; height: 20px; padding: 0 5px;
    display: none; align-items: center; justify-content: center;
    border: 2px solid var(--a11y-surface); border-radius: 999px;
    background: #f08a00; color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
    font-variant-numeric: tabular-nums;
}
.ka-a11y-count.is-visible { display: inline-flex; }

.ka-a11y :focus-visible { outline: 3px solid var(--a11y-accent); outline-offset: 2px; }
.ka-a11y-toggle:focus-visible { outline: 3px solid var(--a11y-accent); outline-offset: 3px; }

/* ---------- Panel ---------- */
.ka-a11y-backdrop {
    position: fixed; inset: 0; z-index: calc(var(--ka-z-drawer, 1040) - 1);
    background: var(--a11y-backdrop);
    opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s;
}
.ka-a11y-panel {
    position: fixed; top: 16px; right: 16px; bottom: 16px; z-index: var(--ka-z-drawer, 1040);
    width: 392px; max-width: calc(100vw - 32px);
    display: flex; flex-direction: column;
    background: var(--a11y-surface); color: var(--a11y-ink);
    border: 1px solid var(--a11y-line); border-radius: 22px;
    overflow: hidden;
    opacity: 0; visibility: hidden; transform: translateX(24px) scale(.98); transform-origin: bottom right;
    transition: opacity .22s ease, transform .28s cubic-bezier(.2, .8, .2, 1), visibility .28s;
}
.ka-a11y.is-open .ka-a11y-panel { opacity: 1; visibility: visible; transform: none; }
.ka-a11y.is-open .ka-a11y-backdrop { opacity: 1; visibility: visible; }

.ka-a11y-head {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 18px 16px; border-bottom: 1px solid var(--a11y-line);
}
.ka-a11y-mark {
    width: 42px; height: 42px; flex: none; border-radius: 13px;
    display: grid; place-items: center;
    background: var(--a11y-accent); color: var(--a11y-on-accent);
}
.ka-a11y-mark svg { width: 24px; height: 24px; }
.ka-a11y-heading { min-width: 0; flex: 1; }
.ka-a11y-title { margin: 0; font-size: 17px; line-height: 1.25; font-weight: 700; color: var(--a11y-ink); }
.ka-a11y-sub { margin: 3px 0 0; font-size: 12.5px; color: var(--a11y-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ka-a11y-kbd {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 1px 6px; border: 1px solid var(--a11y-line); border-bottom-width: 2px; border-radius: 6px;
    background: var(--a11y-tile); color: var(--a11y-ink); font-size: 11px; font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ka-a11y-close {
    width: 36px; height: 36px; padding: 0; flex: none;
    display: grid; place-items: center;
    border: 1px solid var(--a11y-line); border-radius: 50%;
    background: var(--a11y-surface); color: var(--a11y-muted); cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.ka-a11y-close:hover { background: var(--a11y-tile); color: var(--a11y-ink); }
.ka-a11y-close svg { width: 18px; height: 18px; }

.ka-a11y-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px 18px 18px; }
.ka-a11y-section { padding-top: 14px; }
.ka-a11y-section[hidden] { display: none; }
.ka-a11y-section-title {
    margin: 0 0 10px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
    color: var(--a11y-muted);
}
.ka-a11y-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }

/* ---------- Seçenek kutucuğu ---------- */
.ka-a11y-tile {
    position: relative; min-height: 88px; padding: 12px;
    display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 10px;
    border: 1px solid transparent; border-radius: 14px;
    background: var(--a11y-tile); color: var(--a11y-ink);
    font-size: 13.5px; font-weight: 600; line-height: 1.25; text-align: left;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}
.ka-a11y-tile[hidden] { display: none; }
.ka-a11y-tile:hover { background: var(--a11y-tile-hover); }
.ka-a11y-tile--wide { grid-column: span 2; min-height: 0; flex-direction: row; align-items: center; justify-content: flex-start; }
.ka-a11y-tile--wide .ka-a11y-tile-label { flex: 1; }
.ka-a11y-icon {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: var(--a11y-surface); color: var(--a11y-accent-ink);
    border: 1px solid var(--a11y-line);
    transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.ka-a11y-icon svg { width: 18px; height: 18px; }
.ka-a11y-tile-label { display: block; padding-right: 30px; }
.ka-a11y-tile--wide .ka-a11y-tile-label { padding-right: 0; }

/* Sağ üstteki küçük anahtar: açık/kapalı durumu biçimle de gösterir */
.ka-a11y-switch {
    position: absolute; top: 14px; right: 12px;
    width: 26px; height: 16px; border-radius: 999px; background: var(--a11y-switch);
    transition: background-color .15s ease;
}
.ka-a11y-switch::after {
    content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
    background: #fff; transition: transform .18s ease;
}
/* Geniş kutucukta anahtar akışta durur ama topuzu kendine göre konumlansın diye relative kalır */
.ka-a11y-tile--wide .ka-a11y-switch { position: relative; top: auto; right: auto; flex: none; margin-left: auto; }

.ka-a11y-tile.is-active { background: var(--a11y-accent-soft); border-color: var(--a11y-accent-line); }
.ka-a11y-tile.is-active .ka-a11y-icon { background: var(--a11y-accent); border-color: var(--a11y-accent); color: var(--a11y-on-accent); }
.ka-a11y-tile.is-active .ka-a11y-switch { background: var(--a11y-accent); }
.ka-a11y-tile.is-active .ka-a11y-switch::after { transform: translateX(10px); }

/* Sesli okuma kutucuğunda oynat/durdur */
.ka-a11y-play {
    width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--a11y-accent); color: var(--a11y-on-accent);
}
.ka-a11y-play svg { width: 14px; height: 14px; }
.ka-a11y-play .is-stop { display: none; }
.ka-a11y-tile.is-active .ka-a11y-play .is-play { display: none; }
.ka-a11y-tile.is-active .ka-a11y-play .is-stop { display: block; }

/* ---------- Alt çubuk ---------- */
.ka-a11y-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 18px; border-top: 1px solid var(--a11y-line); background: var(--a11y-surface);
}
.ka-a11y-status { font-size: 12.5px; color: var(--a11y-muted); font-variant-numeric: tabular-nums; }
.ka-a11y-reset {
    min-height: 40px; padding: 0 14px;
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--a11y-line); border-radius: 12px;
    background: var(--a11y-surface); color: var(--a11y-ink);
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}
.ka-a11y-reset svg { width: 16px; height: 16px; }
.ka-a11y-reset:hover:not(:disabled) { background: var(--a11y-tile); border-color: var(--a11y-accent-line); }
.ka-a11y-reset:disabled { opacity: .5; cursor: default; }

/* ---------- Dar ekran: alttan açılan sayfa ---------- */
@media (max-width: 640px) {
    .ka-a11y { --a11y-backdrop: rgba(12, 18, 36, .4); }
    .ka-a11y-toggle { right: 14px; bottom: 14px; width: 46px; height: 46px; }
    .ka-a11y-panel {
        top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: none; max-height: 88vh;
        border-radius: 22px 22px 0 0; border-bottom: 0;
        transform: translateY(32px); transform-origin: bottom center;
    }
    .ka-a11y-head { padding-top: 22px; position: relative; }
    .ka-a11y-head::before {
        content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px;
        border-radius: 999px; background: var(--a11y-line);
    }
    .ka-a11y-section--desktop { display: none; }
    .ka-a11y-kbd { display: none; }
}

/* ===== Sayfa etkileri ===== */

/* Renk süzgeçleri: kontrast + doygunluk birlikte çalışsın diye tek filter'da birleşir */
html.ka-a11y-contrast { filter: invert(1) hue-rotate(180deg) var(--ka-a11y-sat, ); }
html:not(.ka-a11y-contrast).ka-a11y-desaturate,
html:not(.ka-a11y-contrast).ka-a11y-low-saturation,
html:not(.ka-a11y-contrast).ka-a11y-high-saturation { filter: var(--ka-a11y-sat); }
html.ka-a11y-desaturate { --ka-a11y-sat: saturate(0); }
html.ka-a11y-low-saturation { --ka-a11y-sat: saturate(.5); }
html.ka-a11y-high-saturation { --ka-a11y-sat: saturate(2); }
/* Kontrastta fotoğraf, video ve menünün kendisi ters dönmesin */
html.ka-a11y-contrast img,
html.ka-a11y-contrast video,
html.ka-a11y-contrast picture,
html.ka-a11y-contrast [style*="background-image"],
html.ka-a11y-contrast .ka-a11y-panel,
html.ka-a11y-contrast .ka-a11y-toggle { filter: invert(1) hue-rotate(180deg); }
html.ka-a11y-contrast .ka-a11y-panel img { filter: none; }

/* Fosforlu kalem: metnin rengine dokunmadan sarı vurgu, kalın alt çizgi ve yumuşak çerçeve.
   Vurgu background-image katmanında; düğme görünümlü bağlantının kendi zemin rengi altta kalır. */
html.ka-a11y-highlight-links a:not(.ka-a11y a) {
    --ka-a11y-mark: rgba(255, 200, 0, .2);
    background-image: linear-gradient(var(--ka-a11y-mark), var(--ka-a11y-mark)) !important;
    outline: 2px solid #f2b705 !important; outline-offset: 2px; border-radius: 6px;
    text-decoration: underline !important; text-decoration-color: #f2b705 !important;
    text-decoration-thickness: 2px !important; text-underline-offset: 3px !important;
}
html.ka-a11y-highlight-links a:not(.ka-a11y a):hover,
html.ka-a11y-highlight-links a:not(.ka-a11y a):focus-visible { --ka-a11y-mark: rgba(255, 200, 0, .38); }
html.dark.ka-a11y-highlight-links a:not(.ka-a11y a) { --ka-a11y-mark: rgba(255, 200, 0, .16); }

html.ka-a11y-remove-images img:not(.ka-a11y img),
html.ka-a11y-remove-images picture,
html.ka-a11y-remove-images video { visibility: hidden !important; }
html.ka-a11y-remove-images [style*="background-image"] { background-image: none !important; }

html.ka-a11y-bigger-text body > :not(.ka-a11y):not(script):not(style) { zoom: 1.2; }

html.ka-a11y-align-text-left body :not(.ka-a11y, .ka-a11y *) { text-align: left !important; }

html.ka-a11y-line-height body :not(.ka-a11y, .ka-a11y *) { line-height: 2 !important; }

html.ka-a11y-dyslexic-friendly body,
html.ka-a11y-dyslexic-friendly body :is(p, a, li, label, button, input, textarea, select, td, th, h1, h2, h3, h4, h5, h6, blockquote, figcaption, dt, dd):not(.ka-a11y, .ka-a11y *) {
    font-family: Verdana, Tahoma, "Comic Sans MS", Arial, sans-serif !important;
    letter-spacing: .05em !important;
    word-spacing: .16em !important;
}

html.ka-a11y-bigger-cursor,
html.ka-a11y-bigger-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cpath d='M6 3l30 27-13 1 7 14-6 3-7-14-11 9z' fill='%23000' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 6 3, auto !important;
}

/* Okuma kılavuzu, okuma maskesi ve mavi ışık süzgeci: tıklamayı engellemeyen üst katmanlar */
.ka-a11y-guide,
.ka-a11y-mask,
.ka-a11y-bluelight { position: fixed; pointer-events: none; display: none; z-index: calc(var(--ka-z-lightbox, 1500) + 10); }
.ka-a11y-guide {
    left: 50%; top: -40px; width: 70vw; min-width: 200px; height: 10px;
    border: 2px solid var(--a11y-accent); border-radius: 999px; background: #fff;
    transform: translate(-50%, -50%);
}
.ka-a11y-mask { left: 0; right: 0; background: rgba(8, 12, 24, .62); }
.ka-a11y-mask--top { top: 0; }
.ka-a11y-mask--bottom { bottom: 0; }
.ka-a11y-bluelight { inset: 0; background: #ffe9b3; mix-blend-mode: multiply; opacity: .75; }
html.ka-a11y-reading-guide .ka-a11y-guide,
html.ka-a11y-reading-mask .ka-a11y-mask,
html.ka-a11y-blue-light-filter .ka-a11y-bluelight { display: block; }

/* Sesli okuma sırasında okunan alan */
.ka-a11y-speaking { outline: 3px solid var(--ka-primary, #073f82) !important; outline-offset: 2px; }

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

@media (prefers-reduced-motion: reduce) {
    .ka-a11y-toggle, .ka-a11y-panel, .ka-a11y-backdrop, .ka-a11y-tile, .ka-a11y-switch::after { transition: none; }
    .ka-a11y-toggle:hover { transform: none; }
}
