/* === CrossLink Learn Page Styles === */

.crosslink-learn-wrapper {
    display: flex;
    gap: 30px;
    align-items: flex-start; /* サイドバーと結果エリアを上揃えに */
}

/* ================================================================
   フィルターサイドバー（独立スクロール）
   ================================================================ */
.crosslink-learn-filter {
    width: 280px;
    flex-shrink: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    /* 独立スクロール：ビューポート高さ上限 */
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    /* スクロールバーをスリムに */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}
.crosslink-learn-filter::-webkit-scrollbar {
    width: 4px;
}
.crosslink-learn-filter::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* フォーム全体のパディング */
.crosslink-filter-form {
    padding: 16px;
}

/* ── ヘッダー行（タイトル + リセットボタン）── */
.filter-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #0066cc;
}

.filter-form-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

/* リセットボタン */
.cl-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    color: #e53e3e;
    background: transparent;
    border: 1.5px solid #e53e3e;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    line-height: 1;
}
.cl-reset-btn::before {
    content: '✕';
    font-size: 0.7rem;
}
.cl-reset-btn:hover {
    background: #e53e3e;
    color: #fff;
}

/* ── フィルターセクション ── */
.filter-section {
    margin-bottom: 14px;
}

.filter-section-title {
    margin: 0 0 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.filter-section input[type="text"],
.filter-section select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.88rem;
    box-sizing: border-box;
}

/* ── 検索ボタン ── */
.crosslink-filter-submit {
    width: 100%;
    padding: 11px;
    background: #0066cc;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 4px;
}
.crosslink-filter-submit:hover {
    background: #0052a3;
}

/* ================================================================
   カスケード・チェックボックス（アコーディオン式・複数選択）
   大項目 → 中項目 → 小項目 の多段連動
   ================================================================ */

.cascade-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* ── 各 details 要素（アコーディオン1段） ── */
.cascade-level {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #ddd;
}

/* L2・L3 はインデントで親子関係を示す */
.cascade-l2-section {
    margin-left: 10px;
    border-color: #b3d4ff;
}
.cascade-l3-section {
    margin-left: 20px;
    border-color: #a8ddb5;
}

/* ── summary（クリックして開閉） ── */
.cascade-summary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    cursor: pointer;
    user-select: none;
    list-style: none; /* Firefox */
    background: #4a5568;
    color: #fff;
    font-size: 0.8rem;
}
.cascade-summary::-webkit-details-marker { display: none; } /* Chrome/Safari */

.cascade-l2-section .cascade-summary { background: #2b6cb0; }
.cascade-l3-section .cascade-summary { background: #276749; }

/* ラベルテキスト */
.cl-lbl {
    flex: 1;
    font-weight: 700;
    letter-spacing: 0.03em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 選択件数バッジ */
.cl-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 20px;
    padding: 1px 6px;
    border-radius: 10px;
    text-align: center;
    flex-shrink: 0;
}

/* 開閉矢印（CSS で描画） */
.cascade-summary::after {
    content: '▶';
    font-size: 0.6rem;
    transition: transform 0.18s ease;
    flex-shrink: 0;
    opacity: 0.75;
}
details[open] > .cascade-summary::after {
    transform: rotate(90deg);
}

/* ── チェックボックス一覧 ── */
.cascade-checks {
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #fff;
}

/* 各チェックボックス行 */
.cascade-check-item {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.86rem;
    color: #333;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: background 0.1s;
    line-height: 1.4;
}
.cascade-check-item:hover {
    background: #ebf4ff;
}
.cascade-l3-section .cascade-check-item:hover {
    background: #e6f4eb;
}

.cascade-check-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: #2b6cb0;
}
.cascade-l3-section .cascade-check-item input[type="checkbox"] {
    accent-color: #276749;
}

/* hidden 属性が付いた item は非表示 */
.cascade-check-item[hidden] {
    display: none !important;
}

/* ================================================================
   Results
   ================================================================ */
.crosslink-learn-results {
    flex: 1;
    min-width: 0;
}

.crosslink-learn-results h2 {
    margin: 0 0 20px;
    font-size: 1.3rem;
}

.result-count {
    font-size: 0.9rem;
    color: #666;
    font-weight: normal;
}

.result-group {
    margin-bottom: 30px;
}

.group-title {
    font-size: 1.1rem;
    margin: 0 0 15px;
    padding: 10px 15px;
    background: #f0f4f8;
    border-radius: 4px;
    border-left: 4px solid #0066cc;
}

.result-cards {
    display: grid;
    gap: 15px;
}

.result-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s, transform 0.2s;
}
.result-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.result-card a {
    display: block;
    padding: 20px;
    color: inherit;
    text-decoration: none;
}

