/**
 * Mobile Styles - Hamburger Menu + Hero Slider
 */

/* ========================================
   MOBILE + TABLET: 0-1400px
   Include iPad Pro 12.9" fullscreen (1366px CSS)
   Desktop 1401px+ (monitor 1440px+)
   ======================================== */

@media (max-width: 1400px) {
    
    /* HAMBURGER BUTTON */
    .mobile-menu-toggle {
        display: flex !important;
        background: none;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
        z-index: 999999 !important; /* FIX: Massima priorità sopra tutto */
        position: relative;
    }
    
    .hamburger-icon {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 24px;
        height: 18px;
    }
    
    .hamburger-icon span {
        display: block;
        width: 100%;
        height: 3px;
        background-color: #fff;
        border-radius: 2px;
        transition: all 0.3s ease;
    }
    
    /* Hamburger animazione */
    .mobile-menu-toggle.active .hamburger-icon span:nth-child(1) {
        transform: rotate(45deg) translate(6px, 6px);
    }
    
    .mobile-menu-toggle.active .hamburger-icon span:nth-child(2) {
        opacity: 0;
    }
    
    .mobile-menu-toggle.active .hamburger-icon span:nth-child(3) {
        transform: rotate(-45deg) translate(6px, -6px);
    }
    
    /* TOPBAR MOBILE */
    .topbar {
        position: sticky;
        top: 0;
        z-index: 99998; /* FIX: Sotto toggle ma sopra contenuto */
    }
    
    .topbar-content {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        position: relative;
    }
    
    /* Logo centrato */
    .site-logo,
    .topbar-logo {
        position: absolute !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        margin: 0 !important;
    }
    
    .site-logo a,
    .topbar-logo a {
        font-size: 1.5rem;
    }
    
    .site-logo img,
    .topbar-logo img {
        max-height: 35px;
    }
    
    /* Nascondi elementi desktop */
    .topbar-social {
        display: none !important;
    }
    
    .main-header {
        display: none !important;
    }
    
    .news-ticker {
        display: none !important;
    }
    
    /* MOBILE MENU SIDEBAR */
    /* MOBILE MENU FULLSCREEN - Design pulito e professionale */
    .mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        min-height: 100vh; /* min-height invece di height per Safari iOS */
        height: auto; /* auto per permettere flexbox di calcolare correttamente */
        background-color: rgba(0, 0, 0, 0.97); /* Nero solido, no gradienti */
        z-index: 99997;
        opacity: 0;
        visibility: hidden;
        pointer-events: none; /* NON intercettare click quando chiuso */
        transition: opacity 0.3s ease, visibility 0.3s ease;
        display: flex;
        flex-direction: column;
        justify-content: center; /* Centratura verticale automatica */
        align-items: center; /* Centratura orizzontale automatica */
        overflow-y: auto;
        padding: 80px 20px 20px; /* Top per header, lati per safety */
    }
    
    .mobile-menu.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto; /* Riattiva click quando aperto */
    }
    
    .mobile-menu-items {
        list-style: none;
        padding: 0;
        margin: 0;
        text-align: center;
        width: 100%;
        max-width: 400px; /* Ridotto per look più compatto */
    }
    
    .mobile-menu-items li {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .mobile-menu-items li:last-child {
        border-bottom: none; /* Pulito senza bordo finale */
    }
    
    .mobile-menu-items a {
        display: block;
        padding: 0.8rem 1.5rem; /* Ridotto da 1.2rem 2rem per compattare */
        color: #fff;
        text-decoration: none;
        font-size: 0.95rem; /* Ridotto da 1.1rem per vedere social e scroll */
        font-weight: 600;
        transition: color 0.2s, background-color 0.2s;
        text-align: center;
    }
    
    .mobile-menu-items a:hover,
    .mobile-menu-items .current-menu-item a {
        background-color: rgba(255, 255, 255, 0.1); /* Sottile highlight, no rosso */
        color: #fff;
    }
    
    /* Social nel menu mobile */
    .mobile-menu-social {
        display: flex;
        justify-content: center;
        gap: 1rem;
        padding: 2rem 1.5rem 0;
        margin-top: 2rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .mobile-menu-social a {
        width: 44px;
        height: 44px;
        background-color: rgba(255, 255, 255, 0.1); /* Pulito, no colori */
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        font-size: 1.1rem;
        transition: background-color 0.2s, transform 0.2s;
    }
    
    .mobile-menu-social a:hover {
        background-color: rgba(255, 255, 255, 0.2); /* Subtle hover */
        transform: scale(1.05);
    }
    
    .mobile-menu-social a svg {
        width: 18px;
        height: 18px;
        fill: currentColor;
    }
    
    .mobile-menu-social a i {
        font-size: 18px;
    }
    
    /* Overlay */
    .mobile-menu-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%  ;
        background-color: rgba(0, 0, 0, 0.6);
        opacity: 0;
        visibility: hidden;
        pointer-events: none; /* NON intercettare click quando chiuso */
        transition: all 0.3s ease;
        z-index: 99996; /* FIX: Sotto menu ma sopra contenuto */
        display: block;
    }
    
    .mobile-menu-overlay.active {
        opacity: 1;
        visibility: visible;
        pointer-events: auto; /* Attiva click quando aperto */
    }
    
    /* HERO SLIDER MOBILE */
    .hero-slider {
        display: block !important;
        position: relative;
        width: 100%;
        overflow: hidden;
        margin-bottom: 2rem;
        background-color: #000;
    }
    
    .hero-slides {
        display: flex;
        transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }
    
    .hero-slide {
        min-width: 100%;
        flex-shrink: 0;
        position: relative;
    }
    
    .hero-slide-image {
        width: 100%;
        height: 0;
        padding-bottom: 50%; /* FIX: Ridotto da 56.25% (16:9) a 50% (2:1) per mobile */
        position: relative;
        overflow: hidden;
        background-color: #000;
    }
    
    .hero-slide-image img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }
    
    .hero-slide-overlay {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.7) 50%, transparent 100%);
        padding: 2rem 1.2rem 1.5rem;
    }
    
    .hero-slide-category {
        display: inline-block;
        background-color: var(--color-primary); /* FIX: Usa colore primario tema invece di rosso fisso */
        color: #fff;
        padding: 5px 14px;
        font-size: 0.75rem;
        font-weight: bold;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 0.8rem;
        border-radius: 2px;
    }
    
    .hero-slide-title {
        color: #fff;
        font-size: 1.4rem;
        font-weight: 800;
        line-height: 1.3;
        margin: 0;
        text-shadow: 0 2px 8px rgba(0,0,0,0.3);
    }
    
    .hero-slide-title a {
        color: #fff;
        text-decoration: none;
    }
    
    /* Slider dots */
    .hero-slider-dots {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
        padding: 1.2rem 0;
        background-color: #000;
    }
    
    .hero-slider-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background-color: rgba(255, 255, 255, 0.3);
        cursor: pointer;
        transition: all 0.3s ease;
        border: none;
        padding: 0;
    }
    
    .hero-slider-dot.active {
        background-color: var(--color-primary); /* Usa colore primario tema */
        width: 28px;
        border-radius: 4px;
    }
    
    /* HOME LAYOUT MOBILE */
    .home-layout {
        display: block !important;
    }
    
    .home-sidebar-left,
    .home-sidebar-right {
        width: 100%;
        margin-bottom: 2rem;
    }
    
    .home-main {
        width: 100%;
    }
    
    /* GRID 1 COLONNA */
    .articles-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }
    
    /* WIDGET 1 COLONNA */
    .category-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    /* FOOTER MOBILE - gestito in footer.css */
}

