/* ============================================================
   hsk-reading.css — HSK 5급 독해 A4 시험지 레이아웃
   실제 인쇄물과 같은 느낌을 내야 하므로, "종이"(--paper/--ink)는
   다크모드에서도 항상 흰 바탕에 검은 글씨로 고정한다 — 진짜 인쇄물이
   테마에 따라 바뀌지 않는 것과 같다. 다크모드는 종이 "밖"(배경, 헤더)
   에만 적용되며, 그 배경색은 css/style.css의 --color-* 다크 테마
   토큰을 그대로 따른다.

   로그인 화면은 css/style.css의 것을 그대로 재사용하므로, 종이
   배경/명조체는 body가 아니라 #exam-root 안에만 적용한다 — 그래야
   로그인 폼은 앱과 같은 산세리프로, 시험지는 명조체로 각각 보인다.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&display=swap');

:root {
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --paper: #ffffff;
  --paper-backdrop: #E5E3DE;
  --callout-bg: #f0efec; /* 종이 위 해설 상자 배경 — 테마와 무관하게 항상 이 색 */
  --rule: #1a1a1a;
  --page-w: 210mm;
  --page-h: 297mm;
  --correct: #2f7d4f;
  --correct-soft: #e4f2e8;
  --wrong: #b0392e;
  --wrong-soft: #fbeae8;
}

/* 종이 자체(--paper/--ink)는 그대로 두고, 종이 밖 배경만 어둡게 한다. */
:root[data-theme="dark"] {
  --paper-backdrop: #17171a;
}

* { box-sizing: border-box; }

/* -------------------- 클래스/단원 탐색 화면 (앱과 같은 산세리프) -------------------- */

#hsk-app-root {
  min-height: 100vh;
  padding: 28px 24px 60px;
}

.hsk-clickable-row { cursor: pointer; }

.hsk-part-section + .hsk-part-section { margin-top: 28px; }
.hsk-part-section-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 10px;
}

/* -------------------- 시험지 위 뒤로가기/편집 바 -------------------- */

/* 시험지(#exam-root)와 같은 배경색을 써서 이어붙였을 때 이음매가 안 보이게 한다. */
.hsk-exam-nav {
  background: var(--paper-backdrop);
  padding: 20px 16px 14px;
}
.hsk-exam-nav-inner {
  width: var(--page-w);
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Noto Sans KR', sans-serif;
}
.hsk-exam-nav-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.hsk-exam-empty {
  text-align: center;
  font-family: 'Noto Sans KR', sans-serif;
  color: var(--ink-soft);
  padding: 60px 0;
}

/* -------------------- 화면 미리보기용 툴바 (인쇄 시 숨김) -------------------- */

.hsk-toolbar {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 10;
}
.hsk-print-btn {
  font-family: 'Noto Sans KR', sans-serif;
  font-size: 13px;
  font-weight: 600;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.hsk-print-btn:hover { background: #000; }

/* -------------------- A4 페이지 -------------------- */

#exam-root {
  min-height: 100vh;
  padding: 32px 0 60px;
  background: var(--paper-backdrop);
  color: var(--ink);
  font-family: 'Noto Serif SC', 'Songti SC', 'PingFang SC', serif;
  -webkit-font-smoothing: antialiased;
}

.exam-page {
  position: relative;
  width: var(--page-w);
  min-height: var(--page-h);
  margin: 0 auto 32px;
  background: var(--paper);
  padding: 24mm 20mm 26mm;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15), 0 8px 24px rgba(0,0,0,0.12);
}

/* -------------------- 제목 / 지시문 -------------------- */

.section-title {
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
}
.part-title {
  text-align: center;
  font-size: 17px;
  font-weight: 700;
  margin: 0 0 18px;
}
.instruction {
  text-align: left;
  font-size: 14.5px;
  font-weight: 600;
  margin: 0 0 22px;
}

/* -------------------- 지문 공통 -------------------- */

.question-group { margin-bottom: 30px; }
.question-group:last-child { margin-bottom: 0; }

.group-range {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 6px;
}

