/**
 * article.css - 記事ページ共通スタイル
 * 目次、見出し帯、ボックス、テーブル等の共通スタイル
 */

/* ========================================
   目次 (Table of Contents)
   ======================================== */
.toc {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.5em;
    margin: 2em 0;
}

.toc h3 {
    margin-top: 0;
    color: #6b8ab8;
    font-size: 1.1em;
}

.toc ul {
    margin-bottom: 0;
    padding-left: 1.5em;
}

.toc > ul {
    padding-left: 0;
    list-style: none;
}

.toc li {
    margin: 0.5em 0;
}

.toc a {
    text-decoration: none;
    color: #333;
}

.toc a:hover {
    text-decoration: underline;
    color: #6b8ab8;
}

/* ネストされた目次項目 */
.toc ul ul {
    margin-top: 0.3em;
    font-size: 0.95em;
}

/* ========================================
   見出し帯スタイル (Heading Bands)
   ======================================== */
article h2 {
    background: #6a6a6a;
    color: #fff;
    padding: 0.6em 1em;
    margin: 2em -1em 1em -1em;
    font-size: 1.5em;
}

article h3 {
    background: #7d7d7d;
    color: #fff;
    padding: 0.5em 1em;
    margin: 1.5em -1em 1em -1em;
    font-size: 1.25em;
}

article h4 {
    background: #9a9a9a;
    color: #fff;
    padding: 0.4em 1em;
    margin: 1.2em -1em 0.8em -1em;
    font-size: 1.1em;
}

article h5 {
    background: #a5a5a5;
    color: #fff;
    padding: 0.3em 1em;
    margin: 1em -1em 0.6em -1em;
    font-size: 1em;
    border-left: 4px solid #999999;
}

/* 見出し帯内の code を読みやすくする */
article h2 code, article h3 code, article h4 code, article h5 code {
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    article h2, article h3, article h4, article h5 {
        margin-left: -0.5em;
        margin-right: -0.5em;
    }
}

/* ========================================
   ボックススタイル (Box Styles)
   ======================================== */

/* 注意・補足ボックス */
.note-box, .note {
    background: #f2e8dd;
    border-left: 4px solid #b89968;
    padding: 1em 1.2em;
    margin: 1.5em 0;
}

.note-box p:last-child,
.note p:last-child {
    margin-bottom: 0;
}

/* 警告ボックス */
.warning-box, .warning {
    background: #fcf4f4;
    border-left: 4px solid #b08080;
    padding: 1em 1.2em;
    margin: 1.5em 0;
}

.warning-box p:last-child,
.warning p:last-child {
    margin-bottom: 0;
}

/* 情報ボックス */
.info-box, .info {
    background: #dde9f2;
    border-left: 4px solid #6b8ab8;
    padding: 1em 1.2em;
    margin: 1.5em 0;
}

.info-box p:last-child,
.info p:last-child {
    margin-bottom: 0;
}

/* 成功・ヒントボックス */
.success-box, .tip {
    background: #e8ede7;
    border-left: 4px solid #7a9b7a;
    padding: 1em 1.2em;
    margin: 1.5em 0;
}

.success-box p:last-child,
.tip p:last-child {
    margin-bottom: 0;
}

/* ボックス内のh4は帯スタイルを解除 */
.note h4, .note-box h4 {
    background: none;
    color: #8b6f47;
    padding: 0;
    margin: 0 0 0.8em 0;
    font-size: 1.05em;
    font-weight: bold;
    border-left: none;
}

.warning h4, .warning-box h4 {
    background: none;
    color: #8b5a5a;
    padding: 0;
    margin: 0 0 0.8em 0;
    font-size: 1.05em;
    font-weight: bold;
    border-left: none;
}

.info h4, .info-box h4 {
    background: none;
    color: #4a5f7f;
    padding: 0;
    margin: 0 0 0.8em 0;
    font-size: 1.05em;
    font-weight: bold;
    border-left: none;
}

.tip h4, .success-box h4 {
    background: none;
    color: #5a6f5a;
    padding: 0;
    margin: 0 0 0.8em 0;
    font-size: 1.05em;
    font-weight: bold;
    border-left: none;
}

/* 導出・計算過程ボックス */
.derivation {
    background: #f5f5f5;
    padding: 0.8em 1.2em;
    margin: 1em 0;
    font-size: 0.95em;
    border-radius: 4px;
}

.detail-calc {
    margin-left: 2em;
    font-size: 0.9em;
}

.example-box {
    margin-left: 3em;
    margin-right: 3em;
    font-size: 0.9em;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 0.8em 1.2em 1em;
    background: #f5f5f5;
}

.example-box p[style*="text-align:center"] {
    overflow-x: auto;
    overflow-y: hidden;
}

@media (max-width: 768px) {
    .example-box {
        margin-left: 0.5em;
        margin-right: 0.5em;
    }
}

