/**
 * Filarete Accessibilità - Main Stylesheet
 * Version: 1.0.3
 * Last Updated: 2026-01-29 09:40
 * 
 * VERIFICA VERSIONE: Se vedi questa riga, hai il file corretto!
 * Fix inclusi:
 * - Widget visibile in scala di grigi (filter: grayscale(0%) sul widget)
 * - Cursore grande gestito via JavaScript
 * - Cache busting automatico
 */

/* ========================================
   WIDGET BUTTON & CONTAINER
   ======================================== */

#filarete-a11y-button {
    position: fixed;
    z-index: 999999;
    /* width and height set inline via PHP */
    border-radius: 50%;
    background: var(--filarete-primary-color, #0073aa);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 24px;
}

#filarete-a11y-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

#filarete-a11y-button:focus {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Posizionamento */
.filarete-a11y-position-bottom-right #filarete-a11y-button {
    bottom: 20px;
    right: 20px;
}

.filarete-a11y-position-bottom-left #filarete-a11y-button {
    bottom: 20px;
    left: 20px;
}

.filarete-a11y-position-top-right #filarete-a11y-button {
    top: 20px;
    right: 20px;
}

.filarete-a11y-position-top-left #filarete-a11y-button {
    top: 20px;
    left: 20px;
}

/* Panel */
#filarete-a11y-panel {
    position: fixed;
    z-index: 999998;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    width: 320px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s ease;
    transform-origin: bottom right;
}

.filarete-a11y-position-bottom-right #filarete-a11y-panel {
    bottom: 90px;
    right: 20px;
    transform-origin: bottom right;
}

.filarete-a11y-position-bottom-left #filarete-a11y-panel {
    bottom: 90px;
    left: 20px;
    transform-origin: bottom left;
}

.filarete-a11y-position-top-right #filarete-a11y-panel {
    top: 90px;
    right: 20px;
    transform-origin: top right;
}

.filarete-a11y-position-top-left #filarete-a11y-panel {
    top: 90px;
    left: 20px;
    transform-origin: top left;
}

#filarete-a11y-panel.active {
    transform: scale(1);
    opacity: 1;
}

/* Header */
.filarete-a11y-header {
    padding: 10px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--filarete-primary-color, #0073aa);
    color: #fff;
    border-radius: 12px 12px 0 0;
}

.filarete-a11y-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.filarete-a11y-close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 24px;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.filarete-a11y-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Content */
.filarete-a11y-content {
    padding: 20px;
}

.filarete-a11y-section {
    margin-bottom: 20px;
}

.filarete-a11y-section:last-child {
    margin-bottom: 0;
}

.filarete-a11y-section-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    display: block;
}

/* Controls */
.filarete-a11y-control {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /*padding: 12px 0;*/
		padding: 0;
    border-bottom: 1px solid #f0f0f0;
}

.filarete-a11y-control:last-child {
    border-bottom: none;
}

.filarete-a11y-control-label {
    font-size: 14px;
    color: #555;
		font-weight: 600
}

/* Buttons */
.filarete-a11y-btn {
    background: var(--filarete-primary-color, #0073aa);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-weight: 500;
}

.filarete-a11y-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.filarete-a11y-btn:active {
    transform: translateY(0);
}

.filarete-a11y-btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.filarete-a11y-btn-group {
    display: flex;
    gap: 8px;
}

/* Toggle Switch */
.filarete-a11y-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.filarete-a11y-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.filarete-a11y-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.filarete-a11y-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.filarete-a11y-toggle input:checked + .filarete-a11y-toggle-slider {
    background-color: var(--filarete-primary-color, #0073aa);
}

.filarete-a11y-toggle input:checked + .filarete-a11y-toggle-slider:before {
    transform: translateX(24px);
}

.filarete-a11y-toggle input:focus + .filarete-a11y-toggle-slider {
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.3);
}

/* Reset Button */
.filarete-a11y-reset {
    width: 100%;
    margin-top: 16px;
    background: #dc3545;
}

.filarete-a11y-reset:hover {
    background: #c82333;
}

/* ========================================
   ACCESSIBILITY FEATURES STYLES
   ======================================== */

/* Text Size - Usa zoom per scalare tutto in modo proporzionale */
body.filarete-text-size-1 {
    zoom: 1.05;
}

body.filarete-text-size-2 {
    zoom: 1.1;
}

body.filarete-text-size-3 {
    zoom: 1.15;
}

body.filarete-text-size--1 {
    zoom: 0.95;
}

body.filarete-text-size--2 {
    zoom: 0.9;
}

/* Il widget rimane alla scala normale */
#filarete-a11y-button,
#filarete-a11y-panel {
    zoom: 1 !important;
}

/* High Contrast - Escludi widget */
body.filarete-high-contrast {
    background: #000 !important;
    color: #fff !important;
}

body.filarete-high-contrast *:not(.filarete-a11y-widget-wrapper):not(.filarete-a11y-widget-wrapper *) {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
}

