/* =========================================================
   プレミアム・ネイビー・建設ブログ専用デザイン V5（完全版）
   カード表示を「1重」に統一し、アニメーションを強化
   統合修正: 楽天ボタンの白文字強制固定済
   統合修正: 画像・Mermaidの物理的幅制限（720px）適用済
   ========================================================= */

/* --- 1. 基本設定と変数 --- */
:root {
    --primary-navy: #0f172a;
    --primary-slate: #94a3b8;
    --accent-crimson: #bf0000;
    --text-main: #333333;
    --text-dark: #1a1a1a;
    --bg-light: #f1f5f9;
    --border-color: #e2e8f0;
    --shadow-main: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --h1-size: 32px;
    --h2-size: 28px;
    --h3-size: 22px;
    --body-size: 18px;
    --line-height: 1.8;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700;800&family=Shippori+Mincho:wght@400;700;800&display=swap');

/* --- 全体基本（レイアウトを壊さないよう修正） --- */
* {
    box-sizing: border-box;
}

body {
    font-family: 'Shippori Mincho', 'Meiryo', serif;
    line-height: var(--line-height);
    color: var(--text-main);
    background-color: #ffffff;
    margin: 0;
    padding: 0;
}

/* --- トータル・センタリング設定（ヘッダー、パンくず、コンテンツを一括中央寄せ） --- */
#header,
#header-inner,
#blog-title,
#blog-title-inner,
#top-box,
#content>#content-inner,
article .content-inner,
#footer,
#footer-inner {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
    float: none !important;
    display: block !important;
}

/* 記事とサイドバーを横並びにするための設定（上記のセンタリングと共存） */
#content>#content-inner,
article .content-inner {
    display: flex !important;
    flex-direction: row !important;
    justify-content: center !important;
    align-items: flex-start !important;
    gap: 20px !important;
}

/* メインエリア（#wrapper または #main）の既存レイアウトをリセット */
#wrapper,
#main,
.entry-content,
article {
    display: block !important;
    float: none !important;
    /* 回り込み解除 */
    flex: 1 !important;
    min-width: 0 !important;
    width: auto !important;
    /* 固定幅を解除 */
    max-width: 840px !important;
    /* 記事エリアの最大幅を固定 */
    margin: 0 auto !important;
    /* 常に中央寄せ */
    padding: 2rem 0 !important;
}

/* サイドバー（#box2）の既存レイアウトをリセット */
#box2 {
    display: block !important;
    float: none !important;
    /* 回り込み解除 */
    width: 300px !important;
    /* サイドバーの幅を固定 */
    margin: 0 0 0 40px !important;
    /* 左側に間隔を空ける */
    padding-top: 2rem !important;
    flex-shrink: 0 !important;
}

/* スマホ表示（幅が狭い時）の調整 */
@media (max-width: 950px) {
    #content-inner {
        flex-wrap: wrap !important;
        flex-direction: column !important;
    }

    #wrapper,
    #main {
        max-width: 100% !important;
        width: 100% !important;
    }

    #box2 {
        width: 100% !important;
        margin-left: 0 !important;
    }
}

/* --- 2. ブログタイトル、デザイン刷新 --- */
#blog-title {
    background: var(--primary-navy);
    padding: 4rem 0 !important;
    margin-bottom: 0;
    text-align: center;
    border-bottom: 6px solid var(--primary-slate);
    position: relative;
    overflow: hidden;
}

/* 装飾的な背景パターン（建設現場のグリッドをイメージ） */
#blog-title::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
    pointer-events: none;
}

#title {
    background: transparent !important; /* 干渉回避 */
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

#title a {
    font-family: 'Shippori Mincho', serif;
    font-size: 48px;
    color: #ffffff !important;
    font-weight: 800;
    text-decoration: none !important;
    letter-spacing: 0.2em;
    display: block;
}

#blog-description {
    color: #ffffff !important;
    font-size: 1.2rem;
    margin-top: 1.5rem;
    letter-spacing: 0.3em;
    font-weight: 400;
    text-transform: uppercase;
    opacity: 0.9; /* わずかに透過させてメインタイトルとの階層を維持 */
}

/* 記事タイトル (h1) の洗練化 - セレクタを限定してブログタイトルとの干渉を防止 */
article h1, .entry-title {
    font-size: 38px !important;
    color: var(--primary-navy) !important;
    font-weight: 800;
    padding: 2rem 2.5rem !important;
    background: #f8fafc;
    border-left: 15px solid var(--primary-navy);
    margin: 4rem 0 3.5rem !important;
    line-height: 1.4 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    position: relative;
}