.example-box > h4:first-child {
    background: #9a9a9a;
    color: #fff;
    padding: 0.5em 1.2em;
    margin: -0.8em -1.2em 0.8em;
    font-size: 1.05em;
    border-radius: 8px 8px 0 0;
}

.example-box > h4:first-child i {
    margin-right: 0.3em;
}

.indent-sub {
    margin-left: 3em;
}

.indent-note {
    margin-left: 2em;
}

.nowrap {
    white-space: nowrap;
}

.warning-box {
    background: #fff3f3;
    border-left: 4px solid #e74c3c;
    padding: 0.8em 1.2em;
    margin: 1em 0;
    color: #c0392b;
    font-weight: 600;
}

.warning-box code {
    color: #c0392b;
    background: rgba(231, 76, 60, 0.1);
}

.formula-graph-row {
    display: flex;
    align-items: center;
    gap: 1em;
    flex-wrap: wrap;
}

.formula-graph-row .formula-side {
    flex: 1;
    min-width: 280px;
}

.formula-graph-row .graph-side {
    flex: 0 0 auto;
}

.convergence-graph {
    max-width: 500px;
    display: block;
    margin: -0.5em auto 1.5em;
    font-family: serif;
}

/* ========================================
   折りたたみ（証明等）
   ======================================== */
.proof-toggle, details.collapsible {
    margin-top: 0.8em;
    font-size: 0.95em;
}

.proof-toggle summary, details.collapsible summary {
    cursor: pointer;
    color: #6b8ab8;
    font-weight: 500;
}

.proof-toggle summary:hover, details.collapsible summary:hover {
    text-decoration: underline;
}

.proof-content, details.collapsible > div {
    margin-top: 0.5em;
    padding: 0.8em;
    background: rgba(255,255,255,0.7);
    border-radius: 4px;
}

.proof-content p:last-child {
    margin-bottom: 0;
}

/* ========================================
   テーブル (Tables)
   ======================================== */

/* article 内の全テーブル共通スタイル */
article table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5em 0;
}

