/**
 * style.css
 * このファイルは、Webサイト「IE-knowledge」全体のスタイリングを定義します。
 * * [設計原則]
 * - 基本的にTailwind CSSのユーティリティクラスをHTML側で使用しますが、
 * サイト全体で共通のデザイン要素や、JavaScriptで動的に生成される要素のスタイルはここで一元管理します。
 * - 可読性と保守性を高めるため、関連するスタイルはセクションごとにグループ化しています。
 * * [目次]
 * 1. 基本スタイル & タイポグラフィ
 * 2. 共通コンポーネント
 * - トップナビゲーション
 * - ヘッダー
 * - パンくずリスト
 * - フッター
 * 3. 動的レイアウト
 * - サイトコンテナ & ラッパー
 * - メインカラム & サイドバー
 * 4. コンテンツ要素
 * - 見出し & 区切り文字
 * - テーブル
 * - コードブロック
 * - 比較表の評価スタイル
 * - D3.js 構成図コンテナ
 * 5. UI要素
 * - 目次 (メイン & サイドバー)
 * - カテゴリメニュー
 * - 記事カード (トップページ)
 * - ソート用セレクトボックス (トップページ)
 * 6. レスポンシブ対応
 * 7. 本文のタイポグラフィ改善
 */

/* --- 1. 基本スタイル & タイポグラフィ --- */
body {
    font-family: 'Inter', 'Noto Sans JP', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f1f5f9; /* slate-100 */
    font-size: 15px; /* 基本フォントサイズを調整 */
}

h1, h2, h3, h4 {
    font-weight: 700;
}

/* --- 2. 共通コンポーネント --- */

/* トップナビゲーション */
.site-top-nav {
    background-color: #ffffff;
    height: 2.5rem; /* 40px */
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}

.site-logo {
    font-size: 1.125rem; /* text-lg */
    font-weight: 700;
    color: #1f2937; /* gray-800 */
    text-decoration: none;
    transition: color 0.2s ease-in-out;
    display: flex;
    align-items: center;
    height: 100%;
}
.site-logo:hover {
    color: #1D4ED8; /* blue-700 */
}
.logo-ie {
    color: #1E3A8A; /* blue-900 */
    margin-right: 0.1rem;
}

/* ヘッダー */
.article-header-bg {
    position: relative;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.article-header-bg::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.4);
    background-image: radial-gradient(circle at center, rgba(255, 255, 255, 0.15) 0, rgba(255, 255, 255, 0.15) 1px, transparent 1px);
    background-size: 4px 4px;
    z-index: 0;
}

.header-inner-border {
    position: absolute;
    top: 0.75rem; right: 0.75rem; bottom: 0.75rem; left: 0.75rem;
    border: 3px solid rgba(255, 255, 255, 0.7);
    border-radius: 0.25rem;
    pointer-events: none;
    z-index: 1;
}

.article-header-bg > header {
    position: relative;
    z-index: 1;
}

.article-meta {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.875rem;
}
.article-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.article-meta-item svg {
    width: 1.125rem;
    height: 1.125rem;
    opacity: 0.8;
}

.header-category-pill {
    border: 1px solid currentColor;
    border-radius: 9999px;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    line-height: 1.25;
}

/* パンくずリスト */
.breadcrumb-container {
    padding: 0.5rem 0;
    font-size: 0.75rem;
    color: #4b5563; /* gray-600 */
    background-color: #f9fafb; /* gray-50 */
    border-bottom: 1px solid #e5e7eb; /* gray-200 */
}
.breadcrumb-item {
    color: #4b5563;
    text-decoration: none;
    transition: color 0.2s;
}
.breadcrumb-item:hover {
    color: #1D4ED8;
}
.breadcrumb-item.current {
    color: #1f2937; /* gray-800 */
    font-weight: 500;
}
.breadcrumb-separator {
    margin: 0 0.5rem;
}


