/* ------ 教材ページ専用スタイル (目次グリッド / 章ナビ / callout) ------ */

/* --- 教材目次: 章カードグリッド --- */
.chapter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    list-style: none;
    padding: 0;
    margin-top: 28px;
    margin-bottom: 48px;
}

.chapter-grid li {
    margin: 0;
}

.chapter-grid a {
    position: relative;
    z-index: 1;
    display: block;
    height: 100%;
    padding: 22px 24px;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    color: var(--color-text-dark);
    text-decoration: none;
    transition: box-shadow 0.2s ease-out, border-color 0.2s ease-out;
}

.chapter-grid a:hover {
    z-index: 2;
    box-shadow: var(--box-shadow-hover);
    border-color: var(--color-accent);
    opacity: 1;
    text-decoration: none;
}

.chapter-grid .chapter-num {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-accent);
    letter-spacing: 1px;
    margin-bottom: 10px;
}

.chapter-grid .chapter-title {
    display: block;
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--color-text-dark);
}

.chapter-grid .chapter-summary {
    display: block;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--color-text-sub);
}

/* --- 章ページの見出し --- */
.chapter-body h2 {
    font-size: 1.5rem;
    margin-top: 48px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--color-border);
}

.chapter-body h3 {
    font-size: 1.2rem;
    margin-top: 32px;
    margin-bottom: 12px;
    color: var(--color-text-dark);
}

.chapter-body p {
    line-height: 1.8;
    margin: 0 0 16px 0;
}

.chapter-body ul,
.chapter-body ol {
    line-height: 1.8;
    margin: 0 0 16px 0;
    padding-left: 1.4em;
}

.chapter-body li {
    margin-bottom: 6px;
}

.chapter-body strong {
    color: #FFFFFF;
}

/* インラインコード (本文内の `git init` など) */
.chapter-body p code,
.chapter-body li code,
.chapter-body td code,
.chapter-body dd code {
    background-color: rgba(96, 165, 250, 0.15);
    border: 1px solid rgba(96, 165, 250, 0.35);
    color: #bfdbfe;
    border-radius: 3px;
    padding: 1px 5px;
    font-family: "Consolas", "Menlo", "Monaco", "Courier New", monospace;
    font-size: 0.9em;
}

/* --- 章冒頭の「この章で分かること」 --- */
.chapter-intro {
    background-color: rgba(96, 165, 250, 0.08);
    border-left: 4px solid var(--color-accent);
    border-radius: 4px;
    padding: 16px 20px;
    margin: 24px 0 32px 0;
}

.chapter-intro h2 {
    margin: 0 0 10px 0;
    padding: 0;
    border: none;
    font-size: 1rem;
    letter-spacing: 1px;
    color: var(--color-accent);
}

.chapter-intro ul {
    margin: 0;
    padding-left: 1.4em;
}

/* --- callout (補足 / 注意 / ヒント) --- */
.callout {
    border-radius: 4px;
    padding: 14px 18px;
    margin: 20px 0;
    border-left: 4px solid var(--color-border);
    background-color: rgba(148, 163, 184, 0.08);
    color: var(--color-text-dark);
}

.callout-title {
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.callout p:last-child {
    margin-bottom: 0;
}

.callout-note {
    border-left-color: #38bdf8;
    background-color: rgba(56, 189, 248, 0.1);
}

.callout-note .callout-title {
    color: #7dd3fc;
}

.callout-warn {
    border-left-color: #eab308;
    background-color: rgba(234, 179, 8, 0.1);
}

.callout-warn .callout-title {
    color: #fde047;
}

.callout-tip {
    border-left-color: #10b981;
    background-color: rgba(16, 185, 129, 0.1);
}

.callout-tip .callout-title {
    color: #6ee7b7;
}

/* --- SVG 図のラッパ --- */
.chapter-figure {
    margin: 28px auto;
    text-align: center;
}

.chapter-figure svg,
.chapter-figure img {
    max-width: 100%;
    height: auto;
}

.chapter-figure figcaption {
    font-size: 0.85rem;
    color: var(--color-text-sub);
    margin-top: 10px;
}

/* --- 章ナビ (前/目次/次) --- */
.chapter-nav {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin: 48px 0 30px 0;
}

.chapter-nav > a,
.chapter-nav > span {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 14px 18px;
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    color: var(--color-text-dark);
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.4;
    min-height: 70px;
    transition: all 0.2s ease;
}

.chapter-nav > a:hover {
    box-shadow: var(--box-shadow);
    border-color: var(--color-accent);
    opacity: 1;
    text-decoration: none;
}

.chapter-nav .nav-label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-sub);
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.chapter-nav .nav-title {
    font-weight: 500;
    color: var(--color-text-dark);
}

.chapter-nav .nav-prev { text-align: left; }
.chapter-nav .nav-toc { text-align: center; }
.chapter-nav .nav-next { text-align: right; }

