/* Learning Centre pages. Same ink/paper/purple as the game; Fredoka (self-hosted, SIL OFL) for headings. */
@font-face { font-family: 'Fredoka'; font-weight: 300 700; font-display: swap; src: url('/learn/fredoka.woff2') format('woff2'); }
:root { --ink: #2b2340; --muted: #5f5775; --paper: #fff8ec; --purple: #7048e8; --link: #4c2fb5; --card: #fff; --line: #e9dfcb; --soft: #f3edff; --gold: #ffd43b; --ease: cubic-bezier(.2, .8, .2, 1); --display: 'Fredoka', ui-rounded, 'SF Pro Rounded', system-ui, sans-serif; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 12px; }
body { margin: 0; font-family: ui-rounded, 'SF Pro Rounded', system-ui, sans-serif; color: var(--ink); background: var(--paper); line-height: 1.65; font-size: 1.0625rem; overflow-wrap: break-word; }
a { color: var(--link); text-underline-offset: .18em; }
a:focus-visible, button:focus-visible { outline: 3px solid var(--purple); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--gold); color: var(--ink); }
svg { width: 1.1em; height: 1.1em; vertical-align: -.15em; margin-right: .35em; }
table, .questions, .cards { font-variant-numeric: tabular-nums; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

/* Header: edges line up with the 720px reading column. Wide: brand, sections, play / grades. Narrow: brand, play / grades / sections. */
.top { background: var(--purple); color: #fff; padding: 10px max(16px, 50% - 360px) 12px; display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: 'brand sections play' 'grades grades grades'; align-items: center; gap: 10px 12px; }
.top a { color: #fff; text-decoration: none; }
.top a:focus-visible { outline-color: #fff; }
.brand { grid-area: brand; justify-self: start; display: flex; align-items: center; gap: 9px; min-height: 44px; font-family: var(--display); font-weight: 700; font-size: 1.15rem; line-height: 1.15; }
.brand img { background: #fff; border-radius: 10px; width: 40px; height: 40px; }
.brand .name { white-space: nowrap; }
.brand .name span { display: block; font-weight: 500; font-size: .92rem; opacity: .92; }
.top .play { grid-area: play; display: inline-flex; align-items: center; min-height: 40px; background: var(--gold); color: var(--ink); padding: 0 16px; border-radius: 999px; font-weight: 700; white-space: nowrap; transition: transform .15s var(--ease); }
.top .play:hover { transform: translateY(-1px); }
.sections { grid-area: sections; display: flex; gap: 2px; }
.sections a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 8px; border-radius: 10px; font-size: .95rem; font-weight: 600; white-space: nowrap; transition: background .15s; }
.sections a:hover { background: rgba(255, 255, 255, .16); }
.sections a[aria-current] { background: rgba(0, 0, 0, .22); }
.grades { grid-area: grades; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: rgba(0, 0, 0, .18); border-radius: 14px; }
.grades a { display: flex; align-items: center; justify-content: center; min-height: 36px; border-radius: 10px; font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; transition: background .15s; }
.grades a:hover { background: rgba(255, 255, 255, .2); }
.top .grades a[aria-current] { background: #fff; color: var(--purple); font-weight: 700; }
@media (max-width: 780px) {
  .top { grid-template-columns: 1fr auto; grid-template-areas: 'brand play' 'grades grades' 'sections sections'; gap: 8px 10px; padding-bottom: 6px; }
  .sections { justify-content: space-between; }
  .sections a { padding: 0 4px; }
  .grades { gap: 2px; }
  .grades a { min-height: 40px; }
}
@media (max-width: 360px) {
  .top { padding-inline: 10px; }
  .brand { font-size: 1rem; gap: 7px; }
  .brand img { width: 34px; height: 34px; }
  .top .play { padding: 0 11px; font-size: .95rem; }
  .sections a { font-size: .82rem; padding: 0 6px; }
  .sections svg { margin-right: .25em; }
}

.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0 auto; padding: 12px 20px 0; max-width: 760px; font-size: .9rem; }
.crumbs li + li::before { content: '›'; margin-right: 4px; opacity: .6; }

main { max-width: 760px; margin: 0 auto; padding: 8px 20px 40px; }
h1, h2, h3 { font-family: var(--display); }
h1 { color: var(--purple); line-height: 1.15; margin: .35em 0 .3em; font-size: clamp(1.9rem, 6vw, 2.6rem); font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
h2 { margin-top: 1.9em; line-height: 1.25; font-size: 1.6rem; color: var(--link); font-weight: 600; text-wrap: balance; }
h3 { margin-top: 1.4em; font-size: 1.2rem; font-weight: 600; }
p, li { text-wrap: pretty; }
.lede { font-size: 1.2rem; margin-top: 0; color: #3d3556; text-wrap: pretty; }
.code { font-size: .82rem; color: var(--muted); border-top: 1px solid var(--line); margin-top: 2.2em; padding-top: 10px; }
table { border-collapse: collapse; width: 100%; margin: 1em 0; display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
th { background: var(--soft); }
.tip, .example { background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 4px 16px; margin: 1em 0; }
.example { border-color: #8ce99a; background: #f6fff7; }
.tip { background: var(--soft); border-color: #d9ccff; }
.together { background: #fff3bf; border: 2px solid #ffe066; border-radius: 16px; padding: 4px 18px 10px; }

.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.cards a { display: block; height: 100%; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; text-decoration: none; color: var(--ink); transition: transform .18s var(--ease), border-color .18s, box-shadow .18s; }
.cards a:hover, .cards a:focus-visible { border-color: var(--purple); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(112, 72, 232, .14); }
.cards strong { font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.grades-list { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.grades-list a { border-width: 2px; background: linear-gradient(180deg, var(--soft), var(--card) 55%); }
.grades-list strong { font-size: 1.3rem; color: var(--purple); }
.cards strong { display: block; color: var(--link); margin-bottom: 4px; }
.cards span { font-size: .95rem; }

.btn { display: inline-flex; align-items: center; border: 0; border-radius: 999px; padding: 10px 20px; min-height: 44px; font: inherit; font-weight: 700; background: var(--purple); color: #fff; text-decoration: none; cursor: pointer; transition: transform .15s var(--ease), background .15s; }
.btn:hover { background: var(--link); transform: translateY(-1px); }
.ad { margin: 2em 0; min-height: 100px; }
.game-box { background: var(--soft); border: 2px solid #d9ccff; border-radius: 16px; padding: 4px 18px 14px; margin: 2em 0; }
.game-box h2 { margin-top: .8em; }
/* Worksheets: one per guide at <guide>worksheet/; the page prints as it looks. */
.ws-card { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 4px 20px 16px; margin: 2em 0; }
.ws-card h2 { margin-top: .7em; }
.ws-more { font-size: .92rem; }
.ws-all { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 1.4em 0 1.6em; }
.ws-list { list-style: none; padding: 0; margin: .3em 0 1.2em; columns: 2; column-gap: 32px; font-size: 1rem; }
.ws-list li { break-inside: avoid; padding: 3px 0; }
.ws-from { margin: .2em 0 1em; font-size: .95rem; }
.ws-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin: 0 0 1.2em; }
.ws-tools label { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; }
.ws-tools input { width: 20px; height: 20px; margin: 0; accent-color: var(--purple); }
.ws-paper, .key { background: var(--card); border: 2px solid var(--line); border-radius: 16px; padding: 22px 26px; margin: 0 0 2em; }
.ws-paper { font-size: 1.125rem; }
.ws-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 16px; }
.ws-head h1 { margin: 0; font-size: 2rem; }
.ws-head p { margin: 0; font-weight: 700; }
.sheet-name { margin: 1em 0 0; font-weight: 700; }
.ws-paper h2 { margin: 1.3em 0 .2em; font-size: 1.15rem; color: var(--ink); }
.ws-sec figure.diagram { margin: .6em 0; }
/* A question and its writing blank share a cell; a long question, or one that asks to draw or explain, takes the full row. */
.questions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 24px; padding-left: 2.4em; margin: .7em 0 0; }
.questions li { display: flex; align-items: flex-end; gap: .5em; break-inside: avoid; }
.questions li::after { content: ''; flex: 1; min-width: 3.5em; height: 1.5em; border-bottom: 1.5px solid var(--ink); }
.questions li.wide, .questions li.room { grid-column: 1 / -1; display: block; }
.questions li.wide::after { display: block; height: 1.5em; }
.questions li.room::after { display: block; height: 5em; margin-top: .4em; border: 1.5px solid var(--ink); border-radius: 10px; }
.key h3 { margin: 1.2em 0 .2em; font-size: 1.05rem; }
.key ol { margin: .2em 0 0; padding-left: 2.2em; }
.key li { break-inside: avoid; }
.ws-credit { display: none; }
@media (min-width: 640px) { .key ol { columns: 2; column-gap: 28px; } }

footer { max-width: 760px; margin: 0 auto; border-top: 2px solid var(--line); text-align: center; padding: 16px 20px 32px; font-size: .9rem; }
footer .credit { font-size: .82rem; color: var(--muted); margin: .5em 0 0; }

.toc { background: var(--soft); border-radius: 12px; padding: 8px 16px 10px; margin: 1em 0 1.4em; font-size: .95rem; }
.toc ol { margin: .2em 0 0; padding-left: 1.3em; columns: 2; column-gap: 24px; }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 2em; }
.pager a { display: block; height: 100%; background: var(--card); border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px; text-decoration: none; color: var(--ink); }
.pager a:hover, .pager a:focus-visible { border-color: var(--purple); }
.pager .next { text-align: right; }
.pager span { display: block; font-size: .85rem; opacity: .7; }
.pager strong { color: var(--link); }

/* Print: a lesson prints as a handout, a worksheet as the sheet, with the key on its own page when its box is ticked (no script). */
@media print {
  body { background: #fff; font-size: 11.5pt; color: #000; }
  .top, .crumbs, footer, .ad, .game-box, .toc, .pager, figure.photo, .ws-tools, .ws-from, .ws-card, .code { display: none !important; }
  main { max-width: none; padding: 0; }
  h1, h2, h3 { color: #000; }
  h2, h3 { break-after: avoid; }
  figure, .tip, .example, .together, .key li, .questions li { break-inside: avoid; }
  .ws-paper, .key { border: 0; padding: 0; margin: 0; }
  .ws-paper { font-size: 11.5pt; }
  .key { break-before: page; }
  body:not(:has(#with-key:checked)) .key { display: none; }
  .ws-credit { display: inline; font-size: 9pt; font-weight: 400; color: #555; }
  /* Diagram fills become steps of grey, so shaded parts stay distinct on a black-and-white printer. */
  figure.diagram [fill="#ffd43b"] { fill: #e0e0e0; }
  figure.diagram [fill="#74c0fc"] { fill: #b0b0b0; }
  figure.diagram [fill="#8ce99a"] { fill: #c8c8c8; }
  figure.diagram [fill="#ffa8a8"] { fill: #989898; }
  figure.diagram [fill="#b197fc"] { fill: #808080; }
}

/* Diagrams inside guides */
figure.diagram { margin: 1.6rem 0; }
figure.diagram svg { display: block; width: 100%; max-width: 640px; height: auto; margin: 0 auto; background: #fff; border: 1px solid #dee2e6; border-radius: 12px; }
figure.diagram table { width: 100%; max-width: 640px; margin: 0 auto; }
figure.diagram figcaption { margin-top: .5rem; font-size: .9rem; text-align: center; }

figure.photo { margin: 0 0 1.4rem; }
figure.photo img { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 16px; background: var(--soft); }
figure.photo figcaption { margin-top: .4rem; font-size: .82rem; color: var(--muted); text-align: center; }
figure.diagram figcaption { color: var(--muted); }

@media (max-width: 520px) { .toc ol { columns: 1; } .pager { grid-template-columns: 1fr; } .pager .next { text-align: left; } .questions { grid-template-columns: minmax(0, 1fr); } .ws-list { columns: 1; } .ws-paper { padding: 16px 14px; } }
/* On a phone the writing blank goes under the question instead of squeezing beside it. */
@media (max-width: 640px) { .questions li:not(.wide, .room) { flex-wrap: wrap; } .questions li:not(.wide, .room)::after { flex: 1 0 100%; } }
h1 + figure.photo { margin-top: 1rem; }
figure.photo img { max-height: 340px; }
