/* ============================================================
   過去問ページ用スタイル
   デジタル庁デザインシステム(DADS)の指針に準拠:
   - 本文は16px以上 / 14px未満は使わない
   - 行間は150%以上（本文は170%前後）
   - タップ領域は44px以上
   - テキストとのコントラスト比 4.5:1 以上
   ============================================================ */

:root {
  --exam-radius: 8px;
  --exam-radius-sm: 6px;
  --exam-gap: 16px;

  /* ライトモード: すべて白背景に対し 4.5:1 以上 */
  --exam-accent: #1a4fa0;        /* 見出し・リンク系 */
  --exam-answer-bg: #f0f5fb;
  --exam-answer-border: #1a4fa0;
  --exam-quote-bg: #f6f7f9;
  --exam-quote-border: #5a6570;
  --exam-meta-fg: #47515c;
  --exam-lead-bg: #f6f7f9;
  --exam-review-fg: #1f5c3d;
}

/* 10月模試の入力式練習用紙 */
.october-paper-question {
  margin: 1rem 0 1.8rem;
  padding: 1rem;
  border: 1px solid var(--exam-quote-border);
  border-radius: var(--exam-radius);
}
.october-paper-question input[type="text"],
.october-paper-question textarea {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: .5rem 0;
  padding: .6rem;
  color: inherit;
  background: var(--md-default-bg-color);
  border: 1px solid var(--exam-quote-border);
  border-radius: var(--exam-radius-sm);
  font: inherit;
}
.october-paper-question textarea { resize: vertical; }
.october-paper-question fieldset { border: 0; padding: 0; }
.october-paper-question fieldset ul { list-style: none; margin: 0; }
.october-paper-question fieldset label {
  display: block;
  min-height: 44px;
  padding: .5rem;
  cursor: pointer;
}
.october-paper-question input[type="radio"],
.october-paper-question input[type="checkbox"] { margin-right: .4rem; }
.paper-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.october-paper button {
  min-height: 44px;
  padding: .5rem .9rem;
  border: 1px solid var(--exam-answer-border);
  border-radius: var(--exam-radius-sm);
  color: var(--exam-accent);
  font: inherit;
  cursor: pointer;
}
.october-paper button[type="submit"] {
  background: var(--exam-answer-border);
  color: var(--md-default-bg-color);
}
.october-paper button:disabled { opacity: .5; cursor: wait; }
.october-paper :is(input,textarea,button):focus-visible {
  outline: 3px solid var(--exam-accent);
  outline-offset: 3px;
}
.paper-result {
  margin-top: .8rem;
  padding: .8rem;
  background: var(--exam-answer-bg);
  border-left: 4px solid var(--exam-answer-border);
}
.paper-result[data-status="correct"] > p { color: var(--exam-review-fg); }
.paper-model { white-space: pre-line; font-weight: bold; }
.paper-note, .october-paper [data-storage-note] { color: var(--exam-meta-fg); }
.october-paper [data-validation]:empty,
.october-paper [data-hint-output]:empty { display: none; }
@media print {
  .october-paper .paper-actions, .october-paper-listen,
  .october-paper [data-paper-progress], .october-paper [data-storage-note],
  .october-paper [data-feedback], .october-paper [data-hint-output],
  .october-paper [data-validation], .october-paper [data-writing-count] { display: none !important; }
  .october-paper-question { break-inside: avoid; padding: .5rem; }
}

/* ダークモード */
[data-md-color-scheme="slate"] {
  --exam-accent: #8ab4f8;
  --exam-answer-bg: #1c2733;
  --exam-answer-border: #8ab4f8;
  --exam-quote-bg: #22262b;
  --exam-quote-border: #9aa4ae;
  --exam-meta-fg: #c2c9d1;
  --exam-lead-bg: #22262b;
  --exam-review-fg: #86d6a8;
}

/* ---------- ページ先頭のメタ情報 ---------- */
.exam-meta {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--exam-radius);
  background: var(--exam-quote-bg);
  color: var(--exam-meta-fg);
  font-size: 0.9rem;
  line-height: 1.6;
  font-weight: 700;
}

/* ---------- 大問リード文 ---------- */
.exam-lead {
  margin: 0 0 1.2rem;
  padding: 0.9rem 1rem;
  border-radius: var(--exam-radius);
  background: var(--exam-lead-bg);
  line-height: 1.8;
}

/* ---------- 目次テーブル ---------- */
.exam-toc table {
  width: 100%;
  font-size: 1rem;
}