.entry-title a {
    font-size: var(--h1-size);
    color: var(--text-dark) !important;
    font-weight: 800;
    text-decoration: none !important;
}

/* --- 大見出し (H2)：セクション・ラベルスタイル --- */
.entry-content h2 {
    font-size: 26px !important;
    color: #ffffff !important;
    background: var(--primary-navy);
    padding: 0 !important; /* 内部パーツで制御 */
    margin-top: 7rem !important;
    margin-bottom: 3.5rem !important;
    display: flex;
    align-items: stretch;
    border-radius: 0 8px 8px 0;
    overflow: hidden;
    box-shadow: 6px 6px 0px var(--primary-slate);
}

.entry-content h2 .h-num {
    background: #ffffff;
    color: var(--primary-navy);
    padding: 1.2rem 1.8rem;
    margin-right: 0;
    border-radius: 0;
    font-weight: 900;
    font-size: 28px;
    display: flex;
    align-items: center;
    border-right: 4px solid var(--primary-slate);
}

.entry-content h2 .h-content {
    padding: 1.2rem 2rem;
    display: flex;
    align-items: center;
    flex: 1;
}

/* --- 中見出し (H3)：インデックス・スタイル --- */
.entry-content h3 {
    font-size: 22px !important;
    color: var(--primary-navy) !important;
    padding: 1rem 0 !important;
    margin-top: 5rem !important;
    margin-bottom: 2rem !important;
    border-bottom: 3px solid var(--primary-navy);
    display: flex;
    align-items: center;
    font-weight: 800;
}

.entry-content h3::before {
    content: '▶';
    font-size: 14px;
    margin-right: 12px;
    color: var(--primary-navy);
    background: var(--bg-light);
    padding: 4px 8px;
    border-radius: 4px;
}

/* --- 3. プレミアム・コンポーネント --- */

.related-card {
    display: block !important;
    border: 1px solid var(--border-color) !important;
    border-left: 8px solid var(--primary-navy) !important;
    background: #ffffff !important;
    padding: 1.5rem 2rem !important;
    margin: 2.5rem 0 !important;
    border-radius: 0 16px 16px 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06) !important;
    text-decoration: none !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative;
    cursor: pointer;
}

.related-card:hover {
    transform: translateX(8px) translateY(-2px) !important;
    background: #f8fafc !important;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.1) !important;
    border-color: var(--primary-navy) !important;
}

.link-card-title {
    display: block;
    font-weight: bold;
    font-size: 1.25rem;
    color: var(--primary-navy);
    margin-bottom: 0.5rem;
    transition: color 0.2s ease;
}

.internal-link-card {
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background: none !important;
    box-shadow: none !important;
}

/* --- 4. その他のパーツ --- */

.rakuten-btn {
    display: inline-block !important;
    background-color: var(--accent-crimson) !important;
    padding: 16px 32px !important;
    border-radius: 8px !important;
    margin: 1.5rem 0 !important;
    box-shadow: 0 4px 6px rgba(191, 0, 0, 0.15) !important;
    text-decoration: none !important;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.rakuten-btn, .rakuten-btn a {
    color: #ffffff !important;
    text-decoration: none !important;
}

.rakuten-btn:hover {
    transform: translateY(-4px) scale(1.03) !important;
    box-shadow: 0 12px 24px rgba(191, 0, 0, 0.3) !important;
    background-color: #d10000 !important;
}

.calc-box {
    background-color: #ffffff;
    border: 2px solid var(--primary-navy);
    padding: 2.5rem;
    margin: 3rem 0;
    border-radius: 12px;
}

.summary-box {
    background-color: var(--bg-light);
    border: 3px solid var(--primary-navy);
    padding: 2.5rem;
    margin-bottom: 4rem;
    border-radius: 16px;
}

/* フッター・最下部要素の中央寄せ */
#footer, .footer-inner, .hatena-module-foot, .hatena-ad-footer {
    text-align: center !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* 画像・Mermaidの物理的幅制限 (CRITICAL) */
.img-container, .mermaid {
    text-align: center !important;
    margin: 4rem auto !important;
    max-width: 720px !important; /* ワイド画面での肥大化を完全防止 */
    width: 100% !important;
}

.img-container img, .mermaid svg {
    max-width: 100% !important;
    width: auto !important;
    height: auto !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}