.passage-text {
  text-indent: 2em;
  font-size: 15px;
  line-height: 2;
  margin: 0 0 4px;
}
.passage-text:last-child { margin-bottom: 0; }

.blank {
  display: inline-block;
  min-width: 2.8em;
  padding: 0 4px;
  text-align: center;
  font-weight: 600;
  border-bottom: 1.4px solid var(--rule);
}

strong { font-weight: 700; }

/* -------------------- 보기 공통 -------------------- */

.option-label {
  font-weight: 700;
  margin-right: 4px;
}
.option-text { font-weight: 400; }

/* 한 줄 4열 / 보기가 길면 2열로 줄바꿈 */
.option-row {
  display: grid;
  gap: 4px 18px;
  font-size: 14.5px;
}
.option-row-4col { grid-template-columns: repeat(4, 1fr); }
.option-row-2col { grid-template-columns: repeat(2, 1fr); }
.option-row .option-item { min-width: 0; }

/* 보기 클릭 → 정답/해설 즉시 확인 (교사·학생 공통) */
.option-item {
  cursor: pointer;
  padding: 2px 5px;
  margin: -2px -5px;
  border-radius: 4px;
  transition: background 100ms ease;
}
.option-item:hover { background: rgba(0, 0, 0, 0.05); }
.option-item.answered { cursor: default; }
.option-item.answered:hover { background: none; }
.option-item.correct {
  background: var(--correct-soft);
  color: var(--correct);
}
.option-item.correct .option-label,
.option-item.correct .option-text { color: var(--correct); font-weight: 700; }
.option-item.wrong {
  background: var(--wrong-soft);
  color: var(--wrong);
}
.option-item.wrong .option-text { text-decoration: line-through; }

.explanation {
  display: none;
  margin-top: 6px;
  padding: 8px 10px;
  background: var(--callout-bg);
  border-radius: 4px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.6;
  white-space: pre-line; /* 해설에 입력한 줄바꿈(Enter)을 그대로 살린다 */
}
.explanation.show { display: block; }
.explanation-label {
  font-weight: 700;
  color: var(--ink);
  margin-right: 4px;
}

/* -------------------- 제1부분: 빈칸 채우기 -------------------- */

.p1-question-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.p1-question-wrap { display: block; }
.p1-question {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.p1-question .q-num {
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
  width: 1.6em;
}
.p1-question .option-row { flex: 1; }

/* -------------------- 제2부분: 일치 고르기 -------------------- */

.question-group-single {
  display: flex;
  flex-direction: column;
}
.question-group-single .q-num {
  font-weight: 700;
  font-size: 15px;
}
.passage-block-inline { margin-top: 4px; }

.option-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 14.5px;
}
.option-list .option-item { display: block; }

/* -------------------- 제3부분: 장문 독해 -------------------- */

.passage-with-image::after { content: ''; display: table; clear: both; }
.passage-image {
  float: right;
  width: 42mm;
  height: auto;
  margin: 2px 0 10px 14px;
  border: 1px solid var(--ink-soft);
}

.p3-question-list {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.p3-question-text {
  font-size: 15px;
  font-weight: 400;
  margin: 0 0 8px;
}
.p3-question-text .q-num { font-weight: 700; margin-right: 2px; }

.option-row-grid {
  grid-template-columns: repeat(2, 1fr) !important;
  grid-template-rows: repeat(2, auto);
}

/* -------------------- 인쇄 -------------------- */

@media print {
  @page { size: A4; margin: 0; }

  #exam-root { background: var(--paper); }
  .hsk-toolbar { display: none; }

  #exam-root { padding: 0; }

  .exam-page {
    margin: 0;
    box-shadow: none;
    page-break-after: always;
  }
  .exam-page:last-child { page-break-after: auto; }
}

/* -------------------- 작은 화면: 스크롤로 넘겨보기 -------------------- */

@media (max-width: 760px) {
  .exam-page {
    width: 100%;
    min-height: auto;
    padding: 16px 16px 40px;
  }
  .passage-image { width: 34vw; }
  .hsk-exam-nav-inner { width: 100%; }
}

