/* ================================
   ACCESSIBILITY STYLES
   ================================ */

/* Skip Links - visibili solo al focus */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* Screen Reader Only - nasconde visualmente ma leggibile da screen reader */
.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;
}

/* Focus indicators migliorati */
*:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

button:focus,
a:focus,
select:focus,
input:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.2);
}

/* Miglioramenti per i pulsanti */
button,
.btn-primary,
.btn-secondary {
    cursor: pointer;
    min-height: 44px; /* WCAG 2.1 AA touch target size */
    min-width: 44px;
    padding: 12px 24px;
    transition: all 0.2s ease;
}

button:hover,
.btn-primary:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active,
.btn-primary:active {
    transform: scale(0.98);
}

/* Controlli tastiera mappa */
.keyboard-controls {
    position: absolute;
    bottom: 100px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1000;
}

.keyboard-controls button {
    background: white;
    border: 2px solid #ccc;
    border-radius: 4px;
    padding: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.keyboard-controls button:hover {
    background: #f0f0f0;
    border-color: #4A90E2;
}

/* Close button nella info card */
.close-button {
    position: absolute;
    top: 16px;
    right: 16px;
    background: transparent;
    border: 2px solid #333;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-button:hover {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.close-button:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* Info card accessibile */
.info-card {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-content {
    background: white;
    padding: 32px;
    border-radius: 8px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.card-content h2 {
    margin-top: 0;
    font-size: 1.8em;
    color: #333;
}

/* Miglioramenti per i link della sidebar */
.listings .item a {
    display: block;
    padding: 16px;
    color: #333;
    text-decoration: none;
    border-left: 4px solid transparent;
    transition: all 0.2s ease;
}

.listings .item a:hover,
.listings .item a:focus {
    background: #f5f5f5;
    border-left-color: #4A90E2;
    padding-left: 20px;
}

.listings .item.active a {
    background: #e3f2fd;
    border-left-color: #1976D2;
    font-weight: bold;
}

/* Select accessibili */
select {
    padding: 12px 40px 12px 12px;
    font-size: 16px;
    border: 2px solid #ccc;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
}

select:hover {
    border-color: #4A90E2;
}

/* Contrasto migliorato */
@media (prefers-contrast: high) {
    button,
    a,
    select {
        border-width: 3px;
    }
    
    *:focus {
        outline-width: 4px;
    }
}

/* Supporto per movimento ridotto */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Dark mode support per utenti con preferenze OS */
@media (prefers-color-scheme: dark) {
    .card-content {
        background: #1e1e1e;
        color: #ffffff;
    }
    
    .card-content h2 {
        color: #ffffff;
    }
    
    .close-button {
        border-color: #ffffff;
        color: #ffffff;
    }
    
    select {
        background-color: #2d2d2d;
        color: #ffffff;
        border-color: #555;
    }
    
    .keyboard-controls button {
        background: #2d2d2d;
        color: #ffffff;
        border-color: #555;
    }
}

/* Tooltip per elementi interattivi */
[aria-label]::after,
[title]::after {
    content: attr(aria-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 10000;
}

[aria-label]:hover::after,
[aria-label]:focus::after {
    opacity: 1;
}

/* Responsive accessibility */
@media (max-width: 768px) {
    .skip-link {
        font-size: 14px;
    }
    
    .keyboard-controls {
        bottom: 80px;
        right: 8px;
    }
    
    .keyboard-controls button {
        width: 40px;
        height: 40px;
        padding: 10px;
    }
    
    .card-content {
        padding: 24px;
        max-width: 90vw;
    }
}