.chapter-nav .nav-disabled {
    background-color: rgba(148, 163, 184, 0.05);
    color: #64748b;
    cursor: default;
}

.chapter-nav .nav-disabled .nav-title {
    color: #64748b;
}

/* スマホで縦並びに */
@media (max-width: 640px) {
    .chapter-nav {
        grid-template-columns: 1fr;
    }
}

/* ------ 論理リテラシー教材 専用スタイル ------ */

/* --- 目次ページ リード段落 --- */
.lead {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--color-text-dark);
    line-height: 1.9;
}

/* --- 練習問題 --- */
.exercise {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid var(--color-accent);
    background-color: rgba(96, 165, 250, 0.06);
    border-radius: 4px;
}

.exercise h3 {
    margin-top: 0;
}

.exercise-answer {
    margin-top: 1rem;
}

.exercise-answer summary {
    cursor: pointer;
    padding: 0.5rem 0;
    font-weight: 700;
    color: var(--color-accent);
    user-select: none;
}

.exercise-answer summary:hover {
    opacity: 0.8;
}

.exercise-answer[open] summary {
    margin-bottom: 0.75rem;
}

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

/* --- 章末コラム — 記号紹介 --- */
.column-symbols {
    margin: 2.5rem 0 2rem 0;
    padding: 1.25rem 1.5rem;
    background-color: rgba(148, 163, 184, 0.08);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
}

.column-symbols h2 {
    margin-top: 0;
    font-size: 1.1rem;
    border-bottom: none;
    padding-bottom: 0;
}

.column-symbols dl {
    margin: 0.75rem 0 0 0;
}

.column-symbols dt {
    font-weight: 700;
    margin-top: 0.75rem;
    color: var(--color-text-dark);
}

.column-symbols dd {
    margin-left: 1rem;
    font-family: "Consolas", "Menlo", "Monaco", "Courier New", monospace;
    color: #bfdbfe;
}

/* --- 章末コラム — 分岐予告 --- */
.branch-preview {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    background-color: rgba(96, 165, 250, 0.05);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
}

.branch-preview h2 {
    margin-top: 0;
    font-size: 1.1rem;
    border-bottom: none;
    padding-bottom: 0;
}

.branch-preview ul {
    margin-bottom: 0;
}

/* --- 準備中表示 (全要素共通) --- */
.preview-disabled,
.chapter-disabled,
.branch-disabled {
    color: var(--color-text-sub);
    cursor: default;
    text-decoration: none;
}

/* 目次ページ・分岐トップで .chapter-grid 内の準備中カードに枠を出す */
.chapter-grid .chapter-disabled {
    position: relative;
    z-index: 1;
    display: block;
    height: 100%;
    padding: 22px 24px;
    background-color: rgba(30, 41, 59, 0.5);
    border: 1px dashed var(--color-border);
    border-radius: var(--border-radius);
}

/* --- 目次ページ 分岐グリッド --- */
.branch-grid {
    list-style: none;
    padding: 0;
    margin: 1rem 0 1.5rem 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.branch-grid li {
    margin: 0;
}

.branch-grid a,
.branch-grid .branch-disabled {
    display: block;
    height: 100%;
    padding: 18px 22px;
    border-radius: var(--border-radius);
    background-color: var(--color-bg-card);
    border: 1px solid var(--color-border);
    color: var(--color-text-dark);
    text-decoration: none;
    transition: box-shadow 0.2s ease-out, border-color 0.2s ease-out;
}

.branch-grid a:hover {
    box-shadow: var(--box-shadow-hover);
    border-color: var(--color-accent);
    opacity: 1;
    text-decoration: none;
}

.branch-grid .branch-disabled {
    border-style: dashed;
    background-color: rgba(30, 41, 59, 0.5);
}

.branch-title {
    display: block;
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 0.35rem;
    color: var(--color-text-dark);
}

.branch-summary {
    display: block;
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--color-text-sub);
}

/* --- 章ページ内の定義リスト (分岐トップの「この分岐について」など) --- */
.chapter-intro dl {
    margin: 0;
}

.chapter-intro dt {
    font-weight: 700;
    color: var(--color-accent);
    margin-top: 0.75rem;
}

.chapter-intro dt:first-child {
    margin-top: 0;
}

.chapter-intro dd {
    margin-left: 1rem;
    margin-bottom: 0.5rem;
}

/* --- 真理値表 (table の汎用ラッパ、横スクロール対応) --- */
.truth-table {
    overflow-x: auto;
    margin: 1.2em 0;
    -webkit-overflow-scrolling: touch;
}

.truth-table table {
    border-collapse: collapse;
    margin: 0 auto;
    background-color: var(--color-bg-card);
}

.truth-table th,
.truth-table td {
    border: 1px solid var(--color-border);
    padding: 0.5em 0.9em;
    text-align: center;
    white-space: nowrap;
}

.truth-table th {
    background-color: var(--color-bg-dark);
    color: var(--color-text-light);
    font-weight: 600;
}
