/* The Ontario final mark calculator (/ontario-final-mark-calculator), in the site's drawn world (DESIGN-SITE.md) and the
   course home's paper language (course-home.css): the night table, the calculator on one ivory sheet, the answer on a
   paper slip set large in the display face with an ink stamp for its level. Only the site's tokens and two families; no
   gradients, no cards, no icons. Reads with scripts off; prints the worked examples with the address at the foot. */

.fm { color: var(--on-night); }
.fm p { margin: 0; }
.fm [hidden] { display: none !important; }
.fm-wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }

/* ---- the first screen, on the table ---- */
.fm-top { padding: 22px 0 40px; }
.fm-top h1 {
  margin: 0; max-width: 16ch; color: var(--on-night);
  font: 500 clamp(2.125rem, 1.45rem + 3vw, 3.75rem)/1.06 var(--display); font-variation-settings: "opsz" 96;
  letter-spacing: -0.02em; text-wrap: balance;
}
.fm .fm-rule-line { margin-top: 12px; max-width: 34em; color: var(--on-night-2); font: 400 var(--t-body)/1.6 var(--text); text-wrap: pretty; }
.fm-top > .fm-wrap > .fm-src { margin-top: 6px; max-width: 40em; color: var(--on-night-3); }
.fm-top > .fm-wrap > .fm-src a { color: var(--on-night-2); }
.fm .fm-src { font-size: var(--t-small); line-height: 1.5; overflow-wrap: anywhere; }

/* the calculator: one ivory sheet */
.fm-calc {
  margin-top: 22px; padding: 18px 16px 20px; max-width: 40rem;
  background: var(--sheet-c); color: var(--ink-2); border-radius: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 28px 60px -18px rgba(0, 0, 0, 0.65);
}
.fm-calc :focus-visible, .fm-sheet :focus-visible { outline: 2px solid var(--focus-sheet); outline-offset: 3px; border-radius: 4px; }

.fm-rules { margin: 0; padding: 0; border: 0; min-width: 0; }
.fm-rules legend, .fm-q h2 { padding: 0; color: var(--ink); }
.fm-rules legend { font: italic 400 var(--t-small)/1.5 var(--display); color: var(--pencil); margin-bottom: 6px; }
.fm-rules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.fm-rule { position: relative; display: flex; }
.fm-rules legend { grid-column: 1 / -1; }
.fm-rule input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.fm-rule > span {
  display: flex; flex-direction: column; justify-content: center; width: 100%; min-height: 48px; padding: 6px 10px;
  border: 1px solid var(--ivory-3); border-radius: 10px; background: var(--paper-c); color: var(--ink-2);
  font: 600 var(--t-small)/1.25 var(--text); transition: border-color var(--t-quick) var(--e-land);
}
.fm-rule__w { font-weight: 400; color: var(--pencil); font-variant-numeric: lining-nums tabular-nums; }
.fm-rule input:checked + span { border: 2px solid var(--ink); padding: 5px 9px; color: var(--ink); }
.fm-rule input:focus-visible + span { outline: 2px solid var(--focus-sheet); outline-offset: 3px; }
.fm .fm-weights { margin-top: 10px; font-size: var(--t-small); line-height: 1.5; color: var(--ink-2); }

.fm-own { margin-top: 8px; }
.fm-own summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--pencil); font: italic 400 var(--t-small)/1.4 var(--display); }
.fm-own summary:hover { color: var(--ink); }
.fm-own__in { padding: 4px 0 6px; }
.fm .fm-hint { font-size: var(--t-small); color: var(--ink-2); margin-bottom: 8px; }
.fm-own__fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 10px 12px; align-items: end; }
.fm .fm-own__status { margin-top: 8px; min-height: 1.5em; font-size: var(--t-small); line-height: 1.5; color: var(--ink); font-weight: 600; }

/* the questions */
.fm-q { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--ivory-3); }
.fm-q h2 { margin: 0 0 10px; font: 540 var(--t-h3)/1.2 var(--display); letter-spacing: -0.008em; text-wrap: balance; }
.fm-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.fm-field { display: flex; flex-direction: column; justify-content: flex-end; }
.fm-field label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; margin-bottom: 4px; color: var(--ink); font: 600 var(--t-small)/1.4 var(--text); }
.fm-w, .fm-unit { color: var(--pencil); font-weight: 400; font-variant-numeric: lining-nums tabular-nums; }
.fm-field input {
  display: block; width: 100%; height: 56px; padding: 0 14px; border: 1px solid var(--ink-2); border-radius: 8px;
  background: var(--paper-c); color: var(--ink); font: 500 1.375rem/1 var(--text); font-variant-numeric: lining-nums tabular-nums;
  -webkit-appearance: none; appearance: none;
}
.fm-field--w input { height: 48px; font-size: 1.125rem; }
.fm-field input:focus-visible { outline: 3px solid var(--focus-sheet); outline-offset: 1px; border-color: var(--ink); }
.fm-field input[aria-invalid="true"] { border: 2px solid var(--ink); background: var(--ivory); }
.fm .fm-range { margin-top: 8px; font-size: var(--t-micro); line-height: 1.5; color: var(--pencil); }
.fm .fm-using { font-size: var(--t-small); line-height: 1.5; margin-bottom: 12px; }

