/* =========================================================================
   CORE VARIABLES & MODERN DESIGN SYSTEM
   ========================================================================= */
:root {
    /* Nuance di colore - Premium e moderne */
    --bg-color: #f7f9fc;
    --container-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-dark: #0f172a;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --accent-blue: #3b82f6;
    
    /* Variabili dinamiche/funzionali */
    --primary-color: var(--accent-color);
    --border-color: #e2e8f0;

    /* Tema Rosso (WW2 o Variante) */
    --accent-red: #991b1b;
    --accent-red-hover: #7f1d1d;

    /* Tema WW1 (Verde Oliva / Seppia) */
    --accent-ww1: #556b2f;
    --accent-ww1-hover: #425424;
    --sepia-filter: sepia(0.3) contrast(1.1);

    /* Superfici e Ombre - Soft e "glassy" */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --border-radius: 12px;
    --border-radius-lg: 20px;

    /* Transizioni fluide */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
}

/* =========================================================================
   DARK MODE OVERRIDES
   ========================================================================= */
:root[data-theme="dark"],
html[data-theme="dark"],
body[data-theme="dark"],
[data-theme="dark"] {
    --bg-color: #0f172a; /* Deep navy */
    --container-bg: #1e293b; /* Slate navy */
    --text-primary: #f8fafc; /* Light ice */
    --text-secondary: #94a3b8; /* Muted gray */
    --text-dark: #f8fafc;
    --border-color: #334155; /* Slate border */
    
    /* Manteniamo l'accento blu ma leggermente più luminoso/brillante per contrasto */
    --accent-color: #60a5fa; 
    --accent-hover: #3b82f6;
    --accent-blue: #60a5fa;
    
    /* Tema WW1 / Rosso - adattiamo leggermente le luminosità */
    --accent-red: #f87171;
    --accent-red-hover: #ef4444;
    --accent-ww1: #a3e635;
    --accent-ww1-hover: #84cc16;

    /* Badge testuale scuro su sfondo chiaro in dark mode */
    --badge-text: var(--bg-color);

    /* Ombre più delicate su fondo scuro */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
    
    /* Per card e modali */
    color-scheme: dark;
}

/* =========================================================================
   BASE RESET & TYPOGRAPHY
   ========================================================================= */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    margin-top: 0;
}

h1 {
    color: var(--text-primary);
    text-align: center;
    padding-top: 2rem;
    font-size: 2.2rem;
    letter-spacing: -0.02em;
}

a {
    text-decoration: none;
    color: var(--accent-color);
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

.mb-8 {
    margin-bottom: 3rem;
}

.py-4 {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
}

/* =========================================================================
   LAYOUT & CONTAINERS
   ========================================================================= */
.container {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: var(--container-bg);
    min-height: calc(100vh - 4rem);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
}

/* =========================================================================
   BUTTONS
   ========================================================================= */
.btn-nav,
.btn-main,
.btn-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-color);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    /* Pill shape - molto moderno */
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    gap: 8px;
    /* Spazio per eventuali icone */
}

.btn-nav:hover,
.btn-main:hover,
.btn-back:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    color: white;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #f1f5f9;
    color: #475569;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-sm);
    gap: 8px;
}