/* DESKTOP: Nascondi elementi mobile (solo sopra 1024px) */
/* Hero slider: nascosto su desktop vero (1025px+) */
@media (min-width: 1401px) {
    .hero-slider {
        display: none !important;
    }
}

/* Hamburger e menu mobile: nascosti da 1025px in su (desktop) */
@media (min-width: 1401px) {
    .mobile-menu-toggle {
        display: none !important;
    }
    
    .mobile-menu {
        display: none !important;
    }
    
    .mobile-menu-overlay {
        display: none !important;
    }
}

/* Tablet: Hero slider ancora più compatto su iPad */
@media (min-width: 768px) and (max-width: 1400px) {
    .hero-slide-image {
        padding-bottom: 50%; /* FIX v1.6.9: Stessa proporzione del cellulare (era 35% troppo stretto) */
    }
}

/* Dark mode mobile */
body.dark-mode .mobile-menu {
    background-color: #0a0a0a;
}

body.dark-mode .mobile-menu-items a {
    color: #f5f5f5;
}

body.dark-mode .hero-slider-dots {
    background-color: #0a0a0a;
}
    
    /* ULTIME NOTIZIE MOBILE (compatte) */
    .mobile-latest-news {
        margin-bottom: 2rem;
        background-color: var(--color-bg-light);
        padding: 1.5rem 1rem;
        border-radius: 4px;
    }
    
    .mobile-section-header {
        display: flex;
        align-items: center;
        margin-bottom: 1rem;
    }
    
    .mobile-section-title {
        font-size: 1rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--color-text);
        margin: 0;
        border-left: 4px solid var(--color-primary);
        padding-left: 10px;
        line-height: 1.2;
    }
    
    .mobile-section-title::before {
        display: none;
    }
    
    /* .mobile-section-link rimosso (link non più presenti) */
    
    .mobile-news-list {
        list-style: none;
        padding: 0;
        margin: 0;
    }
    
    .mobile-news-item {
        display: flex;
        gap: 1rem;
        padding: 0.8rem 0;
        border-bottom: 1px solid rgba(0,0,0,0.1);
    }
    
    .mobile-news-item:last-child {
        border-bottom: none;
    }
    
    .mobile-news-image {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
        border-radius: 4px;
        overflow: hidden;
    }
    
    .mobile-news-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .mobile-news-content {
        flex: 1;
        min-width: 0;
    }
    
    .mobile-news-category {
        font-size: 0.7rem;
        font-weight: bold;
        color: var(--color-primary);
        text-transform: uppercase;
        margin-bottom: 0.3rem;
    }
    
    .mobile-news-title {
        font-size: 0.9rem;
        font-weight: 600;
        line-height: 1.3;
        margin: 0;
    }
    
    .mobile-news-title a {
        color: var(--color-text);
        text-decoration: none;
    }
    
    .mobile-news-meta {
        font-size: 0.7rem;
        color: var(--color-text-light);
        margin-top: 0.3rem;
    }
    
    /* PIÙ LETTI MOBILE */
    .mobile-popular {
        margin-bottom: 2rem;
        background-color: var(--color-bg-light);
        padding: 1.5rem 1rem;
        border-radius: 4px;
    }
    
    /* Dark mode */
    body.dark-mode .mobile-latest-news,
    body.dark-mode .mobile-popular {
        background-color: #2a2a2a;
    }
    
    body.dark-mode .mobile-news-item {
        border-bottom-color: rgba(255,255,255,0.1);
    }
    
    body.dark-mode .mobile-section-title {
        color: #f0f0f0;
    }
    
    body.dark-mode .mobile-section-link {
        color: #ff6b75;
    }
    
    body.dark-mode .mobile-news-title a {
        color: #f5f5f5;
    }
    
    /* Logo nel menu mobile */
    .mobile-menu-logo {
        padding: 1.5rem;
        text-align: center;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        margin-bottom: 1rem;
    }
    
    .mobile-menu-logo a {
        color: #fff;
        text-decoration: none;
        font-size: 1.5rem;
        font-weight: bold;
    }
    
    .mobile-menu-logo img {
        max-height: 40px;
        width: auto;
        display: inline-block;
    }
    
    body.dark-mode .mobile-menu-logo {
        border-bottom-color: rgba(255, 255, 255, 0.05);
    }

