/* Mega Dropdown Navigation Styles - CNET Inspired */

/* Remove all underlines from navigation links */
.main-navigation a {
    text-decoration: none !important;
}

.main-navigation a:hover,
.main-navigation a:focus,
.main-navigation a:active {
    text-decoration: none !important;
}

/* Desktop Navigation Enhancements */
@media (min-width: 769px) {
    /* Main Navigation Container */
    .main-navigation {
        position: relative;
    }

    .nav-menu {
        display: flex;
        align-items: center;
        list-style: none;
        margin: 0;
        padding: 0;
        gap: 0;
    }

    /* Menu Items */
    .menu-item {
        position: relative;
    }

    .menu-item > a {
        display: block;
        padding: 1rem 1.2rem;
        color: #1a1a1a;
        font-weight: 600;
        font-size: 0.95rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        text-decoration: none !important;
        transition: all 0.3s ease;
        position: relative;
    }

    /* Home icon styling */
    .menu-home > a {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1rem;
    }

    .menu-home svg {
        width: 22px;
        height: 22px;
        transition: all 0.3s ease;
    }

    .menu-home:hover svg {
        color: #0066cc;
        transform: scale(1.1);
    }

    /* Hover indicator */
    .menu-item > a::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 0;
        height: 3px;
        background: #0066cc;
        transition: width 0.3s ease;
    }

    .menu-item:hover > a::after,
    .menu-item.active > a::after {
        width: 80%;
    }

    .menu-item:hover > a,
    .menu-item.active > a {
        color: #0066cc;
    }

    /* Dropdown Arrow for items with children */
    .menu-item-has-children > a::before {
        content: '▾';
        position: absolute;
        right: 5px;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.8rem;
        transition: transform 0.3s ease;
    }

    .menu-item-has-children:hover > a::before,
    .menu-item-has-children.active > a::before {
        transform: translateY(-50%) rotate(180deg);
    }

    /* Mega Dropdown Container */
    .mega-dropdown {
        position: absolute;
        top: 100%;
        left: 50%;
        transform: translateX(-50%);
        width: 800px;
        max-width: 90vw;
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
        opacity: 0;
        visibility: hidden;
        transform: translateX(-50%) translateY(-10px);
        transition: all 0.3s ease;
        z-index: 1000;
        margin-top: 0;
    }

    /* Show dropdown on hover */
    .menu-item-has-children:hover .mega-dropdown {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }

    /* Dropdown Inner Container */
    .dropdown-inner {
        padding: 1.5rem;
    }

    /* Dropdown Header */
    .dropdown-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 1rem;
        margin-bottom: 1.5rem;
        border-bottom: 2px solid #e6f2ff;
    }

    .dropdown-header h3 {
        margin: 0;
        color: #001f3f;
        font-size: 1.25rem;
        font-weight: 700;
    }

    .dropdown-header .view-all {
        color: #0066cc;
        font-weight: 600;
        font-size: 0.9rem;
        text-decoration: none !important;
        transition: all 0.3s ease;
        padding: 0.4rem 1rem;
        border: 1px solid #0066cc;
        border-radius: 20px;
    }

    .dropdown-header .view-all:hover {
        background: #0066cc;
        color: white;
    }

    /* Dropdown Articles Grid */
    .dropdown-articles {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
        margin-bottom: 1.5rem;
    }

    /* Individual Article in Dropdown - Text only */
    .dropdown-article {
        padding: 1rem;
        border-radius: 8px;
        border-left: 3px solid transparent;
        transition: all 0.3s ease;
    }

    .dropdown-article:hover {
        background: #f0f8ff;
        border-left-color: #0066cc;
    }

    /* Article Content */
    .dropdown-article-content {
        width: 100%;
    }

    .dropdown-article-content h4 {
        margin: 0 0 0.5rem 0;
        font-size: 1rem;
        line-height: 1.4;
    }

    .dropdown-article-content h4 a {
        color: #1a1a1a;
        text-decoration: none !important;
        transition: color 0.3s ease;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-weight: 600;
    }

    .dropdown-article-content h4 a:hover {
        color: #0066cc;
        text-decoration: none !important;
    }

    .dropdown-article-content time {
        color: #5a6c7d;
        font-size: 0.85rem;
        font-weight: 400;
    }

    /* Subcategories Section */
    .dropdown-subcategories {
        padding-top: 1rem;
        border-top: 1px solid #e2e8f0;
    }

    .dropdown-subcategories h4 {
        margin: 0 0 0.75rem 0;
        color: #001f3f;
        font-size: 0.9rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .dropdown-subcategories ul {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .dropdown-subcategories li {
        margin: 0;
    }

    .dropdown-subcategories a {
        display: inline-block;
        padding: 0.3rem 0.8rem;
        background: #f0f8ff;
        color: #0066cc;
        border-radius: 15px;
        font-size: 0.85rem;
        text-decoration: none !important;
        transition: all 0.3s ease;
    }

    .dropdown-subcategories a:hover {
        background: #0066cc;
        color: white;
    }

    /* Prevent dropdown from closing when hovering over it */
    .mega-dropdown::before {
        content: '';
        position: absolute;
        top: -10px;
        left: 0;
        right: 0;
        height: 10px;
    }

    /* Adjustments for edge cases */
    .menu-item:first-child .mega-dropdown {
        left: 0;
        transform: translateX(0);
    }

    .menu-item:first-child:hover .mega-dropdown {
        transform: translateX(0) translateY(0);
    }

    .menu-item:last-child .mega-dropdown {
        left: auto;
        right: 0;
        transform: translateX(0);
    }

    .menu-item:last-child:hover .mega-dropdown {
        transform: translateX(0) translateY(0);
    }

    /* Loading state */
    .mega-dropdown.loading {
        min-height: 200px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mega-dropdown.loading::after {
        content: '';
        width: 30px;
        height: 30px;
        border: 3px solid #e2e8f0;
        border-top-color: #0066cc;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        to { transform: rotate(360deg); }
    }
}

/* Responsive adjustments for smaller screens */
@media (min-width: 769px) and (max-width: 1024px) {
    .mega-dropdown {
        width: 600px;
    }

    .dropdown-articles {
        grid-template-columns: 1fr;
    }
}

/* Hide dropdowns on mobile */
@media (max-width: 768px) {
    .mega-dropdown {
        display: none !important;
    }

    .menu-item-has-children > a::before {
        display: none;
    }
}

/* Accessibility improvements */
.mega-dropdown:focus-within {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Keyboard navigation support */
.menu-item-has-children > a:focus + .mega-dropdown,
.mega-dropdown:hover {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Animation for menu items */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mega-dropdown.animate-in .dropdown-article {
    animation: slideDown 0.3s ease forwards;
}

.mega-dropdown.animate-in .dropdown-article:nth-child(1) { animation-delay: 0.05s; }
.mega-dropdown.animate-in .dropdown-article:nth-child(2) { animation-delay: 0.1s; }
.mega-dropdown.animate-in .dropdown-article:nth-child(3) { animation-delay: 0.15s; }
.mega-dropdown.animate-in .dropdown-article:nth-child(4) { animation-delay: 0.2s; }