.btn-back:hover {
    background-color: #e2e8f0;
    color: #0f172a;
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.btn-switch {
    display: flex;
    width: 100%;
    max-width: 320px;
    margin: 2rem auto 1rem auto;
    background-color: var(--text-primary);
    padding: 16px 24px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.95rem;
}

.btn-switch:hover {
    background-color: #0f172a;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-switch.red-variant {
    background-color: var(--accent-red);
}

.btn-switch.red-variant:hover {
    background-color: var(--accent-red-hover);
}

/* =========================================================================
   TIMELINE (LISTA EVENTI)
   ========================================================================= */
.timeline {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* =========================================================================
   SKELETON LOADERS
   ========================================================================= */
.skeleton-container {
    list-style: none;
    padding: 0;
    margin: 0;
}

.skeleton {
    background: #e2e8f0;
    background: linear-gradient(110deg, #e2e8f0 8%, #f1f5f9 18%, #e2e8f0 33%);
    background-size: 200% 100%;
    animation: 1.5s shimmer linear infinite;
    border-radius: var(--border-radius);
}

body.theme-red .skeleton {
    background: #fecaca;
    background: linear-gradient(110deg, #fecaca 8%, #fee2e2 18%, #fecaca 33%);
    background-size: 200% 100%;
}

.skeleton-item {
    background: var(--container-bg);
    border: 1px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
}

.skeleton-badge {
    height: 32px;
    width: 75px;
    border-radius: 30px;
    margin-right: 20px;
    flex-shrink: 0;
}

.skeleton-content {
    flex-grow: 1;
}

.skeleton-title {
    height: 20px;
    width: 60%;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-subtitle {
    height: 14px;
    width: 40%;
    border-radius: 4px;
}

@keyframes shimmer {
    to {
        background-position-x: -200%;
    }
}

.event-item {
    background: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
    /* Cascade Animation properties */
    opacity: 0;
    animation: fadeUp 0.5s ease-out forwards;
}

.event-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: scale(1.01) translateY(-2px);
    /* Un leggero rialzo al passaggio */
    background-color: var(--bg-color);
}

/* Freccia/Icona destra */
.event-item::after {
    content: '→';
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    color: #94a3b8;
    opacity: 0;
    /* Nascosto di default */
    transition: all var(--transition-fast);
}

.event-item:hover::after {
    opacity: 1;
    right: 15px;
    /* Animazione slide-in */
    color: var(--accent-color);
}

.event-item .event-content {
    flex-grow: 1;
    padding-right: 40px;
    /* Spazio per la freccia */
}

.time-badge {
    background: var(--text-primary);
    color: var(--badge-text, white);
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-right: 20px;
    min-width: 75px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.event-info h3 {
    margin: 0 0 4px 0;
    font-size: 1.15rem;
    color: var(--text-primary);
    line-height: 1.3;
}

.year-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: inline-block;
}

/* =========================================================================
   FORM DI RICERCA & SELECT
   ========================================================================= */
.search-container {
    text-align: center;
    padding: 2rem 0;
}

select {
    padding: 12px 16px;
    font-size: 1rem;
    font-family: inherit;
    margin: 5px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background-color: white;
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* =========================================================================
   MODAL (POPUP) PREMIUM
   ========================================================================= */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.75);
    /* Sfondo blu notte semitrasparente */
    backdrop-filter: blur(8px);
    /* Effetto vetro iOS */
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.modal.show {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--container-bg);
    padding: 0;
    /* Padding rimosso per permettere all'immagine di toccare i bordi in alto */
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 480px;
    position: relative;
    box-shadow: var(--shadow-lg);
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    /* Anmazione morbida Apple-style */
}

/* Rimozione transizioni per interazione touch 1:1 */
.modal-content.swiping {
    transition: none !important;
}

.modal.show .modal-content {
    transform: translateY(0) scale(1);
}

.modal-handle {
    display: none;
    width: 40px;
    height: 5px;
    background-color: #cbd5e1;
    border-radius: 5px;
    margin: 10px auto;
    cursor: grab;
}

.modal-body {
    padding: 25px;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #334155;
    cursor: pointer;
    z-index: 10;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.close-btn:hover {
    background: white;
    color: #0f172a;
    transform: scale(1.1);
}

/* Wrapper che crea la cornicetta intorno all'immagine */
.modal-img-wrapper {
    background-color: var(--container-bg);
    padding: 10px 10px 0 10px;
    border-top-left-radius: var(--border-radius-lg);
    border-top-right-radius: var(--border-radius-lg);
}

.modal-img-wrapper.hidden {
    display: none !important;
}

.modal-img {
    display: block;
    width: 100%;
    max-height: 280px;
    /* Cap per immagini molto verticali */
    object-fit: contain;
    /* Mostra l'intera immagine senza tagliarla */
    border-radius: 10px;
    /* Bordi arrotondati anche sull'img */
    background-color: var(--container-bg);
    /* Sfondo stesso del modal per le parti vuote laterali */
}

.modal-img.hidden {
    display: none !important;
}

#modalTitle {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.modal-meta {
    color: var(--text-secondary);
    font-size: 0.95em;
    font-weight: 500;
    margin-bottom: 1rem;
}

#modalDesc {
    line-height: 1.6;
    color: #475569;
    font-size: 1rem;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.btn-wiki {
    background-color: #f1f5f9;
    color: #475569;
    flex: 1;
}

.btn-wiki:hover {
    background-color: #e2e8f0;
    color: #0f172a;
}

.btn-whatsapp {
    background-color: #25D366;
    /* Verde Whatsapp brand */
    color: white;
    flex: 1;
}

.btn-whatsapp:hover {
    background-color: #128C7E;
    color: white;
}

/* =========================================================================
   HEART BUTTONS & AUTH FORMS
   ========================================================================= */
.heart-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    opacity: 0.4;
    filter: grayscale(100%);
    padding: 5px;
}

.heart-btn:hover {
    transform: scale(1.15);
    opacity: 0.8;
}

.heart-btn.saved {
    opacity: 1;
    filter: grayscale(0%);
}

.auth-container .form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.auth-container .form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* =========================================================================
   MEDIA QUERIES (RESPONSIVE)
   ========================================================================= */
body.theme-red {
    --accent-color: var(--accent-red);
    --accent-hover: var(--accent-red-hover);
}

body.theme-red h1 {
    color: var(--accent-red-hover);
}

body.theme-red .time-badge {
    background: var(--accent-red-hover);
    color: white;
}

body.theme-red .event-item:hover {
    border-color: #fca5a5;
    background-color: #fef2f2;
}

body.theme-red .event-item:hover::after {
    color: var(--accent-red);
}

body.theme-ww1 {
    --accent-color: var(--accent-ww1);
    --accent-hover: var(--accent-ww1-hover);
}

body.theme-ww1 h1 {
    color: var(--accent-ww1-hover);
}

body.theme-ww1 .time-badge {
    background: var(--accent-ww1-hover);
    color: white;
}

body.theme-ww1 .event-item:hover {
    border-color: #8da367;
    background-color: #f5f5dc; /* Un tocco crema/seppia di sfondo */
}

body.theme-ww1 .event-item:hover::after {
    color: var(--accent-ww1);
}

body.theme-ww1 .modal-img {
    filter: var(--sepia-filter);
}

/* =========================================================================
   SIDEBAR & MOBILE NAVIGATION
   ========================================================================= */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.sidebar-overlay {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

.sidebar-menu {
    position: fixed;
    top: 0;
    right: -320px;
    width: 280px;
    height: 100vh;
    background: var(--container-bg);
    z-index: 1000;
    transition: right var(--transition-normal) cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.1);
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-y: auto;
}

.sidebar-menu.show {
    right: 0;
}

.sidebar-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 10px;
}

.close-sidebar-btn {
    background: none;
    border: none;
    font-size: 2.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.sidebar-item {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 1.05rem;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.sidebar-item:hover {
    background-color: #f1f5f9;
}

[data-theme="dark"] .sidebar-item:hover {
    background-color: rgba(255, 255, 255, 0.06);
}

#themeToggleBtnMobile {
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    font-family: inherit;
    text-align: left;
}

/* Sidebar profile card for logged-in users */
.sidebar-profile {
    padding: 18px 15px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(96, 165, 250, 0.02) 100%);
    border-radius: var(--border-radius);
    text-align: center;
    margin-bottom: 8px;
    border: 1px solid rgba(59, 130, 246, 0.12);
    transition: all var(--transition-normal);
}

body.theme-red .sidebar-profile {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(248, 113, 113, 0.02) 100%);
    border-color: rgba(239, 68, 68, 0.12);
}