/* the answer: a paper slip, the mark set large, the level pressed on it in ink. Its height is kept, so nothing moves. */
.fm .fm-slip {
  position: relative; margin-top: 14px; min-height: 16rem; padding: 16px 18px 16px;
  background: var(--paper-c); color: var(--ink); border-radius: 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 10px 22px -12px rgba(0, 0, 0, 0.45);
}
.fm .fm-slip__kind { font: italic 400 var(--t-small)/1.5 var(--display); color: var(--pencil); }
.fm .fm-big {
  margin-top: 2px; min-height: 4.5rem; color: var(--ink);
  font: 560 clamp(3.5rem, 2.6rem + 4vw, 4.5rem)/1 var(--display); font-variation-settings: "opsz" 96;
  font-variant-numeric: lining-nums tabular-nums; letter-spacing: -0.02em;
}
.fm .fm-big.is-empty { color: var(--ivory-3); }
.fm .fm-big.is-words { display: flex; align-items: center; font-size: clamp(2rem, 1.6rem + 2vw, 2.5rem); line-height: 1.1; }
.fm .fm-slip__line { margin-top: 8px; font: 400 var(--t-body)/1.5 var(--text); color: var(--ink-2); max-width: 30em; }
.fm .fm-slip__note { margin-top: 4px; font-size: var(--t-small); line-height: 1.5; color: var(--ink); font-weight: 600; }
.fm .fm-stamp {
  float: right; margin: 4px 0 8px 14px; padding: 6px 12px 7px; display: flex; flex-direction: column; align-items: center;
  border: 2px solid var(--ink); border-radius: 4px; box-shadow: inset 0 0 0 2px var(--paper-c), inset 0 0 0 3px var(--ink);
  color: var(--ink); opacity: 0.86; transform: rotate(-4deg); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap;
}
.fm-stamp span:first-child { font: italic 500 1.0625rem/1.1 var(--display); }
.fm-stamp span:last-child { font: 600 var(--t-micro)/1.3 var(--text); }
.fm-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (min-width: 600px) {
  .fm-calc { padding: 24px 28px 26px; }
  .fm-fields { grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); }
  .fm .fm-slip { min-height: 12rem; }
}
@media (min-width: 900px) {
  .fm-top { padding: 48px 0 64px; }
  .fm-top .fm-wrap { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); column-gap: clamp(32px, 5vw, 72px); align-items: start; }
  .fm-top h1, .fm-top .fm-rule-line, .fm-top > .fm-wrap > .fm-src { grid-column: 1; }
  .fm-top .fm-calc { grid-column: 2; grid-row: 1 / span 4; margin-top: 0; max-width: none; }
}

/* ---- the sheet to read ---- */
.fm-band { padding: 0 8px 72px; }
.fm-sheet {
  width: min(860px, 100%); margin: 0 auto; padding: clamp(20px, 5.5vw, 64px);
  background: var(--sheet-c); color: var(--ink-2); border-radius: 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 28px 60px -18px rgba(0, 0, 0, 0.65);
  font: 400 var(--t-body)/1.65 var(--text);
}
.fm-sheet a { color: var(--ink); }
.fm-sheet h2 {
  margin: 0 0 12px; color: var(--ink); font: 540 clamp(1.625rem, 1.3rem + 1.3vw, 2.25rem)/1.15 var(--display);
  font-variation-settings: "opsz" 48; letter-spacing: -0.012em; text-wrap: balance;
}
.fm-sheet h3 { margin: 26px 0 8px; color: var(--ink); font: 560 var(--t-h3)/1.25 var(--display); }
.fm-sheet .fm-q { margin-top: 0; padding-top: 0; border-top: 0; }
.fm-part, .fm-next, .fm-close { margin-top: 44px; padding-top: 28px; border-top: 1px solid var(--ivory-3); }
.fm-part > p, .fm-close > p { max-width: 36em; }
.fm-part > p + p, .fm-part > .fm-src + p, .fm-part > p + .fm-tablewrap, .fm-part > .fm-src + .fm-tablewrap { margin-top: 14px; }
.fm-part .fm-src, .fm-close .fm-src { margin-top: 6px; color: var(--pencil); }
.fm-part .fm-src a { color: var(--ink-2); }
.fm .fm-aside { margin-top: 8px; font-size: var(--t-small); color: var(--ink-2); }
.fm-check { display: flex; align-items: center; gap: 12px; min-height: 48px; margin-top: 12px; }
.fm-check input { width: 24px; height: 24px; margin: 0; accent-color: var(--ink); flex: none; }
.fm-check label { color: var(--ink); font-weight: 600; cursor: pointer; }
.fm-split__w { margin-top: 10px; max-width: 24rem; }

