/* ========================================
   Header Layout Component
   ======================================== */

.site-header {
    position: sticky;
    top: 0;
    z-index: 150;
}

.site-header--inner {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

/* ========================================
   フロントページ：ヒーロー内に絶対配置（max-width 1200px・中央）
   ======================================== */

.front-hero .site-header {
    position: relative;
    top: 16px;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .front-hero .site-header.is-fixed {
        width: 100%;
    }
}

/* ヒーローがスクロールで消えたら全幅固定（transition はここで定義） */
.front-hero .site-header.is-fixed {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .5s ease, visibility .5s ease;
}

/* visible クラスが付いたらフェードイン */
.front-hero .site-header.is-fixed.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.site-header--inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    padding: 10px 40px;
    height: var(--header-height);
}

/* ========================================
   ロゴ
   ======================================== */

.site-header--logo {
    height: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    overflow: hidden;
}

.site-header--logo:hover {
    opacity: 0.85;
    text-decoration: none;
}

.site-header--logo-img {
    display: block;
    width: fit-content;
    height: 100%;
    object-fit: contain;
    flex-shrink: 0;
}

.site-header--logo-name {
    font-size: 15px;
    font-weight: bold;
    color: #111;
    white-space: nowrap;
    text-align: left;
}

/* ========================================
   右側エリア
   ======================================== */

