/**
 * Accessibility preferences toolbar + user preference classes on html.
 *
 * @package Clairefontaine_Template
 */

.cf-a11y-toolbar {
    position: fixed;
    left: 16px;
    bottom: 16px;
    z-index: 100001;
    font-family: var(--font-body, Inter, system-ui, sans-serif);
    isolation: isolate;
}

/* Stay above cookie banner (full-width bottom bar) */
body:has(#cf-cookie-consent-root:not([hidden]) .cf-cookie-banner:not([hidden])) .cf-a11y-toolbar {
    bottom: max(7.5rem, calc(16px + env(safe-area-inset-bottom, 0px)));
}

.cf-a11y-toolbar__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: var(--cf-blue-900, #003d7a);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cf-a11y-toolbar__toggle:hover {
    transform: scale(1.04);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
}

.cf-a11y-toolbar__toggle:focus-visible {
    outline: 3px solid #ffeb3b;
    outline-offset: 3px;
}

.cf-a11y-btn:focus-visible,
.cf-a11y-toolbar__close:focus-visible {
    outline: 3px solid var(--cf-blue-900, #003d7a);
    outline-offset: 2px;
}

.cf-a11y-toolbar__panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 12px);
    width: min(320px, calc(100vw - 32px));
    max-height: min(70vh, 520px);
    overflow: auto;
    background: #fff;
    color: #1a1a1a;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 1rem 1.1rem 1.1rem;
}

.cf-a11y-toolbar__panel[hidden] {
    display: none !important;
}

.cf-a11y-toolbar__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.cf-a11y-toolbar__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
}

.cf-a11y-toolbar__close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 0.2rem;
    color: inherit;
}

.cf-a11y-toolbar__intro {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #444;
}

.cf-a11y-toolbar__section {
    margin-bottom: 1rem;
}

.cf-a11y-toolbar__label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #555;
}

.cf-a11y-toolbar__btn-group {
    display: flex;
    gap: 0.35rem;
    align-items: center;
}

.cf-a11y-font-level {
    flex: 0 0 auto;
    min-width: 3.25rem;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #333;
}

.cf-a11y-btn {
    flex: 1;
    min-height: 40px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #f8f8f8;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    color: inherit;
}

.cf-a11y-btn:hover {
    background: #eee;
    border-color: #999;
}

.cf-a11y-btn--reset {
    width: 100%;
    margin-top: 0.25rem;
}

.cf-a11y-toolbar__toggles {
    list-style: none;
    margin: 0 0 0.75rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.cf-a11y-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.9rem;
    cursor: pointer;
}

.cf-a11y-toggle-row input {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--cf-blue-900, #003d7a);
}

/* ---------- Applied preferences on document ---------- */

/* Text scale: zoom affects px-based v3 layouts; toolbar keeps fixed UI size */
html.cf-a11y-font-1 {
    zoom: 1.1;
    font-size: 110%;
}

html.cf-a11y-font-2 {
    zoom: 1.25;
    font-size: 125%;
}

html.cf-a11y-font-3 {
    zoom: 1.4;
    font-size: 140%;
}

html.cf-a11y-font-1 .cf-a11y-toolbar {
    zoom: 0.9090909091;
}

html.cf-a11y-font-2 .cf-a11y-toolbar {
    zoom: 0.8;
}

html.cf-a11y-font-3 .cf-a11y-toolbar {
    zoom: 0.7142857143;
}

@supports not (zoom: 1) {
    html.cf-a11y-font-1 {
        font-size: 110%;
    }

    html.cf-a11y-font-2 {
        font-size: 125%;
    }

    html.cf-a11y-font-3 {
        font-size: 140%;
    }
}

html.cf-a11y-readable-font body,
html.cf-a11y-readable-font body p,
html.cf-a11y-readable-font body li,
html.cf-a11y-readable-font body a,
html.cf-a11y-readable-font body span,
html.cf-a11y-readable-font body label,
html.cf-a11y-readable-font body button,
html.cf-a11y-readable-font body input,
html.cf-a11y-readable-font body textarea,
html.cf-a11y-readable-font body select,
html.cf-a11y-readable-font body h1,
html.cf-a11y-readable-font body h2,
html.cf-a11y-readable-font body h3,
html.cf-a11y-readable-font body h4,
html.cf-a11y-readable-font body h5,
html.cf-a11y-readable-font body h6 {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
}

/* High contrast — v3 header/footer/sections + legacy theme */
html.cf-a11y-high-contrast body {
    background: #000 !important;
    color: #fff !important;
}

html.cf-a11y-high-contrast body > header,
html.cf-a11y-high-contrast body.cf-v3 > header,
html.cf-a11y-high-contrast .site-header,
html.cf-a11y-high-contrast footer,
html.cf-a11y-high-contrast .site-footer {
    background: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
    box-shadow: none !important;
}

html.cf-a11y-high-contrast body > header .breadcrumbs,
html.cf-a11y-high-contrast body > header .cf-v3-breadcrumbs {
    background: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}

html.cf-a11y-high-contrast body p,
html.cf-a11y-high-contrast body li,
html.cf-a11y-high-contrast body span,
html.cf-a11y-high-contrast body label,
html.cf-a11y-high-contrast body h1,
html.cf-a11y-high-contrast body h2,
html.cf-a11y-high-contrast body h3,
html.cf-a11y-high-contrast body h4,
html.cf-a11y-high-contrast body h5,
html.cf-a11y-high-contrast body h6,
html.cf-a11y-high-contrast body td,
html.cf-a11y-high-contrast body th {
    color: #fff !important;
}