/* フッター */
.site-footer {
    background-color: #fff;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
    border-top: 1px solid #e5e7eb; /* gray-200 */
}
.footer-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.footer-link {
    font-size: 0.875rem;
    color: #4b5563; /* gray-600 */
    text-decoration: none;
    transition: color 0.2s;
}
.footer-link:hover {
    color: #1D4ED8; /* blue-700 */
    text-decoration: underline;
}
.footer-separator {
    color: #d1d5db; /* gray-300 */
}
.copyright {
    font-size: 0.75rem; /* text-sm */
    color: #6b7281; /* gray-500 */
}

/* --- 3. 動的レイアウト --- */
/* これらのクラスは layout-generator.js によって動的に生成・適用される */

/* サイト全体の最大幅と中央揃えを制御するコンテナ */
.site-container {
    max-width: 100%;
    padding: 0 1rem; /* 左右の余白 */
    margin-top: 2rem;
}

/* メインカラムとサイドバーをFlexboxで配置するラッパー */
.content-wrapper {
    display: flex;
    justify-content: center;
    gap: 1rem; /* 16px */
    max-width: 100rem; /* 1600px */
    margin: 0 auto;
    width: 100%;
}

/* メインコンテンツ用のカラム */
.main-column {
    flex-grow: 1;
    min-width: 0; /* flexアイテムの縮小を許可 */
}

/* サイドバー用のカラム */
.sidebar {
    width: 12rem; /* 192px */
    flex-shrink: 0;
}

/* サイドバー内のコンテンツがスクロールに追従するためのコンテナ */
.sidebar-scroll-container {
    position: sticky;
    top: 4rem; /* トップナビゲーションの高さ + 余白 */
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    padding-right: 0.5rem; /* スクロールバー用の余白 */
    /* Firefox用のスクロールバー非表示設定 */
    scrollbar-width: none;
}

/* Webkit系ブラウザ（Chrome, Safari, Edge）用のスクロールバー非表示設定 */
.sidebar-scroll-container::-webkit-scrollbar {
    display: none;
}

/* --- 4. コンテンツ要素 --- */

/* 見出し */
.section-title {
    border-bottom: 2px solid #1D4ED8; /* blue-700 */
    padding-bottom: 0.5rem; /* 8px */
}

/* 見出し内の区切り文字スタイル */
.title-separator {
    font-size: 0.6em;
    font-weight: 400;
    color: #6b7281; /* gray-500, コントラスト比向上のため gray-400 から変更 */
    margin: 0 0.25em;
    vertical-align: middle;
}

/* テーブル */
table {
    width: 100%;
    border-collapse: collapse;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    border-radius: 0.5rem;
    overflow: hidden;
}

th, td {
    border: 1px solid #D1D5DB; /* gray-300 */
    padding: 0.75rem 1rem;
    text-align: left;
    vertical-align: top;
}

th {
    background-color: #F3F4F6; /* gray-100 */
    font-weight: 600;
}

tbody tr:nth-child(even) {
    background-color: #F9FAFB; /* gray-50 */
}

strong {
    color: #1D4ED8; /* blue-700 */
}

.text-critical {
    color: #8b0000; /* Dark Red */
}

/* コードブロック */
pre {
    overflow-x: auto;
}

:not(pre) > code {
    background-color: #E5E7EB; /* gray-200 */
    color: #374151; /* gray-700 */
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    border-radius: 3px;
    font-family: 'Menlo', 'Monaco', 'Consolas', "Courier New", monospace;
}

/* --- 引用（参考URL）表示スタイル --- */
.quote-block {
    border-left: 4px solid #d1d5db; /* gray-300 */
    padding-left: 1rem;
    margin-top: 1rem;
    font-style: italic;
    color: #4b5563; /* gray-600 */
}
.quote-source {
    display: block;
    text-align: right;
    font-size: 0.875rem;
    color: #6b7281; /* gray-500 */
    margin-top: 0.5rem;
}

