/* グローバル変数とリセット */
:root {
    --primary-color: #0077b6; /* 新しいメインカラー (深めの青) */
    --secondary-color: #6c757d;
    --bg-light: #f8f9fa;
    --text-color: #333;
    --border-color: #e9ecef;
    --shadow-light: 0 4px 12px rgba(0, 0, 0, 0.08);
    --border-radius: 6px;
}

html, body {
    height: 100%; /* htmlとbodyの高さをウィンドウいっぱいに設定 */
}

body {
    font-family: 'Noto Sans JP', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-light);
    color: var(--text-color);
    line-height: 1.6;
    display: flex; /* bodyをFlexコンテナにする */
    flex-direction: column; /* 子要素を縦に並べる */
}

.content-wrap {
    flex: 1 0 auto; /* 成長を許可し、縮小はしない。フッター以外の領域を埋める */
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ヘッダー */
header {
    background-color: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    padding: 15px 0;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

/* メイン見出しセクション (ヒーローセクションの役割) */
.main-heading-section {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 40px 0;
    margin-bottom: 30px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.main-heading-section h1 {
    font-size: 36px;
    margin-bottom: 10px;
    font-weight: 700;
}

.main-heading-section p {
    font-size: 18px;
    opacity: 0.9;
    font-weight: 300;
}


/* メインコンテンツレイアウト */
main.container {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}

/* コンテンツコンテナ共通スタイル */
.topics-list-container, .topic-detail-container {
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-light);
    padding: 25px;
}

/* トピックス一覧 (左側) */
.topics-list-container {
    flex: 1; /* 比較的小さく */
    min-width: 300px; 
}

.topics-list-container h2, .topic-detail-container h2 {
    font-size: 20px;
    color: var(--primary-color);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 20px;
    font-weight: 700;
}

#topics-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

#topics-list li {
    padding: 12px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 15px;
    line-height: 1.4;
    font-weight: 400;
}

#topics-list li:last-child {
    border-bottom: none;
}

#topics-list li:hover {
    background-color: #e3f2fd; /* 薄い青 */
}

#topics-list li.active {
    background-color: var(--primary-color);
    color: white;
    border-radius: var(--border-radius);
    padding-left: 15px;
}

/* トピック詳細 (右側) */
.topic-detail-container {
    flex: 3; /* 比較的大きく */
}

#topic-detail h3 {
    font-size: 26px;
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
    font-weight: 700;
}

#topic-detail .topic-date {
    font-size: 14px;
    color: var(--secondary-color);
    margin-bottom: 20px;
    display: block;
}

#topic-detail hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 20px 0;
}

#topic-detail p {
    font-size: 16px;
    color: var(--text-color);
    white-space: pre-wrap; /* 改行を反映させるために重要 */
}

.initial-message {
    color: var(--secondary-color);
    text-align: center;
    padding: 50px 0;
    font-size: 18px;
}

/* フッター */
footer {
    background-color: #495057; /* ダークグレー */
    color: white;
    text-align: center;
    padding: 20px 0;
    font-size: 14px;
    flex-shrink: 0; /* 縮小しないように設定 */
}

/* 読み込みアニメーション (前回のものを継承) */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* ======================================= */
/* 📱 レスポンシブ対応 (768px以下で縦並び) */
/* ======================================= */
@media (max-width: 992px) {
    main.container {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    /* 縦並びのレイアウトに変更 */
    main.container {
        flex-direction: column; 
        padding: 0 15px;
    }

    .topics-list-container {
        min-width: auto; /* 最小幅を解除 */
        order: 2; /* スマホでは一覧を下に (任意) */
    }

    .topic-detail-container {
        order: 1; /* スマホでは詳細を上に (任意) */
        margin-bottom: 20px;
    }

    /* 見出し調整 */
    .main-heading-section {
        padding: 30px 0;
    }
    .main-heading-section h1 {
        font-size: 30px;
    }
    .main-heading-section p {
        font-size: 16px;
    }
    
    /* リスト調整 */
    .topics-list-container h2 {
        margin-bottom: 10px;
    }
    #topics-list li {
        font-size: 14px;
        padding: 10px;
    }
    #topics-list li.active {
        padding-left: 10px;
    }

    /* 詳細調整 */
    #topic-detail h3 {
        font-size: 22px;
    }
}