/**
 * CSS Personalizzato per la Sezione News - davidefiore.com
 * Estetica Apple: Vetro, Profondità, Colori tailored e transizioni organiche
 * Aggiornato con Effetti WAHU! (Fascio Neon, Caricamento Cascata, Filtri Fluidi, TTS Player)
 */

:root {
    --ease-apple: cubic-bezier(0.16, 1, 0.3, 1);
}

.page-hero {
    padding: 160px 0 40px;
    text-align: center;
}

.page-title {
    font-size: clamp(2.5rem, 6vw, 3.8rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(to right, #ffffff 30%, #a3a3a3 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 15px;
    text-shadow: 0 0 80px rgba(139, 92, 246, 0.15);
}

/* 🟢 FILTRI CATEGORIA (Apple Segmented Control Style) */
.news-filter-container {
    display: flex;
    justify-content: center;
    margin-bottom: 50px;
    padding: 0 20px;
}

.news-filter-bar {
    display: inline-flex;
    padding: 6px;
    border-radius: 100px;
    background: rgba(25, 25, 25, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    box-shadow: 
        inset 0 1px 0 rgba(255,255,255,0.03),
        0 10px 30px rgba(0, 0, 0, 0.3);
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none; /* Hide scrollbar for Firefox */
}

.news-filter-bar::-webkit-scrollbar {
    display: none; /* Hide scrollbar for Chrome/Safari */
}

.filter-btn {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-sec);
    padding: 10px 22px;
    font-size: 0.88rem;
    font-weight: 500;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.35s var(--ease-apple);
    white-space: nowrap;
    position: relative;
    user-select: none;
}

.filter-btn:hover {
    color: #fff;
}

.filter-btn.active {
    color: #000;
    background: #fff;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
}

/* Griglia News */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 30px;
    padding-bottom: 100px;
}

/* 🌟 CARD NOTIZIA CON BORDO GRADIENTE AL PASSAGGIO (Neon Beam) */
.news-card {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 460px;
    border-radius: 20px;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(23, 23, 25, 0.75) 0%, rgba(15, 15, 15, 0.5) 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 
        inset 0 0 0 1px rgba(255, 255, 255, 0.02),
        0 15px 35px -10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: all 0.4s var(--ease-apple);
    will-change: transform, box-shadow, border-color, background-image;
    
    /* 🎬 Animazione Staggered Blur-In all'avvio */
    opacity: 0;
    transform: translateY(30px) scale(0.97);
    filter: blur(15px);
    animation: staggeredBlurFadeIn 0.9s var(--ease-apple) forwards;
}

@keyframes staggeredBlurFadeIn {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* Gestione Reduced Motion per accessibilità (A11y) */
@media (prefers-reduced-motion: reduce) {
    .news-card {
        opacity: 1;
        transform: none;
        filter: none;
        animation: none;
    }
}

/* Effetto Neon Border-Beam in Hover */
.news-card:hover {
    transform: translateY(-10px) scale(1.015);
    border-color: transparent;
    background-image: 
        linear-gradient(rgba(23, 23, 25, 0.88), rgba(15, 15, 15, 0.7)), 
        linear-gradient(135deg, var(--accent) 0%, var(--accent-secondary) 100%);
    background-clip: padding-box, border-box;
    background-origin: padding-box, border-box;
    
    box-shadow: 
        inset 0 0 0 1px rgba(255, 255, 255, 0.06),
        0 30px 60px -15px rgba(0, 0, 0, 0.8),
        0 0 40px rgba(139, 92, 246, 0.15);
}

.news-card:active {
    transform: translateY(-5px) scale(0.99);
    transition: all 0.15s var(--ease-smooth);
}

.news-card-img-wrapper {
    width: 100%;
    height: 200px;
    overflow: hidden;
    position: relative;
    background: rgba(255, 255, 255, 0.01);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.news-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease-apple);
}

.news-card:hover .news-card-img {
    transform: scale(1.06);
}

.news-card-img-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    background: linear-gradient(to top, rgba(15, 15, 15, 0.6), transparent);
    pointer-events: none;
}

.news-card-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.news-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.news-card-date {
    font-size: 0.78rem;
    color: var(--text-sec);
    font-weight: 500;
}

.news-card-tag {
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 100px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.25);
    transition: all 0.3s;
}

.news-card:hover .news-card-tag {
    background: rgba(217, 70, 239, 0.15);
    color: var(--accent-secondary);
    border-color: rgba(217, 70, 239, 0.3);
}

.news-card-title {
    font-size: 1.22rem;
    color: #fff;
    margin-bottom: 10px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card-summary {
    font-size: 0.88rem;
    color: var(--text-sec);
    line-height: 1.55;
    margin-bottom: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.news-card-cta {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s var(--ease-apple);
}

.news-card:hover .news-card-cta {
    color: #fff;
    transform: translateX(5px);
}

/* Modal Overlay per Dettaglio Articolo */
.news-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s var(--ease-apple), visibility 0.4s var(--ease-apple);
}

.news-modal.active {
    opacity: 1;
    visibility: visible;
}

.news-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 5, 0.78);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
}

