/* 수능 수학 기출 화면. 국어·영어와 같은 목록·모달을 쓰고 수식과 그림 조판만 더한다 */

.table td.is-math {
  font-family: var(--font-serif);
  color: var(--color-text);
  font-weight: 400;
  line-height: 1.9;
}

.table td.is-math .katex { font-size: 1.02em; }
.table td.is-math .tag { font-family: var(--font-sans); vertical-align: 1px; }

/* 일반 보기 */

.mq {
  font-family: var(--font-serif);
  font-size: 15px;
  line-height: 1.95;
  color: var(--color-text-strong);
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* 글 속 수식은 한글과 눈높이를 맞추고, 따로 세운 식은 원문처럼 조금 크게 */
.mq .katex { font-size: 1.12em; }

.mq__stem { display: flex; gap: 8px; }
.mq__no { flex: none; min-width: 26px; font-family: var(--font-sans); font-weight: 700; }
.mq__body { flex: 1; min-width: 0; }
.mq__p { margin: 0 0 6px; }
.mq__unit { text-align: right; margin-bottom: 0; }
.mq__caption { text-align: center; margin-bottom: 0; }
.mq__points { font-family: var(--font-sans); font-size: 12.5px; color: var(--color-text-muted); white-space: nowrap; }

.mq__display { margin: 0 0 2px 1.5em; padding: 6px 0; overflow-x: auto; overflow-y: hidden; }
.mq__display .katex-display { margin: 0; text-align: left; }
/* 따로 세운 식은 글보다 조금 크게 (KaTeX 기본 비율) */
.mq__display .katex { font-size: 1.21em; }
.mq__display .katex-display > .katex { text-align: left; }

.mq__box {
  margin: 10px 0 12px;
  padding: 10px 16px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-control);
}

.mq__box-title {
  text-align: center;
  font-family: var(--font-sans);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}

.mq__line + .mq__line { margin-top: 4px; }
.mq__line--hang { display: flex; align-items: baseline; gap: 0.4em; }
.mq__label { flex: none; }
.mq__linetext { flex: 1; min-width: 0; }
.mq__box .mq__display { margin-left: 1.5em; }