/* スマホでは目次のタップ領域を確保 */
.exam-toc td a {
  display: inline-block;
  min-width: 44px;
  min-height: 44px;
  line-height: 44px;
  text-align: center;
  font-weight: 700;
  text-decoration: none;
}

/* ---------- 大問見出し ---------- */
.md-typeset h2 {
  margin-top: 2.4rem;
  padding-bottom: 0.35rem;
  border-bottom: 3px solid var(--exam-accent);
  line-height: 1.4;
}

/* ---------- 設問見出し ---------- */
.md-typeset h3 {
  margin-top: 1.8rem;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--exam-accent);
}

/* ---------- 解答・解説トグル ---------- */
details.exam-answer {
  margin: 0.9rem 0 1.6rem;
  border: 2px solid var(--exam-answer-border);
  border-radius: var(--exam-radius);
  background: var(--exam-answer-bg);
  overflow: hidden;
}

details.exam-answer > summary {
  /* 44px以上のタップ領域 */
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--exam-answer-border);
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.5;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

[data-md-color-scheme="slate"] details.exam-answer > summary {
  color: #10151b;
}

details.exam-answer > summary::-webkit-details-marker {
  display: none;
}

details.exam-answer > summary::before {
  content: "▶";
  margin-right: 0.6rem;
  font-size: 0.8em;
  transition: transform 0.15s ease;
}

details.exam-answer[open] > summary::before {
  transform: rotate(90deg);
}

details.exam-answer > summary:hover,
details.exam-answer > summary:focus-visible {
  filter: brightness(1.12);
}

details.exam-answer > summary:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: -5px;
}

/* トグル内の本文 */
details.exam-answer > :not(summary) {
  padding-left: 1rem;
  padding-right: 1rem;
  line-height: 1.8;
}

details.exam-answer > :last-child {
  padding-bottom: 0.9rem;
}

/* 証明などの引用ブロック */
details.exam-answer blockquote {
  margin: 0.8rem 0;
  padding: 0.8rem 1rem;
  border-left: 4px solid var(--exam-quote-border);
  border-radius: 0 var(--exam-radius-sm) var(--exam-radius-sm) 0;
  background: var(--exam-quote-bg);
  line-height: 1.9;
}

/* 復習リンク行 */
details.exam-answer p:last-of-type a {
  font-weight: 700;
}

/* ---------- スマートフォン最適化 ---------- */
@media screen and (max-width: 76.1875em) {
  .md-typeset {
    font-size: 1rem;      /* 16px を下回らない */
    line-height: 1.8;
  }

  .md-typeset h2 {
    font-size: 1.25rem;
  }

  .md-typeset h3 {
    font-size: 1.05rem;
  }

  /* 数式が長いときは横スクロール（ページ全体を崩さない） */
  .md-typeset .arithmatex {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    padding-bottom: 0.2rem;
    -webkit-overflow-scrolling: touch;
  }

  /* 表も同様に、はみ出さずスクロール */
  .md-typeset table:not([class]) {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    font-size: 0.95rem;
  }

  .exam-lead,
  details.exam-answer > :not(summary) {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}

/* ---------- 印刷 ---------- */
@media print {
  details.exam-answer {
    break-inside: avoid;
  }

  /* 印刷時は解答も開いた状態で出す */
  details.exam-answer > :not(summary) {
    display: block !important;
  }
}

/* ---------- ドリル（iframe）の埋め込み ---------- */

.drill-launch {
  margin: 1.2rem 0;
}

.drill-launch .md-button {
  display: block;
  width: 100%;
  min-height: 56px;
  padding: 0.9rem 1rem;
  font-size: 1.05rem;
  line-height: 1.6;
  text-align: center;
}

.exam-drill-frame {
  margin: 1.2rem 0 1.6rem;
  border: 2px solid var(--exam-answer-border);
  border-radius: var(--exam-radius);
  overflow: hidden;
}

.exam-drill-frame iframe {
  display: block;
  width: 100%;
  height: 760px; /* simulator-frame.js が中身に合わせて調整する */
  border: 0;
}

/* ---------- 原本PDFで解く年度 ---------- */

.exam-source-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}

.exam-source-actions .md-button {
  margin: 0;
  text-align: center;
}

@media (max-width: 480px) {
  .exam-source-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .exam-source-actions .md-button {
    width: 100%;
    min-height: 48px;
  }
}

/* ---------- 問題の図 ---------- */

.exam-figure {
  margin: 1rem 0 1.2rem;
  padding: 0.9rem;
  border: 1px solid var(--exam-quote-border);
  border-radius: var(--exam-radius);
  text-align: center;
}