/**
 * HIDE DESKTOP LAYOUT SU MOBILE/TABLET
 */
/**
 * HIDE DESKTOP LAYOUT SU MOBILE/TABLET
 * Changed from 1400px to 1024px - monitor 1366px should show desktop layout
 */
@media (max-width: 1024px) {
    .home-layout {
        display: none !important;
    }
}

/**
 * MENU DESKTOP — nascosto su tutto fino a 1366px (copre iPad Pro landscape)
 */
@media (max-width: 1366px) {
    .main-header {
        display: none !important;
    }
    
    .news-ticker {
        display: none !important;
    }
    
    /* Social topbar visibili solo su desktop vero */
    .topbar-social {
        display: none !important;
    }
}

/**
 * SHOW DESKTOP LAYOUT SOLO SU DESKTOP
 */
@media (min-width: 1401px) {
    .mobile-latest-news,
    .mobile-popular {
        display: none !important;
    }
}

/**
 * SINGLE POST MOBILE
 */
@media (max-width: 1400px) {
    /* Layout 1 colonna */
    .single-post-layout {
        display: block !important;
        grid-template-columns: 1fr !important;
        padding: var(--spacing-lg) 0 !important;
    }
    
    /* Container con meno padding laterale su mobile */
    .single-post-layout .container,
    body.single .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    
    /* Nascondi sidebar */
    .single-sidebar {
        display: none !important;
    }
    
    /* Titolo più piccolo */
    .article-title {
        font-size: 1.75rem !important;
        line-height: 1.3 !important;
    }
    
    /* Immagine featured full width */
    .article-featured-image {
        margin: 0 -1rem !important;
        border-radius: 0 !important;
    }
    
    /* Social share mobile friendly */
    .social-share {
        position: sticky !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: #fff !important;
        padding: 1rem !important;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1) !important;
        z-index: 100 !important;
        margin: 0 -1rem !important;
    }
    
    .social-share-btn {
        font-size: 1.2rem !important;
        padding: 0.75rem !important;
    }
}