.mq__table { border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.mq__table th, .mq__table td { border: 1px solid var(--color-border-strong); padding: 0.15em 1.25em; text-align: center; font-weight: 400; }

.mq__side { display: flex; align-items: flex-start; gap: 20px; }
.mq__side .mq__p, .mq__side > .mq__figure { flex: 1; min-width: 0; }
.mq__side > .mq__figure { margin: 0; }
.mq__side > .mq__table, .mq__side > .mq__tbl { flex: none; margin-top: 4px; }
.mq__tbl { display: table; margin: 10px 0; }
.mq__tbl .mq__table { margin: 4px 0 0; }
.mq__side--stack { display: block; }

.mq__glyph { height: 1.05em; width: auto; vertical-align: -0.15em; }
.mq__glyph[style] { height: auto; }
.mq__figrow { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 8px 24px; }
.mq__figrow .mq__figure { margin: 14px 0; }
.mq__cfig { display: block; max-width: 100%; height: auto; }

.mq__figure { margin: 14px 0; text-align: center; }
.mq__figure img { max-width: 100%; height: auto; }

.mq__choices {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px 12px;
}

.mq__choices--long, .mq__choices--c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mq__choices--c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mq__choices--c1 { grid-template-columns: minmax(0, 1fr); }
.mq__choice { min-width: 0; }
.mq__nb { white-space: nowrap; }
.mq__nb--free { white-space: normal; }
.mq__inl { white-space: nowrap; display: inline-block; padding: 0.12em 0; }
.mq__inl--free, .mq__nb--free .mq__inl { white-space: normal; display: inline; }
.mq .katex .text { font-family: KaTeX_Main, var(--font-serif); }
.mq__ctext { min-width: 0; white-space: nowrap; }
.mq__choices--c1 .mq__ctext { white-space: normal; }

.mq__choice {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 2px 6px;
  border-radius: var(--radius-control);
}

.mq__ctable { margin: 10px 0 0; border-collapse: collapse; }
.mq__ctable th { font-weight: 400; padding: 0.15em 1em; text-align: center; }
.mq__ctable td { padding: 0.2em 1em; text-align: center; }
.mq__ctable tr.mq__choice { display: table-row; }
.mq__ctable td.mq__mark { text-align: left; padding-left: 6px; }

.mq__mark { flex: none; font-size: 1.1em; color: var(--color-text-muted); }

.show-answers .mq__choice.is-answer { background: var(--color-primary-soft); }
.show-answers .mq__choice.is-answer .mq__mark { color: var(--color-primary-dark); font-weight: 700; }

.mq__answer {
  margin: 14px 0 0 34px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: var(--color-text-muted);
}

.mq__answer b { color: transparent; font-weight: 600; }
.show-answers .mq__answer b { color: var(--color-primary-dark); }

@media (max-width: 640px) {
  .mq__choices:not(.mq__choices--c2):not(.mq__choices--c1):not(.mq__choices--fig) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 시험지 */

.sheet--math .mq--paper { font-size: 10.4pt; line-height: 1.85; color: #111; text-align: left; }
.sheet--math .mq--paper .mq__no { display: inline; margin-right: 4pt; }
.sheet--math .mq--paper .mq__p { text-indent: 0; margin: 0 0 5pt; }
.sheet--math .mq--paper .mq__points,
.sheet--math .mq--paper .mq__mark { color: #111; }
.sheet--math .mq--paper .mq__box { border-color: #111; border-radius: 0; }
.sheet--math .mq--paper .mq__box-title { color: #111; }
.sheet--math .mq--paper .mq__table th,
.sheet--math .mq--paper .mq__table td { border-color: #111; }
.sheet--math .mq--paper .mq__side { gap: 8pt; }
.sheet--math .mq--paper .mq__table { font-size: 9pt; line-height: 1.5; }
.sheet--math .mq--paper .mq__table th,
.sheet--math .mq--paper .mq__table td { padding: 0.3em 0.9em; }
.sheet--math .mq--paper .mq__choices { gap: 2px 12px; }
.sheet--math .mq--paper .mq__choice { padding: 2px 3px; gap: 4px; }
.sheet--math .mq--paper .mq__figure img { max-width: 100%; }
.sheet--math .mq--paper .mq__answer { margin-left: 0; color: #111; }
.sheet--math .mq--paper .mq__answer b { color: transparent; }
.show-answers .sheet--math .mq--paper .mq__answer b { color: #111; }
.show-answers .sheet--math .mq__choice.is-answer { background: #ffeeb8; }

/* 그림 선택지: 번호는 그림 왼쪽 위, 칸 폭은 문제지에 실린 그림 폭(--cfig)에 맞춤 */
.mq__choice:has(.mq__cfig) { align-items: flex-start; }
.mq__choices--fig,
.sheet--math .mq--paper .mq__choices--fig { grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--cfig) + 2.4em)), 1fr)); gap: 10px 16px; }
.mq__choices--fig .mq__ctext { white-space: normal; }
.sheet--math .mq--paper .mq__choices--fig2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sheet--math .mq--paper .mq__ctable th,
.sheet--math .mq--paper .mq__ctable td { padding: 0.15em 0.45em; }
.mq .mq__table--tight th, .mq .mq__table--tight td,
.sheet--math .mq--paper .mq__table--tight th, .sheet--math .mq--paper .mq__table--tight td { padding-left: 0.35em; padding-right: 0.35em; }
.mq__ctable td { white-space: nowrap; }
.mq__ctable--wrap td { white-space: normal; }

/* 밑줄 친 구절 속 수식까지 한 줄로 긋는다 (수식은 inline-block 이라 text-decoration 이 닿지 않음) */
.mq u { text-decoration: none; border-bottom: 1px solid currentColor; }

/* 수식 속 빈칸 상자가 괄호에 붙지 않게 */
.mq .katex .vlist-t:has(> .vlist-r > .vlist > span > .fbox) { margin: 0 0.18em; }
/* 분수 속 빈칸 상자가 분수선에 붙지 않게 테두리만 조금 줄인다 */
.mq .katex .mfrac .fbox { transform: scaleY(0.86); }

/* 분수가 든 칸은 위아래 여백을 넉넉히 (위아래 행 분수·테두리가 붙지 않게) */
.mq .mq__ctable td:has(.mfrac) { padding-top: 0.4em; padding-bottom: 0.4em; }
.mq .mq__table td:has(.mfrac) { padding-top: 0.3em; padding-bottom: 0.3em; }

/* 넓은 표가 든 문항은 시험지에서 한 단으로 (원문도 쪽 폭을 다 씀) */
.sheet__cols--one .sheet__col + .sheet__col { display: none; }

/* 해설 */
.solution { margin: 28px auto 0; padding-top: 18px; border-top: 1px solid var(--color-divider); }
.solution__h { margin: 0 0 8px; font-family: var(--font-sans); font-size: 13px; font-weight: 600; letter-spacing: 0.02em; color: var(--color-text-muted); }
.solution__h + .solution__h, .mq--solution + .solution__h { margin-top: 22px; }
.solution__answer { margin: 0 0 4px; font-family: var(--font-serif); font-size: 20px; color: var(--color-primary-dark); }
.mq--solution .mq__p { margin-bottom: 8px; }

/* 목록의 좁은 칸(학년도·시험·과목·번호·배점)은 내용 폭만큼만 차지한다 */
.table--tight th, .table--tight td { padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.table--tight th:first-child, .table--tight td:first-child { padding-left: 12px; }
.table--tight th:last-child, .table--tight td:last-child { white-space: normal; padding-left: 12px; }
.table--tight .col-exam { white-space: normal; word-break: keep-all; }

/* ---------- 좁은 화면 ---------- */

@media (max-width: 900px) {
  .mq { font-size: 16px; line-height: 1.9; }
  .mq__points { font-size: 13.5px; }
  .mq__choice { padding: 7px 6px; }
  .mq__answer { font-size: 14.5px; }
  .solution__h { font-size: 14px; }
  .mq__table { font-size: 14.5px; }
  /* 끊을 자리가 없는 긴 수식은 그 줄만 옆으로 밀어 본다 */
  .mq__p, .mq__linetext { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .mq__p::-webkit-scrollbar, .mq__linetext::-webkit-scrollbar { display: none; }
}
