@import url('print.css');

.math-main {
  padding: 26px 0 0;
}

.math-intro {
  margin-bottom: 25px;
}

.math-intro h1 {
  font-size: 2.25rem;
  margin: 8px 0;
}

.math-intro p {
  color: var(--muted);
  margin: 0;
}

.math-layout {
  display: grid;
  grid-template-columns: minmax(300px,320px) minmax(0,1fr);
  gap: 22px;
  align-items: start;
}

.math-panel,
.math-preview {
  position: relative;
  background: #fffefa;
  border-radius: 6px;
  box-shadow: var(--paper-shadow);
  padding: 30px 22px 22px;
}

/* A magnet holds each panel to the fridge. */
.math-panel::before,
.math-preview::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  width: 30px;
  height: 30px;
  margin-left: -15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff9 0 4px, var(--green) 5px);
  box-shadow: 0 4px 5px #0004;
}

.math-preview::before {
  background: radial-gradient(circle at 35% 30%, #fff9 0 4px, var(--blue) 5px);
}

.math-panel h2,
.math-preview h2 {
  margin: 0 0 8px;
}

.math-panel label {
  margin: 16px 0 7px;
}

.math-panel input:not([type=checkbox]),
.math-panel textarea,
.math-panel select {
  padding: 10px 11px;
}

.math-panel textarea {
  min-height: 72px;
}

.math-panel fieldset {
  border: 2px dashed #d6dcea;
  border-radius: 9px;
  margin: 18px 0 0;
  padding: 10px 12px 14px;
}

.math-panel legend {
  font-weight: 650;
  font-size: .85rem;
  padding: 0 5px;
}

.math-panel fieldset label {
  font-size: .85rem;
}

.math-panel .checks-label {
  font-weight: 700;
  font-size: .85rem;
  margin: 14px 0 4px;
}

.math-panel .checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.math-panel .checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
}

.math-panel input[type=checkbox] {
  accent-color: var(--accent);
  width: 17px;
  height: 17px;
}

.math-panel hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 23px 0 6px;
}

.math-panel details {
  border: 2px solid #e3e8f2;
  border-radius: 9px;
  margin-top: 20px;
}

.math-panel summary {
  cursor: pointer;
  padding: 13px;
  font-weight: 650;
}

.detail-body {
  padding: 0 13px 15px;
}

.math-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 19px;
}

.math-actions .primary-button {
  margin: 0;
}

.math-status {
  min-height: 2.5em;
  color: var(--accent);
  font-family: var(--hand);
  font-size: 1.2rem;
  line-height: 1.5;
}

.math-hint {
  font-size: .78rem;
  line-height: 1.4;
  color: var(--muted);
  margin: 6px 0 10px;
}

.math-preview {
  min-width: 0;
  padding: 10px 0 0;
}

