@import "../core/_tokens.css";

.mock-exam-result {
    --result-navy: #102a43;
    --result-blue: #2563eb;
    --result-soft: #eff6ff;
    width: min(1120px, calc(100% - 24px));
    margin: 24px auto 56px;
    color: #1e293b;
    font-family: var(--mock-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
}

.mock-exam-result__hero {
    position: relative;
    overflow: hidden;
    padding: clamp(24px, 5vw, 52px);
    color: #fff;
    border-radius: 28px;
    background: linear-gradient(135deg, #102a43 0%, #164e63 58%, #0f766e 100%);
    box-shadow: 0 24px 60px rgba(15, 42, 67, .2);
}

.mock-exam-result__hero.is-review { background: linear-gradient(135deg, #172554 0%, #1e3a8a 58%, #2563eb 100%); }
.mock-exam-result__hero::after { content: ""; position: absolute; width: 320px; height: 320px; right: -110px; top: -160px; border-radius: 50%; background: rgba(255,255,255,.09); }
.mock-exam-result__eyebrow { margin-bottom: 10px; font-size: 13px; font-weight: 700; letter-spacing: .12em; }
.mock-exam-result__hero-grid { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.mock-exam-result__hero h1 { margin: 0; color: #fff; font-size: clamp(30px, 5vw, 48px); line-height: 1.2; }
.mock-exam-result__lead { margin: 12px 0 0; color: rgba(255,255,255,.82); }
.mock-exam-result__verdict { flex: 0 0 auto; min-width: 160px; padding: 16px 22px; text-align: center; border: 1px solid rgba(255,255,255,.28); border-radius: 18px; background: rgba(255,255,255,.13); backdrop-filter: blur(8px); }
.mock-exam-result__verdict-label { display: block; margin-bottom: 4px; font-size: 12px; opacity: .75; }
.mock-exam-result__verdict strong { font-size: 20px; }
.mock-exam-result__score-cards { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 30px; }
.mock-exam-result__score-card { padding: 16px 20px; border-radius: 16px; background: rgba(255,255,255,.12); }
.mock-exam-result__score-card span { display: block; font-size: 12px; opacity: .78; }
.mock-exam-result__score-card strong { display: block; margin-top: 3px; font-size: 28px; }
.mock-exam-result__score-card small { font-size: 14px; font-weight: 600; }

/* 何を・なぜ: サイドバー表示などで結果カード自体が狭くなる場合にも、コンテナ幅に応じて問題表を読みやすく並べ替えるため。 */
.mock-exam-result__section { container-type: inline-size; margin-top: 24px; padding: clamp(20px, 4vw, 34px); border: 1px solid #e2e8f0; border-radius: 22px; background: #fff; box-shadow: 0 10px 35px rgba(15,23,42,.07); }
.mock-exam-result__section-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.mock-exam-result__section-heading > div:first-child { display: flex; align-items: center; gap: 10px; }
/* 何を・なぜ: テーマの共通h2装飾が結果カードの見出しへ干渉し、濃色背景と文字色の組み合わせで読めなくなるため、この画面内だけ素の見出しに戻す。 */
.post_content .mock-exam-result .mock-exam-result__section-heading h2 {
    margin: 0 !important;
    padding: 0 !important;
    color: var(--result-navy) !important;
    font-size: clamp(20px, 3vw, 27px);
    line-height: 1.35;
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}
.mock-exam-result__section-heading p { margin: 0; color: #64748b; font-size: 14px; }
.mock-exam-result__step { display: inline-grid; place-items: center; width: 36px; height: 36px; color: var(--result-blue); font-size: 12px; font-weight: 800; border-radius: 11px; background: var(--result-soft); }
.mock-exam-result__hint { margin: -4px 0 18px; padding: 12px 16px; color: #475569; font-size: 14px; border-left: 4px solid #60a5fa; border-radius: 6px 12px 12px 6px; background: #f8fafc; }

.mock-exam-result table { width: 100%; margin: 0; text-align: center; border-spacing: 0; border-collapse: separate; }
.mock-exam-result table th { padding: 13px 12px; color: #475569; font-size: 12px; font-weight: 700; background: #f1f5f9; border: 0; border-bottom: 1px solid #dbe3ec; }
.mock-exam-result table th:first-child { border-radius: 12px 0 0; }
.mock-exam-result table th:last-child { border-radius: 0 12px 0 0; }
.mock-exam-result table td { padding: 15px 12px; border: 0; border-bottom: 1px solid #e8edf3; background: #fff; vertical-align: middle; }
.mock-exam-result table tbody tr:hover td { background: #f8fbff; }
.mock-exam-result table a { color: #1d4ed8; font-weight: 650; text-decoration: underline; text-decoration-color: #bfdbfe; text-underline-offset: 3px; }
.mock-exam-result__summary-table-wrap { overflow-x: auto; }
.mock_exam_results-container { width: 100%; overflow-x: auto; padding: 0; outline-offset: 4px; -webkit-overflow-scrolling: touch; }
.mock_exam_results { min-width: 780px; table-layout: fixed; }
.mock_exam_results th:nth-child(1) { width: 29%; }
.mock_exam_results th:nth-child(2) { width: 13%; }
.mock_exam_results th:nth-child(3), .mock_exam_results th:nth-child(4), .mock_exam_results th:nth-child(5) { width: 10%; }
.mock_exam_results th:nth-child(6) { width: 28%; }
.mock_exam_results_summary td:first-child { color: #475569; font-weight: 700; text-align: left; }
.mock_exam_results_summary tbody tr:first-child td { color: #0f766e; font-size: 17px; font-weight: 800; background: #f0fdfa; }
.mock_exam_results_summary tbody tr:first-child td:first-child { color: #0f766e; }
/* 何を・なぜ: 3科目の得点を横並びの表で追わせず、科目単位で比較・復習判断できるようカード化する。 */
.mock-exam-result__subject-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.mock-exam-result__subject-card { padding: 18px; border: 1px solid #dbe3ec; border-radius: 16px; background: #fff; }
.mock-exam-result__subject-card.is-passed { border-color: #99e0cb; background: #f0fdfa; }
.mock-exam-result__subject-card.is-review { border-color: #bfdbfe; background: #f8fbff; }
.post_content .mock-exam-result .mock-exam-result__subject-card h3 { margin: 0; padding: 0; color: var(--result-navy); font-size: 18px; line-height: 1.4; background: transparent; border: 0; box-shadow: none; }
.mock-exam-result__subject-score { margin: 14px 0; color: #475569; font-size: 14px; }
.mock-exam-result__subject-score strong { color: #0f766e; font-size: 30px; line-height: 1; }
.mock-exam-result__subject-card dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.mock-exam-result__subject-card dl div { padding: 9px 10px; border-radius: 10px; background: rgba(255, 255, 255, .72); }
.mock-exam-result__subject-card dt { color: #64748b; font-size: 11px; font-weight: 700; }
.mock-exam-result__subject-card dd { margin: 3px 0 0; color: #1e293b; font-size: 14px; font-weight: 800; }
/* 何を・なぜ: 科目見出しを大きな開閉ボタンにして、長い問題一覧でも必要な科目へすぐ絞り込めるようにする。 */
.mock_exam_results .mock-exam-result__subject-row th { padding: 0; text-align: left; background: #eff6ff; border-top: 1px solid #bfdbfe; border-bottom: 1px solid #bfdbfe; }
.mock-exam-result__subject-toggle { display: flex; align-items: center; width: 100%; gap: 14px; padding: 16px 18px; color: #1e3a8a; font: inherit; text-align: left; cursor: pointer; border: 0; background: transparent; }
.mock-exam-result__subject-toggle:hover { background: #dbeafe; }
.mock-exam-result__subject-toggle:focus-visible { outline: 3px solid #60a5fa; outline-offset: -3px; }
.mock-exam-result__subject-toggle-icon { display: grid; gap: 4px; flex: 0 0 24px; }
.mock-exam-result__subject-toggle-icon i { display: block; height: 3px; border-radius: 999px; background: currentColor; }
.mock-exam-result__subject-toggle-label { flex: 1; font-size: clamp(22px, 4vw, 30px); font-weight: 800; line-height: 1.25; }
.mock-exam-result__subject-toggle-state { flex: 0 0 auto; padding: 5px 9px; color: #1d4ed8; font-size: 12px; font-weight: 700; border-radius: 999px; background: #dbeafe; }
/* 何を・なぜ: カード表示用のdisplay指定より優先して、閉じた科目の問題行を確実に隠す。 */
.mock_exam_results .mock-exam-result__question-row[hidden] { display: none !important; }
.mock-exam-result input.frequentsample_quiz { max-width: 100%; padding: 8px 10px; color: #1d4ed8; font-weight: 650; white-space: normal; cursor: pointer; border: 1px solid #dbeafe; border-radius: 9px; background: #eff6ff; }
.mock-exam-result input.frequentsample_quiz:hover { border-color: #93c5fd; background: #dbeafe; }
.result-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; margin: auto; color: #fff; border-radius: 50%; font-weight: 800; }
.result-mark--correct { background: #059669; }
.result-mark--incorrect { background: #e11d48; }
.mock-exam-result__legend { display: flex; gap: 14px; color: #475569; font-size: 13px; }
.mock-exam-result__legend > span { display: flex; align-items: center; gap: 6px; }
.mock-exam-result__legend-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; color: #fff; border-radius: 50%; font-style: normal; font-weight: 800; }
.mock-exam-result__legend-mark.is-correct { background: #059669; }
.mock-exam-result__legend-mark.is-incorrect { background: #e11d48; }
/* 何を・なぜ: 管理画面のプレビューや直接アクセス時にも、エラーではなく結果画面であることが分かる案内を表示する。 */
.mock-exam-result__empty-state { margin: 24px auto; padding: 20px; color: #475569; text-align: center; border: 1px solid #dbe3ec; border-radius: 14px; background: #f8fafc; }

@container (max-width: 850px) {
    /* 何を・なぜ: 横スクロールで「同トピックの問題」が隠れないよう、狭い結果カードでは1問をカード形式で完結表示する。 */
    .mock_exam_results-container { overflow-x: visible; }
    .mock_exam_results,
    .mock_exam_results tbody { display: block; min-width: 0; width: 100%; }
    .mock_exam_results thead { display: none; }
    .mock_exam_results tbody tr {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow: hidden;
        margin-top: 12px;
        border: 1px solid #dbe3ec;
        border-radius: 14px;
    }
    .mock_exam_results tbody tr:first-child { margin-top: 0; }
    /* 何を・なぜ: テーブル由来の内容幅への縮小を防ぎ、科目アコーディオンを結果カードいっぱいの操作領域にする。 */
    .mock_exam_results tbody .mock-exam-result__subject-row { display: grid; grid-template-columns: minmax(0, 1fr); width: 100% !important; min-width: 0; box-sizing: border-box; margin-top: 22px; border: 0; border-radius: 0; }
    .mock_exam_results tbody .mock-exam-result__subject-row:first-child { margin-top: 0; }
    .mock_exam_results tbody .mock-exam-result__subject-row th { display: block; width: 100% !important; min-width: 0; box-sizing: border-box; border: 1px solid #bfdbfe; border-radius: 10px; }
    .mock_exam_results tbody .mock-exam-result__subject-row .mock-exam-result__subject-toggle { width: 100% !important; min-width: 0; box-sizing: border-box; padding: 14px; }
    .mock_exam_results tbody td {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        padding: 10px 12px;
        text-align: left;
        border: 0;
        border-bottom: 1px solid #e8edf3;
    }
    .mock_exam_results tbody td:nth-child(1),
    .mock_exam_results tbody td:nth-child(2),
    .mock_exam_results tbody td:nth-child(6) { grid-column: 1 / -1; }
    .mock_exam_results tbody td:nth-child(1) { background: #f8fbff; }
    .mock_exam_results tbody td:nth-child(6) { border-bottom: 0; }
    .mock_exam_results tbody td::before {
        flex: 0 0 5.5em;
        color: #64748b;
        font-size: 12px;
        font-weight: 700;
    }
    .mock_exam_results tbody td:nth-child(1)::before { content: "出典"; }
    .mock_exam_results tbody td:nth-child(2)::before { content: "区分"; }
    .mock_exam_results tbody td:nth-child(3)::before { content: "正解"; }
    .mock_exam_results tbody td:nth-child(4)::before { content: "あなたの回答"; }
    .mock_exam_results tbody td:nth-child(5)::before { content: "正誤"; }
    .mock_exam_results tbody td:nth-child(6)::before { content: "同トピック"; }
    .mock_exam_results tbody td:nth-child(6) input.frequentsample_quiz { width: 100%; box-sizing: border-box; }
}

@media (max-width: 700px) {
    .mock-exam-result { width: min(100% - 16px, 1120px); margin-top: 12px; }
    .mock-exam-result__hero { padding: 24px 20px; border-radius: 20px; }
    .mock-exam-result__hero-grid, .mock-exam-result__section-heading { align-items: flex-start; flex-direction: column; }
    .mock-exam-result__verdict { min-width: 0; width: 100%; box-sizing: border-box; text-align: left; }
    .mock-exam-result__score-cards { grid-template-columns: 1fr; gap: 8px; margin-top: 20px; }
    .mock-exam-result__score-card { display: flex; align-items: baseline; justify-content: space-between; padding: 12px 15px; }
    .mock-exam-result__score-card strong { font-size: 22px; }
    .mock-exam-result__section { padding: 20px 14px; border-radius: 18px; }
    .mock-exam-result__section-heading { gap: 12px; }
    .mock-exam-result__subject-cards { grid-template-columns: 1fr; }
    .mock_exam_results_summary { min-width: 520px; }
}

@media (prefers-reduced-motion: reduce) {
    .mock-exam-result * { scroll-behavior: auto !important; transition: none !important; }
}
