/* ==========================================
   2段ナビゲーション共通CSS
   全LPで共有（/css/nav.css）
   ベースの .navbar CSS は各LP の style.css に存在する前提
   ========================================== */

/* === ヘッダーコンテナ: 2段ナビを1つのfixed要素にまとめる === */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1001;

    /* site-header 内の .navbar は親が fixed なので自身の fixed を解除 */
    & .navbar {
        position: relative;
        top: auto;
        left: auto;
    }

    & .navbar-sub {
        position: relative;
        top: auto;
    }
}

/* === 上段: グローバルナビ === */
.navbar-global {
    padding: 0.65rem 0;
    z-index: 1001;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: rgba(10, 10, 10, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);

    & .nav-container { max-width: 1200px; }
    & .logo { gap: 0; }
    & .logo-main { font-size: 1.5rem; }
    & .logo-subtitle { font-size: 0.6rem; }
    & .nav-menu {
        gap: 2rem;
        & > li > a, & > li > .nav-dropdown-toggle { font-size: 0.95rem; }
    }

    /* --- 事業案内ドロップダウン --- */
    & .nav-dropdown {
        position: relative;

        /* ドロップダウンとの隙間を透明ブリッジで埋める */
        &::after {
            content: '';
            position: absolute;
            top: 100%;
            left: 0;
            width: 100%;
            height: 16px;
        }

        & > .nav-dropdown-toggle {
            background: none;
            border: none;
            color: inherit;
            font-family: inherit;
            font-size: inherit;
            line-height: inherit;
            letter-spacing: inherit;
            word-spacing: inherit;
            cursor: pointer;
            padding: 0;

            & i {
                font-size: 0.55rem;
                margin-left: 0.3rem;
                opacity: 0.6;
                transition: transform 0.3s ease;
            }
        }
    }
}

.nav-dropdown-menu {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    transform: translateY(10px);
    min-width: 240px;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.5rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    transition-behavior: allow-discrete;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    list-style: none;
    z-index: 100;

    & li a {
        display: flex;
        align-items: center;
        gap: 0.8rem;
        padding: 0.8rem 1rem;
        font-size: 0.9rem;
        color: rgba(255, 255, 255, 0.8) !important;
        border-radius: 8px;
        white-space: nowrap;
        transition: color 0.2s ease, background 0.2s ease;

        /* サブテキスト持ちリンクだけ折り返し */
        &:has(.nav-dropdown-sub) {
            flex-wrap: wrap;
            align-items: baseline;
            gap: 0.3rem 0.8rem;
        }

        & i {
            width: 20px;
            text-align: center;
            color: rgba(255, 255, 255, 0.6);
            font-size: 0.85rem;
        }
        &::after { display: none !important; }
        &:hover {
            background: rgba(255, 255, 255, 0.08);
            color: #ffffff !important;

            & i { color: #ff20ca; }
        }
    }
}

/* ドロップダウン内サブテキスト（2行目の日本語説明） */
.nav-dropdown-sub {
    display: block;
    width: 100%;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 400;
    letter-spacing: 0.02em;
    padding-left: calc(20px + 0.8rem); /* アイコン幅 + gap */
    margin-top: -0.1rem;
}

/* hover対応デバイスのみ :hover で開く */
@media (hover: hover) {
    .nav-dropdown:hover {
        & .nav-dropdown-menu {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }
        & > .nav-dropdown-toggle i { transform: rotate(180deg); }
    }
}

/* JS の .open クラスで開く（タッチ & デスクトップ両対応） */
.nav-dropdown.open {
    & .nav-dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    & > .nav-dropdown-toggle i { transform: rotate(180deg); }
}

/* @starting-style: 初期遷移の明示（86.6%対応） */
@starting-style {
    .nav-dropdown.open .nav-dropdown-menu,
    .nav-dropdown:hover .nav-dropdown-menu {
        opacity: 0;
        visibility: hidden;
        transform: translateY(10px);
    }
}

/* === 下段: LP内セクションナビ === */
.navbar-sub {
    padding: clamp(0.4rem, 0.55vw, 0.6rem) 0;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);

    & .nav-container {
        max-width: 1200px;
        justify-content: center;
    }
}

/* 旧構造（site-header 無し）用フォールバック */
.navbar-sub:not(.site-header .navbar-sub) {
    position: fixed;
    top: 50px;
    left: 0;
    width: 100%;
    z-index: 1000;
}

