/* =====================================================================
 * PJM — Widżet dostępności (WCAG). Pływający przełącznik + tryby.
 * Klasy aplikowane na <html>: pjm-a11y-contrast, pjm-a11y-fs1/fs2,
 * pjm-a11y-focus, pjm-a11y-no-motion. Wszystko opcjonalne, użytkownik włącza.
 * ===================================================================== */

/* --- Przycisk wywołujący --- */
.pjm-a11y-toggle {
    position: fixed;
    left: 18px;
    bottom: 18px;
    z-index: 99990;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #1B5E4B;
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(20, 53, 42, .35);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .18s ease, background .18s ease;
}

.pjm-a11y-toggle:hover {
    background: #14352A;
    transform: translateY(-2px);
}

.pjm-a11y-toggle:focus-visible {
    outline: 3px solid #94d3b4;
    outline-offset: 3px;
}

.pjm-a11y-toggle svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
}

/* --- Panel --- */
.pjm-a11y-panel {
    position: fixed;
    left: 18px;
    bottom: 80px;
    z-index: 99991;
    width: 300px;
    max-width: calc(100vw - 36px);
    background: #fff;
    color: #1f2d27;
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, .25);
    padding: 18px;
    display: none;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.pjm-a11y-panel.is-open {
    display: block;
    animation: pjmA11yIn .2s ease;
}

@keyframes pjmA11yIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.pjm-a11y-panel h2 {
    font-size: 16px;
    font-weight: 800;
    margin: 0 0 4px;
    color: #14352A;
}

.pjm-a11y-panel p.pjm-a11y-sub {
    font-size: 12px;
    color: #64748b;
    margin: 0 0 14px;
}

.pjm-a11y-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-top: 1px solid #eef2f0;
    font-size: 14px;
}

.pjm-a11y-opt:first-of-type {
    border-top: none;
}

.pjm-a11y-opt-label {
    font-weight: 600;
    color: #1f2d27;
}

.pjm-a11y-btn {
    border: 1px solid #d4e8de;
    background: #f1f8f4;
    color: #1B5E4B;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.pjm-a11y-btn:hover {
    background: #e2f1e9;
}

.pjm-a11y-btn.is-active {
    background: #1B5E4B;
    color: #fff;
    border-color: #1B5E4B;
}

.pjm-a11y-btn:focus-visible {
    outline: 3px solid #94d3b4;
    outline-offset: 2px;
}

.pjm-a11y-fs-group {
    display: inline-flex;
    gap: 6px;
}

.pjm-a11y-reset {
    width: 100%;
    margin-top: 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    border-radius: 8px;
    padding: 9px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.pjm-a11y-reset:hover {
    background: #f8fafc;
    color: #334155;
}

/* =====================================================================
 * TRYBY — aplikowane na <html>
 * ===================================================================== */

/* Powiększenie czcionki (rem-based) */
html.pjm-a11y-fs1 { font-size: 112.5%; }
html.pjm-a11y-fs2 { font-size: 125%; }

/* Wysoki kontrast — wzmocnienie tekstu, podkreślenia linków, mocniejsze obramowania */
html.pjm-a11y-contrast body {
    color: #0a0f0d;
}

html.pjm-a11y-contrast a:not(.pjm-header-btn):not(.qr-btn):not(.button) {
    text-decoration: underline;
}

html.pjm-a11y-contrast .pjm-site-header {
    background: #0d2c22 !important;
}

html.pjm-a11y-contrast :is(p, li, label, td, th) {
    color: #11201b;
}

/* Wyraźny fokus klawiatury */
html.pjm-a11y-focus *:focus {
    outline: 3px solid #1B5E4B !important;
    outline-offset: 2px !important;
}

/* Redukcja ruchu */
html.pjm-a11y-no-motion *,
html.pjm-a11y-no-motion *::before,
html.pjm-a11y-no-motion *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
}

@media (max-width: 600px) {
    .pjm-a11y-toggle {
        width: 46px;
        height: 46px;
        left: 12px;
        bottom: 12px;
    }
    .pjm-a11y-panel {
        left: 12px;
        bottom: 66px;
    }
}

/* Na stronach PANELU (mobile) jest dolny pasek aplikacji (.pjm-mobile-header,
   ~60px + safe-area), który zawiera hamburger / „Panel PJM" / awatar.
   Podnosimy przełącznik dostępności i jego panel NAD ten pasek, żeby ich nie zasłaniał. */
@media (max-width: 992px) {
    body.pjm-dashboard-page .pjm-a11y-toggle {
        bottom: calc(74px + env(safe-area-inset-bottom));
    }
    body.pjm-dashboard-page .pjm-a11y-panel {
        bottom: calc(128px + env(safe-area-inset-bottom));
    }
}
