/* ==========================================================================
   ITALY INTERNET GUIDE - ULTRA-RESPONSIVE STYLES (MOBILE, TABLET, DESKTOP)
   Fixes all 3D tilt bugs, horizontal overflow, crooked cards, and mobile viewports
   ========================================================================== */

/* Prevent any horizontal overflow on body/html */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw;
}

/* Hide mobile toggle and mobile nav drawer by default on desktop */
.mobile-menu-toggle {
    display: none;
}
.mobile-nav-drawer {
    display: none;
}
.mobile-quick-nav {
    display: none;
}

/* Laptop & Small Desktop (max-width: 1024px) */
@media (max-width: 1024px) {
    .hero-grid {
        grid-template-columns: 1fr;
        gap: 2.5rem;
        text-align: center;
    }

    .hero-actions {
        justify-content: center;
    }

    .tips-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .guide-grid {
        grid-template-columns: 1fr;
    }

    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    .operators-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* Medium Tablets & Touch Devices (max-width: 992px) */
@media (max-width: 992px) {
    /* Disable 3D tilt skewing on touch/tablet screens to prevent crooked card bugs */
    .operator-card, .showcase-card, .tip-card, .speed-card, .rating-card {
        transform: none !important;
        perspective: none !important;
    }

    .operator-card:hover, .showcase-card:hover, .tip-card:hover, .speed-card:hover, .rating-card:hover {
        transform: translateY(-4px) !important;
    }

    .trap-grid-wrapper {
        grid-template-columns: 1fr;
    }
}

/* Tablet & Mobile Portrait (max-width: 768px) */
@media (max-width: 768px) {
    .navbar {
        height: 65px;
    }

    .nav-links {
        display: none;
    }

    .btn-wizard-nav {
        display: none;
    }

    .mobile-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 42px;
        height: 42px;
        border-radius: var(--radius-md);
        background: var(--italian-green-light);
        border: 1px solid rgba(0, 146, 70, 0.25);
        color: var(--italian-green-dark);
        font-size: 1.25rem;
        cursor: pointer;
        transition: var(--transition-fast);
    }

    .mobile-menu-toggle:hover {
        background: var(--italian-green);
        color: #ffffff;
    }

    /* Mobile Nav Drawer */
    .mobile-nav-drawer {
        display: block;
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: #ffffff;
        border-bottom: 2px solid var(--italian-green);
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
        padding: 1rem 1.5rem;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
        z-index: 999;
    }

    .mobile-nav-drawer.active {
        max-height: 480px;
        padding: 1rem 1.5rem 1.5rem 1.5rem;
        overflow-y: auto;
    }

    .mobile-nav-links {
        list-style: none;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mobile-nav-links a {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        color: var(--text-primary);
        text-decoration: none;
        font-weight: 800;
        font-size: 0.95rem;
        border-radius: var(--radius-sm);
        transition: var(--transition-fast);
    }

    .mobile-nav-links a i {
        color: var(--italian-green);
        font-size: 1.1rem;
        width: 22px;
    }

    .mobile-nav-links a:hover,
    .mobile-nav-links a.active {
        background: var(--italian-green-light);
        color: var(--italian-green-dark);
    }

    /* Horizontal Quick Nav for Mobile */
    .mobile-quick-nav {
        display: block;
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid rgba(0, 146, 70, 0.15);
        padding: 0.4rem 0.5rem;
        z-index: 998;
    }

    .quick-nav-container {
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        padding: 0.2rem 0.5rem;
    }

    .quick-nav-container::-webkit-scrollbar {
        display: none;
    }

    .quick-nav-container a {
        display: inline-block;
        padding: 0.35rem 0.85rem;
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        border-radius: var(--radius-full);
        color: var(--text-secondary);
        font-size: 0.8rem;
        font-weight: 700;
        text-decoration: none;
        transition: var(--transition-fast);
    }

    .quick-nav-container a:hover,
    .quick-nav-container a.active {
        background: var(--italian-green);
        color: #ffffff;
        border-color: var(--italian-green);
    }

    /* Adjust main padding for fixed double header on mobile */
    .hero {
        padding-top: 155px;
        padding-bottom: 60px;
    }

    .hero-title {
        font-size: 2.1rem;
    }

    .hero-description {
        font-size: 1rem;
    }

    .operators-grid {
        grid-template-columns: 1fr;
    }

    .traps-grid-standalone,
    .phrases-grid-standalone {
        grid-template-columns: 1fr !important;
    }

    .ratings-grid {
        grid-template-columns: 1fr;
    }

    .speed-grid {
        grid-template-columns: 1fr;
    }

    .tips-grid {
        grid-template-columns: 1fr;
    }

    .glossary-grid {
        grid-template-columns: 1fr;
    }

    .search-row {
        flex-direction: column;
    }

    .filter-controls-grid {
        grid-template-columns: 1fr;
    }

    .wizard-card {
        padding: 1.35rem;
    }

    .wizard-options-grid {
        grid-template-columns: 1fr;
    }

    .footer-grid {
        grid-template-columns: 1fr;
    }

    .section-title {
        font-size: 1.8rem;
    }

    .section-subtitle {
        font-size: 0.98rem;
    }

    /* Modal responsiveness */
    .modal-container {
        padding: 1.35rem;
        max-width: 95%;
        max-height: 85vh;
        margin: 0 auto;
    }

    div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Table responsive wrapper */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: var(--radius-md);
        border: 1px solid rgba(0, 146, 70, 0.15);
    }

    .matrix-table {
        min-width: 650px;
    }
}

/* Small Smartphone Screen Mode (max-width: 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0 0.85rem;
    }

    .brand-icon {
        width: 38px;
        height: 38px;
        font-size: 1.1rem;
    }

    .brand-text h1 {
        font-size: 1.05rem;
    }

    .hero-title {
        font-size: 1.75rem;
    }

    .hero-actions {
        flex-direction: column;
        width: 100%;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        padding: 0.85rem 1.5rem;
    }

    .showcase-card {
        padding: 1.25rem 1rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .stat-box {
        padding: 0.85rem 0.5rem;
    }

    .stat-number {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: 0.75rem;
    }

    .city-selector-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 0.5rem;
    }

    .city-btn {
        padding: 0.6rem 0.3rem;
        font-size: 0.8rem;
    }

    .flag {
        width: 130px;
        height: 80px;
    }

    .flag-pole {
        height: 105px;
    }

    .lang-btn {
        padding: 0.45rem 0.75rem;
        font-size: 0.8rem;
    }

    .operator-card {
        padding: 1.25rem 1rem;
    }

    .card-actions {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .plan-metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
}