.news-modal-container {
    position: relative;
    width: 90%;
    max-width: 780px;
    max-height: 85vh;
    background: linear-gradient(180deg, rgba(20, 20, 22, 0.9) 0%, rgba(10, 10, 10, 0.95) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 30px 70px -10px rgba(0, 0, 0, 0.9);
    border-radius: 24px;
    overflow-y: auto;
    z-index: 2002;
    transform: scale(0.94) translateY(20px);
    transition: transform 0.4s var(--ease-apple);
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.news-modal.active .news-modal-container {
    transform: scale(1) translateY(0);
}

/* 🟥 BARRA DI PROGRESSO LETTURA NELLA MODALE */
.modal-progress-container {
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.04);
    z-index: 2015;
}

.modal-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent-secondary) 100%);
    box-shadow: 0 0 10px var(--accent);
    transition: width 0.1s ease;
}

.news-modal-header-img {
    width: 100%;
    height: 350px;
    object-fit: cover;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.news-modal-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2010;
    transition: all 0.3s var(--ease-apple);
}

.news-modal-close-btn:hover {
    background: #fff;
    color: #000;
    transform: scale(1.08) rotate(90deg);
}

.news-modal-body {
    padding: 40px;
}

/* 🔊 PLAYER SINTESI VOCALE AI "READ ALOUD" */
.tts-player-container {
    display: inline-flex;
    align-items: center;
    gap: 15px;
    padding: 8px 18px;
    border-radius: 100px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    margin-bottom: 25px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.02);
    user-select: none;
}

.tts-play-btn {
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.tts-play-btn:hover {
    color: var(--accent);
}

/* Onde sonore animate */
.sound-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 14px;
}

.sound-wave .stroke {
    display: block;
    width: 2px;
    height: 100%;
    background: var(--accent);
    border-radius: 10px;
    animation: soundWavePulse 1.2s infinite ease-in-out;
}

.sound-wave .stroke:nth-child(1) { animation-delay: 0s; }
.sound-wave .stroke:nth-child(2) { animation-delay: 0.3s; background: var(--accent-secondary); }
.sound-wave .stroke:nth-child(3) { animation-delay: 0.6s; }
.sound-wave .stroke:nth-child(4) { animation-delay: 0.15s; background: var(--accent-secondary); }
.sound-wave .stroke:nth-child(5) { animation-delay: 0.4s; }

@keyframes soundWavePulse {
    0%, 100% { height: 3px; }
    50% { height: 14px; }
}

.news-modal-title {
    font-size: clamp(1.8rem, 4vw, 2.3rem);
    color: #fff;
    margin-bottom: 15px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.news-modal-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 15px;
}

.news-modal-date {
    font-size: 0.9rem;
    color: var(--text-sec);
}

.news-modal-text {
    color: rgba(245, 245, 247, 0.9);
    font-size: 1.05rem;
    line-height: 1.75;
}

.news-modal-text p {
    margin-bottom: 24px;
}

.news-modal-text strong {
    color: #fff;
}

.news-modal-text h2, .news-modal-text h3 {
    color: #fff;
    margin: 35px 0 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.news-modal-text h2 { font-size: 1.5rem; }
.news-modal-text h3 { font-size: 1.25rem; }

.news-modal-text a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    transition: all 0.2s;
}

.news-modal-text a:hover {
    color: var(--text-main);
    border-bottom-color: var(--text-main);
}

.news-modal-text ul, .news-modal-text ol {
    margin-bottom: 24px;
    padding-left: 20px;
}

.news-modal-text li {
    margin-bottom: 10px;
}

/* Empty State */
.news-empty-state {
    text-align: center;
    padding: 80px 40px;
    background: linear-gradient(180deg, rgba(23, 23, 25, 0.4) 0%, rgba(15, 15, 15, 0.2) 100%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 24px;
    max-width: 550px;
    margin: 60px auto 100px;
    backdrop-filter: blur(15px);
}

.news-empty-icon {
    font-size: 3.5rem;
    margin-bottom: 20px;
    display: inline-block;
    filter: drop-shadow(0 0 15px rgba(255,255,255,0.1));
}

.news-empty-state h3 {
    font-size: 1.4rem;
    color: #fff;
    margin-bottom: 10px;
}

.news-empty-state p {
    color: var(--text-sec);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Media Queries Responsiveness */
@media (max-width: 768px) {
    .page-hero {
        padding: 130px 0 30px;
    }
    
    .news-modal-body {
        padding: 30px 20px;
    }
    
    .news-modal-header-img {
        height: 220px;
    }
    
    .news-filter-bar {
        padding: 4px;
    }
    
    .filter-btn {
        padding: 8px 16px;
        font-size: 0.8rem;
    }
}
