/* --- ベース設定 --- */
:root {
    --primary-color: #1e293b;
    --secondary-color: #334155;
    --bg-color: #f8fafc;
    --text-color: #333;
    --border-color: #e2e8f0;
    --accent-color: #3b82f6;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- ヘッダー・フッター --- */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 15px 30px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.header-weapon {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 { margin: 0; font-size: 1.5rem; letter-spacing: 1px; }

footer {
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 15px;
    margin-top: auto;
}

/* --- 全体レイアウト（左端固定化） --- */
.container {
    display: flex;
    flex: 1;
    /* max-width と margin を削除し、常に画面幅いっぱいを使うようにしました */
    width: 100%;
}

/* --- サイドバー --- */
.sidebar {
    width: 250px;
    min-width: 250px;
    background-color: white;
    border-right: 1px solid var(--border-color);
    padding: 20px 15px;
    box-sizing: border-box;
}

.sidebar ul { list-style: none; padding-left: 0; margin: 0; }
.sidebar li { margin-bottom: 5px; }

.sidebar details summary {
    font-weight: bold;
    color: var(--secondary-color);
    cursor: pointer;
    padding: 8px 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}
.sidebar details summary:hover { background-color: #f1f5f9; }

.sidebar details ul { padding-left: 20px; margin-top: 5px; }
.sidebar li a {
    text-decoration: none;
    color: var(--text-color);
    display: block;
    padding: 5px;
    font-size: 0.95rem;
    transition: color 0.2s;
}
.sidebar li a:hover { color: var(--accent-color); }

.top-link {
    font-weight: bold;
    color: var(--primary-color);
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
    padding-bottom: 10px !important;
}

/* --- メインコンテンツ --- */
.main-content {
    flex: 1;
    padding: 30px;
    position: relative;
    box-sizing: border-box;
}

.center-layout, .weapon-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* --- 検索バー ＆ サジェスト --- */
.search-container { position: relative; width: 100%; }

.hero-image-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto 30px auto;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.hero-image {
    width: 100%;
    display: block;
}

.overlay-search {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 600px;
    z-index: 10;
}

.right-search { max-width: 300px; }

#search-input {
    width: 100%;
    padding: 14px 20px;
    font-size: 1.05rem;
    border: none;
    border-radius: 30px;
    outline: none;
    box-sizing: border-box;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: box-shadow 0.3s;
}

#search-input:focus { box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4); }

.suggest-box {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    margin-top: 8px;
    max-height: 250px;
    overflow-y: auto;
    text-align: left;
}

.suggest-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-color);
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background-color: #f1f5f9; color: var(--accent-color); font-weight: bold;}
.no-hover:hover { background-color: white; color: var(--text-color); font-weight: normal; cursor: default;}

/* --- 個別ページ要素 --- */
.welcome-text { margin-top: 10px; }
.weapon-title { font-size: 2rem; color: var(--primary-color); border-bottom: 2px solid var(--accent-color); padding-bottom: 10px; margin-bottom: 20px; display: inline-block;}
.weapon-image-wrapper { margin: 20px 0; }
.weapon-image-wrapper img { max-width: 100%; height: auto; border-radius: 4px; box-shadow: 0 4px 8px rgba(0,0,0,0.1); }

.weapon-description { max-width: 800px; margin: 0 auto; text-align: left; line-height: 1.8; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.05);}
.weapon-description h3 { color: var(--secondary-color); margin-top: 25px; }
    
/* --- Wikipedia風レイアウト --- */
.wiki-layout {
    text-align: left;
    width: 100%;
    max-width: 900px; /* 読みやすい横幅に制限 */
    margin: 0 auto;
    line-height: 1.8;
    color: #202122;
}

.weapon-title-wiki {
    font-size: 2.2rem;
    font-family: serif; /* 歴史サイトらしく明朝・セリフ体を意識 */
    border-bottom: 1px solid #a2a9b1;
    padding-bottom: 10px;
    margin-bottom: 20px;
}

/* インフォボックス (右寄せの表) */
.infobox {
    float: right;
    width: 300px;
    margin: 0 0 1em 1.5em;
    border: 1px solid #a2a9b1;
    background-color: #f8f9fa;
    padding: 5px;
    font-size: 0.9em;
    border-collapse: collapse;
}

.infobox th, .infobox td {
    padding: 8px;
    border-bottom: 1px solid #eaecf0;
}

.infobox-title {
    background-color: #b0c4de; /* 海軍らしい少し渋いブルー */
    text-align: center;
    font-size: 1.1em;
}

.infobox-header {
    background-color: #e2e8f0;
    text-align: center;
}

.infobox-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* 目次 */
.toc {
    border: 1px solid #a2a9b1;
    background-color: #f8f9fa;
    padding: 15px 20px;
    display: table; /* 中身に合わせて幅を調整 */
    margin-bottom: 2em;
    border-radius: 2px;
}

.toc-title {
    text-align: center;
    font-weight: bold;
    margin-bottom: 10px;
}

.toc ul {
    list-style-type: none;
    padding-left: 0;
    margin: 0;
}

.toc li { margin-bottom: 5px; }
.toc a { text-decoration: none; color: #0645ad; }
.toc a:hover { text-decoration: underline; }

/* セクションと見出し */
.wiki-section {
    clear: both; /* インフォボックスの回り込みを解除 */
    margin-top: 2em;
}

.wiki-section h2 {
    font-family: serif;
    font-size: 1.5rem;
    border-bottom: 1px solid #a2a9b1;
    padding-bottom: 5px;
    margin-bottom: 15px;
}

.wiki-section h3 {
    font-size: 1.2rem;
    margin-top: 1.5em;
}

/* ギャラリー */
.gallery {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.gallery img {
    border: 1px solid #ccc;
    padding: 5px;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- 広告用コンテナ --- */
.ad-container {
    margin: 25px 0;
    text-align: center;
    background: #f1f5f9; /* 広告が読み込まれる前のプレースホルダー色 */
    padding: 10px;
    min-height: 100px;
}

/* 広告ラベル（AdSenseの推奨事項に沿って「スポンサーリンク」等を明記） */
.ad-container::before {
    content: "スポンサーリンク";
    font-size: 0.75rem;
    color: #64748b;
    display: block;
    margin-bottom: 5px;
}

/* モバイル向け調整 */
@media (max-width: 768px) {
    .infobox {
        float: none;
        width: 100%;
        margin: 0 0 1em 0;
    }
    .wiki-section { margin-top: 1em; }
}