html.cf-a11y-high-contrast body a:not(.cf-a11y-toolbar a) {
    color: #ffeb3b !important;
    text-decoration: underline !important;
}

html.cf-a11y-high-contrast body button:not(.cf-a11y-toolbar button),
html.cf-a11y-high-contrast body .btn,
html.cf-a11y-high-contrast body input[type="submit"],
html.cf-a11y-high-contrast body .search-btn,
html.cf-a11y-high-contrast body .menu-btn {
    background: #fff !important;
    color: #000 !important;
    border: 2px solid #fff !important;
}

html.cf-a11y-high-contrast body input:not([type="checkbox"]):not([type="radio"]),
html.cf-a11y-high-contrast body textarea,
html.cf-a11y-high-contrast body select {
    background: #000 !important;
    color: #fff !important;
    border: 2px solid #fff !important;
}

html.cf-a11y-high-contrast body section,
html.cf-a11y-high-contrast body article,
html.cf-a11y-high-contrast body main,
html.cf-a11y-high-contrast body .section,
html.cf-a11y-high-contrast body .legal-page__content {
    background-color: #000 !important;
}

html.cf-a11y-high-contrast .cf-seyes-paper {
    filter: contrast(1.35);
}

/* Keep toolbar panel readable in high-contrast mode */
html.cf-a11y-high-contrast .cf-a11y-toolbar__panel {
    background: #fff !important;
    color: #1a1a1a !important;
    border: 2px solid #000 !important;
}

html.cf-a11y-high-contrast .cf-a11y-toolbar__panel .cf-a11y-toolbar__title,
html.cf-a11y-high-contrast .cf-a11y-toolbar__panel .cf-a11y-toolbar__intro,
html.cf-a11y-high-contrast .cf-a11y-toolbar__panel .cf-a11y-toggle-row,
html.cf-a11y-high-contrast .cf-a11y-toolbar__panel .cf-a11y-toolbar__label,
html.cf-a11y-high-contrast .cf-a11y-toolbar__panel .cf-a11y-font-level {
    color: #1a1a1a !important;
}

html.cf-a11y-grayscale body {
    filter: grayscale(100%);
}

html.cf-a11y-grayscale .cf-a11y-toolbar {
    filter: none;
}

html.cf-a11y-underline-links body a {
    text-decoration: underline !important;
    text-underline-offset: 2px;
}

html.cf-a11y-reduce-motion *,
html.cf-a11y-reduce-motion *::before,
html.cf-a11y-reduce-motion *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

html.cf-a11y-large-cursor body,
html.cf-a11y-large-cursor body * {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 32 32'%3E%3Cpath fill='%23000' stroke='%23fff' stroke-width='1' d='M4 4 L4 26 L12 18 L18 28 L22 26 L16 16 L26 16 Z'/%3E%3C/svg%3E") 4 4, auto !important;
}

html.cf-a11y-large-cursor .cf-a11y-toolbar,
html.cf-a11y-large-cursor .cf-a11y-toolbar * {
    cursor: pointer !important;
}

/* Live search modal — high contrast + readable font */
html.cf-a11y-high-contrast .cf-search-modal__backdrop {
    background: rgba(0, 0, 0, 0.75) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}

html.cf-a11y-high-contrast .cf-search-modal__visible-label,
html.cf-a11y-high-contrast .cf-search-modal__hint,
html.cf-a11y-high-contrast .cf-search-group__title,
html.cf-a11y-high-contrast .cf-search-result__name,
html.cf-a11y-high-contrast .cf-search-empty,
html.cf-a11y-high-contrast .cf-search-loading {
    color: #fff !important;
    text-shadow: none !important;
}

html.cf-a11y-high-contrast .cf-search-modal__form,
html.cf-a11y-high-contrast .cf-search-modal__close {
    background: #fff !important;
    color: #000 !important;
    border: 3px solid #fff !important;
    box-shadow: none !important;
}

html.cf-a11y-high-contrast .cf-search-modal__input,
html.cf-a11y-high-contrast .cf-search-modal .search-field {
    background: #fff !important;
    color: #000 !important;
    border: none !important;
}

html.cf-a11y-high-contrast .cf-search-modal__input::placeholder,
html.cf-a11y-high-contrast .cf-search-modal .search-field::placeholder {
    color: #333 !important;
}

html.cf-a11y-high-contrast .cf-search-result {
    background: rgba(0, 0, 0, 0.35) !important;
    border-bottom-color: #fff !important;
}

html.cf-a11y-high-contrast .cf-search-result__meta {
    color: #ffeb3b !important;
}

html.cf-a11y-high-contrast .cf-search-result:hover,
html.cf-a11y-high-contrast .cf-search-result:focus-visible {
    background: #000 !important;
    outline: 3px solid #ffeb3b !important;
}

html.cf-a11y-high-contrast .cf-search-view-all {
    color: #ffeb3b !important;
}

html.cf-a11y-readable-font .cf-search-modal__input,
html.cf-a11y-readable-font .cf-search-modal .search-field,
html.cf-a11y-readable-font .cf-search-modal__hint,
html.cf-a11y-readable-font .cf-search-modal__visible-label,
html.cf-a11y-readable-font .cf-search-result__name,
html.cf-a11y-readable-font .cf-search-result__meta {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
}

@media (max-width: 640px) {
    .cf-a11y-toolbar {
        left: 12px;
        bottom: 12px;
    }

    .cf-a11y-toolbar__toggle {
        width: 48px;
        height: 48px;
    }
}
