/* ==========================================================================
   Dostępność (WCAG 2.1 AA) – wspólne dla kalkulatora i bloga.
   Klasy na <html>: a11y-contrast, a11y-links; rozmiar tekstu przez font-size na <html>.
   ========================================================================== */

/* ---------- Widoczny fokus z klawiatury (2.4.7) ---------- */

:focus-visible {
    outline: 3px solid #000;
    outline-offset: 2px;
}

body.dark-mode :focus-visible {
    outline-color: #fbbf24;
}

/* Kafelki wyboru w kalkulatorze: radio jest ukryte, więc fokus pokazuje kafelek */
.tile input:focus-visible + .tile-content {
    outline: 3px solid #000;
    outline-offset: 4px;
}

body.dark-mode .tile input:focus-visible + .tile-content {
    outline-color: #fbbf24;
}

html.a11y-contrast .tile input:focus-visible + .tile-content {
    outline: 3px solid #ff0 !important;
}

/* ---------- Link „Przejdź do treści” (2.4.1) ---------- */

.skip-link {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2000;
    padding: 12px 18px;
    background: #000;
    color: #fff;
    font-weight: 600;
    text-decoration: underline;
    transform: translateY(-120%);
}

.skip-link:focus {
    transform: translateY(0);
    outline: 3px solid #fbbf24;
    outline-offset: 0;
}

/* ---------- Linki w tekście odróżnialne nie tylko kolorem (1.4.1) ---------- */

.privacy-container p a,
.privacy-container li a {
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* ---------- Przewijane tabele: fokus na kontenerze ---------- */

div[role="region"][tabindex="0"]:focus-visible {
    outline-offset: 4px;
}

/* ---------- Panel dostępności ---------- */

.a11y-widget {
    position: fixed;
    right: 20px;
    bottom: 70px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.a11y-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #0d6b45;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(13, 107, 69, 0.3);
}

.a11y-toggle:hover {
    background: #0a5537;
}

.a11y-panel {
    width: 230px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    padding: 14px;
    border-radius: 14px;
    background: #fff;
    color: #1f2937;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 15px;
    text-align: left;
}

.a11y-panel[hidden] {
    display: none;
}

.a11y-panel__title {
    margin: 0 0 10px;
    font-weight: 700;
    font-size: 1.05em;
}

.a11y-panel__btn {
    display: block;
    width: 100%;
    margin: 0 0 6px;
    padding: 9px 12px;
    border: 2px solid #0d6b45;
    border-radius: 8px;
    background: #fff;
    color: #0d6b45;
    font: inherit;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.a11y-panel__btn:hover {
    background: #ecfdf5;
}

.a11y-panel__btn[aria-pressed="true"] {
    background: #0d6b45;
    color: #fff;
}

.a11y-panel__btn[aria-pressed="true"]::after {
    content: " ✓";
}

.a11y-panel__btn:disabled {
    border-color: #9ca3af;
    color: #4b5563;
    cursor: not-allowed;
    opacity: 0.7;
}

.a11y-panel__status {
    min-height: 1.3em;
    margin: 4px 0 6px;
    font-size: 0.9em;
    color: #374151;
}

.a11y-panel__link {
    color: #0d6b45;
    text-decoration: underline;
    font-size: 0.9em;
}

body.dark-mode .a11y-toggle {
    background: #22c55e;
    color: #0b1020;
}

body.dark-mode .a11y-panel {
    background: #1f2937;
    color: #f3f4f6;
}

body.dark-mode .a11y-panel__btn {
    background: #1f2937;
    border-color: #4ade80;
    color: #4ade80;
}

body.dark-mode .a11y-panel__btn:hover {
    background: #111827;
}

body.dark-mode .a11y-panel__btn[aria-pressed="true"] {
    background: #4ade80;
    color: #0b1020;
}

body.dark-mode .a11y-panel__status {
    color: #d1d5db;
}

body.dark-mode .a11y-panel__link {
    color: #4ade80;
}

/* ---------- Podkreślanie linków ---------- */

html.a11y-links a {
    text-decoration: underline !important;
}

/* ---------- Wysoki kontrast ---------- */

/* :where() zeruje specyficzność listy wyjątków – dzięki temu reguły niżej (linki, aktywne elementy) wygrywają */
html.a11y-contrast body,
html.a11y-contrast body :where(*:not(img, svg, svg *, iframe, ins, ins *)) {
    background-color: #000 !important;
    background-image: none !important;
    color: #fff !important;
    border-color: #fff !important;
    box-shadow: none !important;
    text-shadow: none !important;
    -webkit-text-fill-color: currentColor !important;
    filter: none !important;
}

html.a11y-contrast .a11y-panel {
    border: 2px solid #fff !important;
}

html.a11y-contrast a,
html.a11y-contrast a * {
    color: #ff0 !important;
    text-decoration: underline !important;
}

html.a11y-contrast button,
html.a11y-contrast input,
html.a11y-contrast select,
html.a11y-contrast textarea,
html.a11y-contrast .btn {
    border: 2px solid #fff !important;
}

html.a11y-contrast button[aria-pressed="true"],
html.a11y-contrast button[aria-pressed="true"] *,
html.a11y-contrast input:checked + label,
html.a11y-contrast .tile input:checked + .tile-content,
html.a11y-contrast .tile input:checked + .tile-content *,
html.a11y-contrast .is-active,
html.a11y-contrast .is-active * {
    background-color: #ff0 !important;
    color: #000 !important;
}

html.a11y-contrast .progress-fill,
html.a11y-contrast .reading-progress {
    background-color: #ff0 !important;
}

html.a11y-contrast button:disabled {
    border-style: dashed !important;
    color: #aaa !important;
}

html.a11y-contrast :focus-visible {
    outline: 3px solid #ff0 !important;
    outline-offset: 2px;
}

html.a11y-contrast input::placeholder {
    color: #ccc !important;
}

/* ---------- Zatrzymanie animacji z panelu (2.2.2) ---------- */

html.a11y-no-motion *,
html.a11y-no-motion *::before,
html.a11y-no-motion *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

/* ---------- Ograniczenie animacji (ustawienie systemowe) ---------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