article table th,
article table td {
    border: 1px solid var(--color-border, #ddd);
    padding: 0.6em 0.8em;
    text-align: left;
}

article table thead th {
    background: linear-gradient(to bottom, #4a90e2, #357abd);
    color: white;
    font-weight: 600;
}

article table thead th code {
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
}

article table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

article table tbody tr:hover {
    background: #e3f2fd;
    transition: background 0.2s;
}

@media (prefers-color-scheme: dark) {
    article table thead th {
        background: linear-gradient(to bottom, #2c5f8d, #1e4668);
    }
    article table tbody tr:nth-child(even) {
        background: #2d2d2d;
    }
    article table tbody tr:hover {
        background: #1e3a5f;
    }
}

[data-theme="dark"] article table thead th {
    background: linear-gradient(to bottom, #2c5f8d, #1e4668);
}
[data-theme="dark"] article table tbody tr:nth-child(even) {
    background: #2d2d2d;
}
[data-theme="dark"] article table tbody tr:hover {
    background: #1e3a5f;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5em 0;
}

.comparison-table th, .comparison-table td {
    border: 1px solid #ddd;
    padding: 0.6em 0.8em;
    text-align: left;
}

.comparison-table th {
    background: #f0f0f0;
}

.comparison-table tr:nth-child(even) {
    background: #fafafa;
}

/* ========================================
   図 (Figures)
   ======================================== */
figure {
    margin: 2em 0;
    text-align: center;
}

figure img, figure svg {
    max-width: 100%;
    height: auto;
}

figcaption {
    font-size: 0.9em;
    color: #666;
    margin-top: 0.5em;
}

/* ========================================
   コードブロック (Code Blocks)
   ======================================== */
pre code {
    display: block;
    background: #f5f7fa;
    color: #2d3436;
    padding: 1em;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.5;
}

/* ========================================
   ページナビゲーション
   ======================================== */
.page-nav {
    display: flex;
    justify-content: space-between;
    margin: 2em 0;
    padding: 1em 0;
    border-top: 1px solid #e0e0e0;
}

.page-nav a {
    text-decoration: none;
}

.page-nav a:hover {
    text-decoration: underline;
}

/* ========================================
   定理・定義・補題ボックス (Updated 2026-02-06)
   ======================================== */
.theorem, .definition, .lemma, .corollary {
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1em 1.2em;
    margin: 1.5em 0;
}

.theorem {
    background: #fce4ec;
    border-left: 4px solid #b08080;
}

.definition {
    background: #fff;
    border: 3px double #7a8ab8;
    outline: 2px solid #7a8ab8;
    outline-offset: 4px;
    border-radius: 0;
    padding: 1.5em 1.8em !important;
    margin: 2em 0.5em;
}

.lemma {
    background: #fff3e0;
    border-left: 4px solid #b89968;
}

.corollary {
    background: #f3e5f5;
    border-left: 4px solid #9a7a9a;
}

.theorem-title, .definition-title, .lemma-title, .corollary-title {
    font-weight: bold;
    margin-bottom: 0.5em;
}

/* 定理・定義ボックス内のh4は帯スタイルを解除 */
.theorem h4, .definition h4, .lemma h4, .corollary h4 {
    background: none;
    color: #6b7aaa;
    padding: 0;
    margin: 0 0 0.8em 0;
    font-size: 1.1em;
    font-weight: bold;
    border-left: none;
}

.definition h4 {
    color: #6b7aaa;
}

.theorem h4 {
    color: #998080;
}

.lemma h4 {
    color: #b89968;
}

.corollary h4 {
    color: #8b6f8b;
}

/* ========================================
   アルゴリズム・擬似コード
   ======================================== */
.algorithm {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 1em 1.2em;
    margin: 1.5em 0;
    font-family: 'Consolas', 'Monaco', monospace;
}

.algorithm-title {
    font-weight: bold;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.5em;
    margin-bottom: 0.8em;
}

.algorithm ol {
    margin-bottom: 0;
}

/* ========================================
   関連項目リスト
   ======================================== */
.related-items {
    background: #f8f9fa;
    padding: 1em 1.5em;
    border-radius: 4px;
    margin: 1.5em 0;
}

.related-items h3 {
    background: none;
    color: #333;
    padding: 0;
    margin: 0 0 0.5em 0;
    font-size: 1em;
}

.related-items ul {
    margin-bottom: 0;
    columns: 2;
}

@media (max-width: 600px) {
    .related-items ul {
        columns: 1;
    }
}

/* ========================================
   フィルタ比較カード (Filter Type Cards)
   ======================================== */
.filter-types {
    display: flex;
    gap: 1.5em;
    margin: 1.5em 0;
}

.filter-type-card {
    flex: 1;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1.2em 1.5em;
    border-top: 4px solid #6b8ab8;
    display: flex;
    flex-direction: column;
}

.filter-type-card h4 {
    background: none;
    color: #6b8ab8;
    padding: 0;
    margin: 0 0 0.8em 0;
    font-size: 1.15em;
}

/* メイン部分（特性説明＋数式）は伸縮する */
.filter-type-main {
    flex: 1;
}

.filter-type-main p:first-child {
    margin-bottom: 1em;
}

.filter-type-main p:nth-child(2) {
    margin-bottom: 0.3em;
}

/* スペック部分（設計パラメータ、極、零点）は下に固定 */
.filter-type-specs {
    margin-top: auto;
    padding-top: 1em;
    border-top: 1px dashed #ddd;
}

.filter-type-specs p {
    margin: 0.3em 0;
}

.filter-type-specs p:first-child {
    margin-top: 0;
}

.filter-type-specs p:last-child {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .filter-types {
        flex-direction: column;
    }
}

/* ========================================
   テンプレートカード
   ======================================== */
.template-card-header {
    padding: 1em;
    color: black;
    font-weight: bold;
    font-size: 1.05em;
    background: linear-gradient(135deg, #FFF9E6 0%, #FFECB3 50%, #FFE082 100%);
}

/* テンプレートボックス */
.template-box {
    margin: 1.5rem 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(153, 153, 153, 0.15);
    border: 2px solid #cccccc;
}

.template-header {
    padding: 0.8rem 1.2rem;
    font-size: 1.1em;
    font-weight: bold;
    background: linear-gradient(135deg, #FFF9E6 0%, #FFECB3 50%, #FFE082 100%);
    color: black;
}

.template-header i {
    font-size: 1.2em;
    margin-right: 0.3em;
}

.template-content {
    padding: 1rem;
    background: white;
}

/* ========================================
   テンプレートステップラベル
   ======================================== */
.step-num,
.card-step {
    font-weight: bold;
    color: #707070;
    margin-right: 0.4rem;
}

.step-label,
.step-label-green,
.step-label-orange,
.card-label {
    background: #8a92b8;
    color: black;
    padding: 0.15rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85em;
    margin-right: 0.5rem;
    font-weight: 500;
    display: inline-block;
    width: 6.5em;
    text-align: center;
    white-space: nowrap;
}

/* テンプレートカード追加スタイル */
.template-card {
    margin: 1.5em 0;
}

.template-card-content {
    padding: 1em;
}

.card-step {
    color: black;
    font-weight: bold;
}

.card-step-red {
    color: #707070;
}

.template-key-point {
    margin-top: 1em;
    padding: 0.8em;
    background: #f0f0f0;
    border-left: 3px solid #707070;
    border-radius: 4px;
    font-size: 0.9em;
}

.template-card-red {
    border: 2px solid #cccccc;
}

.compact-list {
    margin: 0;
    padding-left: 0;
    counter-reset: step-counter;
    list-style: none;
    margin-bottom: 1em;
}

.compact-list li {
    margin: 0.5em 0;
    line-height: 1.35;
    letter-spacing: -0.01em;
}