/* 比較表の評価用スタイル */
.rating-highlight {
    display: block;
    height: 100%;
    box-sizing: border-box;
    padding: 0.75rem;
    border-radius: 0.375rem; /* rounded-md */
    font-weight: 600;
    line-height: 1.25;
}
/* 比較表の評価用スタイル */
.rating-great {
    background-color: #eff6ff; /* blue-50 */
    color: #1e40af; /* blue-800 */
    background-image: repeating-linear-gradient(-45deg, rgba(30, 64, 175, 0.08), rgba(30, 64, 175, 0.08) 1px, transparent 1px, transparent 3px);
}
.rating-good {
    background-color: #f0fdf4; /* green-50 */
    color: #15803d; /* green-700 */
    background-image: repeating-linear-gradient(-45deg, rgba(21, 128, 61, 0.08), rgba(21, 128, 61, 0.08) 1px, transparent 1px, transparent 3px);
}
.rating-ok {
    background-color: #fefce8; /* yellow-50 */
    color: #b45309; /* amber-700 */
    background-image: repeating-linear-gradient(-45deg, rgba(180, 83, 9, 0.07), rgba(180, 83, 9, 0.07) 1px, transparent 1px, transparent 3px);
}
.rating-bad {
    background-color: #fef2f2; /* red-50 */
    color: #b91c1c; /* red-700 */
    background-image: repeating-linear-gradient(-45deg, rgba(185, 28, 28, 0.07), rgba(185, 28, 28, 0.07) 1px, transparent 1px, transparent 3px);
}


/* D3.js 構成図用コンテナ */
.diagram-container {
    background-color: #f9fafb;
    border-radius: 0.75rem;
    padding: 1.5rem;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    overflow: hidden;
    position: relative;
}

.diagram-container svg {
    width: 100%;
    min-height: 400px;
    aspect-ratio: 4 / 3;
    cursor: grab;
}
.diagram-container svg:active {
    cursor: grabbing;
}

/* --- 5. UI要素 --- */

/* メインコンテンツ内 目次 */
.main-toc {
    border-top: 3px double #e5e7eb;
    border-bottom: 3px double #e5e7eb;
    padding: 1rem 0;
    background-image: repeating-linear-gradient(-45deg, rgba(0, 0, 0, 0.03), rgba(0, 0, 0, 0.03) 1px, transparent 1px, transparent 2px);
}
.main-toc-title {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.75rem;
}
.main-toc-title svg {
    width: 1.25rem;
    height: 1.25rem;
    margin-right: 0.5rem;
    color: #6b7281;
}
.main-toc-list {
    padding: 0 1.5rem;
    columns: 2;
    gap: 1rem;
}
.main-toc-list ul {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    break-inside: avoid;
}
.main-toc-list li a {
    text-decoration: none;
    color: #4b5563;
    transition: color .2s;
}
.main-toc-list li a:hover {
    color: #1D4ED8;
}
.main-toc-list ul ul {
    padding-left: 1rem;
    margin-top: 0.25rem;
    font-size: 0.9em;
}

/* サイドバーの共通グループスタイル */
.sidebar-group {
    margin-bottom: 1rem;
}
.sidebar-group > h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    padding: 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background-color .2s;
}
.sidebar-group > h3:hover {
    background-color: #f3f4f6;
}
.sidebar-group > ul {
    display: none;
    list-style: none;
    padding: 0.5rem 0 0 0.5rem;
    margin: 0;
}
.sidebar-group.expanded > ul {
    display: block;
}

/* 開閉アイコン */
.toggle-icon {
    display: inline-block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 4px 0 4px 5px;
    border-color: transparent transparent transparent #6b7281;
    transition: transform .2s;
}
.sidebar-group.expanded .toggle-icon {
    transform: rotate(90deg);
}

