/* ========================================
   YOKOTA Theme - Mega Menu Styles (Taiji Style v2.0)
   フルワイド、2カラムレイアウト、5列グリッド
   ======================================== */

/* モバイルではメガメニューを非表示 */
@media (max-width: 768px) {
    .mega-menu-container,
    .mega-menu {
        display: none !important;
    }
}

/* デスクトップのみ表示 */
@media (min-width: 769px) {
    
    /* メガメニューコンテナ（固定位置） */
    #mega-menu-container {
        position: fixed;
        top: 100px; /* デフォルト値、JavaScriptで動的に更新される */
        left: 0;
        right: 0;
        width: 100%;
        height: 0; /* ホバーをブロックしないように高さ0 */
        z-index: 9999;
        pointer-events: none;
        overflow: visible;
    }
    
    /* 個別のメガメニュー - フルワイド */
    .mega-menu {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        width: 100%;
        background-color: #ffffff;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
        border-bottom: 1px solid #e5e7eb;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s ease-out, visibility 0s linear 0.25s;
        pointer-events: auto;
    }
    
    /* アクティブ時に表示 */
    .mega-menu.active {
        opacity: 1;
        visibility: visible;
        transition: opacity 0.25s ease-out, visibility 0s linear 0s;
    }
    
    /* メガメニュー内部 */
    .mega-menu-inner {
        width: 100%;
        max-width: 1400px;
        margin: 0 auto;
        padding: 3rem 2rem;
    }
    
    /* 2カラムレイアウト */
    .mega-menu-layout {
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: 3rem;
        align-items: start;
    }
    
    /* 左カラム：セクション情報 */
    .mega-menu-section {
        position: sticky;
        top: 2rem;
        padding-right: 2rem;
        border-right: 1px solid #e5e7eb;
    }
    
    .mega-menu-section-title-ja {
        font-size: 2rem;
        font-weight: 700;
        color: #1f2937;
        margin: 0 0 0.5rem 0;
        line-height: 1.3;
        letter-spacing: 0.02em;
    }
    
    .mega-menu-section-title-en {
        font-size: 0.9rem;
        font-weight: 800;
        font-family: var(--font-family-en);
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.15em;
        margin: 0 0 1.5rem 0;
    }
    
    .mega-menu-section-description {
        font-size: 0.95rem;
        color: #4b5563;
        line-height: 1.7;
        margin: 0 0 2rem 0;
    }
    
    .mega-menu-section-link {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1.5rem;
        background-color: transparent;
        color: var(--color-primary-green, #2e8540);
        border: 2px solid var(--color-primary-green, #2e8540);
        border-radius: 50px;
        font-size: 0.95rem;
        font-weight: 600;
        text-decoration: none;
        transition: all 0.3s ease;
    }
    
    .mega-menu-section-link:hover {
        background-color: var(--color-primary-green, #2e8540);
        color: #ffffff;
        transform: translateX(4px);
    }
    
    .mega-menu-section-link .arrow {
        font-size: 1.2rem;
        transition: transform 0.3s ease;
    }
    
    .mega-menu-section-link:hover .arrow {
        transform: translateX(4px);
    }
    
    /* 右カラム：商品グリッド */
    .mega-menu-content {
        width: 100%;
    }
    
    /* グリッドレイアウト */
    .mega-menu-grid {
        display: grid;
        gap: 1.5rem;
        width: 100%;
    }
    
    /* 3カラム */
    .mega-menu-columns-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* 4カラム */
    .mega-menu-columns-4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* 5カラム（推奨） */
    .mega-menu-columns-5 {
        grid-template-columns: repeat(5, 1fr);
    }
    
    /* セクション情報がない場合は1カラムレイアウト */
    .mega-menu-inner:not(:has(.mega-menu-layout)) .mega-menu-grid {
        max-width: 1200px;
        margin: 0 auto;
    }
    
    /* メガメニューアイテム */
    .mega-menu-item {
        position: relative;
        overflow: hidden;
        background-color: #ffffff;
        transition: transform 0.3s ease;
    }
    
    .mega-menu-item:hover {
        transform: translateY(-4px);
    }
    
    /* メガメニューアイテムリンク */
    .mega-menu-item-link {
        display: flex;
        flex-direction: column;
        text-decoration: none;
        color: inherit;
        height: 100%;
    }
    
    /* メガメニューアイテム画像（正方形） */
    .mega-menu-item-image {
        position: relative;
        width: 100%;
        aspect-ratio: 1 / 1;
        overflow: hidden;
        background-color: #f9fafb;
        border-radius: 4px;
    }
    
    .mega-menu-item-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.4s ease, opacity 0.3s ease;
    }
    
    .mega-menu-item:hover .mega-menu-item-image img {
        transform: scale(1.1);
        opacity: 0.9;
    }
    
    /* メガメニューアイテムタイトル */
    .mega-menu-item-title {
        font-size: 0.9rem;
        font-weight: 600;
        color: #1f2937;
        margin: 0.75rem 0 0 0;
        padding: 0 0.25rem;
        line-height: 1.4;
        text-align: center;
        transition: color 0.3s ease;
    }
    
    .mega-menu-item:hover .mega-menu-item-title {
        color: var(--color-primary-green, #2e8540);
    }
    
    /* 矢印インジケーター */
    .has-mega-menu > .menu-link::after {
        content: '';
        display: inline-block;
        width: 0;
        height: 0;
        margin-left: 0.4rem;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-top: 4px solid currentColor;
        vertical-align: middle;
        transition: transform 0.3s ease;
    }
    
    .has-mega-menu.mega-menu-active > .menu-link::after {
        transform: rotate(180deg);
    }
    
    /* レスポンシブ調整：中型デスクトップ */
    @media (min-width: 769px) and (max-width: 1200px) {
        .mega-menu-inner {
            padding: 2.5rem 1.5rem;
        }
        
        .mega-menu-layout {
            grid-template-columns: 240px 1fr;
            gap: 2rem;
        }
        
        .mega-menu-section {
            padding-right: 1.5rem;
        }
        
        .mega-menu-section-title-ja {
            font-size: 1.75rem;
        }
        
        .mega-menu-columns-5 {
            grid-template-columns: repeat(4, 1fr);
        }
        
        .mega-menu-grid {
            gap: 1.25rem;
        }
    }
    
    /* レスポンシブ調整：小型デスクトップ */
    @media (min-width: 769px) and (max-width: 1024px) {
        .mega-menu-inner {
            padding: 2rem 1rem;
        }
        
        .mega-menu-layout {
            grid-template-columns: 200px 1fr;
            gap: 1.5rem;
        }
        
        .mega-menu-section {
            padding-right: 1rem;
        }
        
        .mega-menu-section-title-ja {
            font-size: 1.5rem;
        }
        
        .mega-menu-section-title-en {
            font-size: 0.8rem;
        }
        
        .mega-menu-columns-5,
        .mega-menu-columns-4 {
            grid-template-columns: repeat(3, 1fr);
        }
        
        .mega-menu-grid {
            gap: 1rem;
        }
    }
    
    /* 大画面 */
    @media (min-width: 1600px) {
        .mega-menu-inner {
            max-width: 1600px;
            padding: 3.5rem 3rem;
        }
        
        .mega-menu-layout {
            grid-template-columns: 320px 1fr;
            gap: 4rem;
        }
        
        .mega-menu-section-title-ja {
            font-size: 2.25rem;
        }
        
        .mega-menu-item-title {
            font-size: 1rem;
        }
    }
    
    /* アクセシビリティ：フォーカス時のスタイル */
    .mega-menu-item-link:focus {
        outline: 2px solid var(--color-primary-green, #2e8540);
        outline-offset: 2px;
        border-radius: 4px;
    }
    
    .mega-menu-section-link:focus {
        outline: 2px solid var(--color-primary-green, #2e8540);
        outline-offset: 4px;
    }
    
    /* JavaScript が有効になるまで非表示 */
    .no-js .mega-menu-container {
        display: none;
    }
    
    /* プリント時は非表示 */
    @media print {
        .mega-menu-container,
        .mega-menu {
            display: none !important;
        }
    }
}

/* ダークモード対応（オプション） */
@media (prefers-color-scheme: dark) {
    @media (min-width: 769px) {
        .mega-menu {
            background-color: #1f2937;
            border-bottom-color: #374151;
        }
        
        .mega-menu-section {
            border-right-color: #374151;
        }
        
        .mega-menu-section-title-ja {
            color: #f9fafb;
        }
        
        .mega-menu-section-title-en {
            color: #9ca3af;
        }
        
        .mega-menu-section-description {
            color: #d1d5db;
        }
        
        .mega-menu-item {
            background-color: #1f2937;
        }
        
        .mega-menu-item-image {
            background-color: #374151;
        }
        
        .mega-menu-item-title {
            color: #f9fafb;
        }
    }
}

/* パフォーマンス最適化 */
.mega-menu-item-image,
.mega-menu-item {
    will-change: transform;
}

.mega-menu {
    will-change: opacity, visibility;
}