/* サブナビメニュー: ベースCSSのハンバーガー化を完全に無効化 */
.nav-menu-sub {
    display: flex !important;
    position: relative !important;
    left: 0 !important;
    top: auto !important;
    flex-direction: row !important;
    background: none !important;
    padding: 0 !important;
    width: auto !important;
    box-shadow: none !important;
    gap: clamp(0.6rem, 1.5vw, 1.5rem) !important;
    flex-wrap: nowrap;
    transition: none !important;

    & a {
        font-size: clamp(0.7rem, 1.15vw, 0.9rem) !important;
        color: rgba(255, 255, 255, 0.5) !important;
        transition: color 0.3s ease;
        letter-spacing: 0.02em;
        white-space: nowrap;

        &:hover { color: rgba(255, 255, 255, 0.9) !important; }
        &.active { color: var(--secondary-color) !important; }
        &::after { display: none !important; }
    }
}

/* スライディングインジケーター（nav.js が動的に追加） */
.sub-indicator {
    position: absolute;
    bottom: -4px;
    height: 2px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 1px;
    transition: left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

/* ヒーローの padding: 上段+下段分 */
.hero { padding-top: 115px; }

/* === TOPページリンク: デスクトップでは非表示 === */
.nav-top-link { display: none; }

/* === 768px以上: 2段ナビ表示 === */
@media (width >= 768px) {
    .navbar-global {
        & .menu-toggle { display: none !important; }
        & .nav-menu {
            display: flex !important;
            position: static !important;
            left: auto !important;
            flex-direction: row !important;
            background: none !important;
            padding: 0 !important;
            width: auto !important;
            box-shadow: none !important;
        }
    }
    .navbar-sub .menu-toggle { display: none !important; }
}

/* === 767px以下: ハンバーガー化 + サブナビ非表示 === */
@media (width <= 767px) {
    .navbar-sub { display: none !important; }

    .navbar-global {
        padding: 0.35rem 0;
        overflow: visible !important;

        & .logo-main { font-size: 1.25rem; white-space: nowrap; }
        & .menu-toggle { display: flex; }
        & .nav-dropdown > .nav-dropdown-toggle i { display: none; }
        & .nav-menu {
            left: 0 !important;
            top: 100% !important;
            width: 100% !important;
            position: absolute !important;
            transform: none !important;
            flex-direction: column !important;
            clip-path: inset(0 0 100% 0) !important;
            transition: clip-path 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
            padding: 1rem 1.5rem !important;
            gap: 0 !important;
            pointer-events: none !important;
            background: rgba(10, 10, 10, 0.95) !important;
            backdrop-filter: blur(20px) !important;
            -webkit-backdrop-filter: blur(20px) !important;

            &.active {
                left: 0 !important;
                clip-path: inset(0) !important;
                pointer-events: auto !important;
            }
        }
        & .nav-menu > li > a {
            display: block;
            width: 100%;
            padding: 0.65rem 0.5rem;
        }
    }

    .hero { padding-top: 70px; }

    .menu-toggle.active {
        & span:nth-child(1) { transform: rotate(45deg) translate(8px, 8px); }
        & span:nth-child(2) { opacity: 0; }
        & span:nth-child(3) { transform: rotate(-45deg) translate(7px, -7px); }
    }

    /* TOPページリンク: モバイルでは表示 */
    .nav-top-link { display: list-item; }

    /* ドロップダウンをハンバーガー内でインライン表示 */
    .nav-dropdown-menu {
        position: static;
        transform: none;
        min-width: 0;
        background: none;
        border: none;
        border-radius: 0;
        padding: 0.15rem 0 0.15rem 1rem;
        opacity: 1;
        visibility: visible;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .nav-dropdown-menu li a {
        display: flex;
        width: 100%;
        padding: 0.55rem 1rem;
        font-size: 0.95rem;
        border-radius: 6px;
    }
}

/* === ndocs ナビリンク === */
/* ツールチップは nav.js で JS 実装（position: fixed で親のoverflow影響なし） */

/* === View Transitions API === */
/* 同一オリジン内のページ遷移で共通要素をスムーズにアニメーション */
/* site-header には名前を付けない（子要素に個別名があるため競合する） */
.navbar-global {
    view-transition-name: site-global-nav;

    & .logo { view-transition-name: site-logo; }
    & .nav-menu { view-transition-name: site-nav; }
}
.navbar-sub { view-transition-name: site-subnav; }

/* 遷移アニメーションのカスタマイズ */
::view-transition-old(site-global-nav),
::view-transition-new(site-global-nav),
::view-transition-old(site-logo),
::view-transition-new(site-logo),
::view-transition-old(site-subnav),
::view-transition-new(site-subnav) {
    animation-duration: 0.3s;
    animation-timing-function: ease-in-out;
}