/**
 * CATEGORY MOBILE
 */
@media (max-width: 1400px) {
    /* Hero full width */
    .category-hero-image {
        height: 300px !important;
    }
    
    .category-hero-title {
        font-size: 1.5rem !important;
    }
    
    .category-hero-excerpt {
        display: none !important;
    }
    
    /* List 1 colonna */
    .category-list-content {
        display: block !important;
        grid-template-columns: 1fr !important;
    }
    
    .category-list-image {
        margin-bottom: 1rem !important;
    }
    
    .category-list-title {
        font-size: 1.25rem !important;
    }
}

/* =======================
   CORRELATI INLINE MOBILE
   ======================= */
@media (max-width: 767px) {
    .related-articles-grid {
        grid-template-columns: 1fr !important;
    }
    
    .related-articles-inline {
        margin-top: 1.5rem;
        padding-top: 1.5rem;
    }
    
    .related-articles-inline .related-title {
        font-size: 1.1rem;
    }
}

@media (min-width: 768px) and (max-width: 1400px) {
    .related-articles-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* =======================
   AUTHOR PAGE MOBILE FIX
   Force articles visibility
   ======================= */
@media (max-width: 1024px) {
    .author-articles-grid {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .author-articles-grid .article-card,
    .author-articles-grid article,
    .author-articles-grid > * {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        margin-bottom: 24px !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }
}

/* =======================
   TAGS MOBILE - Touch friendly
   ======================= */
@media (max-width: 768px) {
    .tag-link {
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
        min-height: 44px; /* iOS touch target minimum */
        display: inline-flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation; /* Prevent zoom on double tap */
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }
    
    .article-tags {
        position: relative;
        z-index: 1; /* Ensure above any background elements */
        padding-bottom: var(--spacing-xl);
    }
}

/* =======================
   FIX TAGS MOBILE - EXTRA AGGRESSIVE
   Assicura che i tag siano cliccabili
   ======================= */
@media (max-width: 768px) {
    /* Tags - massima priorità e spazio */
    .article-tags {
        position: relative;
        z-index: 10 !important; /* Molto alto */
        margin-bottom: var(--spacing-2xl) !important;
        padding-bottom: var(--spacing-xl) !important;
    }
    
    .tags-list {
        position: relative;
        z-index: 11 !important;
    }
    
    .tag-link {
        padding: 12px 18px !important;
        font-size: 0.95rem !important;
        min-height: 48px !important; /* Più grande */
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: relative !important;
        z-index: 12 !important;
        pointer-events: auto !important; /* Forzato */
        cursor: pointer !important;
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(232, 72, 85, 0.2) !important;
        margin-bottom: 8px !important; /* Spazio tra righe */
    }
    
    /* Author box - assicura che non si sovrapponga */
    .author-box {
        position: relative;
        z-index: 5; /* Più basso dei tag */
        margin-top: var(--spacing-2xl) !important;
        clear: both; /* Evita float overlap */
    }
}
