/* --- リセット＆ベース設定 --- */
*, *::before, *::after { box-sizing: border-box; }

html {
    width: 100%;
    height: 100%;
    margin: 0; padding: 0;
    color-scheme: light;
}

/* overflow-x: clip を使う。
   hidden はスクロールコンテナを生成し、WKWebView（Instagram・LINE等）では
   position:fixed の基準がビューポートでなくその要素になってしまう。
   clip は hidden と同じ見た目だがスクロールコンテナを作らないため
   position:fixed が正しくビューポート基準になる。
   clip 非対応の古いブラウザ向けに hidden をフォールバックとして先に書く。 */
body {
    overflow-x: hidden; /* fallback: iOS 15以下 */
    overflow-x: clip;   /* clip はスクロールコンテナを作らない（iOS 16+ / Chrome 90+ / FF 81+） */
    width: 100%;
    margin: 0; padding: 0;
}

:root {
    --header-height: 160px;
    --bg: #ffffff;
    --text-main: #333333;
    --text-sub: #888888;
    --border: #eeeeee;
}

body {
    background-color: var(--bg);
    color: var(--text-main);
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
    line-height: 1.8;
    -webkit-font-smoothing: antialiased;
}

/* --- ヘッダー（色反転デザイン） --- */
.global-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-height);
    z-index: 2000;
    background-color: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.4s ease;
}

/* チャット画面が開いているときはヘッダーを完全に隠す */
body.ai-chat-open .global-header {
    transform: translateY(-120%);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: transform 0.25s ease, opacity 0.2s ease;
}

body.ai-chat-open {
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
}

/* ヘッダーを隠した分の余白を詰める（チャット中はトップ余白不要） */
body.ai-chat-open main.container,
body.ai-chat-open main.home-main {
    padding-top: 0;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 30px; width: 100%; }

.brand-logo {
    font-weight: 200;
    letter-spacing: 0.4em;
    font-size: 1.8rem;
    margin: 0 0 20px 0;
    text-align: center;
    /* スクロール縮小アニメーション用 */
    overflow: hidden;
    max-height: 100px;
    opacity: 1;
    transition: max-height 0.4s ease, opacity 0.3s ease, margin 0.4s ease;
}

/* スクロール時: タイトルを上に隠しナビだけ表示 */
.global-header.scrolled {
    height: 60px;
}

.global-header.scrolled .brand-logo {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
}

.nav-list { list-style: none; padding: 0; margin: 0; display: flex; justify-content: center; gap: 30px; }

.nav-list a {
    text-decoration: none;
    color: var(--text-sub);
    font-size: 0.85rem;
    letter-spacing: 0.2em;
    padding: 10px 20px;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.nav-list a:hover { color: var(--text-main); background-color: #f8f8f8; }

/* 選択中のメニュー（色反転） */
.nav-list a.current {
    color: #ffffff;
    background-color: var(--text-main);
    font-weight: 500;
}

main.container, main.home-main { padding-top: var(--header-height); }

.global-footer { padding: 100px 0 60px; text-align: center; font-size: 0.8rem; color: var(--text-sub); letter-spacing: 0.1em; }

.page-subtitle { display: none; }

/* --- ハンバーガーボタン（デスクトップでは非表示） --- */
.hamburger {
    display: none;
}

/* --- モバイルメニュー（デスクトップでは非表示） --- */
.mobile-menu {
    display: none;
}

/* --- スマホ最適化 --- */
@media (max-width: 768px) {
    :root { --header-height: 100px; }
    .global-header.scrolled { height: 45px; }
    .container { padding: 0 20px; }
    .brand-logo { font-size: 1.3rem; letter-spacing: 0.2em; margin: 0 0 10px 0; }

    /* モバイルではデスクトップナビを非表示にしてハンバーガーに切り替え */
    .global-header nav { display: none; }

    /* ハンバーガーボタン */
    .hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 6px;
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        width: 44px;
        height: 44px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 10px;
        z-index: 2001;
    }

    .hamburger span {
        display: block;
        width: 22px;
        height: 1px;
        background-color: var(--text-main);
        transition: transform 0.35s ease, opacity 0.25s ease;
        transform-origin: center;
    }

    /* ✕ アニメーション */
    .hamburger.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .hamburger.is-open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
    .hamburger.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* フルスクリーンモバイルメニュー */
    .mobile-menu {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: fixed;
        inset: 0;
        z-index: 1999; /* ヘッダー(2000)より下で、ハンバーガー(2001)より下 */
        background-color: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        /* フェードイン/アウトアニメーション */
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    }

    .mobile-menu.is-open {
        visibility: visible;
        opacity: 1;
        transition: opacity 0.3s ease, visibility 0s;
    }

    /* モバイルメニューのリンク */
    .mobile-nav-list {
        list-style: none;
        padding: 0;
        margin: 0;
        width: 100%;
        text-align: center;
    }

    .mobile-nav-list li + li {
        border-top: 1px solid #f0f0f0;
    }

    .mobile-nav-list a {
        display: block;
        padding: 22px 40px;
        font-size: 0.95rem;
        letter-spacing: 0.35em;
        color: var(--text-sub);
        text-decoration: none;
        transition: color 0.25s;
    }

    .mobile-nav-list a.current,
    .mobile-nav-list a:active {
        color: var(--text-main);
        font-weight: 500;
    }

    .global-footer { padding: 60px 0 40px; }
}

.copyright {
    font-size: 0.85rem;
    color: #666;
}

.copyright a {
    color: #333;
    text-decoration: none;
    font-weight: bold;
}

.copyright a:hover {
    text-decoration: underline;
}

/* --- ローディングスピナー --- */
#loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 80px 0;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 2px solid #e0e0e0;
    border-top-color: var(--text-main);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}