﻿/* =====================================================
 *  Accessibility widget
 *  Font size + colour scheme controls (EAA / WCAG 2.1 AA)
 *  ===================================================== */

#topbar .accessibility { float: right; position: relative; margin-left: 5px; }

#topbar .accessibility-toggle {
    display: block;
    float: left;
    align-items: center;
    margin: 0 0 0 5px;
    padding: 7px;
    background: transparent;
    border: 0;
    outline: 0;
    color: #f8f8f8;
    font-size: 0.8em;
    line-height: 0.8em;
    cursor: pointer;
    border-radius: 2px;
}
#topbar .accessibility-toggle:hover,
#topbar .accessibility-toggle[aria-expanded="true"] { background: #444; }

/* Visible focus outline for keyboard users on the dark topbar */
#topbar .accessibility-toggle:focus-visible,
.a11y-panel button:focus-visible,
.a11y-panel input:focus-visible,
.a11y-panel a:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}


#topbar .accessibility-toggle .icon {
    width: 24px;
    height: 24px;
    display: inline-block;
    border: 1px solid #f8f8f8;
    padding: 3px;
    border-radius: 12px;
}
#topbar .accessibility-toggle .icon svg { display: block; width: 100%; height: 100%; }

.a11y-panel {
    display: none;
    width: 100%;
    background: #fff;
    color: #222;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    font-size: 14px;
    line-height: 1.4;
    position: relative;
    z-index: 1000;
}
.a11y-panel.is-open { display: block; }

.a11y-panel .wrapper {
    padding: 16px 0 20px;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 28px;
}

.a11y-panel h2 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #0e2431;
    width: 100%;
}

.a11y-panel fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    min-width: 180px;
}
.a11y-panel legend {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #555;
    margin-bottom: 8px;
    padding: 0;
}

.a11y-panel-actions {
    margin-left: auto;
    display: flex;
    align-items: flex-end;
    height: 100%;
    padding-top: 20px;
}

