/* =====================================================================
   Wulpio - dostępność (WCAG 2.1 AA / 2.2 AA tam, gdzie to tanie)
   Ładowane jako OSTATNI arkusz we wszystkich układach (public, auth, aplikacja).
   1. Poprawki globalne: fokus, link „Przejdź do treści”, ruch, cele dotykowe
   2. Pływający przycisk i panel dostępności
   3. Tryby panelu (klasy na <html> ustawiane przez views/a11y/_head.php i a11y.js)
   ===================================================================== */
:root {
    --a11y-focus: #5233a8;          /* 7,1:1 na białym, 3:1+ na jasnych tłach */
    --a11y-focus-light: #fff;       /* fokus na ciemnych tłach */
    --a11y-ink: #1d1534;
}

/* ---------- 1. Fokus widoczny zawsze (2.4.7, kontrast 3:1 - 1.4.11) ---------- */
:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }
body.public :focus-visible { outline-color: #c24e00; }  /* lisi pomarańcz w wersji o kontraście 4,8:1 */
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--a11y-focus); outline-offset: 1px; }
/* ciemne tła: jasny obrys */
:is(.sidebar-promo, .acc-save, .lp-dark, .lp-cta-band, .lp-footer-dark, .stats-colorful > .stat:first-child, .role-admin, .tabs a.active, .wchat-head) :focus-visible,
body.app .tabs a.active:focus-visible { outline-color: var(--a11y-focus-light); box-shadow: 0 0 0 5px var(--a11y-ink); }
/* elementy, które wcześniej gasiły obrys bez zamiennika */
.ins-bar-link:focus-visible, .ins-seg:focus-visible { outline: 3px solid var(--a11y-focus) !important; outline-offset: 2px; }
summary:focus-visible { outline: 3px solid var(--a11y-focus); outline-offset: 2px; }
/* przewijane tabele dostępne z klawiatury (a11y.js nadaje tabindex) */
[data-a11y-scroll]:focus-visible { outline-offset: -3px; }