.fm-tablewrap { overflow-x: auto; border-radius: 4px; margin-top: 14px; }
.fm-table { border-collapse: collapse; min-width: 100%; font-size: var(--t-small); font-variant-numeric: lining-nums tabular-nums; }
.fm-table caption { text-align: left; padding-bottom: 10px; color: var(--pencil); font: italic 400 var(--t-small)/1.5 var(--display); caption-side: top; }
.fm-table th, .fm-table td { text-align: right; padding: 8px 6px; border-bottom: 1px solid var(--ivory-3); white-space: nowrap; }
.fm-table thead th { color: var(--ink); font-weight: 600; }
.fm-table thead tr:last-child th { border-bottom: 2px solid var(--ink); }
.fm-table thead th[scope="colgroup"] { text-align: center; font: italic 400 var(--t-small)/1.4 var(--display); color: var(--pencil); border-bottom: 0; padding-bottom: 0; }
.fm-table .fm-corner { border-bottom: 0; }
.fm-table tbody th { color: var(--ink); font-weight: 600; }
.fm-table th:first-child { text-align: left; }
.fm-table td { color: var(--ink-2); }
.fm-table--levels th, .fm-table--levels td { text-align: left; white-space: normal; vertical-align: top; padding-right: 14px; }
.fm-table--levels td:nth-child(2) { white-space: nowrap; }
.fm-subs { color: var(--pencil) !important; }
@media (max-width: 599px) { .fm-table--levels .fm-subs, .fm-table--levels thead th:last-child { display: none; } }

.fm-formula { max-width: 40em; }
.fm-formula p + p { margin-top: 10px; }
.fm-formula strong { color: var(--ink); }
.fm-next p { max-width: 36em; color: var(--ink); font: 500 var(--t-lead)/1.5 var(--text); }
.fm-next p + p { margin-top: 12px; }
.fm-close h2 { font-size: var(--t-h3); }
.fm-sources { margin: 12px 0 0; padding-left: 1.25em; font-size: var(--t-small); overflow-wrap: anywhere; }
.fm-sources li + li { margin-top: 6px; }
.fm .fm-teacher { margin-top: 18px; font-size: var(--t-small); color: var(--pencil); }
.fm .fm-report { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 4px 24px; }
.fm-report a { display: inline-flex; align-items: center; min-height: 44px; }
.fm-printfoot { display: none; }

/* ---- on paper: the worked examples, the formula, the rules and the levels, with the address at the foot ---- */
@media print {
  body.tc { background: #fff !important; }
  .tc-usage, .fm-calc, #q2, #split, .fm-next, .fm-teacher, .fm-report { display: none !important; }
  .fm, .fm-sheet, .fm-sheet p, .fm-table td, .fm-src, .fm-rule-line { color: #000 !important; }
  .fm-top { padding: 0 0 8pt; }
  .fm-top h1 { color: #000; font-size: 22pt; max-width: none; }
  .fm-top .fm-wrap { display: block; width: auto; }
  .fm-top > .fm-wrap > .fm-src a, .fm-sheet a { color: #000; }
  .fm-band { padding: 0; }
  .fm-sheet { width: auto; padding: 0; background: #fff; box-shadow: none; font-size: 10.5pt; line-height: 1.45; }
  .fm-sheet h2 { color: #000; font-size: 15pt; break-after: avoid; }
  .fm-sheet h3 { color: #000; font-size: 12pt; break-after: avoid; }
  .fm-part, .fm-close { margin-top: 14pt; padding-top: 10pt; }
  .fm-sheet > .fm-part:first-of-type { margin-top: 0; border-top: 0; }
  .fm-tablewrap { overflow: visible; break-inside: avoid; }
  .fm-table th, .fm-table td { padding: 3pt 5pt; border-color: #999; }
  .fm-subs, .fm-table--levels thead th:last-child { display: table-cell !important; }
  .fm .fm-printfoot { display: block; margin-top: 18pt; padding-top: 6pt; border-top: 1px solid #888; font-size: 9pt; color: #000; }
}

/* round 2 (review R14): the rule in use on each slip, what the number is and is not, and what the attendance box means */
.fm .fm-slip__rule { margin-top: 2px; font-size: var(--t-small); line-height: 1.5; color: var(--ink-2); font-variant-numeric: lining-nums tabular-nums; }
.fm .fm-judgement { margin-top: 14px; max-width: 36em; font-size: var(--t-small); line-height: 1.55; color: var(--ink-2); }
.fm-calc .fm-src, .fm-hint__src { color: var(--pencil); }
.fm-calc .fm-src { margin-top: 4px; }
.fm-calc .fm-src a, .fm-hint__src a { color: var(--ink-2); }
.fm .fm-hint--att { margin-top: 8px; max-width: 36em; font-size: var(--t-small); line-height: 1.5; color: var(--ink-2); overflow-wrap: anywhere; }
.fm-hint__src { display: block; margin-top: 2px; font-size: var(--t-micro); }