/* Font size step buttons */
.a11y-fontsize-controls {
    display: flex;
    gap: 6px;
}
.a11y-fontsize-controls button {
    flex: 1;
    height: 36px;
    border: 1px solid #ccc;
    background: #f8f8f8;
    color: #222;
    cursor: pointer;
    border-radius: 3px;
    font-family: inherit;
}
.a11y-fontsize-controls button:hover { background: #eee; }
.a11y-fontsize-controls button[aria-pressed="true"] {
    background: #0e2431;
    border-color: #0e2431;
    color: #fff;
}
.a11y-fontsize-controls button:nth-child(1) { font-size: 12px; }
.a11y-fontsize-controls button:nth-child(2) { font-size: 15px; }
.a11y-fontsize-controls button:nth-child(3) { font-size: 18px; }

/* Colour scheme swatch buttons */
.a11y-scheme-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.a11y-scheme-controls button {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid #ccc;
    background: #f8f8f8;
    color: #222;
    cursor: pointer;
    border-radius: 3px;
    font-size: 12px;
    font-family: inherit;
    text-align: left;
}
.a11y-scheme-controls button:hover { background: #eee; }
.a11y-scheme-controls button[aria-pressed="true"] {
    background: #0e2431;
    border-color: #0e2431;
    color: #fff;
}
.a11y-scheme-controls .swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.2);
    flex-shrink: 0;
}
.a11y-swatch-default { background: linear-gradient(135deg, #fff 50%, #222 50%); }
.a11y-swatch-contrast { background: #000; border-color: #ff0; box-shadow: inset 0 0 0 2px #ff0; }
.a11y-swatch-contrast-inv { background: #fff100; box-shadow: inset 0 0 0 2px #000; }

/* Toggle rows (underline links, readable font, reduce motion) */
.a11y-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}
.a11y-toggle-row label { font-size: 13px; cursor: pointer; }
.a11y-switch {
    position: relative;
    width: 38px;
    height: 20px;
    flex-shrink: 0;
}
.a11y-switch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}
.a11y-switch .track {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 999px;
    transition: background 0.15s ease-out;
    pointer-events: none;
}
.a11y-switch .thumb {
    position: absolute;
    top: 2px; left: 2px;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    transition: transform 0.15s ease-out;
    pointer-events: none;
}
.a11y-switch input:checked + .track { background: #0e2431; }
.a11y-switch input:checked ~ .thumb { transform: translateX(18px); }
.a11y-switch input:focus-visible ~ .track { outline: 3px solid #ffbf47; outline-offset: 2px; }

.a11y-reset {
    height: 34px;
    padding: 0 16px;
    white-space: nowrap;
    background: transparent;
    border: 1px solid #0e2431;
    color: #0e2431;
    border-radius: 3px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
}
.a11y-reset:hover { background: #0e2431; color: #fff; }

@media (max-width: 768px) {
    .a11y-panel .wrapper { flex-direction: column; gap: 16px; padding: 16px 15px 20px; }
    .a11y-panel-actions { margin-left: 0; padding-top: 0; width: 100%; }
    .a11y-reset { width: 100%; }
}

html.a11y-fs-1 { font-size: 16px !important; }
html.a11y-fs-2 { font-size: 18px !important; }
html.a11y-fs-3 { font-size: 21px !important; }

html.a11y-contrast,
html.a11y-contrast body,
html.a11y-contrast #topbar,
html.a11y-contrast header.main,
html.a11y-contrast footer.main,
html.a11y-contrast main,
html.a11y-contrast section,
html.a11y-contrast article,
html.a11y-contrast div,
html.a11y-contrast aside:not(.a11y-panel-host) {
    background: #000 !important;
    color: #ffff00 !important;
    border-color: #ffff00 !important;
}
html.a11y-contrast a { color: #ffff00 !important; text-decoration: underline !important; }
html.a11y-contrast a:hover { color: #fff !important; }
html.a11y-contrast h1, html.a11y-contrast h2, html.a11y-contrast h3, html.a11y-contrast h4 { color: #fff !important; }
html.a11y-contrast img { filter: grayscale(1) contrast(1.2); }
html.a11y-contrast input,
html.a11y-contrast select,
html.a11y-contrast textarea {
    background: #000 !important;
    color: #ffff00 !important;
    border: 1px solid #ffff00 !important;
}
html.a11y-contrast .a11y-panel,
html.a11y-contrast .a11y-panel div { background: #fff !important; color: #000 !important; }

/* ---- Uncaught content elements ---- */
html.a11y-contrast #logo_large,
html.a11y-contrast header.main .widgets .weather .icon img { filter: invert(1) !important; }

html.a11y-contrast #sitemap .info h2,
html.a11y-contrast header.main .widgets .date-info .congratulations { color: #fff100 !important; }

html.a11y-contrast .posts .menu li.active a,
html.a11y-contrast .posts .menu li.active a:hover {
    border: 1px solid #fff100 !important;
    background: transparent !important;
}

html.a11y-contrast #widgets .carousel-pagination,
html.a11y-contrast #slideshow .carousel-pagination { background: transparent !important; }

html.a11y-contrast header.main .menu_main ul,
html.a11y-contrast #data-list .side-menu,
html.a11y-contrast #sitemap .links ul ul,
html.a11y-contrast #widgets .carousel-pagination a,
html.a11y-contrast #slideshow .carousel-pagination a {
    background: #000 !important;
    border: 1px solid #fff100 !important;
}
html.a11y-contrast #widgets .carousel-pagination a.active,
html.a11y-contrast #slideshow .carousel-pagination a.active { background: #000 !important; }

html.a11y-contrast #widgets .carousel { background: #fff !important; }

html.a11y-contrast #sitemap:before,
html.a11y-contrast .content .toggle-switch:hover {
    background: #000 !important;
}


/* ---- High contrast, inverted: yellow background / black text ---- */
html.a11y-contrast-inv,
html.a11y-contrast-inv body,
html.a11y-contrast-inv #topbar,
html.a11y-contrast-inv header.main,
html.a11y-contrast-inv footer.main,
html.a11y-contrast-inv main,
html.a11y-contrast-inv section,
html.a11y-contrast-inv article,
html.a11y-contrast-inv div,
html.a11y-contrast-inv aside:not(.a11y-panel-host) {
    background: #fff100 !important;
    color: #000 !important;
    border-color: #000 !important;
}
html.a11y-contrast-inv a { color: #1a1a1a !important; text-decoration: underline !important; }
html.a11y-contrast-inv img { filter: grayscale(1) contrast(1.2); }
html.a11y-contrast-inv input,
html.a11y-contrast-inv select,
html.a11y-contrast-inv textarea {
    background: #fff100 !important;
    color: #000 !important;
    border: 1px solid #000 !important;
}
html.a11y-contrast-inv .a11y-panel,
html.a11y-contrast-inv .a11y-panel div { background: #fff !important; color: #000 !important; }

/* ---- Uncaught content elements ---- */
html.a11y-contrast-inv #topbar .accessibility-toggle { color: #000 !important; }
html.a11y-contrast-inv #topbar .accessibility-toggle .icon { border: 1px solid #000 !important; }
html.a11y-contrast-inv #topbar .accessibility-toggle:hover,
html.a11y-contrast-inv #topbar .accessibility-toggle[aria-expanded="true"] { color: #fff100 !important; }
html.a11y-contrast-inv #topbar .accessibility-toggle:hover .icon,
html.a11y-contrast-inv #topbar .accessibility-toggle[aria-expanded="true"] .icon { border: 1px solid transparent !important; }

/* These values are opposite as they will be inverted due to white background icon */
html.a11y-contrast-inv #topbar .language_selection a,
html.a11y-contrast-inv #topbar .secondary_menu a { color: #fff !important; }
html.a11y-contrast-inv #topbar .language_selection li.active a {
    color: #000eff !important;
    background: #bbb !important;
}
html.a11y-contrast-inv #topbar .language_selection a:hover,
html.a11y-contrast-inv #topbar .secondary_menu a:hover {
    color: #000eff !important;
    background: #fff !important;
}
html.a11y-contrast-inv #topbar .language_selection,
html.a11y-contrast-inv #topbar .secondary_menu { filter: invert(1); } /* .language_selection and .secondary_menu gets inverted here */

html.a11y-contrast-inv .posts .menu li.active a,
html.a11y-contrast-inv .posts .menu li.active a:hover {
    border: 1px solid #000 !important;
    background: transparent !important;
}

html.a11y-contrast-inv #sitemap .info h2 { color: #000 !important; }
html.a11y-contrast-inv #sitemap .info .content img { filter: invert(1) !important; }

html.a11y-contrast-inv #widgets .carousel-pagination,
html.a11y-contrast-inv #slideshow .carousel-pagination { background: transparent !important; }

html.a11y-contrast-inv header.main .menu_main ul,
html.a11y-contrast-inv #data-list .side-menu,
html.a11y-contrast-inv #sitemap .links ul ul,
html.a11y-contrast-inv #widgets .carousel-pagination a,
html.a11y-contrast-inv #slideshow .carousel-pagination a {
    background: #fff100 !important;
    border: 1px solid #000 !important;
}
html.a11y-contrast-inv #widgets .carousel-pagination a.active,
html.a11y-contrast-inv #slideshow .carousel-pagination a.active { background: #000 !important; }

html.a11y-contrast-inv #widgets .carousel { background: #fff !important; }

html.a11y-contrast-inv #sitemap:before,
html.a11y-contrast-inv .content .toggle-switch:hover {
    background: #fff100 !important;
}

/* ---- Underline all links (WCAG 1.4.1 — don't rely on colour alone) ---- */
html.a11y-underline-links a { text-decoration: underline !important; }

/* ---- Readable / dyslexia-friendlier font ---- */
html.a11y-readable-font,
html.a11y-readable-font body,
html.a11y-readable-font * {
    font-family: Arial, Verdana, "Comic Sans MS", sans-serif !important;
    letter-spacing: 0.02em !important;
    word-spacing: 0.05em !important;
}

/* ---- Reduce motion / animations (WCAG 2.3.3) ---- */
html.a11y-reduce-motion *,
html.a11y-reduce-motion *::before,
html.a11y-reduce-motion *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
}

/* Respect OS-level preference automatically on first visit */
@media (prefers-reduced-motion: reduce) {
    html:not(.a11y-initialised) * {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