.site-header--right {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

/* ========================================
   ナビゲーション
   ======================================== */

.site-header--nav {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow: hidden;
    min-width: 0;
    flex-shrink: 1;
    flex-grow: 1;
}

.site-header--nav-separator {
    color: #ccc;
    font-size: 14px;
    user-select: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.site-header--nav-link {
    font-size: 14px;
    color: #333;
    text-decoration: none;
    padding: 4px 12px;
    transition: color 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
}

.site-header--nav-link:hover {
    color: #000;
    text-decoration: none;
}

.site-header--nav-link.is-current {
    color: #000;
    font-weight: bold;
}

/* ========================================
   検索
   ======================================== */

.site-header--search-wrap {
    display: flex;
    align-items: center;
    margin-left: 8px;
    flex-shrink: 0;
}

.site-header--search-form {
    display: flex;
    align-items: center;
    width: 48px;
    overflow: hidden;
    transition: width 0.25s ease;
}

.site-header--search-wrap.is-open .site-header--search-form {
    width: 280px;
    background: #F2F2F2;
}

.site-header--search-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: none;
    border: none;
    cursor: pointer;
    color: #333333;
    flex-shrink: 0;
    transition: color 0.15s;
}

.site-header--search-wrap.is-open .site-header--search-btn {
    color: #999999;
}

.site-header--search-icon {
    display: inline-flex;
    align-items: center;
}

.site-header--search-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.site-header--search-input {
    flex: 1;
    min-width: 0;
    height: 48px;
    padding: 0 8px;
    border: none;
    font-size: 14px;
    color: #333;
    background: #F2F2F2;
    outline: none;
    appearance: none;
}

.site-header--search-input::placeholder {
    color: #999;
}

.site-header--search-input::-webkit-search-cancel-button {
    display: none;
}

/* ========================================
   お問い合わせボタン
   ======================================== */

.site-header--contact {
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: #1d2b4f;
    border: 1.5px solid #1d2b4f;
    text-decoration: none;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: bold;
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: 16px;
    position: relative;
    overflow: hidden;
    isolation: isolate;
    transition: color .35s ease;
}

.site-header--contact::before {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: #1d2b4f;
    transition: left .4s ease;
    z-index: -1;
}

.site-header--contact:hover::before {
    left: 0;
}

.site-header--contact:hover {
    color: #fff;
    text-decoration: none;
}

/* ========================================
   ハンバーガーボタン（スマホのみ表示）
   ＝ → ✕ は2段階（55%でいったん中央に寄せてから回転）
   ======================================== */

@keyframes menuLineTopOpen {
    0%   { transform: translateY(0) rotate(0deg); }
    55%  { transform: translateY(3px) rotate(0deg); }
    100% { transform: translateY(3px) rotate(45deg); }
}

@keyframes menuLineBottomOpen {
    0%   { transform: translateY(0) rotate(0deg); }
    55%  { transform: translateY(-3px) rotate(0deg); }
    100% { transform: translateY(-3px) rotate(-45deg); }
}

@keyframes menuLineTopClose {
    0%   { transform: translateY(3px) rotate(45deg); }
    55%  { transform: translateY(3px) rotate(0deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

@keyframes menuLineBottomClose {
    0%   { transform: translateY(-3px) rotate(-45deg); }
    55%  { transform: translateY(-3px) rotate(0deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

.site-header--menu-btn {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
}

.site-header--menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: #43c4f6;
}

/* 開く：寄せてから回転（✕へ） */
body.menu-open .site-header--menu-btn span:nth-child(1) {
    animation: menuLineTopOpen .45s ease forwards;
}

body.menu-open .site-header--menu-btn span:nth-child(2) {
    animation: menuLineBottomOpen .45s ease forwards;
}

/* 閉じる：回転を戻してから広げる（＝へ） */
body.menu-closing .site-header--menu-btn span:nth-child(1) {
    animation: menuLineTopClose .45s ease forwards;
}

body.menu-closing .site-header--menu-btn span:nth-child(2) {
    animation: menuLineBottomClose .45s ease forwards;
}

/* ========================================
   モバイルメニュー
   ヘッダー下端から下へ伸び、中の内容を同時に露出させる。
   パネルの top / left / width / bottom は JS がヘッダーの実寸から設定する。
   ======================================== */

.site-header--mobile-overlay {
    display: none;
}

@media (max-width: 1023px) {
    .site-header--mobile-overlay {
        position: fixed;
        inset: 0;
        z-index: 99;
        display: block;
        visibility: hidden;
        pointer-events: none;
        /* 閉じるアニメーション(.45s)が終わってから非表示にする */
        transition: visibility 0s linear .45s;
    }

    .site-header--mobile-overlay.is-open {
        visibility: visible;
        pointer-events: auto;
        transition: visibility 0s;
    }
}

/* 下へ伸びるパネル本体 */
.site-header--mobile-panel {
    position: absolute;
    top: 60px; /* JS 未実行時のフォールバック */
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 24px 16px;
    background: #fff;
    overflow: hidden; /* スクロールはナビ側が担当。パネル自体は固定 */
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.16);
    /* 下端を 100% クリップ → 0 で「高さが伸びる」演出。内容は上から順に露出 */
    clip-path: inset(0 0 100% 0);
    transition: clip-path .45s cubic-bezier(.4, 0, .2, 1);
}

.site-header--mobile-overlay.is-open .site-header--mobile-panel {
    clip-path: inset(0 0 0 0);
}

/* 下部固定エリア（検索 + お問い合わせ） */
.site-header--mobile-bottom {
    flex-shrink: 0;     /* 常に下部に表示。縮まない */
    margin-top: auto;   /* ナビが無い/短いときも下端へ寄せる */
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* 検索窓 */
.site-header--mobile-search {
    display: flex;
    align-items: center;
    background: #F2F2F2;
    padding: 0 12px;
    height: 48px;
}

.site-header--mobile-search-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: #999;
}

.site-header--mobile-search-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.site-header--mobile-search-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 8px;
    border: none;
    font-size: 14px;
    color: #333;
    background: transparent;
    outline: none;
    appearance: none;
}

.site-header--mobile-search-input::placeholder {
    color: #999;
}

.site-header--mobile-search-input::-webkit-search-cancel-button {
    display: none;
}

/* ヘッダーの内容（カテゴリ）：上部・余った高さを使い、溢れたらここだけスクロール */
.site-header--mobile-nav {
    flex: 1 1 0;
    min-height: 0; /* これがないと中身に押し上げられてスクロールしない */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

.site-header--mobile-nav-link {
    flex-shrink: 0; /* 項目が増えても潰れず、はみ出したらスクロール */
    font-size: 14px;
    color: #333;
    text-decoration: none;
    padding: 20px 12px;
    border-bottom: 1px solid #F2F2F2;
    text-align: left;
}

.site-header--mobile-nav-link.is-current {
    font-weight: bold;
    color: #000;
}

/* お問い合わせ */
.site-header--mobile-contact {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1d2b4f;
    color: #fff;
    text-decoration: none;
    padding: 14px;
    font-size: 14px;
    font-weight: bold;
}

.site-header--mobile-contact:hover {
    background: #2a3d6e;
    color: #fff;
    text-decoration: none;
}

/* バックドロップ（全面・クリックで閉じる。パネルの背面でフェード） */
.site-header--mobile-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    cursor: pointer;
    background: rgba(17, 24, 39, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity .4s ease;
}

.site-header--mobile-overlay.is-open .site-header--mobile-backdrop {
    opacity: 1;
}

/* ========================================
   WordPress 管理バー対応
   ======================================== */

/* 通常ページのstickyヘッダー：管理バー分下にずらす */
body.admin-bar .site-header {
    top: 32px;
}

/* フロントページのfixedヘッダー：管理バー分下にずらす */
body.admin-bar .front-hero .site-header.is-fixed {
    top: 32px;
}

/* ========================================
   レスポンシブ
   ======================================== */

@media (max-width: 1023px) {
    .site-header {
        width: 100%;
    }

    .site-header--inner {
        width: 100%;
        height: var(--header-height);
        padding: 10px 12px;
        justify-content: space-between;
    }

    .site-header--nav {
        display: none;
    }

    .site-header--right {
        display: none;
    }

    .site-header--menu-btn {
        display: inline-flex;
    }

    .site-header--logo-name {
        font-size: 13px;
    }

    body.admin-bar .site-header {
        top: 46px;
    }

    body.admin-bar .front-hero .site-header.is-fixed {
        top: 46px;
    }

}

/* ========================================
   モーション低減設定への配慮
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    .site-header--mobile-panel,
    .site-header--mobile-backdrop {
        transition: none;
    }

    .site-header--menu-btn span {
        animation-duration: 0.01ms !important;
    }
}