body.filarete-high-contrast a:not(.filarete-a11y-widget-wrapper a) {
    color: #ffff00 !important;
    text-decoration: underline !important;
}

body.filarete-high-contrast img:not(.filarete-a11y-widget-wrapper img),
body.filarete-high-contrast video:not(.filarete-a11y-widget-wrapper video) {
    filter: contrast(1.2);
}

/* Grayscale - Applica solo al contenuto, NON a elementi fixed */
/*
body.filarete-grayscale main,
body.filarete-grayscale main *,
body.filarete-grayscale article,
body.filarete-grayscale article *,
body.filarete-grayscale section:not([id*="filarete"]),
body.filarete-grayscale section:not([id*="filarete"]) *,
body.filarete-grayscale .content,
body.filarete-grayscale .content *,
body.filarete-grayscale img:not(.filarete-a11y-widget-wrapper img),
body.filarete-grayscale p:not(.filarete-a11y-widget-wrapper p),
body.filarete-grayscale h1, h2, h3, h4, h5, h6,
body.filarete-grayscale div:not([id*="sidebar"]):not([class*="fixed"]):not(.filarete-a11y-widget-wrapper) {
    filter: grayscale(100%);
}

/* Escludi esplicitamente #sidebar e elementi fixed */
/*body.filarete-grayscale #sidebar,
body.filarete-grayscale #sidebar *,
body.filarete-grayscale nav[class*="fixed"],
body.filarete-grayscale [style*="position: fixed"],
body.filarete-grayscale .fixed-header {
    filter: none !important;
}*/

body.filarete-grayscale::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 999998;
    mix-blend-mode: saturation;
    background: white;
    opacity: 0;
}

/* Approccio alternativo più semplice: backdrop-filter */
body.filarete-grayscale {
    position: relative;
}

body.filarete-grayscale::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: grayscale(1);
    -webkit-backdrop-filter: grayscale(1);
    pointer-events: none;
    z-index: 999998;
}

/* Widget sopra l'overlay */
.filarete-a11y-widget-wrapper {
    z-index: 999999 !important;
    position: relative;
}

/* Widget sempre escluso */
.filarete-a11y-widget-wrapper,
.filarete-a11y-widget-wrapper *,
#filarete-a11y-button,
#filarete-a11y-panel {
    filter: none !important;
}

/* Text Spacing - Escludi widget completamente */
body.filarete-text-spacing *:not(.filarete-a11y-widget-wrapper):not(.filarete-a11y-widget-wrapper *) {
    line-height: 2 !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
}

body.filarete-text-spacing p:not(.filarete-a11y-widget-wrapper p) {
    margin-bottom: 2em !important;
}

/* Reset forte per il widget */
.filarete-a11y-widget-wrapper,
.filarete-a11y-widget-wrapper * {
    line-height: 1.5 !important;
    letter-spacing: normal !important;
    word-spacing: normal !important;
}

/* Readable Font - Escludi widget completamente */
body.filarete-readable-font *:not(.filarete-a11y-widget-wrapper):not(.filarete-a11y-widget-wrapper *) {
    font-family: 'Arial', 'Helvetica', sans-serif !important;
}

/* Reset forte per il widget - mantieni font di sistema elegante */
.filarete-a11y-widget-wrapper,
.filarete-a11y-widget-wrapper * {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

/* Highlight Links - Escludi widget */
body.filarete-highlight-links a:not(.filarete-a11y-widget-wrapper a) {
    background: #ffff00 !important;
    color: #000 !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
    font-weight: bold !important;
    text-decoration: underline !important;
}

/* Pause Animations - Escludi widget */
body.filarete-pause-animations *:not(.filarete-a11y-widget-wrapper):not(.filarete-a11y-widget-wrapper *) {
    animation-play-state: paused !important;
    transition: none !important;
}

/* Keyboard Navigation Focus */
body.filarete-keyboard-nav *:focus {
    outline: 4px solid var(--filarete-primary-color, #0073aa) !important;
    outline-offset: 2px !important;
}

/* Skip to content link (for keyboard navigation) */
.filarete-skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--filarete-primary-color, #0073aa);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 100;
    border-radius: 0 0 4px 0;
}

.filarete-skip-link:focus {
    top: 0;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
    #filarete-a11y-panel {
        width: calc(100vw - 40px);
        max-width: 320px;
    }
    
    /* Il pulsante si adatta automaticamente, ma su mobile può essere ridotto se troppo grande */
    #filarete-a11y-button {
        max-width: 50px;
        max-height: 50px;
    }
    
    #filarete-a11y-button svg {
        max-width: 20px;
        max-height: 20px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    #filarete-a11y-button,
    #filarete-a11y-panel {
        display: none !important;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Screen reader only */
.filarete-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Scrollbar styling for panel */
#filarete-a11y-panel::-webkit-scrollbar {
    width: 8px;
}

#filarete-a11y-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 12px 12px 0;
}

#filarete-a11y-panel::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#filarete-a11y-panel::-webkit-scrollbar-thumb:hover {
    background: #555;
}
