/*
  MMT Exam Builder — Class Test Template CSS
  -----------------------------------------
  This file is loaded after the HSC template. It only takes effect when the
  renderer adds .template-class-test to .exam-document.
*/

.exam-document.template-class-test {
  background: #ffffff;
  font-family: var(--exam-font, "Times New Roman", Times, serif);
  color: var(--exam-ink, #111827);
}


/* Class-test maths typography */
.template-class-test .math,
.template-class-test .math-frac,
.template-class-test .question-prompt,
.template-class-test .question-text,
.template-class-test .question-diagram,
.template-class-test .question-table,
.template-class-test .question-matching,
.template-class-test .choice-list,
.template-class-test .answer-space,
.template-class-test .compact-question-table,
.template-class-test .compact-question-prompt,
.template-class-test .compact-answer-cell {
  font-family: var(--exam-math-font, "Cambria Math", "STIX Two Math", "STIXGeneral", "Times New Roman", serif);
}

.template-class-test .class-test-page {
  min-height: auto;
  padding: 14mm 14mm 16mm;
  page-break-after: auto;
  break-after: auto;
}

.template-class-test .class-test-header {
  border: 2px solid var(--exam-border, #111827);
  padding: 6mm;
  margin-bottom: 7mm;
  break-inside: avoid;
  page-break-inside: avoid;
}

.template-class-test .class-test-title-row {
  display: grid;
  grid-template-columns: 1fr 26mm;
  gap: 8mm;
  align-items: stretch;
}

.template-class-test .class-test-brand {
  margin-bottom: 2mm;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.template-class-test .class-test-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
}

.template-class-test .class-test-subtitle {
  margin: 1.5mm 0 0;
  font-size: 14px;
  font-weight: 700;
}

.template-class-test .class-test-mark-box {
  border: 1.6px solid var(--exam-border, #111827);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 20mm;
  text-align: center;
}

.template-class-test .class-test-mark-box strong {
  font-size: 24px;
  line-height: 1;
}

.template-class-test .class-test-mark-box span {
  margin-top: 1.5mm;
  font-size: 10px;
  font-weight: 700;
}

.template-class-test .class-test-info-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr 0.8fr;
  gap: 3mm 5mm;
  margin-top: 5mm;
  font-size: 12px;
}

.template-class-test .class-test-info-grid div {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2.5mm;
  align-items: end;
  min-height: 7mm;
}

.template-class-test .class-test-info-grid strong {
  font-weight: 700;
  white-space: nowrap;
}

.template-class-test .class-test-info-grid span {
  display: block;
  height: 5.5mm;
  border-bottom: 1.4px solid var(--exam-border, #111827);
}

.template-class-test .class-test-info-grid em {
  font-style: normal;
  font-weight: 700;
}

.template-class-test .class-test-instructions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4mm;
  margin-top: 4mm;
  padding-top: 3.5mm;
  border-top: 1.2px solid var(--exam-soft-border, #d1d5db);
  font-size: 11.5px;
  line-height: 1.25;
}

.template-class-test .class-test-instructions strong {
  white-space: nowrap;
}

.template-class-test .class-test-instructions ul {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5mm 7mm;
  margin: 0;
  padding-left: 4mm;
}

.template-class-test .class-test-section {
  margin-top: 7mm;
}

.template-class-test .class-test-section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6mm;
  border-top: 1.8px solid var(--exam-border, #111827);
  border-bottom: 1.2px solid var(--exam-border, #111827);
  padding: 2.2mm 0;
  margin-bottom: 4.5mm;
  break-inside: avoid;
  page-break-inside: avoid;
}

.template-class-test .class-test-section-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.15;
}

.template-class-test .class-test-section-header p {
  margin: 0;
  font-size: 11.5px;
  color: var(--exam-muted, #4b5563);
  font-weight: 700;
}

.template-class-test .class-test-question-list {
  gap: 5.5mm;
}

.template-class-test .exam-question {
  padding-bottom: 1mm;
}

.template-class-test .question-heading {
  grid-template-columns: 10mm 1fr 19mm;
  gap: 5mm;
  font-size: 13px;
  line-height: 1.22;
}

.template-class-test .question-prompt {
  font-size: 13.5px;
}

.template-class-test .question-marks {
  font-size: 11.5px;
}

.template-class-test .choice-list {
  margin: 3mm 0 0 13mm;
  gap: 2mm 8mm;
  font-size: 13px;
}

.template-class-test .question-diagram {
  margin-top: 3mm;
  margin-bottom: 2mm;
  max-width: 112mm;
  min-height: 42mm;
}

.template-class-test .answer-space {
  margin: 3mm 0 0 13mm;
}

.template-class-test .answer-space-small {
  height: 16mm;
}

.template-class-test .answer-space-medium {
  height: 28mm;
}

.template-class-test .answer-space-large {
  height: 46mm;
}

.template-class-test .compact-question-group {
  border: 1.4px solid var(--exam-border, #111827);
  break-inside: avoid;
  page-break-inside: avoid;
}

.template-class-test .compact-question-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4mm;
  padding: 2mm 3mm;
  border-bottom: 1.2px solid var(--exam-border, #111827);
  background: #f3f4f6;
  font-size: 12.5px;
}

.template-class-test .compact-question-group-header span {
  font-weight: 700;
  white-space: nowrap;
}

.template-class-test .compact-question-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--exam-math-font, "Cambria Math", "Times New Roman", serif);
  font-size: 12.8px;
  line-height: 1.18;
}

.template-class-test .compact-question-table th,
.template-class-test .compact-question-table td {
  border-bottom: 1px solid var(--exam-soft-border, #d1d5db);
  vertical-align: middle;
}

.template-class-test .compact-question-table tr:last-child th,
.template-class-test .compact-question-table tr:last-child td {
  border-bottom: none;
}

.template-class-test .compact-question-table th {
  width: 18mm;
  padding: 2.1mm 2.4mm;
  text-align: left;
  white-space: nowrap;
}

.template-class-test .compact-question-number::before {
  content: "Q";
}

.template-class-test .compact-part-label {
  margin-left: 1mm;
  color: var(--exam-muted, #4b5563);
  font-size: 0.92em;
}

.template-class-test .compact-question-prompt {
  padding: 2.1mm 3mm;
}

.template-class-test .compact-answer-cell {
  width: 42mm;
  min-width: 42mm;
  padding: 2.1mm 3mm;
  background:
    linear-gradient(to bottom, transparent calc(100% - 1.3mm), rgba(17, 24, 39, 0.55) calc(100% - 1.1mm), transparent calc(100% - 0.9mm));
}

.template-class-test .math-frac {
  font-size: 0.96em;
}

@media screen and (max-width: 820px) {
  .template-class-test .class-test-page {
    padding: 18px;
  }

  .template-class-test .class-test-title-row,
  .template-class-test .class-test-info-grid,
  .template-class-test .class-test-instructions,
  .template-class-test .class-test-instructions ul {
    grid-template-columns: 1fr;
  }

  .template-class-test .compact-question-table,
  .template-class-test .compact-question-table tbody,
  .template-class-test .compact-question-table tr,
  .template-class-test .compact-question-table th,
  .template-class-test .compact-question-table td {
    display: block;
    width: 100%;
  }

  .template-class-test .compact-answer-cell {
    min-height: 28px;
  }
}

@page class-test-page {
  size: A4;
  margin: 12mm 12mm 13mm 12mm;
}

@media print {
  .exam-document.template-class-test {
    width: auto !important;
    min-height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  .template-class-test .class-test-page {
    page: class-test-page;
  }

  .template-class-test .exam-section,
  .template-class-test .class-test-page {
    width: auto !important;
    min-height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    page-break-after: auto !important;
    break-after: auto !important;
    page-break-inside: auto !important;
    break-inside: auto !important;
  }

  .template-class-test .section-break-before {
    page-break-before: auto !important;
    break-before: auto !important;
  }

  .template-class-test .class-test-header,
  .template-class-test .class-test-section-header,
  .template-class-test .compact-question-group,
  .template-class-test .exam-question,
  .template-class-test .question-heading,
  .template-class-test .question-diagram,
  .template-class-test .answer-space,
  .template-class-test .choice-list {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .template-class-test .class-test-question-list {
    gap: 5mm;
  }

  .template-class-test .mc-answer-sheet {
    display: none !important;
  }
}

/* Class-test compact diagram response layout
   -----------------------------------------
   Diagram questions are usually the biggest space users in the class-test
   template. When a question has both a generated diagram and a written answer
   space, place the diagram beside the answer box instead of stacking the answer
   space underneath. The HSC template is unaffected. */
.template-class-test .exam-question.has-diagram-answer-layout {
  display: grid;
  grid-template-columns: minmax(74mm, 1fr) minmax(48mm, 58mm);
  column-gap: 7mm;
  row-gap: 3mm;
  align-items: center;
  break-inside: avoid;
  page-break-inside: avoid;
}

.template-class-test .exam-question.has-diagram-answer-layout .question-editor-controls,
.template-class-test .exam-question.has-diagram-answer-layout .question-heading,
.template-class-test .exam-question.has-diagram-answer-layout .question-table-wrap,
.template-class-test .exam-question.has-diagram-answer-layout .question-matching,
.template-class-test .exam-question.has-diagram-answer-layout .choice-list,
.template-class-test .exam-question.has-diagram-answer-layout .student-diagram-space {
  grid-column: 1 / -1;
}

.template-class-test .exam-question.has-diagram-answer-layout .question-diagram {
  grid-column: 1;
  grid-row: auto;
  width: 100%;
  max-width: none;
  min-height: 34mm;
  margin: 1mm 0 0 8mm;
  justify-self: stretch;
  align-self: center;
}

.template-class-test .exam-question.has-diagram-answer-layout .question-diagram svg {
  max-height: 54mm;
}

.template-class-test .exam-question.has-diagram-answer-layout .answer-space {
  grid-column: 2;
  width: 100%;
  margin: 1mm 0 0;
  align-self: stretch;
  min-height: 30mm;
}

.template-class-test .exam-question.has-diagram-answer-layout .answer-space-small {
  height: 24mm;
  min-height: 24mm;
}

.template-class-test .exam-question.has-diagram-answer-layout .answer-space-medium {
  height: 36mm;
  min-height: 36mm;
}

.template-class-test .exam-question.has-diagram-answer-layout .answer-space-large {
  height: 52mm;
  min-height: 52mm;
}

/* Some generated graph/protractor diagrams need a little more horizontal room.
   Keeping the answer box to the right still saves space, but avoids crushing
   wide diagrams on screen and in print. */
.template-class-test .exam-question.has-diagram-answer-layout .question-diagram[data-engine="linear-engine"],
.template-class-test .exam-question.has-diagram-answer-layout .question-diagram[data-engine="rates-engine"] {
  min-height: 48mm;
}

.template-class-test .exam-question.has-diagram-answer-layout .question-diagram[data-engine="linear-engine"] svg,
.template-class-test .exam-question.has-diagram-answer-layout .question-diagram[data-engine="rates-engine"] svg,
.template-class-test .exam-question.has-diagram-answer-layout .question-diagram[data-engine="angle-engine"] svg {
  max-height: 62mm;
}

@media screen and (max-width: 820px) {
  .template-class-test .exam-question.has-diagram-answer-layout {
    grid-template-columns: 1fr;
  }

  .template-class-test .exam-question.has-diagram-answer-layout .question-diagram,
  .template-class-test .exam-question.has-diagram-answer-layout .answer-space {
    grid-column: 1;
    margin-left: 0;
  }
}


/* Class-test diagram margin refinement
   ------------------------------------
   The first side-by-side version saved vertical space, but the answer box could
   sit too close to the right print edge. Reserve a small right gutter and reduce
   the answer column slightly so the layout stays inside the class-test page. */
.template-class-test .exam-question.has-diagram-answer-layout {
  grid-template-columns: minmax(62mm, 1fr) minmax(40mm, 50mm);
  column-gap: 5mm;
  padding-right: 5mm;
  box-sizing: border-box;
}

.template-class-test .exam-question.has-diagram-answer-layout .question-diagram {
  margin: 1mm 0 0 0;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
}

.template-class-test .exam-question.has-diagram-answer-layout .answer-space {
  justify-self: stretch;
  max-width: 50mm;
  box-sizing: border-box;
}

@media print {
  .template-class-test .exam-question.has-diagram-answer-layout {
    grid-template-columns: minmax(58mm, 1fr) minmax(38mm, 48mm);
    column-gap: 5mm;
    padding-right: 5mm;
  }

  .template-class-test .exam-question.has-diagram-answer-layout .answer-space {
    max-width: 48mm;
  }
}

/* Class-test 12pt readability update
   ----------------------------------
   Browser print uses 96px per inch, so 12pt is equivalent to 16px.
   These overrides keep the class-test template compact, but make the
   main student-facing text print at approximately 12pt. */
.template-class-test {
  --class-test-print-font-size: 16px;
  --class-test-print-line-height: 1.25;
}

.template-class-test .exam-question,
.template-class-test .question-heading,
.template-class-test .question-number,
.template-class-test .question-prompt,
.template-class-test .question-text,
.template-class-test .choice-list,
.template-class-test .question-table,
.template-class-test .question-matching,
.template-class-test .student-diagram-space {
  font-size: var(--class-test-print-font-size);
  line-height: var(--class-test-print-line-height);
}

.template-class-test .question-heading {
  grid-template-columns: 11mm 1fr 22mm;
}

.template-class-test .question-marks {
  font-size: var(--class-test-print-font-size);
  line-height: var(--class-test-print-line-height);
  white-space: nowrap;
}

.template-class-test .choice-list {
  gap: 2.2mm 8mm;
}

.template-class-test .compact-question-group-header {
  font-size: 15px;
  line-height: 1.22;
}

.template-class-test .compact-question-table {
  font-size: var(--class-test-print-font-size);
  line-height: 1.22;
}

.template-class-test .compact-question-table th {
  width: 21mm;
}

.template-class-test .compact-question-prompt {
  padding: 2.4mm 3mm;
}

.template-class-test .compact-answer-cell {
  width: 48mm;
  min-width: 48mm;
  padding: 2.4mm 3mm;
}

.template-class-test .math-frac {
  font-size: 1em;
}

@media print {
  .template-class-test .exam-question,
  .template-class-test .question-heading,
  .template-class-test .question-number,
  .template-class-test .question-prompt,
  .template-class-test .question-text,
  .template-class-test .choice-list,
  .template-class-test .question-table,
  .template-class-test .question-matching,
  .template-class-test .student-diagram-space,
  .template-class-test .question-marks,
  .template-class-test .compact-question-table {
    font-size: 16px !important;
    line-height: 1.25 !important;
  }

  .template-class-test .compact-question-group-header {
    font-size: 15px !important;
  }
}