/* サイドバー 目次(TOC)の個別スタイル */
#toc a {
    display: block;
    padding: 0.25rem 0.5rem;
    text-decoration: none;
    color: #4b5563;
    border-left: 2px solid transparent;
    transition: all .2s;
    font-size: 0.8125rem; /* 13px */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#toc a:hover {
    color: #1D4ED8;
    background-color: #eff6ff;
}
#toc a.active {
    color: #1D4ED8;
    font-weight: 500;
    border-left-color: #1D4ED8;
    background-color: #eff6ff;
}
#toc ul ul a {
    padding-left: 1.25rem;
}

/* サイドバー カテゴリメニューの個別スタイル */
#category-list a {
    display: block;
    padding: 0.375rem 0.5rem;
    text-decoration: none;
    color: #374151;
    border-radius: 0.25rem;
    transition: background-color .2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.8125rem; /* 13px */
}
#category-list a:hover {
    background-color: #f3f4f6;
}
#category-list a.active {
    background-color: #e0e7ff;
    color: #3730a3;
    font-weight: 500;
}


/* Article Card Grid (index.html) */
.article-card {
    background-color: #fff;
    border-radius: 0.5rem;
    border: 1px solid #e5e7eb; /* gray-200 */
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.article-card-image-placeholder {
    height: 160px;
    background-color: #f3f4f6; /* gray-100 */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af; /* gray-400 */
    border-bottom: 1px solid #e5e7eb;
}

.article-card-content {
    padding: 1rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.article-card-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    background-color: #e0e7ff; /* indigo-100 */
    color: #3730a3; /* indigo-800 */
    border-radius: 9999px;
    margin-bottom: 0.75rem;
    align-self: flex-start;
}

.article-card-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    color: #1f2937; /* gray-800 */
}

/* Sort Select (index.html) */
.sort-select {
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    border-radius: 0.375rem;
    border: 1px solid #d1d5db; /* gray-300 */
    background-color: #fff;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7281' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    cursor: pointer;
    font-size: 0.875rem;
}

/* --- 6. レスポンシブ対応 --- */
@media (max-width: 1024px) {
    body {
        font-size: 13px; /* スマホ表示のフォントサイズを調整 */
        background-color: #ffffff; /* スマホでは白背景に */
    }

    .main-column table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .main-column {
        padding: 1.5rem 1rem;
    }
    .section-title {
        font-size: 1.25rem;
    }
    .article-meta {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1rem;
    }
    .sidebar {
        display: none;
    }
    .content-wrapper {
        gap: 0;
    }
    .site-container {
        padding: 0;
        margin-top: 0;
    }
    .main-toc-list {
        columns: 1;
    }
}


/* --- 7. 本文のタイポグラフィ改善 --- */

/* 記事セクション内の要素間に一貫したマージンを適用 */
.main-column main section > * + * {
    margin-top: 1.25rem; /* 20px */
}

/* 記事セクション間のマージンを定義 */
.main-column main section + section {
    margin-top: 4rem; /* 64px */
}

/* h3見出しの上のマージンを調整 */
.main-column main section > h3 {
    margin-top: 3rem; /* 48px */
}

/* 見出しの直後の要素のマージンは少し詰める */
.main-column main section > h2 + *,
.main-column main section > h3 + * {
    margin-top: 1.5rem; /* 24px */
}
/* ツールチップのスタイル */
.tooltip-container {
    position: relative;
    display: inline-block;
    border-bottom: 1px dotted #374151; /* gray-700 */
    cursor: help;
}

.tooltip-content {
    visibility: hidden;
    width: 320px; /* 幅を大きめに設定 */
    background-color: #1f2937; /* gray-800 */
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 12px;
    position: absolute;
    z-index: 10;
    bottom: 120%; /* 表示位置を少し調整 */
    left: 0; /* 左端を基準にする */
    margin-left: 0; /* 中央揃えのマージンを削除 */
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.875rem; /* text-sm */
    line-height: 1.5;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

/* ツールチップの矢印 */
.tooltip-content::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #1f2937 transparent transparent transparent;
}

.tooltip-container:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
}