/* ---------- Link „Przejdź do treści” (2.4.1) ---------- */
.a11y-skip, .lp-skip {
    position: fixed !important; left: 12px; top: 12px; z-index: 2000; transform: translateY(-160%);
    padding: 12px 18px; border-radius: 12px; background: var(--a11y-ink); color: #fff !important; font-weight: 600;
    text-decoration: underline !important; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .6);
}
.a11y-skip:focus, .lp-skip:focus { transform: none; outline: 3px solid #ffd23f; outline-offset: 2px; }
main:focus { outline: none; } /* cel linku pomijającego (tabindex=-1), nie element interaktywny */

/* ---------- Tekst tylko dla czytników ekranu ---------- */
.a11y-sr-inline { display: inline-block; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; vertical-align: top; }
.a11y-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---------- Cele dotykowe min. 24 x 24 px (2.5.8) ---------- */
.link, button.link { min-height: 24px; }
.pill a, .lg-anchor, .tag a { display: inline-block; min-width: 24px; min-height: 24px; }
input[type=checkbox], input[type=radio] { min-width: 18px; min-height: 18px; }

/* ---------- Zmniejszony ruch (2.3.3 / preferencje systemu) ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto !important; }
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}

/* =====================================================================
   2. Przycisk i panel dostępności
   ===================================================================== */
.a11y-fab {
    position: fixed; z-index: 56; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
    display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
    background: var(--a11y-ink); color: #fff; cursor: pointer;
    box-shadow: 0 0 0 2px #fff, 0 8px 22px -8px rgba(29, 21, 52, .55); transition: transform .2s, background .2s;
}
.a11y-fab .ic { width: 26px; height: 26px; stroke-width: 1.7; }
.a11y-fab:hover { background: #5233a8; transform: translateY(-2px); }
.a11y-fab:focus-visible { outline: 3px solid #c24e00; outline-offset: 3px; }
.a11y-fab.is-active::after { content: ""; position: absolute; top: 1px; right: 1px; width: 11px; height: 11px; border-radius: 50%; background: #ffd23f; box-shadow: 0 0 0 2px var(--a11y-ink); }
/* public / logowanie: nad okrągłym przyciskiem cookies (.cmp-fab, lewy dół) */
body:has(.cmp-fab:not([hidden])) .a11y-fab { bottom: calc(74px + env(safe-area-inset-bottom)); }
/* aplikacja (komputer): w lewym dolnym rogu treści, obok menu bocznego; czat „Zapytaj Wulpio” jest po prawej */
body.app .a11y-fab { left: calc(var(--sidebar-w, 264px) + 16px); bottom: 16px; width: 40px; height: 40px; }
body.app .a11y-fab .ic { width: 24px; height: 24px; }
/* tymczasowe banery (zgody, instalacja) zasłaniają lewy dół - przycisk wraca po ich zamknięciu;
   panel jest wtedy dostępny ze stopki, menu konta i skrótem Alt+Shift+A */
body.cmp-pending .a11y-fab, body.has-install-banner .a11y-fab, body.cmp-modal-open .a11y-fab, body.sidebar-open .a11y-fab { display: none; }
@media (max-width: 960px) {
    body.app .a11y-fab { left: 12px; bottom: calc(84px + env(safe-area-inset-bottom)); }
    body.app:has(.fab-store) .a11y-fab { bottom: calc(146px + env(safe-area-inset-bottom)); }
}
@media (max-width: 640px) {
    .a11y-fab { left: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); width: 42px; height: 42px; }
    body:has(.cmp-fab:not([hidden])) .a11y-fab { bottom: calc(64px + env(safe-area-inset-bottom)); }
    body.app .a11y-fab { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media print { .a11y-fab, .a11y-panel { display: none !important; } }

.a11y-panel {
    width: min(460px, calc(100vw - 24px)); max-height: min(720px, calc(100vh - 24px)); max-height: min(720px, calc(100dvh - 24px));
    margin: auto; padding: 0; border: 0; border-radius: 22px; background: #fff; color: #2a2047;
    box-shadow: 0 40px 80px -20px rgba(29, 21, 52, .55); overflow: hidden; display: none; flex-direction: column;
    font-family: var(--font, system-ui, sans-serif); font-size: 1rem; line-height: 1.45;
}
.a11y-panel[open] { display: flex; }
.a11y-panel::backdrop { background: rgba(29, 21, 52, .5); }
.a11y-head { display: flex; align-items: center; gap: 12px; padding: 16px 12px 14px 20px; border-bottom: 1px solid #e8e4f2; }
.a11y-head-ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: #1d1534; color: #fff; flex: none; }
.a11y-head-ico .ic { width: 24px; height: 24px; }
.a11y-panel h2 { flex: 1; margin: 0; font-size: 1.2rem; font-weight: 700; letter-spacing: -.02em; color: #1d1534; }
.a11y-x { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: #1d1534; cursor: pointer; }
.a11y-x:hover { background: #f4f0fe; }
.a11y-body { padding: 14px 20px 6px; overflow-y: auto; overscroll-behavior: contain; }
.a11y-desc { margin: 0 0 14px; font-size: .9rem; color: #4d4766; }
.a11y-size { margin: 0 0 12px; padding: 0; border: 0; }
.a11y-size legend { padding: 0; margin-bottom: 8px; font-weight: 600; color: #1d1534; font-size: .95rem; }
.a11y-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 4px; border-radius: 14px; background: #f4f0fe; }
.a11y-seg label { position: relative; display: block; cursor: pointer; }
.a11y-seg input { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; }
.a11y-seg span { display: grid; place-items: center; min-height: 44px; border-radius: 10px; font-weight: 600; color: #2a2047; font-size: .95rem; }
.a11y-seg .a11y-a1 { font-size: 1.08rem; }
.a11y-seg .a11y-a2 { font-size: 1.22rem; }
.a11y-seg input:checked + span { background: #fff; color: #5233a8; box-shadow: 0 0 0 2px #5233a8; }
.a11y-seg input:focus-visible + span { outline: 3px solid #5233a8; outline-offset: 2px; }
.a11y-opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.a11y-opt { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 10px 10px; border-radius: 14px; cursor: pointer; }
.a11y-opt:hover { background: #faf8ff; }
.a11y-opt input { position: absolute; z-index: 1; left: 10px; top: 11px; width: 44px; height: 28px; margin: 0; opacity: 0; cursor: pointer; }
.a11y-switch { position: relative; flex: none; width: 44px; height: 26px; margin-top: 1px; border-radius: 99px; background: #8a83a6; transition: background .2s; }
.a11y-switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.a11y-opt input:checked + .a11y-switch { background: #5233a8; }
.a11y-opt input:checked + .a11y-switch::after { transform: translateX(18px); }
.a11y-opt input:focus-visible + .a11y-switch { outline: 3px solid #5233a8; outline-offset: 2px; }
.a11y-opt-text { display: grid; gap: 1px; min-width: 0; }
.a11y-opt-text strong { font-weight: 600; color: #1d1534; font-size: .95rem; }
.a11y-opt-text small { font-size: .82rem; color: #5b5577; }
.a11y-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 12px 20px 16px; border-top: 1px solid #e8e4f2; background: #faf9fd; }
.a11y-reset { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 16px; border: 0; border-radius: 99px; background: #1d1534; color: #fff; font: 600 .9rem/1.1 var(--font, system-ui, sans-serif); cursor: pointer; }
.a11y-reset .ic { width: 18px; height: 18px; }
.a11y-reset:hover { background: #5233a8; }
.a11y-decl { color: #5233a8; font-weight: 600; text-decoration: underline; min-height: 24px; }
.a11y-kbd { flex-basis: 100%; margin: 0; font-size: .8rem; color: #5b5577; }
.a11y-kbd kbd { display: inline-block; padding: 1px 6px; border-radius: 6px; background: #fff; box-shadow: inset 0 0 0 1px #c9c3da; font: 600 .78rem/1.4 ui-monospace, Consolas, monospace; color: #1d1534; }
@media (max-width: 640px) {
    .a11y-panel { width: 100%; max-width: 100%; max-height: 92vh; max-height: 92dvh; margin: auto 0 0; border-radius: 22px 22px 0 0; }
    .a11y-foot { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
/* przyciski „Ustawienia dostępności” w menu i stopkach */
.a11y-link { display: inline; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; cursor: pointer; min-height: 24px; }
.a11y-link:hover { color: var(--primary-600, #5233a8); }
body.app .nav-link.a11y-nav { width: calc(100% - 28px); border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }

/* =====================================================================
   3. Tryby panelu
   ===================================================================== */
/* --- Większy tekst (1.4.4): skaluje rem; podstawowe rozmiary tekstu są w rem --- */
html[data-a11y-text="1"] { font-size: 115%; }
html[data-a11y-text="2"] { font-size: 130%; }
html[data-a11y-text] body.app { --sidebar-w: 300px; }

/* --- Wysoki kontrast --- */
html.a11y-contrast, html.a11y-contrast body {
    --text: #1d1534 !important; --heading: #000 !important; --muted: #2f2950 !important; --line: #6f6890 !important;
    --primary: #4a2a9e !important; --primary-600: #2f1680 !important; --primary-50: #fff !important; --primary-100: #4a2a9e !important;
    --bg: #fff !important; --surface: #fff !important; --ui-hair: #1d1534 !important;
    --lp-body: #1d1534 !important; --lp-soft: #2f2950 !important; --lp-ink-2: #000 !important; --lp-line: #1d1534 !important;
    --lp-purple: #4a2a9e !important; --lp-purple-deep: #2f1680 !important; --lp-mist: #fff !important; --lp-mist-2: #ece6ff !important;
    --lp-fox: #a84300 !important; --lp-fox-ink: #8a3600 !important; --lp-mint: #075c42 !important;
    --soc-fox: #a84300 !important; --soc-fox-ink: #8a3600 !important; --soc-mint: #075c42 !important; --soc-line: #1d1534 !important;
    --success-ink: #075c42 !important; --warning-ink: #8a3600 !important; --danger-ink: #a01d45 !important; --danger: #a01d45 !important;
    --cmp-body: #1d1534 !important;
}
html.a11y-contrast body { background: #fff !important; color: #1d1534; }
html.a11y-contrast :is(.card, .panel, .stat, .table, .list-card, .pick-card, .dir-card, .lg-card, .soc-post, .ui-empty, .acc-option, .notif-dropdown, .user-dropdown, .a11y-panel) { border: 1.5px solid #1d1534 !important; }
html.a11y-contrast :is(input, select, textarea):not([type=checkbox]):not([type=radio]) { border: 2px solid #1d1534 !important; background: #fff !important; color: #000 !important; }
html.a11y-contrast ::placeholder { color: #4d4766 !important; opacity: 1; }
html.a11y-contrast .btn:not(.btn-ghost):not(.btn-outline):not(.btn-soft):not(.btn-light), html.a11y-contrast .lp-btn-primary { background: #2f1680 !important; color: #fff !important; }
html.a11y-contrast :is(.btn-ghost, .btn-outline, .btn-soft, .btn-light, .lp-btn-secondary, .lp-btn-quiet, .chip) { background: #fff !important; color: #1d1534 !important; box-shadow: inset 0 0 0 2px #1d1534 !important; }
html.a11y-contrast :is(.btn-fox, .lp-btn-fox, .fab-store) { background: #8a3600 !important; color: #fff !important; }
html.a11y-contrast :is(.muted, small, .small, .footer, .auth-foot, .nav-section, .header-crumb) { color: #2f2950 !important; }
html.a11y-contrast :is(.pill, .role, .tag, .count, .list-type) { box-shadow: inset 0 0 0 1.5px currentColor !important; }
html.a11y-contrast a:not([class]) { color: #2f1680; text-decoration: underline; }
html.a11y-contrast body.app .sidebar, html.a11y-contrast body.app .header { border-color: #1d1534 !important; }
html.a11y-contrast body.app .nav-link { color: #000 !important; }
html.a11y-contrast body.app .nav-link.active { background: #1d1534 !important; color: #fff !important; }
html.a11y-contrast body.app .nav-link.active .ic { color: #fff !important; }
html.a11y-contrast .lp-nav { background: #fff !important; border-bottom: 1.5px solid #1d1534 !important; }

/* --- Podkreślaj linki --- */
html.a11y-links a { text-decoration: underline !important; text-decoration-thickness: max(1px, .08em) !important; text-underline-offset: .18em; }

/* --- Wyraźny fokus (żółto-czarny, widoczny na każdym tle) --- */
html.a11y-focus :focus-visible, html.a11y-focus .a11y-seg input:focus-visible + span, html.a11y-focus .a11y-opt input:focus-visible + .a11y-switch {
    outline: 4px solid #000 !important; outline-offset: 3px !important; box-shadow: 0 0 0 3px #000, 0 0 0 9px #ffd23f !important;
}
html.a11y-focus :focus:not(:focus-visible):is(input, select, textarea) { outline: 3px solid #000 !important; }

/* --- Większe odstępy (wartości z kryterium 1.4.12) --- */
html.a11y-spacing body, html.a11y-spacing body :not(svg):not(svg *):not(code):not(pre):not(kbd) {
    line-height: 1.5 !important; letter-spacing: .12em !important; word-spacing: .16em !important;
}
html.a11y-spacing :is(p, li, dd) { margin-bottom: 1em; }
html.a11y-spacing main p:not(:last-child) { margin-bottom: 2em; }
html.a11y-spacing :is(.btn, .lp-btn, .cmp-btn, .nav-link, .chip, .pill, .tabs a) { white-space: normal; height: auto; }
html.a11y-spacing :is(.legend, .cmp-actions, .cmp-actions-main) { flex-wrap: wrap; }

/* --- Czytelna czcionka --- */
html.a11y-font, html.a11y-font body, html.a11y-font body.app, html.a11y-font body.auth {
    --font: "Atkinson Hyperlegible", Verdana, Tahoma, "Segoe UI", system-ui, sans-serif !important;
}
html.a11y-font body, html.a11y-font body :not(code):not(pre):not(kbd):not(svg *) { font-family: var(--font) !important; }

/* --- Zatrzymaj animacje --- */
html.a11y-motion { scroll-behavior: auto !important; }
html.a11y-motion *, html.a11y-motion *::before, html.a11y-motion *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important;
    transition-duration: .001ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
}

/* --- Ukryj obrazki dekoracyjne (img alt="", ozdobne tła i ilustracje) --- */
html.a11y-images img[alt=""]:not(.avatar img):not(.has-img img):not(.brand-mark):not([class*="logo"]),
html.a11y-images [aria-hidden="true"]:is(.auth-art, .lp-hero-art, .lp-deco, .dash-hero-mark) { visibility: hidden !important; }
html.a11y-images :is(.dash-hero, .lp-hero, .ui-empty, .sidebar-promo) { background-image: none !important; }
html.a11y-images .sidebar-promo { background: #1d1534 !important; }

/* --- Większy kursor --- */
html.a11y-cursor, html.a11y-cursor * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M4 2l26 18-12 2 7 13-5 3-7-13-9 8z' fill='%23000' stroke='%23fff' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") 4 2, auto !important;
}
html.a11y-cursor :is(a, button, summary, label, select, [role="button"], [role="switch"], input[type=checkbox], input[type=radio]),
html.a11y-cursor :is(a, button, summary, label) * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40' viewBox='0 0 40 40'%3E%3Cpath d='M14 4a3 3 0 0 1 6 0v12l2-1a3 3 0 0 1 4 1l1 1a3 3 0 0 1 4 1l1 1a3 3 0 0 1 4 2v8c0 5-4 9-9 9h-5c-3 0-5-1-7-4L8 25a3 3 0 0 1 4-4l2 2z' fill='%23000' stroke='%23fff' stroke-width='2.2' stroke-linejoin='round'/%3E%3C/svg%3E") 14 2, pointer !important;
}
html.a11y-cursor :is(input:not([type=checkbox]):not([type=radio]), textarea) { cursor: text !important; }

/* ---------- Linki w tekście odróżnialne nie tylko kolorem (1.4.1) ---------- */
main :is(p, li, dd, .small, .muted):not(nav *) > a:not([class]) { text-decoration: underline; text-underline-offset: .15em; }

/* ---------- Podpowiedzi w polach: kontrast 5:1 (domyślne szarości przeglądarek bywają za jasne) ---------- */
::placeholder { color: #6f6890; opacity: 1; }