.preview-head {
  padding: 20px 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.preview-head p {
  color: var(--muted);
  font-size: .85rem;
  margin: 0;
}

.preview-switches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.segmented {
  display: flex;
  background: #eef1f7;
  padding: 4px;
  border-radius: 999px;
}

.segmented button {
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  background: transparent;
  color: #595a6c;
  padding: 8px 12px;
  font-size: .84rem;
}

.segmented button[aria-pressed=true] {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 5px #20213720;
}

.preview-actions {
  padding: 0 22px 18px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.paper-preview {
  background: #e7edf3;
  border-radius: 0 0 6px 6px;
  border-top: 2px dashed #d6dcea;
  padding: 25px 16px;
  overflow: auto;
  display: grid;
  justify-items: center;
  gap: 20px;
}

.math-paper {
  display: flex;
  flex-direction: column;
  background: white;
  width: 210mm;
  min-height: 297mm;
  padding: 16mm;
  color: #1e2433;
  box-shadow: 0 7px 30px #171c3a1a;
  font-family: Arial,sans-serif;
}

.math-paper h2 {
  /* The paper's own font, not the site's web font: page fitting is measured
     before web fonts finish loading, so the heading must not change size. */
  font-family: Arial, sans-serif;
  font-size: 18pt;
  margin: 0 0 5mm;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.math-paper p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.paper-instructions {
  font-size: 10pt;
  line-height: 1.35;
  margin-bottom: 5mm !important;
}

.paper-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 3mm 9mm;
  margin: 5mm 0 !important;
  font-size: 10pt;
}

.paper-meta span {
  white-space: nowrap;
}

.paper-key-label {
  font-size: 10pt;
  font-weight: 700;
  color: #4d399d;
  margin-bottom: 5mm !important;
}

.paper-grid {
  display: grid;
  gap: 2mm 4mm;
  align-content: start;
}

/* On a full page, share the space left over (less than one row) between the
   rows as extra working space, instead of leaving a blank band at the bottom. */
.math-paper.is-full .paper-grid {
  flex: 1 0 auto;
  align-content: space-between;
}

.paper-row {
  display: grid;
  grid-template-columns: repeat(var(--cols),minmax(0,1fr));
  gap: 4mm;
}

.paper-question {
  min-width: 0;
  padding-top: 2mm;
  font-variant-numeric: tabular-nums;
  break-inside: avoid;
}

.question-line {
  display: flex;
  align-items: baseline;
  gap: 2mm;
  white-space: nowrap;
}

.question-number {
  font-size: .62em;
  color: #5f6474;
  min-width: 1.5em;
}

.question-text {
  font-size: var(--question-size);
  white-space: nowrap;
}

.vertical-question {
  display: inline-grid;
  grid-template-columns: 1.3em auto;
  justify-items: end;
  line-height: 1.2;
  font-size: var(--question-size);
  font-variant-numeric: tabular-nums;
}

.vertical-question .operator {
  grid-column: 1;
}

.vertical-question .top-number {
  grid-column: 2;
}

.vertical-question .bottom-number {
  grid-column: 2;
  border-bottom: 1px solid #202137;
  width: 100%;
  text-align: right;
}

.vertical-question .vertical-answer {
  grid-column: 2;
  width: 100%;
  text-align: right;
}

/* Self-assessment: four outline faces to colour, pinned to the page bottom. */
.paper-feelings {
  margin-top: auto;
  padding-top: 3mm;
  border-top: 0.4mm dashed #9aa0ad;
  break-inside: avoid;
}

.feelings-prompt {
  font-size: 12pt;
  font-weight: 700;
  margin: 0 0 2mm !important;
}

.feelings-row {
  display: flex;
  justify-content: space-around;
}

.feeling {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: 1mm;
}

.feeling svg {
  width: 17mm;
  height: 17mm;
}

.feeling figcaption {
  font-size: 10pt;
}

.face-outline,
.face-mouth-open {
  fill: #fff;
}

.face-outline,
.face-line {
  stroke: #1e2433;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.face-line {
  fill: none;
}

.face-mouth-open {
  fill: #fff;
}

.face-eye {
  fill: #1e2433;
}

/* Places a child writes: answer lines and the comparison box. */
.question-text .blank {
  letter-spacing: -0.02em;
}

.compare-box {
  display: inline-block;
  width: 1.3em;
  height: 1.3em;
  border: 0.45mm solid #1e2433;
  border-radius: 1mm;
  vertical-align: -0.25em;
}

/* Compact answer key: four narrow columns, every version on as few pages as possible. */
.key-paper .paper-key-label {
  margin-bottom: 3mm !important;
}

.key-section h3 {
  font-family: Arial, sans-serif;
  font-size: 12pt;
  margin: 4mm 0 2mm;
  padding-bottom: 1mm;
  border-bottom: 0.3mm solid #c9cdd6;
}

.key-grid {
  display: grid;
  gap: 1.5mm;
}

.key-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 3mm;
}

.key-item {
  display: flex;
  align-items: baseline;
  gap: 1.5mm;
  font-size: 11pt;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.key-item .question-text {
  font-size: inherit;
}

.key-value {
  text-decoration: underline;
  text-underline-offset: 0.6mm;
}

.key-item .question-number {
  font-size: 8pt;
}

.math-paper .paper-footer {
  font-size: 8pt;
  color: #7b7f8a;
  margin-top: 5mm;
}

.math-panel [hidden],
#mixed-ops[hidden],
.math-preview [hidden] {
  display: none !important;
}

@media (max-width:1300px) {
  .math-paper {
    transform-origin: top center;
  }
  .paper-preview {
    overflow: auto;
  }
}

@media (max-width:1050px) {
  .math-layout {
    grid-template-columns: 1fr;
  }
  .math-panel {
    max-width: none;
  }
}

@media (max-width:760px) {
  .math-main {
    padding-top: 20px;
  }
  .math-intro h1 {
    font-size: 1.9rem;
  }
  .preview-head {
    flex-wrap: wrap;
  }
  .paper-preview {
    justify-items: start;
  }
  .math-paper {
    zoom: .75;
  }
}

@media (max-width:540px) {
  .math-paper {
    zoom: .52;
  }
  .paper-preview {
    padding: 14px 8px;
  }
  .math-panel,
  .preview-head {
    padding: 17px;
  }
}
