:root {
    --primary-color: #1e293b;
    --secondary-color: #2563eb;
    --accent-color: #f1f5f9;
    --text-color: #334155;
    --code-bg: #0f172a;
    --border-color: #e2e8f0;
}

body {
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", Meiryo, sans-serif;
    line-height: 1.7;
    color: var(--text-color);
    margin: 0;
    padding: 0;
    background-color: #f8fafc;
}

header {
    background: linear-gradient(135deg, #0f172a, #1e3a8a);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

header h1 {
    margin: 0;
    font-size: 2.2rem;
    font-weight: 700;
}

.subtitle {
    margin: 0.5rem 0 0 0;
    font-size: 1.1rem;
    color: #93c5fd;
}

/* 2カラムレイアウト用のコンテナ定義 */
.container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    gap: 2rem;
    padding: 2rem;
}

/* ポータル画面（index.html）専用スタイル */
.main-portal {
    display: block;
    max-width: 1200px;
}

.portal-desc {
    font-size: 1.1rem;
    color: #64748b;
    margin-bottom: 2rem;
}

.chapter-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 2rem;
}

.chapter-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chapter-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05);
}

.chapter-card h3 {
    margin: 0.75rem 0;
    font-size: 1.3rem;
    color: var(--primary-color);
}

.chapter-card p {
    color: #64748b;
    font-size: 0.95rem;
    flex-grow: 1;
    margin-bottom: 1.5rem;
}

/* 各章ドキュメント画面用の共通サイドバー（左側固定メニュー） */
.sidebar {
    width: 320px;
    position: sticky;
    top: 2rem;
    height: calc(100vh - 4rem);
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    overflow-y: auto;
    box-sizing: border-box;
}

.sidebar h2 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-top: 0;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border-color);
    border-left: none;
    padding-left: 0;
}

#table-of-contents ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#table-of-contents li {
    margin-bottom: 0.5rem;
}

#table-of-contents a {
    display: block;
    padding: 0.6rem 0.75rem;
    color: #475569;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    line-height: 1.4;
}

#table-of-contents a:hover {
    background-color: var(--accent-color);
    color: var(--secondary-color);
}

#table-of-contents li.active a {
    background-color: #eff6ff;
    color: var(--secondary-color);
    font-weight: 600;
    border-left: 4px solid var(--secondary-color);
    border-radius: 0 6px 6px 0;
}

/* 各章ドキュメント画面用のメインコンテンツエリア */
.content-page {
    flex: 1;
    background: white;
    border-radius: 12px;
    padding: 3.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    box-sizing: border-box;
    min-width: 0;
}

.back-link {
    display: inline-block;
    margin-bottom: 1.5rem;
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: bold;
}

.back-link:hover {
    text-decoration: underline;
}

.bottom-nav {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    border-left: 6px solid var(--secondary-color);
    padding-left: 1rem;
    margin-bottom: 1.5rem;
    margin-top: 0;
}

h3 {
    font-size: 1.35rem;
    color: #1e293b;
    margin-top: 2.5rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

/* テクニカルパーツ */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 1rem;
}
.badge-info { background-color: #e0f2fe; color: #0369a1; }
.badge-success { background-color: #dcfce7; color: #15803d; }
.badge-warning { background-color: #fef9c3; color: #a16207; }
.badge-danger { background-color: #fee2e2; color: #b91c1c; }
.badge-secondary { background-color: #f1f5f9; color: #475569; }

.btn-enter {
    background-color: var(--secondary-color);
    color: white;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.95rem;
    transition: background-color 0.2s ease;
}

.btn-enter:hover {
    background-color: #1d4ed8;
}

.detailed-steps {
    padding-left: 1.5rem;
}

.detailed-steps li {
    margin-bottom: 1.5rem;
}

/* 章本文中の対比カード（card-grid / card）
   ※ 序章・第1章・第8章で使用。従来 style.css に未定義だったため追記。 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin: 1.5rem 0;
}

.card {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
}

.card h4 {
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.card p {
    margin: 0;
    color: #475569;
    font-size: 0.95rem;
}

.card p + p {
    margin-top: 0.75rem;
}

.code-block, pre {
    background-color: var(--code-bg);
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: 8px;
    overflow-x: auto;
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 1rem 0;
}

.diagram-box pre, .report-box pre {
    background-color: #1e293b;
    color: #38bdf8;
    border-left: 4px solid #38bdf8;
}

.note {
    background-color: #fff7ed;
    border-left: 4px solid #ea580c;
    color: #c2410c;
    padding: 1.25rem;
    border-radius: 6px;
    margin: 1.5rem 0;
}

.glossary dt {
    font-weight: bold;
    color: var(--primary-color);
    margin-top: 1.5rem;
    font-size: 1.1rem;
}

.glossary dd {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
    color: #475569;
}

.faq-box {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.question {
    font-weight: bold;
    color: #166534;
    margin-top: 0;
}

.answer {
    margin-bottom: 1.5rem;
    color: #1e293b;
}

.answer:last-child {
    margin-bottom: 0;
}

footer {
    text-align: center;
    padding: 2rem;
    background-color: var(--primary-color);
    color: #94a3b8;
    font-size: 0.9rem;
    margin-top: 4rem;
}

/* レスポンシブ設計：タブレット・スマホ時は縦並びにする */
@media (max-width: 1024px) {
    .container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }
    .content-page {
        padding: 2rem;
    }
}

/* =========================================================
   基礎編（CPUのしくみ ― 命令セットの裏側）追加スタイル
   読み物編 style.css をそのまま土台にし、基礎編で新たに使う
   「図版（SVG）」「準備中ボタン」「判断ボックス」のみを追記。
   既存の定義には一切手を加えていません。
   ========================================================= */

/* 図版（SVG図解）と説明文 */
figure.diagram {
    margin: 1.75rem 0;
    text-align: center;
}
figure.diagram svg {
    max-width: 680px;
    width: 100%;
    height: auto;
}
figure.diagram figcaption {
    margin-top: 0.6rem;
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.6;
}

/* ポータルの「準備中」ボタン（未公開の章） */
.btn-soon {
    display: inline-block;
    background-color: #e2e8f0;
    color: #94a3b8;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.95rem;
    cursor: default;
}

/* 「ここで決めること」判断ボックス（基礎編の背骨） */
.decide {
    background-color: #eff6ff;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #2563eb;
    border-radius: 6px;
    padding: 1rem 1.25rem;
    margin: 1.5rem 0;
}
.decide strong { color: #1d4ed8; }

/* ポータル副題の補足（基礎01〜03との区別を示す一文） */
.portal-note {
    font-size: 0.95rem;
    color: #64748b;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 4px solid #64748b;
    border-radius: 6px;
    padding: 0.9rem 1.1rem;
    margin: 0 0 2rem 0;
}
