/**
 * AccesID Accessibility Widget v2 — CSS
 *
 * UI inspirée d AllAccessible.org : panel slide-in droite avec sections
 * pliables, sliders modernes, color swatches, toggles iOS-style.
 *
 * @package AccesID
 * @since   1.1.5
 */

/* CSS Variables (autonomes pour ne pas dépendre du thème) */
.acc-a11y-fab,
.acc-a11y-panel-v2,
.acc-a11y-overlay {
    --w-primary: #6366f1;
    --w-primary-dark: #4338ca;
    --w-purple: #8b5cf6;
    --w-success: #10b981;
    --w-bg: #ffffff;
    --w-bg-alt: #f8fafc;
    --w-bg-hover: #f1f5f9;
    --w-border: #e2e8f0;
    --w-text: #0f172a;
    --w-text-light: #475569;
    --w-text-muted: #94a3b8;
    --w-radius: 14px;
    --w-radius-sm: 8px;
    --w-shadow: 0 20px 60px rgba(15, 23, 42, .15);
    --w-z-fab: 99998;
    --w-z-panel: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
}

.acc-a11y-panel-v2 *,
.acc-a11y-panel-v2 *::before,
.acc-a11y-panel-v2 *::after { box-sizing: border-box; }

/* ============================================================================
   FAB BUTTON
   ============================================================================ */
.acc-a11y-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(99, 102, 241, .4);
    z-index: var(--w-z-fab);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .3s, box-shadow .3s;
}
.acc-a11y-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(99, 102, 241, .55);
}
.acc-a11y-fab:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 3px;
}
.acc-a11y-fab::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    opacity: .3;
    z-index: -1;
    animation: acc-a11y-pulse 2s ease-out infinite;
}
@keyframes acc-a11y-pulse {
    0% { transform: scale(1); opacity: .5; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* ============================================================================
   OVERLAY
   ============================================================================ */
.acc-a11y-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .4);
    z-index: 99998;
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
}
.acc-a11y-overlay[hidden] { display: none; }
.acc-a11y-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================================
   PANEL (slide-in from right)
   ============================================================================ */
.acc-a11y-panel-v2 {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: var(--w-bg);
    box-shadow: var(--w-shadow);
    z-index: var(--w-z-panel);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
    color: var(--w-text);
    line-height: 1.5;
    font-size: 14px;
}
.acc-a11y-panel-v2[hidden] { display: none; }
.acc-a11y-panel-v2.is-visible { transform: translateX(0); }

/* Header */
.acc-a11y-panel-v2-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    color: #fff;
    flex-shrink: 0;
}
.acc-a11y-panel-v2-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.acc-a11y-icon-btn {
    background: rgba(255, 255, 255, .15);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
}
.acc-a11y-icon-btn:hover { background: rgba(255, 255, 255, .25); }
.acc-a11y-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

.acc-a11y-lang-switcher {
    background: rgba(255, 255, 255, .15);
    border: none;
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.acc-a11y-lang-switcher option { color: var(--w-text); background: #fff; }

/* Hero */
.acc-a11y-panel-v2-hero {
    padding: 28px 20px 20px;
    text-align: center;
    background: linear-gradient(180deg, rgba(99, 102, 241, .03), transparent);
    border-bottom: 1px solid var(--w-border);
    flex-shrink: 0;
}
.acc-a11y-panel-v2-hero h2 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 800;
    color: var(--w-text);
    line-height: 1.2;
}
.acc-a11y-panel-v2-hero p {
    margin: 0;
    color: var(--w-text-light);
    font-size: 13px;
}

/* Body — scrollable */
.acc-a11y-panel-v2-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    -webkit-overflow-scrolling: touch;
}
.acc-a11y-panel-v2-body::-webkit-scrollbar { width: 8px; }
.acc-a11y-panel-v2-body::-webkit-scrollbar-thumb { background: var(--w-border); border-radius: 4px; }
.acc-a11y-panel-v2-body::-webkit-scrollbar-thumb:hover { background: var(--w-text-muted); }

/* Section (collapsible) */
.acc-a11y-section {
    background: var(--w-bg-alt);
    border-radius: var(--w-radius);
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--w-border);
}
.acc-a11y-section-header {
    width: 100%;
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: filter .2s;
}
.acc-a11y-section-header:hover { filter: brightness(1.08); }
.acc-a11y-chevron { transition: transform .25s; }
.acc-a11y-section-header[aria-expanded="false"] .acc-a11y-chevron { transform: rotate(-90deg); }
.acc-a11y-section-content {
    padding: 16px;
    display: block;
    overflow: hidden;
}
.acc-a11y-section-header[aria-expanded="false"] + .acc-a11y-section-content { display: none; }

