/* 基本リセットと共通設定 */
:root {
    --header-bg: #1a1a1a;
    --header-text: #ffffff;
    --washi-bg: #f9f9f9;
    --line-color: #555;
    --card-bg: #ffffff;
    --card-shadow: 0 2px 5px rgba(0,0,0,0.1);
    --highlight-color: #d32f2f; /* 検索ヒット時の色 */
    --accent-color: #333;
}

body {
    margin: 0;
    font-family: "Yu Mincho", "Hiragino Mincho ProN", serif; /* 明朝体で和の雰囲気 */
    overflow: hidden; /* マップ操作のためスクロール禁止 */
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
.site-header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 10px 20px;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.site-header h1 {
    margin: 0;
    font-size: 1.2rem;
    font-family: sans-serif;
}
.subtitle {
    font-size: 0.9rem;
    font-weight: normal;
    margin-left: 10px;
    opacity: 0.8;
}

/* --- 検索エリアと候補リスト --- */
.search-container {
    position: absolute;
    top: 60px;
    left: 20px;
    z-index: 5;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    display: flex;
    align-items: flex-start;
    gap: 5px;
}

.search-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
}

#search-input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 200px;
}

#search-btn {
    padding: 8px 16px;
    background: var(--header-bg);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

/* 候補リストの箱 */
.suggestions-box {
    position: absolute;
    top: 100%; /* 入力欄の真下 */
    left: 0;
    width: 100%; /* 入力欄と同じ幅 */
    background: #fff;
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
    display: none; /* 初期状態は非表示 */
}

/* 候補アイテム */
.suggestion-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.95rem;
    color: #333;
    text-align: left;
}
.suggestion-item:last-child {
    border-bottom: none;
}
.suggestion-item:hover {
    background-color: #f5f5f5;
}

/* 系譜図エリア */
#genealogy-container {
    flex: 1;
    width: 100%;
    height: 100%;
    background-color: var(--washi-bg);
    /* 和紙風のノイズパターン */
    background-image: 
        radial-gradient(#ccc 1px, transparent 1px),
        radial-gradient(#ccc 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
    cursor: grab;
}

#genealogy-container:active {
    cursor: grabbing;
}

/* ノード（カード）デザイン */
.node-card {
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: var(--card-shadow);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* 縦書き設定 */
    writing-mode: vertical-rl;
    text-orientation: upright;
    transition: all 0.3s ease;
    user-select: none;
}

.node-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-color: #999;
}

.node-card.highlighted {
    border: 2px solid var(--highlight-color);
    box-shadow: 0 0 10px rgba(211, 47, 47, 0.4);
}

.node-name {
    font-size: 16px;
    font-weight: bold;
    letter-spacing: 0.1em;
    color: #333;
}

/* 左上：故人バッジ */
.badge-deceased {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 10px;
    color: #fff;
    background-color: #777;
    padding: 2px 4px;
    border-radius: 2px;
    writing-mode: horizontal-tb;
}

/* 右下（縦書き基準だと左下）：階級 */
.rank-label {
    position: absolute;
    bottom: 5px;
    left: 5px;
    font-size: 10px;
    color: #666;
    writing-mode: horizontal-tb;
}

/* 代数（上部に配置） */
.generation-label {
    position: absolute;
    top: 5px;
    right: 5px;
    font-size: 10px;
    color: #666;
    writing-mode: vertical-rl;
}

/* サイドバー (Details Panel) */
.sidebar {
    position: fixed;
    top: 50px;
    right: 0;
    width: 500px; /* 必要に応じて幅を変更してください */
    height: calc(100% - 50px);
    background: #fff;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    z-index: 20;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar.hidden {
    display: none;
}

#close-sidebar {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

/* サイドバー内部デザイン */
.sidebar-content h2.vertical-text-title {
    font-size: 1.5rem;
    margin-bottom: 5px;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
    display: inline-block;
}

.info-list dt {
    font-weight: bold;
    color: #555;
    margin-top: 10px;
    font-size: 0.9rem;
}
.info-list dd {
    margin-left: 0;
    margin-bottom: 10px;
    font-size: 1rem;
}

