/* Year 5 Maths: the keypad keys for decimals, minus signs and coordinates, the word-problem
   card, the Extreme topics, and the Year 5 pictures (js/maths/y5/). */

/* ---- Typed answers: a row of extra keys above the digits ---- */

.keypad-extra { grid-column: 1 / -1; display: flex; justify-content: center; gap: 12px; }
.keypad-extra .key { flex: 1; max-width: 132px; min-height: 64px; color: var(--accent); font: 800 40px/1 var(--ui); }
.keypad.has-extra .key:not(.extra) { min-height: 68px; }
.answer-box .entry, .cell.blank .entry { white-space: nowrap; }

/* ---- Word problems ---- */

.story {
  display: grid;
  gap: 10px;
  width: min(100%, 640px);
  margin: 0 auto;
  padding: 18px 22px;
  border-radius: 20px;
  background: #fffaf0;
  box-shadow: inset 0 0 0 3px #f2c14e;
  font: 400 26px/1.35 var(--book);
  text-align: left;
}
.story p { margin: 0; }
.story-table { border-collapse: collapse; justify-self: center; font: 600 20px/1.3 var(--ui); }
.story-table th, .story-table td { padding: 6px 14px; border: 2px solid var(--line); text-align: center; }
.story-table th { background: var(--accent-soft); }

/* ---- Extreme: Year 6 and beyond ---- */