/* Profile cards */
.acc-a11y-profile-card {
    background: var(--w-bg);
    border-radius: var(--w-radius-sm);
    padding: 12px 14px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--w-border);
    transition: border-color .2s;
}
.acc-a11y-profile-card.is-active {
    border-color: var(--w-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, .04), rgba(139, 92, 246, .04));
}
.acc-a11y-profile-info { flex: 1; min-width: 0; }
.acc-a11y-profile-info strong {
    display: block;
    font-size: 14px;
    font-weight: 700;
    color: var(--w-text);
    margin-bottom: 2px;
}
.acc-a11y-profile-info small {
    display: block;
    color: var(--w-text-light);
    font-size: 12px;
    line-height: 1.4;
}

/* Toggle switch */
.acc-a11y-toggle-switch {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    font-family: inherit;
}
.acc-a11y-toggle-track {
    width: 44px;
    height: 24px;
    background: var(--w-border);
    border-radius: 100px;
    position: relative;
    transition: background .2s;
}
.acc-a11y-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
    transition: transform .25s;
}
.acc-a11y-toggle-switch[aria-checked="true"] .acc-a11y-toggle-track {
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
}
.acc-a11y-toggle-switch[aria-checked="true"] .acc-a11y-toggle-thumb { transform: translateX(20px); }
.acc-a11y-toggle-label-off,
.acc-a11y-toggle-label-on {
    font-size: 11px;
    font-weight: 700;
    color: var(--w-text-muted);
    min-width: 28px;
    display: none;
}
.acc-a11y-toggle-switch[aria-checked="true"] .acc-a11y-toggle-label-on { display: inline; color: var(--w-success); }
.acc-a11y-toggle-switch[aria-checked="false"] .acc-a11y-toggle-label-off { display: inline; }

/* Grid 2 cols */
.acc-a11y-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

/* Tool button */
.acc-a11y-tool-btn {
    background: var(--w-bg);
    border: 2px solid var(--w-border);
    border-radius: var(--w-radius-sm);
    padding: 16px 12px;
    cursor: pointer;
    text-align: center;
    transition: all .2s;
    font-family: inherit;
    color: var(--w-text);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
.acc-a11y-tool-btn:hover {
    border-color: var(--w-primary);
    background: rgba(99, 102, 241, .04);
}
.acc-a11y-tool-btn.is-active {
    border-color: var(--w-primary);
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    color: #fff;
}
.acc-a11y-tool-icon {
    font-size: 20px;
    line-height: 1;
    font-weight: 800;
}
.acc-a11y-tool-label {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
}

/* Sliders */
.acc-a11y-slider-group {
    background: var(--w-bg);
    border-radius: var(--w-radius-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--w-border);
}
.acc-a11y-slider-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.acc-a11y-slider-row label {
    font-size: 13px;
    font-weight: 600;
    color: var(--w-text);
}
.acc-a11y-slider-value {
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    color: #fff;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
}
.acc-a11y-slider {
    width: 100%;
    height: 6px;
    background: var(--w-border);
    border-radius: 100px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}
.acc-a11y-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(99, 102, 241, .4);
    border: 2px solid #fff;
}
.acc-a11y-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(99, 102, 241, .4);
    border: 2px solid #fff;
}