body.theme-ww1 .sidebar-profile {
    background: linear-gradient(135deg, rgba(85, 107, 47, 0.08) 0%, rgba(163, 230, 53, 0.02) 100%);
    border-color: rgba(85, 107, 47, 0.12);
}

[data-theme="dark"] .sidebar-profile {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.01) 100%);
    border-color: rgba(255, 255, 255, 0.06);
}

.sidebar-avatar {
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    width: 54px;
    height: 54px;
    margin: 0 auto 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
    border: 2px solid white;
}

[data-theme="dark"] .sidebar-avatar {
    border-color: var(--container-bg);
}

.sidebar-username {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Sidebar custom logout button styling */
.sidebar-logout {
    margin-top: auto;
    padding-top: 15px;
}

.sidebar-logout-btn {
    color: var(--accent-red) !important;
    justify-content: center;
    background-color: rgba(239, 68, 68, 0.06);
    border: 1px solid rgba(239, 68, 68, 0.12);
}

.sidebar-logout-btn:hover {
    background-color: rgba(239, 68, 68, 0.12);
    color: var(--accent-red-hover) !important;
}

[data-theme="dark"] .sidebar-logout-btn {
    background-color: rgba(248, 113, 113, 0.08);
    border-color: rgba(248, 113, 113, 0.15);
}

[data-theme="dark"] .sidebar-logout-btn:hover {
    background-color: rgba(248, 113, 113, 0.15);
}

/* =========================================================================
   MOBILE RESPONSIVENESS (SMARTPHONES)
   ========================================================================= */
@media (max-width: 768px) {
    .desktop-nav {
        display: none !important;
    }

    .mobile-menu-btn {
        display: block !important;
    }
}

@media (max-width: 640px) {
    .container {
        margin: 0;
        padding: 15px;
        width: 100%;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }

    h1 {
        font-size: 2rem;
        padding-top: 1rem;
    }

    .event-item {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .event-item .event-content {
        padding-right: 0;
    }

    .event-item::after {
        display: none;
        /* Nasconde la freccia su mobile a favore dello spazio */
    }

    .time-badge {
        margin-right: 0;
        font-size: 0.85rem;
    }

    .modal-content {
        width: 100%;
        height: 100%;
        /* Full screen su mobile */
        max-height: 100vh;
        border-radius: 0;
        transform: translateY(100%);
        /* Slide dal basso */
    }

    .modal.show .modal-content {
        transform: translateY(0);
    }

    .modal-img-wrapper {
        padding: 8px 8px 0 8px;
        border-radius: 0;
    }

    .modal-img {
        max-height: 30vh;
        border-radius: 8px;
    }

    .modal-handle {
        display: block;
    }

    .close-btn {
        top: 20px;
        right: 20px;
        background: rgba(0, 0, 0, 0.5);
        /* Più scuro su mobile se va sopra foto bianche */
        color: white;
    }

    .modal-actions {
        flex-direction: column;
        /* Bottoni uno sotto l'altro su mobile per clic facile */
        gap: 10px;
        padding-bottom: 20px;
    }

    .btn-nav,
    .btn-main,
    .btn-switch,
    .btn-back {
        font-size: 1.1rem;
        /* Più grande su mobile per tappare facile */
        padding: 14px 24px;
    }
}

/* =========================================================================
   ADMIN PANEL STYLES
   ========================================================================= */
.admin-card {
    background-color: var(--container-bg);
    border: 1px solid #e2e8f0;
    padding: 30px;
    border-radius: var(--border-radius);
    text-align: center;
    margin-top: 30px;
    box-shadow: var(--shadow-sm);
}

.admin-card-dashed {
    background-color: #f8fafc;
    border: 2px dashed #cbd5e1;
    box-shadow: none;
}

.alert {
    padding: 16px;
    border-radius: var(--border-radius);
    text-align: center;
    margin: 20px 0;
    font-weight: 600;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.btn-success {
    background-color: #22c55e;
}

.btn-success:hover {
    background-color: #16a34a;
}

/* =========================================================================
   ANIMATIONS & KEYFRAMES (Cascade / Fade Up)
   ========================================================================= */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Classi per animare le frasi similmente agli eventi */
.frase-item {
    opacity: 0;
    animation: fadeUp 0.5s ease-out forwards;
}

.frase-item:hover {
    box-shadow: var(--shadow-md);
    transform: scale(1.01) translateY(-2px);
    border-color: #cbd5e1;
}

.frase-preview-text {
    font-family: 'Georgia', serif;
    font-size: 1.15rem;
    color: var(--text-dark);
    margin-bottom: 5px;
    font-style: italic;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 640px) {
    .frase-preview-text {
        font-size: 1rem;
    }
}

/* =========================================================================
   SCROLL TO TOP BUTTON
   ========================================================================= */
#scrollToTopBtn {
    display: none;
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99;
    font-size: 1.5rem;
    border: none;
    outline: none;
    background-color: var(--accent-color);
    color: white;
    cursor: pointer;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    box-shadow: var(--shadow-md);
    transition: background-color var(--transition-fast), transform var(--transition-fast), opacity var(--transition-normal);
    opacity: 0;
    align-items: center;
    justify-content: center;
}

#scrollToTopBtn.show {
    display: flex;
    opacity: 1;
}

#scrollToTopBtn:hover {
    background-color: var(--accent-hover);
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

@media (max-width: 640px) {
    #scrollToTopBtn {
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
}

/* =========================================================================
   FOOTER & LEGAL PAGES
   ========================================================================= */
.site-footer {
    background-color: #ffffff;
    border-top: 1px solid #e2e8f0;
    padding: 30px 20px;
    margin-top: 40px;
    text-align: center;
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.footer-social {
    display: flex;
    gap: 25px;
    margin-bottom: 5px;
}

.footer-social a {
    color: var(--text-secondary);
    font-size: 1.5rem;
    transition: all var(--transition-normal);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: transparent;
}

.footer-social a:hover {
    color: var(--accent-color);
    transform: translateY(-3px);
    background: rgba(59, 130, 246, 0.05); /* Un tocco di blu trasparente */
}

.footer-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
    opacity: 0.8;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--accent-color);
    text-decoration: underline;
}

