/**
 * Header Component Styles (Updated with Design Mock)
 * ヘッダーコンポーネントのスタイル - デザインモック適用版
 * 要件: 2.7-2.17 (基本ページ構成・ナビゲーション)
 */

/* ========================================
   Fixed Header - Glass Morphism Design
   ======================================== */

#main-header,
.glass-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height-desktop, 60px);
    background: rgba(27, 23, 32, 0.9);
    backdrop-filter: blur(12px);
    z-index: 1000; /* 100 → 1000に変更して確実に最前面に */
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: background-color var(--transition-base), 
                box-shadow var(--transition-base),
                transform var(--transition-base);
}

/* スクロール時の透明度調整 (要件: 2.15) */
#main-header.scrolled {
    background: rgba(27, 23, 32, 0.95);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

#main-header.transparent {
    background: rgba(27, 23, 32, 0.85);
}

/* ヘッダー非表示 */
#main-header.header-hidden {
    transform: translateY(-100%);
}

/* ヘッダーコンテンツ */
.header-content,
#main-header .container {
    width: 100%;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

/* ========================================
   Logo Frame (要件: 2.8, 2.10)
   ======================================== */

.logo,
.logo-frame {
    display: flex;
    align-items: center;
    height: 100%;
    flex-shrink: 0;
}

.logo a,
.logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    transition: opacity 0.2s;
}

.logo a:hover,
.logo a:focus,
.logo-link:hover,
.logo-link:focus {
    opacity: 0.8;
}

.logo a:focus-visible,
.logo-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
    border-radius: var(--border-radius-sm, 4px);
}

/* ロゴ画像 */
.logo img,
.logo-img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

/* ========================================
   Header Right (Navigation + Sound Button)
   ======================================== */

.header-right {
    display: flex;
    align-items: center;
    gap: 0;
    height: 100%;
}

/* ========================================
   Desktop Navigation - Image Based (要件: 2.9)
   ======================================== */

.main-nav {
    display: none;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 0;
    margin: 0px;
    padding-left: 0px;
}

.main-nav li {
    position: relative;
    margin-left: -47px; /* ボタン間の間隔調整: マイナス値で重ねる、0で隙間なし、プラス値で間隔を空ける */
    margin-right: 0;
}

/* 最初のボタンはmargin-leftを無効化 */
.main-nav li:first-child {
    margin-left: 0;
}

/* ナビゲーションリンク */
.nav-link {
    display: block;
    cursor: pointer;
    text-decoration: none;
}

/* 無効化されたナビゲーション項目 */
.nav-disabled {
    display: block;
    cursor: default;
    text-decoration: none;
    opacity: 0.6;
}

.nav-disabled:hover {
    cursor: default;
}

/* ナビゲーションアイテムのラッパー */
.nav-item-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* ナビゲーション画像 */
.nav-img {
    display: block;
    height: var(--header-height-desktop, 60px);
    /* width: auto; を削除して固定幅に */
    transition: opacity 0.3s ease;
    max-width: 100%;
    object-fit: contain;
}

/* ホバー時の画像重ね合わせ制御 */
.nav-img.normal {
    opacity: 1;
}

.nav-img.hover {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

/* ホバー時のみhover画像を表示 */
.nav-link:hover .nav-img.normal {
    opacity: 0;
}

.nav-link:hover .nav-img.hover {
    opacity: 1;
}

/* フォーカス時は通常画像を維持（キーボードナビゲーション用） */
.nav-link:focus .nav-img.normal {
    opacity: 1;
}

.nav-link:focus .nav-img.hover {
    opacity: 0;
}

/* アクティブ時（クリック時）は通常画像に戻す */
.nav-link:active .nav-img.normal {
    opacity: 1;
}

.nav-link:active .nav-img.hover {
    opacity: 0;
}

.nav-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm, 4px);
}

/* アクティブ状態 */
.nav-link.active .nav-img.normal {
    opacity: 0;
}

.nav-link.active .nav-img.hover {
    opacity: 1;
}

/* ========================================
   Sound Toggle Button
   ======================================== */

.sound-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.sound-btn img {
    height: 20px; /* サイズ調整: 24px → 20px */
    width: auto;
    transition: transform 0.2s ease;
}

.sound-btn:hover img,
.sound-btn:focus img {
    transform: scale(1.1);
}

.sound-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
    border-radius: var(--border-radius-sm, 4px);
}

/* Sound Button Spacer (一時的にBGMボタンの代わりに配置) */
.sound-btn-spacer {
    width: 40px;
    height: 100%;
    margin-left: 10px;
}

/* ========================================
   Mobile Menu Button
   ======================================== */

.menu-btn,
.mobile-menu-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-left: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    position: relative;
}

.menu-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
    stroke-width: 2;
}

.menu-btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 4px;
    border-radius: var(--border-radius-sm, 4px);
}

/* ========================================
   Responsive - Tablet (761px-1199px)
   ======================================== */

@media (min-width: 761px) and (max-width: 1199px) {
    .nav-img {
        height: auto;
        width: 100%;
        max-height: var(--header-height-desktop, 60px);
    }
    
    .nav-link {
        flex-shrink: 1;
        min-width: 0;
    }
    
    .main-nav ul {
        width: 100%;
        justify-content: flex-end;
    }
    
    .main-nav li {
        flex: 1;
        display: flex;
        justify-content: center;
        min-width: 0;
    }
}

/* ========================================
   Responsive - Desktop (768px以上)
   ======================================== */

@media (min-width: 768px) {
    .main-nav {
        display: block;
    }
    
    .desktop-only {
        display: flex !important;
    }
    
    .mobile-only {
        display: none !important;
    }
}

/* ========================================
   Responsive - Mobile (760px以下)
   ======================================== */

@media (max-width: 760px) {
    #main-header,
    .glass-header {
        height: var(--header-height-mobile, 60px);
        background: transparent;
        backdrop-filter: none;
        box-shadow: none;
    }
    
    /* ヘッダーコンテンツを非表示 */
    .header-content {
        justify-content: flex-end;
        padding: 16px;
    }
    
    /* ロゴを非表示 */
    .logo-frame {
        display: none;
    }
    
    /* サウンドボタンを非表示 */
    .sound-btn {
        display: none !important;
    }
    
    .logo img,
    .logo-img {
        height: 32px;
    }
    
    .main-nav {
        display: none !important;
    }
    
    .desktop-only {
        display: none !important;
    }
    
    .mobile-only {
        display: flex !important;
    }
    
    .menu-btn,
    .mobile-menu-toggle {
        display: flex;
        position: fixed;
        top: 16px;
        right: 16px;
        z-index: 1001;
        padding: 0;
        margin: 0;
    }
    
    /* ハンバーガーアイコン */
    .hamburger-icon {
        width: 80px;
        height: 80px;
        object-fit: contain;
    }
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    #main-header {
        position: static;
        box-shadow: none;
        background-color: var(--color-white);
    }
}