/* Alignment buttons */
.acc-a11y-align-group {
    background: var(--w-bg);
    border-radius: var(--w-radius-sm);
    padding: 12px 14px;
    border: 1px solid var(--w-border);
}
.acc-a11y-align-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--w-text);
    margin-bottom: 8px;
}
.acc-a11y-align-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.acc-a11y-align-btn {
    background: var(--w-bg-alt);
    border: 1px solid var(--w-border);
    border-radius: var(--w-radius-sm);
    padding: 10px;
    cursor: pointer;
    color: var(--w-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s;
    font-family: inherit;
    font-size: 16px;
}
.acc-a11y-align-btn:hover { background: rgba(99, 102, 241, .08); border-color: var(--w-primary); }
.acc-a11y-align-btn.is-active {
    background: linear-gradient(135deg, var(--w-primary), var(--w-purple));
    color: #fff;
    border-color: transparent;
}

/* Color picker */
.acc-a11y-color-picker {
    background: var(--w-bg);
    border-radius: var(--w-radius-sm);
    padding: 12px 14px;
    margin-bottom: 10px;
    border: 1px solid var(--w-border);
}
.acc-a11y-color-picker label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--w-text);
    margin-bottom: 10px;
}
.acc-a11y-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.acc-a11y-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--w-border);
    cursor: pointer;
    padding: 0;
    transition: transform .15s, border-color .15s;
    position: relative;
}
.acc-a11y-swatch:hover { transform: scale(1.15); border-color: var(--w-primary); }
.acc-a11y-swatch.is-active {
    border-color: var(--w-primary);
    box-shadow: 0 0 0 2px var(--w-primary), 0 0 0 4px #fff;
}
.acc-a11y-swatch-reset {
    background:
        linear-gradient(45deg, transparent 47%, #ef4444 47%, #ef4444 53%, transparent 53%);
    background-color: #fff;
    border: 2px solid var(--w-border);
}

/* Footer */
.acc-a11y-panel-v2-footer {
    padding: 12px 20px;
    background: var(--w-bg-alt);
    border-top: 1px solid var(--w-border);
    text-align: center;
    flex-shrink: 0;
}
.acc-a11y-panel-v2-footer p {
    margin: 0 0 4px;
    font-size: 12px;
    color: var(--w-text-muted);
}
.acc-a11y-panel-v2-footer-links {
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 12px;
}
.acc-a11y-panel-v2-footer-links a {
    color: var(--w-text-muted);
    text-decoration: none;
}
.acc-a11y-panel-v2-footer-links a:hover { color: var(--w-primary); }

/* ============================================================================
   ACCESSIBILITY MODES — appliqués au <html> via JS
   ============================================================================ */

html.aa-readable-font * { font-family: Arial, Helvetica, sans-serif !important; }
html.aa-dyslexia-font * { font-family: 'Comic Sans MS', 'OpenDyslexic', sans-serif !important; }

html.aa-highlight-titles h1,
html.aa-highlight-titles h2,
html.aa-highlight-titles h3,
html.aa-highlight-titles h4 {
    background: #fef08a !important;
    padding: 4px 8px !important;
    border-left: 4px solid #eab308 !important;
}
html.aa-highlight-links a {
    background: #fef08a !important;
    color: #422006 !important;
    padding: 2px 4px !important;
    text-decoration: underline !important;
    text-decoration-thickness: 2px !important;
}

html.aa-high-contrast { filter: contrast(1.4); }
html.aa-dark-contrast,
html.aa-dark-contrast body {
    background: #0f172a !important;
    color: #f1f5f9 !important;
}
html.aa-dark-contrast * { color: #f1f5f9 !important; }
html.aa-dark-contrast a { color: #93c5fd !important; }

html.aa-invert { filter: invert(1) hue-rotate(180deg); }
html.aa-invert img,
html.aa-invert video,
html.aa-invert iframe,
html.aa-invert .mapboxgl-map,
html.aa-invert canvas { filter: invert(1) hue-rotate(180deg); }

html.aa-monochrome { filter: grayscale(1); }

html.aa-high-saturation { filter: saturate(2); }
html.aa-low-saturation { filter: saturate(0.4); }

html.aa-stop-animations *,
html.aa-stop-animations *::before,
html.aa-stop-animations *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
}

html.aa-hide-images img,
html.aa-hide-images video,
html.aa-hide-images svg:not(.acc-a11y-panel-v2 svg):not(.acc-a11y-fab svg) {
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
}

html.aa-big-cursor,
html.aa-big-cursor * {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48"><polygon points="0,0 32,16 18,18 24,32 16,32 14,16" fill="black" stroke="white" stroke-width="2"/></svg>') 0 0, auto !important;
}

html.aa-keyboard-nav :focus,
html.aa-keyboard-nav :focus-visible {
    outline: 4px solid #6366f1 !important;
    outline-offset: 3px !important;
}

/* Reading guide */
.aa-reading-guide-line {
    position: fixed;
    left: 0;
    right: 0;
    height: 50px;
    background: rgba(254, 240, 138, .35);
    border-top: 2px solid #fbbf24;
    border-bottom: 2px solid #fbbf24;
    pointer-events: none;
    z-index: 99997;
    transform: translateY(-50%);
    transition: top .05s linear;
}

/* Reading mask */
.aa-reading-mask-top,
.aa-reading-mask-bottom {
    position: fixed;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, .6);
    pointer-events: none;
    z-index: 99996;
}
.aa-reading-mask-top { top: 0; }
.aa-reading-mask-bottom { bottom: 0; }

/* Highlight on hover */
html.aa-highlight-hover *:hover {
    outline: 3px solid #fbbf24 !important;
    outline-offset: 2px !important;
}

/* Color overrides via custom properties */
html.aa-custom-bg body { background: var(--aa-bg-color) !important; }
html.aa-custom-bg body * { background: transparent !important; }
html.aa-custom-text body,
html.aa-custom-text body p,
html.aa-custom-text body span,
html.aa-custom-text body li,
html.aa-custom-text body td,
html.aa-custom-text body div {
    color: var(--aa-text-color) !important;
}
html.aa-custom-title h1,
html.aa-custom-title h2,
html.aa-custom-title h3,
html.aa-custom-title h4,
html.aa-custom-title h5,
html.aa-custom-title h6 {
    color: var(--aa-title-color) !important;
}

/* Text alignment */
html.aa-text-align-left body p,
html.aa-text-align-left body div { text-align: left !important; }
html.aa-text-align-center body p,
html.aa-text-align-center body div { text-align: center !important; }
html.aa-text-align-right body p,
html.aa-text-align-right body div { text-align: right !important; }

/* ============================================================================
   RESPONSIVE
   ============================================================================ */
@media (max-width: 480px) {
    .acc-a11y-panel-v2 { width: 100vw; }
    .acc-a11y-fab { width: 52px; height: 52px; bottom: 16px; right: 16px; }
}