/* =========================================================================
   COOKIE BANNER
   ========================================================================= */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #ffffff;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    border-top: 3px solid var(--accent-color);
}

.cookie-banner.show {
    transform: translateY(0);
}

.cookie-banner.hidden {
    display: none;
}

.cookie-content {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px 25px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

.cookie-text {
    flex: 1;
}

.cookie-text h3 {
    margin: 0 0 10px 0;
    color: var(--text-primary);
    font-size: 1.2rem;
}

.cookie-text p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.cookie-actions {
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .cookie-content {
        flex-direction: column;
        align-items: stretch;
        gap: 20px;
        padding: 20px;
    }

    .cookie-actions .btn-main {
        width: 100%;
    }
}

/* =========================================================================
   ANIMAZIONI UX (Fade-up & Scroll)
   ========================================================================= */
.fade-up-element {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: opacity, transform;
}

.fade-up-element.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Gestione delle transizioni su tilt */
.js-tilt-glare {
    border-radius: var(--border-radius);
}
/* =========================================================================
   VIEW TRANSITIONS API CUSTOMIZATION
   ========================================================================= */
::view-transition-old(root),
::view-transition-new(root) {
    animation-duration: 0.6s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

::view-transition-old(root) {
    animation-name: fade-out, slide-out-left;
}

::view-transition-new(root) {
    animation-name: fade-in, slide-in-right;
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slide-out-left {
    from { transform: translateX(0); }
    to { transform: translateX(-15%); }
}

@keyframes slide-in-right {
    from { transform: translateX(15%); }
    to { transform: translateX(0); }
}