.topics.advanced.y5 .topic-card.advanced { background: linear-gradient(135deg, #fff 55%, #ffe1d6); box-shadow: var(--shadow), inset 0 0 0 3px #e8692d; }

/* ---- Year 5 pictures: SVG text in the page's font ---- */

.svg-text { font-family: var(--ui); font-weight: 700; }

/* ---- number-draw.js ---- */

/* A sentence of numbers, signs, mixed numbers and one blank; it shrinks to fit, as .row does. */
.n5-expr { --most: 84px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.2em; font: 400 min(var(--most), calc(88cqw / var(--em, 6))) / 1.15 var(--book); }
.n5-expr .cell.sign { color: var(--muted); }
.n5-expr .cell.word { color: var(--muted); font-size: 0.72em; }
.n5-mixed { display: inline-flex; align-items: center; gap: 0.1em; }
.n5-mixed .frac { font-size: 0.8em; }
.n5-mixed .frac .cell.blank { display: inline-block; min-width: 1.3em; margin: 0.06em 0; padding: 0 0.15em; border-radius: 12px; line-height: 1.1; }
.work > .pic.n5-numline { max-width: 640px; }
.n5-fline { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; min-height: 0; }
.n5-fline .pic.svg { max-height: 180px; }
.n5-under { --most: 72px; }
.n5-under > .cell.sign { font-size: 0.5em; }
.work > .pic.n5-hundred { max-width: 330px; }
.n5-card { display: grid; gap: 8px; text-align: center; color: var(--muted); font: 400 32px/1.3 var(--book); }
.n5-card p { margin: 0; }
.n5-card b { color: var(--ink); font: 400 1.55em/1.1 var(--book); }
.n5-card .cell.blank { display: inline-block; font-size: 1.4em; line-height: 1.1; }
.n5-card b.sign { color: var(--muted); }
.n5-family { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 100%; }
.n5-given { padding: 6px 20px; border-radius: 16px; background: var(--accent-soft); }
.n5-given .n5-expr { --most: 44px; font-size: min(var(--most), calc(72cqw / var(--em, 6))); }

/* ---- measure-draw.js ---- */

/* ---- extreme-draw.js ---- */

/* Signs and brackets grow and shrink with their sentence (.sign alone is a fixed 64px), so a long
   sentence shrinks to one line on a phone. */
.x5expr .cell.sign, .x5frac .cell.sign, .n5-expr .cell.sign { font-size: 0.9em; }
.x5expr .cell.bracket { padding: 0; color: var(--muted); }
/* Words like "of" sit smaller: in the book font they stand taller than the digits. */
.x5expr .cell.word, .x5frac .cell.word { font-size: 0.72em; }
.x5frac { align-items: center; }
.x5frac .mixed { display: inline-flex; align-items: center; gap: 0.06em; }
.x5frac .frac { font-size: 0.78em; }
.x5frac .frac-top .cell.blank { display: inline-block; min-width: 1.4em; padding: 0 0.1em; border-width: 2px; border-radius: 10px; }
.x5note { display: grid; gap: 2px; text-align: center; font: 400 24px/1.3 var(--book); }
.x5note p { margin: 0; }
.x5chart { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 5px; width: min(100%, 580px); }
.chart-cell { display: grid; place-items: center; min-height: 44px; border-radius: 10px; background: var(--accent-soft); font: 700 21px/1 var(--ui); }
.chart-cell.off { background: transparent; }
.x5seq { display: grid; justify-items: center; gap: 22px; font: 400 44px/1.2 var(--book); }
.x5seq-terms { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.x5seq-term { min-width: 2em; padding: 4px 12px; border: 3px solid var(--line); border-radius: 14px; background: #fff; text-align: center; }
.x5seq-more { align-self: end; color: var(--muted); }
.x5seq-ask { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px; }
.x5machine { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 14px; font: 400 46px/1.2 var(--book); }
.x5m-box { display: grid; place-items: center; min-width: 2.2em; min-height: 1.6em; padding: 2px 12px; border: 3px solid var(--ink); border-radius: 14px; background: #fff; }
.x5m-box .cell.blank { border: 0; padding: 0; background: none; }
.x5m-step { padding: 6px 16px; border-radius: 999px; background: #ffe7c2; font-weight: 700; }
.x5m-arrow { color: var(--muted); }
.x5m-label { color: var(--muted); font-size: 0.6em; font-weight: 700; text-transform: uppercase; }
.work > .pic.svg.x5plane { max-width: 440px; }
.work > .pic.svg.x5angles { max-width: 480px; }
.work > .pic.svg.x5bag { max-width: 360px; }
.work > .pic.svg.x5spin { max-width: 300px; }
.work > .pic.svg.x5trip { max-width: 560px; }
.work > .pic.svg.x5sticks { max-width: 620px; }
.hint .x5note { font-size: 20px; }
/* The train timetable (six rows) packs tighter than a bus one so the card fits above the keypad. */
.story:has(.story-table tr:nth-child(6)) { gap: 6px; padding-block: 12px; }
.story-table:has(tr:nth-child(6)) :is(th, td) { padding: 3px 12px; }

@media (max-width: 600px) {
  .keypad-extra { gap: 6px; }
  .keypad-extra .key { min-height: 46px; font-size: 30px; }
  .keypad.has-extra .key:not(.extra) { min-height: 50px; }
  .story { padding: 12px 14px; font-size: 20px; }
  .story-table { font-size: 16px; }
  .n5-expr { --most: 44px; }
  .n5-card { font-size: 22px; }
  .work > .pic.n5-hundred { max-width: 230px; }
  .n5-given .n5-expr { --most: 30px; }
  .x5note { font-size: 18px; }
  .chart-cell { min-height: 30px; border-radius: 6px; font-size: 14px; }
  .x5chart { gap: 3px; }
  .x5seq { gap: 10px; font-size: 24px; }
  .x5machine { gap: 6px; font-size: 22px; }
  .x5m-step { padding: 4px 10px; }
  /* The number line and the grid shrink to a third of their size: bigger numbers, and on the grid
     only the even ones, bigger points and labels. */
  .x5line .x5num { font-size: 34px; }
  .x5line .x5mark { font-size: 44px; }
  .x5plane .x5num { font-size: 30px; }
  .x5plane .x5num.odd { display: none; }
  .x5plane .x5pt { font-size: 40px; stroke-width: 6px; }
  .x5plane .x5dot { r: 14px; }
  .story-table:has(tr:nth-child(6)) :is(th, td) { padding: 2px 6px; white-space: nowrap; }
}

/* An iPhone SE: a timetable of four trains is too wide for the card, so it packs tighter, and long
   stop names may wrap. */
@media (max-width: 380px) {
  .story { padding: 10px; }
  .story-table { font-size: 13px; }
  .story-table :is(th, td), .story-table:has(tr:nth-child(6)) :is(th, td) { padding: 2px 3px; }
  .story-table :is(th, td):first-child, .story-table:has(tr:nth-child(6)) :is(th, td):first-child { white-space: normal; }
}