.exam-figure img {
  display: block;
  width: 100%;
  max-width: 320px;
  height: auto;
  margin: 0 auto;
}

.exam-figure figcaption {
  margin-top: 0.5rem;
  color: var(--exam-meta-fg);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ---------- 解答欄の空欄（あ・い・おか など） ---------- */
/* MathJaxは日本語グリフを持たないため、\boxed{} ではなくHTMLで描く */

.blank {
  display: inline-block;
  min-width: 2.2em;
  padding: 0.1em 0.35em;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

/* 根号の中の空欄は、上線で √ とつなげて見せる */
.blank-rad {
  border-top-width: 3px;
  margin-left: -0.15em;
}

/* 分数の形に積む空欄 */
.blank-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  vertical-align: middle;
}

.blank-frac .blank:first-child {
  border-bottom-width: 3px;
}

/* ---------- 図の中のデータ表 ---------- */
/* ドリル側と同じ見た目にする（罫線をはっきり引く） */

.exam-figure .figure-table {
  width: auto;
  min-width: 60%;
  margin: 0 auto 0.6rem;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.exam-figure .figure-table th,
.exam-figure .figure-table td {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--exam-quote-border);
  line-height: 1.6;
  text-align: center;
  white-space: nowrap;
}

.exam-figure .figure-table th {
  background: var(--exam-quote-bg);
  font-weight: 700;
}

.exam-figure .figure-subcaption {
  margin: 0 0 0.3rem;
  font-size: 0.875rem;
  font-weight: 700;
  text-align: left;
}

/* 表が画面より広いときは横スクロール */
.exam-figure {
  overflow-x: auto;
}

/* ---------- 選択肢（ア〜エ） ---------- */
/* 1行ずつ改行して読みやすくする */

.exam-choices {
  margin: 0.8rem 0 1.2rem;
  padding: 0;
  list-style: none;
}

.exam-choices li {
  display: flex;
  gap: 0.6rem;
  margin: 0 0 0.5rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--exam-quote-border);
  border-radius: var(--exam-radius-sm);
  line-height: 1.8;
}

.exam-choices .mark {
  flex-shrink: 0;
  min-width: 1.6em;
  font-weight: 700;
}

/* ---------- 英語の読む資料 ---------- */

.exam-figure .script {
  padding: 0.2rem;
  text-align: left;
}

.exam-figure .script-title {
  margin: 0 0 0.5rem;
  font-weight: 700;
}

.exam-figure .script-note {
  margin: 0 0 0.7rem;
  padding: 0.5rem 0.7rem;
  border-radius: var(--exam-radius-sm);
  background: var(--exam-quote-bg);
  color: var(--exam-meta-fg);
  font-size: 0.875rem;
  line-height: 1.7;
}

.exam-figure .script p {
  margin: 0 0 0.7rem;
  line-height: 1.9;
}

.exam-figure .say {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
  line-height: 1.9;
}

.exam-figure .say .who {
  flex-shrink: 0;
  min-width: 4.2em;
  font-weight: 700;
}

.exam-figure .blank-area {
  display: block;
  padding: 0.9rem 0.7rem;
  border: 2px dashed var(--exam-quote-border);
  border-radius: var(--exam-radius-sm);
  color: var(--exam-meta-fg);
  text-align: center;
}

/* ---------- 大問の共通本文（長文・対話文） ---------- */
/* 原本と同じく、本文は大問の先頭に1回だけ置く */

.exam-passage {
  margin: 1rem 0 1.6rem;
  padding: 1rem;
  border: 2px solid var(--exam-answer-border);
  border-radius: var(--exam-radius);
  background: var(--exam-answer-bg);
}

.exam-passage .script {
  padding: 0;
}

.exam-passage .script p {
  line-height: 1.95;
}

/* ---------- 原本から取り込んだ図・写真 ---------- */

.exam-figure .fig-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.exam-figure .fig-grid figure,
.exam-figure figure.photo {
  margin: 0;
}

.exam-figure .fig-grid img,
.exam-figure figure.photo img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--exam-quote-border);
  border-radius: var(--exam-radius-sm);
  background: #fff;
}

.exam-figure figure.photo {
  margin-bottom: 0.7rem;
}
/* 模試対策の作図・証明を、本文幅に収まる図として表示する。 */
.md-typeset .october-figure svg { display: block; width: 100%; max-width: 720px; height: auto; }
.md-typeset .october-figure figcaption { color: var(--md-default-fg-color--light); font-size: .8rem; }