.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 5px;
}
.badge.deceased { background: #555; color: #fff; }
.badge.rank { background: #eee; color: #333; border: 1px solid #ccc; }

.hidden { display: none; }

/* 経歴リストのデザイン */
.career-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

.career-list li {
    display: flex;
    margin-bottom: 8px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 4px;
}

.career-year {
    font-weight: bold;
    color: #555;
    width: 50px;
    flex-shrink: 0;
}

.career-title {
    color: #333;
}

/* --- 仮想ルート（落語界）とそのリンクを非表示にする --- */

/* 1. 「落語界」のカード自体を非表示にする */
.node-card.invisible-card,
div[class*="invisible-card"] {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* 2. 「落語界」から伸びる線を非表示にする */
.link.hidden-link,
path[class*="hidden-link"] {
    visibility: hidden !important;
    stroke: none !important;
    display: none !important;
}

/* =========================================
   Header & Hamburger Menu Styles (Left Side Ver.)
   ========================================= */
   header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: #1a1a1a;
    color: #fff;
    z-index: 1000;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

.header-inner {
    width: 100%;
    padding: 0 20px;
    display: flex;
    /* ロゴを中央寄せにする（左上のボタンと重ならないように） */
    justify-content: center; 
    align-items: center;
    position: relative;
}

.logo {
    text-decoration: none;
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo span {
    font-weight: 400;
    font-size: 0.9rem;
    color: #ccc;
    border-left: 1px solid #555;
    padding-left: 10px;
}

/* ▼ ハンバーガーメニューアイコン（左上に配置） ▼ */
.menu-btn {
    position: fixed;
    top: 15px;
    left: 20px; /* ここを Left に変更 */
    display: flex;
    height: 30px;
    width: 30px;
    justify-content: center;
    align-items: center;
    z-index: 1002;
    cursor: pointer;
}

.menu-btn span,
.menu-btn span:before,
.menu-btn span:after {
    content: '';
    display: block;
    height: 2px;
    width: 25px;
    border-radius: 3px;
    background-color: #ffffff;
    position: absolute;
    transition: all 0.3s ease-in-out;
}

.menu-btn span:before { bottom: 8px; }
.menu-btn span:after { top: 8px; }

/* チェックボックスは隠す */
#menu-btn-check { display: none; }

/* メニューが開いた時のアイコン変化 */
#menu-btn-check:checked ~ .menu-btn span { background-color: rgba(255, 255, 255, 0); }
#menu-btn-check:checked ~ .menu-btn span::before { bottom: 0; transform: rotate(45deg); }
#menu-btn-check:checked ~ .menu-btn span::after { top: 0; transform: rotate(-45deg); }

/* ▼ メニュー本体（左側から出てくる設定） ▼ */
.menu-content {
    width: 350px;        /* ★ここを変更: 固定幅にする */
    max-width: 80vw;     /* (スマホ対策) 画面幅が350pxより狭い場合は80%にする */
    height: 100%;
    position: fixed;
    top: 0;
    left: -350px;        /* ★ここを変更: widthと同じ分だけ隠す */
    z-index: 1001;
    background-color: rgba(20, 20, 20, 0.98); /* 背景を少し濃く */
    box-shadow: 5px 0 15px rgba(0,0,0,0.3);   /* ★追加: 右側に影を落とす */
    transition: all 0.4s ease-in-out;
    display: flex;
    justify-content: center;
    align-items: center;
}
/* メニューが開いた時 */
#menu-btn-check:checked ~ .menu-content {
    left: 0; /* 画面内（左端）へ */
}

/* メニューリスト */
.nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 80%;
    max-width: 600px;
}

.nav-list li {
    margin-bottom: 20px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s, transform 0.4s;
}

/* メニューが開いた時のリストアニメーション */
#menu-btn-check:checked ~ .menu-content .nav-list li {
    opacity: 1;
    transform: translateY(0);
}
/* 遅延設定 */
#menu-btn-check:checked ~ .menu-content .nav-list li:nth-child(1) { transition-delay: 0.1s; }
#menu-btn-check:checked ~ .menu-content .nav-list li:nth-child(2) { transition-delay: 0.15s; }
#menu-btn-check:checked ~ .menu-content .nav-list li:nth-child(3) { transition-delay: 0.2s; }
#menu-btn-check:checked ~ .menu-content .nav-list li:nth-child(4) { transition-delay: 0.25s; }
#menu-btn-check:checked ~ .menu-content .nav-list li:nth-child(5) { transition-delay: 0.3s; }
#menu-btn-check:checked ~ .menu-content .nav-list li:nth-child(6) { transition-delay: 0.35s; }
#menu-btn-check:checked ~ .menu-content .nav-list li:nth-child(7) { transition-delay: 0.4s; }

.nav-list a {
    text-decoration: none;
    color: #fff;
    font-size: 1.5rem;
    font-weight: 700;
    display: block;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 5px;
    transition: color 0.3s;
}

.nav-list a span {
    display: block;
    font-size: 0.9rem;
    font-weight: 400;
    color: #aaa;
    margin-top: 5px;
}

.nav-list a:hover {
    color: #3498db;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.2);
    margin: 30px 0;
}

/* Chart表示エリアの調整 */
#chart-container {
    padding-top: 60px;
    height: calc(100vh - 60px);
}

/* スマホ対応 */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 50vh;
        top: auto;
        bottom: 0;
        transform: translateY(100%);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
    }
    .sidebar.open {
        transform: translateY(0);
    }
    
    .search-container {
        width: calc(100% - 40px);
        top: auto;
        bottom: 20px;
    }
    #search-input {
        width: 100%;
    }
    .suggestions-box {
        bottom: 100%; /* スマホでは入力欄の上に候補を出す */
        top: auto;
        border-top: 1px solid #ccc;
        border-bottom: none;
        border-radius: 4px 4px 0 0;
    }
}