.card-meta {
    display: inline-block;
    font-size: 0.8rem;
    color: #666;
    background: #f5f5f5;
    padding: 4px 10px;
    border-radius: 3px;
    margin-bottom: 8px;
}
.card-title {
    margin: 0 0 10px;
    font-size: 1rem;
    color: #0066cc;
}
.card-excerpt {
    margin: 0;
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
}

.no-results {
    padding: 40px;
    text-align: center;
    color: #666;
    background: #fff;
    border-radius: 8px;
}

/* ================================================================
   Pagination
   ================================================================ */
.crosslink-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 30px;
}

.page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.page-number:hover {
    background: #0066cc;
    border-color: #0066cc;
    color: #fff;
    text-decoration: none;
}
.page-number.current {
    background: #0066cc;
    border-color: #0066cc;
    color: #fff;
}
.page-number.dots {
    border: none;
    background: transparent;
    cursor: default;
    color: #999;
    pointer-events: none;
}
.page-number.dots:hover {
    background: transparent;
    color: #999;
}
.page-number.prev,
.page-number.next {
    font-size: 1.1em;
}

/* ================================================================
   Question Detail (single-question)
   ================================================================ */
.single-question-page .question-detail { padding: 30px; }

.question-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}
.question-meta { margin-bottom: 10px; }
.question-meta .meta-item {
    display: inline-block;
    font-size: 0.85rem;
    color: #666;
    background: #f0f4f8;
    padding: 4px 12px;
    border-radius: 3px;
    margin-right: 8px;
}
.question-title { margin: 0 0 15px; font-size: 1.4rem; }
.question-terms { font-size: 0.85rem; }
.term-label { color: #666; margin-right: 5px; }
.term-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 3px;
    margin-right: 5px;
    font-size: 0.8rem;
}
.term-badge.profession { background: #e3f2fd; color: #1565c0; }
.term-badge.subject    { background: #f3e5f5; color: #7b1fa2; }

.question-body, .question-choices,
.question-explanation, .question-source { margin-bottom: 30px; }

.question-body h2, .question-choices h2,
.question-explanation h2, .question-source h2 {
    font-size: 1.1rem; margin: 0 0 15px; color: #333;
}

.question-text {
    background: #fafafa;
    padding: 20px;
    border-radius: 4px;
    line-height: 1.8;
}

.choices-list { list-style: none; margin: 0; padding: 0; }
.choice-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 15px;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 10px;
    transition: background 0.2s;
}
.choice-item.correct { background: #e8f5e9; border-color: #a5d6a7; }
.choice-label { font-weight: 700; color: #0066cc; flex-shrink: 0; }
.choice-text  { flex: 1; }
.correct-badge {
    background: #4caf50; color: #fff;
    font-size: 0.75rem; padding: 2px 8px; border-radius: 3px; flex-shrink: 0;
}

.explanation-text {
    background: #fff8e1;
    padding: 20px;
    border-radius: 4px;
    border-left: 4px solid #ffc107;
    line-height: 1.8;
}

.no-source { color: #999; font-style: italic; }

.question-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}
.question-nav a {
    padding: 10px 20px;
    background: #f5f5f5;
    border-radius: 4px;
    font-weight: 500;
}
.question-nav a:hover { background: #e0e0e0; text-decoration: none; }

/* ================================================================
   Responsive
   ================================================================ */
@media (max-width: 900px) {
    .crosslink-learn-wrapper {
        flex-direction: column;
    }
    .crosslink-learn-filter {
        width: 100%;
        position: static;
        max-height: none;
        overflow-y: visible;
    }
    .cascade-l2-section { margin-left: 8px; }
    .cascade-l3-section { margin-left: 16px; }
}
