/* 
 * Blog Carousel V3 - Colorful Service Grid Style
 * Design ispirato ai service grid con colori vivaci e scrolling laterale fluido
 */

/* === CONTAINER PRINCIPALE === */
.blog-section-v3 {
    position: relative;
    padding: 60px 20px;
    /*background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);*/
    min-height: 500px;
    overflow: visible;
}

/* Rimosso ::before per eliminare la linea visibile sopra il titolo */

.blog-section-v3-fullwidth {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
}

/* === HEADER === */
.blog-header-v3 {
    text-align: center;
    margin-bottom: 50px;
    position: relative;
    z-index: 2;
}

.blog-title-v3 {
    font-size: 3rem;
    font-weight: var(--st-font-bold);
    color: var(--st-text-primary);
    margin-bottom: 15px;
    text-shadow: 0 0 30px rgba(var(--st-primary-rgb), 0.3);
    background: linear-gradient(45deg, var(--st-primary), #ff4757, #7877c6, var(--st-primary));
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 4s ease-in-out infinite;
}

.blog-title-v3 .highlight {
    color: var(--st-primary);
    text-shadow: 0 0 20px rgba(var(--st-primary-rgb), 0.6);
}

.blog-subtitle-v3 {
    font-size: 1.2rem;
    color: var(--st-text-secondary);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* === CAROUSEL CONTAINER === */
.blog-carousel-v3 {
    position: relative;
    max-width: none;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: visible;
}

/* === TRACK SCORREVOLE === */
.blog-carousel-track-v3 {
    display: flex;
    gap: 20px;
    padding: 60px 120px; /* Aumentato padding per evitare taglio ombre */
    overflow-x: auto;
    overflow-y: visible;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-snap-type: x proximity;
    position: relative;
    /* Miglioramenti per fluidità swipe */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    scroll-padding: 0;
}

.blog-carousel-track-v3::-webkit-scrollbar {
    display: none;
}

/* === BLOG CARDS V3 - Hybrid Image + Color Style === */
.blog-card-v3 {
    flex: 0 0 380px;
    height: 420px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--st-radius-lg);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    scroll-snap-align: center;
    transition: all 0.3s ease-out;
    transform-style: preserve-3d;
    margin: 20px 10px;
    /* Touch-friendly ottimizzazioni */
    touch-action: pan-x;
    user-select: none;
}

/* === HEADER CON IMMAGINE === */
.blog-card-header-v3 {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.blog-card-image-v3 {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    border-radius: var(--st-radius-lg) var(--st-radius-lg) 0 0;
}

.blog-card-v3:hover .blog-card-image-v3 {
    transform: scale(1.05);
}

.blog-card-overlay-v3 {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--card-gradient-start), var(--card-gradient-end));
    opacity: 0.7;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.blog-card-v3:hover .blog-card-overlay-v3 {
    opacity: 0.85;
}

/* Badge categoria sopra l'immagine */
.blog-card-category-v3 {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    backdrop-filter: blur(10px);
    z-index: 2;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Tempo di lettura sopra l'immagine */
.blog-card-reading-time-v3 {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 10px;
    border-radius: 15px;
    font-size: 0.8rem;
    font-weight: 500;
    backdrop-filter: blur(10px);
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 4px;
}

.blog-card-reading-time-v3::before {
    content: '🕒';
    font-size: 0.8rem;
}

/* Gradienti colorati per le card - Stile Service Grid */
.blog-card-v3:nth-child(4n+1) {
    --card-gradient-start: rgba(var(--st-primary-rgb), 0.85);
    --card-gradient-end: rgba(0, 212, 170, 0.90);
    --card-shadow: rgba(var(--st-primary-rgb), 0.2); /* Ridotta da 0.4 a 0.2 */
    --card-glow: rgba(var(--st-primary-rgb), 0.35); /* Ridotta da 0.6 a 0.35 */
    --card-text-color: var(--st-text-primary);
    --card-bg-color: var(--st-primary);
}

.blog-card-v3:nth-child(4n+2) {
    --card-gradient-start: rgba(255, 71, 87, 0.85);
    --card-gradient-end: rgba(255, 55, 66, 0.90);
    --card-shadow: rgba(255, 71, 87, 0.2); /* Ridotta da 0.4 a 0.2 */
    --card-glow: rgba(255, 71, 87, 0.35); /* Ridotta da 0.6 a 0.35 */
    --card-text-color: var(--st-text-primary);
    --card-bg-color: #ff4757;
}

.blog-card-v3:nth-child(4n+3) {
    --card-gradient-start: rgba(120, 119, 198, 0.85);
    --card-gradient-end: rgba(95, 95, 196, 0.90);
    --card-shadow: rgba(120, 119, 198, 0.2); /* Ridotta da 0.4 a 0.2 */
    --card-glow: rgba(120, 119, 198, 0.35); /* Ridotta da 0.6 a 0.35 */
    --card-text-color: var(--st-text-primary);
    --card-bg-color: #7877c6;
}

.blog-card-v3:nth-child(4n+4) {
    --card-gradient-start: rgba(255, 167, 38, 0.85);
    --card-gradient-end: rgba(255, 152, 0, 0.90);
    --card-shadow: rgba(255, 167, 38, 0.2); /* Ridotta da 0.4 a 0.2 */
    --card-glow: rgba(255, 167, 38, 0.35); /* Ridotta da 0.6 a 0.35 */
    --card-text-color: var(--st-text-primary);
    --card-bg-color: #ffa726;
}

.blog-card-v3:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: 
        0 15px 45px var(--card-shadow), /* Ridotta sfocatura da 20px/60px a 15px/45px */
        0 0 30px var(--card-glow), /* Ridotta da 40px a 30px */
        inset 0 0 0 1px rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* === CONTENUTO DELLA CARD === */
.blog-card-content-v3 {
    position: relative;
    z-index: 2;
    height: calc(100% - 200px);
    display: flex;
    flex-direction: column;
    padding: 25px;
    color: white;
    background: linear-gradient(180deg, 
        rgba(0, 0, 0, 0.1) 0%, 
        rgba(0, 0, 0, 0.4) 50%, 
        rgba(0, 0, 0, 0.7) 100%);
    backdrop-filter: none;
}

.blog-card-title-v3 {
    font-size: 1.4rem;
    font-weight: var(--st-font-bold);
    line-height: 1.3;
    margin: 0 0 15px 0;
    color: var(--st-text-primary);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blog-card-excerpt-v3 {
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--st-text-secondary);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 20px;
}

.blog-card-footer-v3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.blog-card-date-v3 {
    font-size: 0.85rem;
    color: var(--st-text-muted);
    font-weight: var(--st-font-medium);
}

.blog-card-cta-v3 {
    background: var(--card-gradient-start);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.blog-card-cta-v3::after {
    content: '→';
    transition: transform 0.3s ease;
}

.blog-card-v3:hover .blog-card-cta-v3 {
    background: var(--card-gradient-end);
    transform: translateX(3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.blog-card-v3:hover .blog-card-cta-v3::after {
    transform: translateX(3px);
}

/* === BLOG WALL EXTENSIONS === */
.blog-card-tags .tag-pill {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    padding:4px 10px;
    border-radius: 999px;
    line-height:1;
    font-size:.65rem;
    letter-spacing:.5px;
    font-weight:500;
    color: var(--st-text-secondary);
    backdrop-filter: blur(6px);
    transition:.25s;
}
.blog-card-tags .tag-pill.more { background:linear-gradient(135deg,var(--st-primary),#ff4757); color:#fff; border-color:rgba(255,255,255,0.3); }
.blog-card-tags .tag-pill:hover { color: var(--st-text-primary); border-color:rgba(var(--st-primary-rgb),0.6); }

/* No-image fallback gradient */
.blog-card-wall.no-image .blog-card-header-v3 {
    background: linear-gradient(135deg,var(--card-gradient-start),var(--card-gradient-end));
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
}
.blog-card-wall.no-image .blog-card-header-v3 img { display:none; }
/* If images still not visible, ensure cards are not erroneously getting no-image class; see template logic updated to set no-image only when no $img. */

/* Fade-in animation */
.fade-in-observe { opacity:0; transform: translateY(25px); transition: opacity .6s ease, transform .6s cubic-bezier(.4,.2,.1,1); }
.fade-in-observe.in { opacity:1; transform:translateY(0); }

/* === BLOG WALL IMAGE SIZE REFINEMENTS (CSS-only) === */
/* Use aspect-ratio for responsive header instead of fixed heights */
.blog-card-v3.blog-card-wall .blog-card-header-v3 {
    border-top-left-radius: var(--st-radius-lg);
    border-top-right-radius: var(--st-radius-lg);
    overflow: hidden;
    display: flex;
    align-items: stretch;
    position: relative;
    aspect-ratio: 16/9;
}
@supports not (aspect-ratio: 16/9){
    .blog-card-v3.blog-card-wall .blog-card-header-v3 { height:230px; }
}

/* Image behavior */
.blog-card-v3.blog-card-wall .blog-card-image-v3 {
    width:100%;
    height:100%;
    object-fit:cover;
    object-position:center;
    transform:scale(1.05);
    transition:transform .8s cubic-bezier(.22,.61,.36,1), filter .6s;
    filter:brightness(.9) saturate(1.05);
    /*border-radius: var(--st-radius-lg) var(--st-radius-lg) 0 0;*/
}
.blog-card-v3.blog-card-wall:hover .blog-card-image-v3,
.blog-card-v3.blog-card-wall:focus-visible .blog-card-image-v3 {
    transform:scale(1.12);
    filter:brightness(1) saturate(1.15);
}

/* Overlay adjustment */
.blog-card-v3.blog-card-wall .blog-card-overlay-v3 {
    opacity:.55;
    backdrop-filter:blur(2px);
    transition:opacity .5s;
}
.blog-card-v3.blog-card-wall:hover .blog-card-overlay-v3 { opacity:.35; }

/* No-image gradient fallback */
.blog-card-v3.blog-card-wall.no-image .blog-card-header-v3 {
    background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.08), rgba(0,0,0,.55)),
               linear-gradient(135deg, var(--card-gradient-start, var(--st-primary)), var(--card-gradient-end, #ff4757));
}
.blog-card-v3.blog-card-wall.no-image .blog-card-image-v3 { display:none; }

/* Adjust content spacing after shorter header */
.blog-card-v3.blog-card-wall .blog-card-content-v3 { 
    padding-top:1.25rem;
    display:flex;
    flex-direction:column;
    flex:1 1 auto;
}
.blog-card-v3.blog-card-wall .blog-card-content-v3 .blog-card-excerpt-v3 { flex:0 0 auto; }
.blog-card-v3.blog-card-wall .blog-card-footer-v3 { margin-top:auto; }

/* Ensure excerpt clamp retained */
.blog-card-v3.blog-card-wall .blog-card-excerpt-v3 { -webkit-line-clamp:3; line-clamp:3; }


/* === NAVIGATION BUTTONS === */
.blog-nav-v3 {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(20px);
    z-index: 3;
    opacity: 0.8;
}

.blog-nav-v3:hover {
    background: rgba(var(--st-primary-rgb), 0.2);
    border-color: rgba(var(--st-primary-rgb), 0.4);
    box-shadow: 0 0 20px rgba(var(--st-primary-rgb), 0.3);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.blog-nav-prev-v3 {
    left: 20px;
}

.blog-nav-next-v3 {
    right: 20px;
}

/* === PROGRESS BAR === */
.blog-progress-v3 {
    margin: 40px auto 0;
    max-width: 300px;
    background: rgba(255, 255, 255, 0.1);
    height: 3px;
    border-radius: 2px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.blog-progress-bar-v3 {
    height: 100%;
    background: linear-gradient(90deg, var(--st-primary), #ff4757, #7877c6, #ffa726);
    background-size: 300% 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: progressGlow 3s ease-in-out infinite;
}

@keyframes progressGlow {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* === BLOG WALL (Vertical Grid using V3 cards) === */
.blog-index-wall {
    /*background: linear-gradient(135deg, #0a0a0f 0%, #141822 50%, #0f1625 100%);*/
    min-height: 100vh;
    position: relative;
}

.blog-wall-hero {
    position: relative;
}

.blog-wall-layout {
    position: relative;
    z-index: 2;
}

.blog-wall-content {
    position: relative;
    z-index: 1;
}

.blog-wall-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 40px 30px;
}

/* Wall variant: remove fixed heights so content can grow naturally */
.blog-card-wall.blog-card-v3 {
    flex: initial;
    width: auto;
    height: auto;
    min-height: 420px;
    margin: 0;
    display:flex;
    flex-direction:column;
}
@media (max-width: 992px){ .blog-card-wall.blog-card-v3 { min-height:380px; } }
@media (max-width: 576px){ .blog-card-wall.blog-card-v3 { min-height:340px; } }

.blog-wall-sidebar .blog-filter-block {
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.08);
    padding: 20px 18px;
    border-radius: var(--st-radius-lg);
    backdrop-filter: blur(12px);
}

.blog-filter-list li + li { margin-top: 6px; }

.blog-filter-list .filter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--st-text-secondary);
    background: rgba(255,255,255,0.02);
    border: 1px solid transparent;
    transition: .25s;
    font-weight: 500;
}
.blog-filter-list .filter-item .count { font-size: .7rem; background: rgba(255,255,255,0.08); padding: 2px 6px; border-radius: 12px; }
.blog-filter-list .filter-item:hover { color: var(--st-text-primary); border-color: rgba(var(--st-primary-rgb),0.4); }
.blog-filter-list .filter-item.active { background: linear-gradient(135deg,var(--st-primary),#ff4757); color:#fff; box-shadow: 0 0 0 1px rgba(255,255,255,0.15); }

.tag-chip {
    --chip-bg: rgba(255,255,255,0.06);
    display:inline-flex;
    align-items:center;
    padding:6px 12px;
    border-radius:20px;
    font-size:.75rem;
    text-decoration:none;
    background:var(--chip-bg);
    color:var(--st-text-secondary);
    border:1px solid rgba(255,255,255,0.1);
    transition:.25s;
}
.tag-chip:hover { color: var(--st-text-primary); background: rgba(255,255,255,0.12); }
.tag-chip.active { background: linear-gradient(135deg,var(--st-primary),#ff4757); color:#fff; border-color: rgba(255,255,255,0.3); }

.blog-active-filters .badge { margin-right:6px; }
/* Active filters styled like filter list items */
.blog-active-filters .filter-item {
    background: linear-gradient(135deg,var(--st-primary),#ff4757);
    color:#fff;
    padding:6px 12px;
    border-radius:8px;
    display:inline-flex;
    align-items:center;
    gap:4px;
    font-weight:600;
    border:1px solid rgba(255,255,255,0.25);
    box-shadow:0 4px 15px rgba(0,0,0,.25);
}
.blog-active-filters .filter-item:hover { filter:brightness(1.1); text-decoration:none; }

/* Improve stretched-link click area without layout shift */
.blog-card-v3 .stretched-link::after { top:0; left:0; right:0; bottom:0; }


/* === INDICATORS DOTS - RIMOSSI ===
Indicatori rimossi per richiesta utente */

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .blog-carousel-track-v3 {
        gap: 18px;
        padding: 50px 80px; /* Aumentato padding laterale */
    }
    
    .blog-card-v3 {
        flex: 0 0 350px;
        height: 400px;
        margin: 15px 8px;
    }
    
    .blog-card-header-v3 {
        height: 180px;
    }
    
    .blog-card-content-v3 {
        height: calc(100% - 180px);
        padding: 20px;
    }
    
    .blog-nav-prev-v3 {
        left: 15px;
    }
    
    .blog-nav-next-v3 {
        right: 15px;
    }
}

@media (max-width: 768px) {
    .blog-section-v3 {
        padding: 40px 0;
    }
    
    .blog-carousel-track-v3 {
        gap: 15px;
        padding: 40px 60px; /* Aumentato padding su tablet */
        /* Ottimizzazioni specifiche mobile */
        scroll-snap-type: none;
        scroll-behavior: auto;
    }
    
    .blog-title-v3 {
        font-size: 2.2rem;
    }
    
    .blog-card-v3 {
        flex: 0 0 300px;
        height: 360px;
        margin: 10px 5px;
        /* Rimuovo snap su mobile per fluidità */
        scroll-snap-align: none;
        transition: transform 0.2s ease-out;
    }
    
    .blog-card-header-v3 {
        height: 160px;
    }
    
    .blog-card-content-v3 {
        height: calc(100% - 160px);
        padding: 18px;
    }
    
    .blog-card-title-v3 {
        font-size: 1.2rem;
    }
    
    .blog-card-excerpt-v3 {
        font-size: 0.9rem;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .blog-nav-v3 {
        width: 50px;
        height: 50px;
        font-size: 1rem;
    }
    
    .blog-nav-prev-v3 {
        left: 10px;
    }
    
    .blog-nav-next-v3 {
        right: 10px;
    }
}

@media (max-width: 480px) {
    .blog-carousel-track-v3 {
        gap: 12px;
        padding: 30px 40px; /* Aumentato padding anche su mobile */
        /* Massima fluidità su schermi piccoli */
        scroll-snap-type: none;
    }
    
    .blog-card-v3 {
        flex: 0 0 280px;
        height: 340px;
        margin: 10px 3px;
        scroll-snap-align: none;
    }
    
    .blog-card-header-v3 {
        height: 140px;
    }
    
    .blog-card-content-v3 {
        height: calc(100% - 140px);
        padding: 15px;
    }
    
    .blog-nav-v3 {
        display: none;
    }
}

/* === LOADING STATE === */
.blog-carousel-loading-v3 {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
}

.blog-loading-spinner-v3 {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top: 3px solid var(--st-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* === FEATURED CARDS === */
.blog-card-featured-v3 {
    position: relative;
}

.blog-card-featured-v3::after {
    content: '⭐';
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 1.2rem;
    z-index: 10;
    filter: drop-shadow(0 0 10px rgba(255, 255, 0, 0.6));
    pointer-events: none;
}

/* Sposta il tempo di lettura nelle card featured per lasciare spazio alla stellina a destra */
.blog-card-featured-v3 .blog-card-reading-time-v3 {
    right: 45px;
}

/* Rimuovo la regola per spostare la categoria dato che ora la stellina è a destra */

/* === SMOOTH ANIMATIONS === */
.blog-card-v3 * {
    transition: all 0.3s ease;
}

/* === ACCESSIBILITY === */
.blog-card-v3:focus,
.blog-nav-v3:focus {
    outline: 2px solid var(--st-primary);
    outline-offset: 2px;
}

/* === PERFORMANCE OPTIMIZATIONS === */
.blog-carousel-track-v3 {
    will-change: scroll-position;
    /* Ottimizzazioni scroll fluido */
    scroll-snap-stop: normal;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.blog-card-v3 {
    will-change: transform;
    /* Hardware acceleration per smooth animations */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* === OTTIMIZZAZIONI TOUCH E SWIPE === */
@media (pointer: coarse) {
    .blog-carousel-track-v3 {
        /* Su dispositivi touch, rimuovo snap per fluidità */
        scroll-snap-type: none;
        overscroll-behavior-x: auto;
    }
    
    .blog-card-v3 {
        scroll-snap-align: none;
        /* Transizioni più veloci su touch */
        transition: transform 0.2s ease-out;
    }
    
    .blog-card-v3:hover {
        /* Riduco gli effetti hover su touch per evitare lag */
        transform: translateY(-5px) scale(1.01);
    }
}
