/* Mega Menu Styles - Full Width Grid Layout */

/* Header must be position relative for dropdown positioning */
header {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
}

/* Dropdown (Mega Menu) - Attached to header with overlap */
.dropdown {
    position: absolute !important;
    top: calc(100% - 20px) !important; /* Overlap with nav item */
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    margin: 0 !important;
    background: #000;
    padding: 3rem 4rem;
    padding-top: 3rem; /* Extra top padding to compensate for overlap */
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    justify-content: center;
    gap: 2rem;
    z-index: 50; /* Below header but above content */
}

/* Show dropdown on hover or when active */
.nav-item:hover .dropdown,
.nav-item.dropdown-active .dropdown {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

/* Nav item link positioning for bridge */
.nav-item > a {
    position: relative;
    display: block;
    /* padding: 1rem 0; */
}

/* Invisible bridge between nav item and dropdown */
.nav-item > a::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: -20px;
    right: -20px;
    height: 40px;
    background: transparent;
}

/* Mega Item styles */
.mega-item {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
    text-decoration: none;
}

.mega-item:hover .mega-image {
    transform: scale(1.05);
    border-color: #fff;
}

.mega-image {
    width: 100%;
    height: 160px;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    transition: transform 0.5s;
    border: 1px solid #333;
}

.mega-text {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.mega-title {
    font-family: var(--font-display);
    font-size: 1rem;
    color: #fff;
}

.mega-desc {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.4;
}

.dropdown a {
    color: #fff;
    text-decoration: none;
    display: block;
    transition: 0.3s;
}

.dropdown a:hover {
    color: #fff;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .dropdown {
        position: static !important;
        width: 100% !important; /* 幅を親に合わせる */
        margin: 0 !important;
        transform: none;
        background: rgba(255, 255, 255, 0.05); /* 少し明るくして区別 */
        box-shadow: none;
        padding: 0; /* JS制御にするため初期paddingなし */
        opacity: 1;
        visibility: visible;
        display: none; /* 初期非表示 */
        text-align: center;
        min-width: auto;
        border: none;
        max-height: 0; /* アニメーション用 */
        overflow: hidden;
        transition: max-height 0.3s ease;
    }
    
    .nav-item.active .dropdown {
        display: block;
        padding: 1rem 0;
        max-height: 1000px; /* 開いた時の高さ確保 */
    }
    
    .nav-item:hover .dropdown,
    .nav-item.dropdown-active .dropdown {
        display: none; /* PC用のホバー動作を無効化 */
    }
    
    /* スマホで開いたときは block 上書き */
    .nav-item.active .dropdown {
        display: block !important;
    }
    
    .mega-item {
        flex-direction: row;
        padding: 1rem; /* タップしやすく */
        gap: 1rem;
        border-bottom: 1px solid rgba(255,255,255,0.1);
        justify-content: flex-start; /* 左寄せ */
        text-align: left;
    }
    
    .mega-image {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }
    
    .mega-title {
        font-size: 1rem;
        font-weight: bold;
    }
    
    .mega-desc {
        display: block; /* 説明も表示してみる（スペースあれば） */
        font-size: 0.8rem;
        margin-top: 4px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
}
