/* ========================================
   情報数学入門
   アカデミックスタイル
   ======================================== */

/* ========================================
   基本設定
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "Noto Serif JP", "Hiragino Mincho ProN", "Yu Mincho", serif;
    line-height: 2.0;
    color: #333;
    background: #fdfcf9;
    font-size: 16px;
}

/* ========================================
   サイトヘッダー
   ======================================== */

.site-header {
    padding: 20px;
    border-bottom: none;
}

.site-logo h1 {
    font-size: 24px;
    font-weight: bold;
    color: #1a365d;
}

/* ========================================
   パンくずリスト
   ======================================== */

.breadcrumb {
    background: #fdfcf9;
    padding: 12px 20px;
    font-size: 14px;
    border-bottom: 1px solid #d4c5a9;
}

.breadcrumb a {
    color: #1a365d;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* ========================================
   レイアウト
   ======================================== */

main {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* テキストの両端揃え */
p {
    text-align: justify;
    margin-bottom: 1.5em;
}

/* ========================================
   ページヘッダー
   ======================================== */

.page-header {
    margin-bottom: 60px;
    padding-bottom: 20px;
    border-bottom: 2px solid #1a365d;
}

.page-header h1 {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #1a365d;
}

.subtitle {
    font-size: 16px;
    color: #666;
    margin-bottom: 20px;
}

/* ========================================
   イントロダクション
   ======================================== */

.intro-note {
    background: #f8f6f1;
    padding: 2rem;
    margin-bottom: 3rem;
    border-left: 4px solid #1a365d;
}

.intro-note .section-title {
    display: block;
    font-size: 1.2rem;
    font-weight: bold;
    color: #1a365d;
    margin: 2rem 0 1rem 0;
}

.intro-note .section-title:first-child {
    margin-top: 0;
}

/* 注意書きボックス */
.notice-box {
    background: #fff;
    border: 1px solid #d4c5a9;
    padding: 1rem 1.5rem;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.notice-box p {
    text-indent: 0;
    margin: 0.5rem 0;
}

.notice-box p:first-child {
    margin-top: 0;
}

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

.notice-box a {
    color: #1a365d;
}

.intro-note p {
    margin: 0 0 1rem 0;
    text-indent: 1em;
}

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

/* ========================================
   目次
   ======================================== */

.toc {
    margin-bottom: 60px;
}

.toc h2 {
    font-size: 22px;
    margin-bottom: 30px;
    border-bottom: 1px solid #d4c5a9;
    padding-bottom: 10px;
    color: #1a365d;
}

/* 章セクション */
.chapter {
    margin-bottom: 35px;
}

.chapter h3 {
    font-size: 18px;
    margin-bottom: 15px;
    font-weight: bold;
    color: #2c5282;
}

.chapter ul {
    list-style: none;
    padding-left: 0;
}

.chapter li {
    margin-bottom: 8px;
    padding-left: 20px;
    position: relative;
    line-height: 1.8;
}

.chapter li::before {
    content: "・";
    position: absolute;
    left: 0;
}

.chapter a {
    color: #1a365d;
    text-decoration: none;
}

.chapter a:hover {
    text-decoration: underline;
}

/* 説明テキスト */
.desc {
    display: inline-block;
    font-size: 13px;
    color: #888;
    margin-left: 10px;
}

/* ========================================
   コンテンツページ用
   ======================================== */

article h2 {
    font-size: 1.4rem;
    color: #1a365d;
    margin: 2.5rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #d4c5a9;
}

article h3 {
    font-size: 1.15rem;
    color: #2c5282;
    margin: 2rem 0 0.8rem 0;
}

article h4 {
    font-size: 1rem;
    color: #333;
    margin: 1.5rem 0 0.5rem 0;
}

/* ナレーションボックス */
.narrative {
    background: #f8f6f1;
    border-left: 4px solid #1a365d;
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    font-style: italic;
    line-height: 2.2;
}

/* キーワード */
.keywords {
    margin: 1rem 0 2rem 0;
    font-size: 0.9rem;
    color: #666;
}

.keywords span {
    display: inline-block;
    background: #eee;
    padding: 0.2rem 0.6rem;
    margin: 0.2rem 0.3rem 0.2rem 0;
    border-radius: 3px;
    font-family: sans-serif;
}

/* 定義ボックス */
.definition {
    background: #fff;
    border: 1px solid #d4c5a9;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.definition-title {
    font-weight: bold;
    color: #1a365d;
    margin-bottom: 0.5rem;
}

/* 実務接点 */
.practical {
    background: #f0f4f8;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 4px;
}

.practical h4 {
    color: #2c5282;
    margin-top: 0;
    margin-bottom: 1rem;
}

.practical-web,
.practical-ai {
    margin-bottom: 1rem;
}

.practical-web:last-child,
.practical-ai:last-child {
    margin-bottom: 0;
}

/* 深掘りリンク */
.further {
    background: #fdfcf9;
    border: 1px solid #d4c5a9;
    padding: 1.5rem;
    margin: 2rem 0;
}

.further h4 {
    color: #1a365d;
    margin-top: 0;
    margin-bottom: 1rem;
}

.further ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.further li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.further li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: #888;
}

.further a {
    color: #1a365d;
    text-decoration: none;
}

.further a:hover {
    text-decoration: underline;
}

/* テーブル */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

th, td {
    border: 1px solid #d4c5a9;
    padding: 0.75rem;
    text-align: left;
}

th {
    background: #f8f6f1;
    font-weight: bold;
    color: #1a365d;
}

/* 数式（KaTeX用） */
.math-block {
    overflow-x: auto;
    margin: 1.5rem 0;
    padding: 1rem;
    background: #fff;
    border: 1px solid #eee;
}

/* コード */
code {
    font-family: "Source Code Pro", Consolas, monospace;
    background: #f5f5f5;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.9em;
}

pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    border-radius: 4px;
}

pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ========================================
   フッター
   ======================================== */

footer {
    margin-top: 80px;
    padding: 40px 20px;
    border-top: 2px solid #1a365d;
    background: #f8f6f1;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.footer-links a {
    color: #1a365d;
    text-decoration: none;
    font-size: 14px;
}

.footer-links a:hover {
    text-decoration: underline;
}

footer p {
    color: #666;
    font-size: 14px;
}

/* ========================================
   上に戻るボタン
   ======================================== */

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    background: #1a365d;
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 48px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.back-to-top.visible {
    opacity: 0.8;
    visibility: visible;
}

.back-to-top:hover {
    opacity: 1;
}

/* ========================================
   レスポンシブ対応
   ======================================== */

@media (max-width: 768px) {
    body {
        font-size: 15px;
    }
    
    main {
        padding: 1rem;
    }
    
    .site-header {
        padding: 15px;
    }
    
    .site-logo h1 {
        font-size: 20px;
    }
    
    .intro-note {
        padding: 1.5rem;
    }
    
    .narrative {
        padding: 1rem 1.5rem;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    article h2 {
        font-size: 1.2rem;
    }
    
    article h3 {
        font-size: 1.05rem;
    }
    
    .chapter h3 {
        font-size: 1rem;
    }
    
    .chapter li {
        font-size: 14px;
    }
    
    .desc {
        display: block;
        margin-left: 0;
        margin-top: 4px;
    }
    
    footer {
        margin-top: 60px;
        padding: 30px 15px;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 10px;
    }
}
