/* Steply website. Light, friendly, notebook colours: ink blue (the pen), highlighter yellow, paper cream. */
:root {
  --ink: #1f3a8a; --ink-2: #2f4fb0; --hl: #f4c430; --hl-soft: #fff2b8;
  --bg: #f6f3ea; --card: #ffffff; --paper: #fbf7ec; --text: #1d2433; --muted: #5d6578; --line: #e3ddcc;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 Inter, system-ui, sans-serif; overflow-x: hidden; }
button, input, select { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.top { display: flex; align-items: center; gap: 18px; padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
       position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.logo { width: 30px; height: 30px; border-radius: 50%; }
.word { font: 700 32px/1 Caveat, cursive; letter-spacing: .5px; }
.subjects { display: flex; gap: 4px; }
.subjects a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 15px; }
.subjects a.on { background: var(--hl-soft); color: var(--ink); }
.lang { margin-left: auto; }
.lang select { border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; background: var(--card); font-size: 15px; }

main { max-width: 1140px; margin: 0 auto; padding: 0 20px; }

/* ---------- hero: the problem box ---------- */
.hero { text-align: center; padding: 34px 0 20px; }
h1 { margin: 0 0 20px; font-size: 32px; line-height: 1.2; font-weight: 800; letter-spacing: -.5px; }
h1 .pen { font: 700 40px/1.1 Caveat, cursive; color: var(--ink); letter-spacing: 0; }
.ask { display: flex; gap: 10px; max-width: 640px; margin: 0 auto; }
#eq { flex: 1; min-width: 0; padding: 14px 16px; font-size: 20px; border: 2px solid var(--line); border-radius: var(--radius);
      background: var(--card); outline: none; transition: border-color .15s; }
#eq:focus { border-color: var(--ink-2); }
#playBtn { padding: 0 26px; border: 0; border-radius: var(--radius); background: var(--ink); color: #fff; font-weight: 800; font-size: 18px; cursor: pointer; }
#playBtn:hover { background: var(--ink-2); }
#status { max-width: 640px; margin: 12px auto 0; color: var(--text); font-weight: 600; }
#status:empty { display: none; }
#status:not(:empty) + .examples { display: none; }   /* the note brings its own examples */
#status { background: var(--hl-soft); border-radius: 12px; padding: 10px 14px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }

.chip, button.try { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 5px 12px; font-size: 15px;
        cursor: pointer; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip:hover, button.try:hover { border-color: var(--ink-2); color: var(--ink); background: #f3f6ff; }
button.try { margin: 6px 4px 0; font-weight: 400; }

/* ---------- player ---------- */
.player { margin: 8px 0 30px; scroll-margin-top: 70px; }
.topics, #status { scroll-margin-top: 70px; }
.stage { display: flex; justify-content: center; }
.stage canvas { display: block; width: 100%; height: auto; border-radius: var(--radius); background: var(--paper);
                box-shadow: 0 10px 30px rgba(40, 35, 20, .16), 0 1px 3px rgba(0, 0, 0, .08); }
.stage:fullscreen { background: #111; align-items: center; }
.stage:fullscreen canvas { max-width: none !important; width: min(100vw, calc(100vh * var(--ar, 1.7778))); border-radius: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; align-items: center; margin-top: 14px; }
.ghost { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 14px; cursor: pointer; font-weight: 600; font-size: 15px; }
.ghost:hover { border-color: var(--ink-2); }
.tog { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 15px; }
.tog input { width: 18px; height: 18px; accent-color: var(--ink); }
.tog select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 6px; background: var(--card); }

/* ---------- topic menu ---------- */
.topics { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px 24px 26px; margin-bottom: 30px; }
.topics-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
h2 { margin: 0; font-size: 24px; }
#findTopic { flex: 0 1 320px; min-width: 0; padding: 9px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.areas { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; }
.areas button { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 8px 14px; cursor: pointer; font-size: 15px; }
.areas button b { color: var(--ink); margin-right: 3px; }
.areas button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.areas button.on b { color: var(--hl); }
.lessons { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0 26px; }
.lessons h3 { grid-column: 1 / -1; margin: 18px 0 2px; font-size: 15px; text-transform: uppercase; letter-spacing: .8px; color: var(--ink); }
.lesson { padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.lt { font-weight: 600; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips .chip { font-size: 14px; padding: 3px 10px; }
.none { color: var(--muted); grid-column: 1 / -1; }

.foot { text-align: center; color: var(--muted); padding: 10px 20px 40px; }
.foot a { color: var(--ink); }
.foot .small { font-size: 14px; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .top { padding: 10px 16px; gap: 10px; }
  .word { font-size: 28px; }
  .subjects a { padding: 5px 10px; }
  main { padding: 0 16px; }
  .hero { padding: 22px 0 14px; }
  h1 { font-size: 23px; margin-bottom: 14px; }
  h1 .pen { font-size: 31px; }
  .ask { gap: 8px; }
  #eq { font-size: 18px; padding: 12px 14px; }
  #playBtn { padding: 0 18px; font-size: 17px; }
  .examples .chip:nth-child(n+5) { display: none; }   /* four examples are enough on a phone */
  .examples { gap: 6px; }
  .chip { font-size: 14px; }
  .stage canvas { border-radius: 10px; }
  .controls { gap: 8px 10px; }
  .topics { padding: 16px; border-radius: 14px; }
  #findTopic { flex-basis: 100%; }
  .areas button { padding: 6px 10px; font-size: 14px; }
  .lessons { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- lesson, problem and course pages (site/pages.py) ---------- */
.hero.small { text-align: left; padding: 22px 0 14px; }
.hero.small h1 { margin-bottom: 6px; font-size: 30px; }
.hero.small .ask { margin: 14px 0 0; }
.hero.small #status { margin-left: 0; }
.sub { margin: 0 0 6px; color: var(--muted); }
.sub a { color: var(--ink); }
.crumbs { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--ink); text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.crumbs span { margin: 0 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 20px 24px; margin: 0 0 20px; }
.card h2 { margin: 0 0 10px; font-size: 21px; }
.btn { display: inline-block; padding: 10px 18px; border-radius: var(--radius); background: var(--ink); color: #fff; font-weight: 700; text-decoration: none; }
.btn:hover { background: var(--ink-2); }
.acts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 0; }
.small { font-size: 14px; color: var(--muted); }
/* the solution as text: sentences + the written rows in the pen's hand */
.sol h3 { display: flex; align-items: center; gap: 10px; margin: 22px 0 8px; font-size: 17px; }
.sol h3.q { color: var(--muted); font-size: 15px; text-transform: uppercase; letter-spacing: .5px; }
.sol .num { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 6px; background: var(--ink); color: #fff; font-size: 14px; }
.sol p { margin: 4px 0; }
.m { font: 400 26px/1.5 Caveat, cursive; color: var(--ink); margin: 6px 0; padding: 4px 14px; background: var(--paper); border-left: 3px solid var(--hl);
     border-radius: 6px; overflow-x: auto; white-space: nowrap; }
.m.side { margin-left: 28px; color: #b9521b; border-left-color: #f0c9a8; font-size: 23px; }
.m.ans { display: inline-block; border: 2px solid var(--ink); border-left-width: 2px; background: var(--hl-soft); }
.m s { text-decoration: none; background: linear-gradient(to top right, transparent 45%, #c0392b 45%, #c0392b 55%, transparent 55%); }
.m sup, .m sub { font-size: .65em; }
.fr { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 3px; line-height: 1.05; }
.fr > span:first-child { border-bottom: 2px solid currentColor; padding: 0 3px; }
.fr > span:last-child { padding: 0 3px; }
.rad { border-top: 2px solid currentColor; padding: 0 2px; margin-left: 1px; }
.ri { font-size: .55em; margin-right: -4px; }
.answer { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
.answer > span { font-weight: 800; color: var(--ink); }
.answer .m { margin: 0; border: 2px solid var(--ink); background: var(--hl-soft); }
.careful { border-left: 5px solid #c0392b; }
.careful b { color: #c0392b; margin-right: 6px; }
.turn .m { display: inline-block; }
details { margin: 6px 0; }
summary { cursor: pointer; color: var(--ink); font-weight: 600; }
.pn { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 20px; }
.pn a { color: var(--ink); font-weight: 600; text-decoration: none; }
.pn .next { margin-left: auto; text-align: right; }
.plist { columns: 2; padding-left: 20px; }
.plist li, .prac li { margin: 4px 0; break-inside: avoid; }
.prac a { color: var(--text); }
.prac details .m { display: inline-block; font-size: 22px; }
.method li { margin: 4px 0; font-weight: 600; }
.sol.ex { border-top: 1px solid var(--line); padding-top: 4px; margin-top: 12px; }
.exh { font-size: 19px !important; }
.exh a { color: var(--text); }
.lv { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--bg); padding: 2px 8px; border-radius: 999px; }
.lessons-list li { margin: 8px 0; }
.lessons-list a, .all-courses a { color: var(--ink); text-decoration: none; }
.all-courses ul { columns: 3; padding-left: 20px; }
.lt a { color: var(--text); text-decoration: none; }
.lt a:hover { color: var(--ink); text-decoration: underline; }
.courses { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; font-size: 14px; margin-bottom: 12px; }
.video .yt { position: relative; aspect-ratio: 16 / 9; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: var(--radius); }
.ws { display: none; }
@media (max-width: 640px) {
  .card { padding: 16px; border-radius: 14px; }
  .hero.small h1 { font-size: 24px; }
  .m { font-size: 22px; }
  .plist, .all-courses ul { columns: 1; }
  .pn { flex-direction: column; }
}
/* printed worksheet (lesson pages): problems with room to work, answer key on its own page */
@media print {
  body { background: #fff; }
  body > *:not(main), main > *:not(.ws) { display: none !important; }
  .ws { display: block; font: 15px/1.4 Inter, sans-serif; color: #000; }
  .ws h1 { font-size: 24px; margin: 0 0 6px; }
  .ws .wsn { margin: 0 0 18px; }
  .ws > ol > li { margin: 0 0 70px; break-inside: avoid; }
  .ws .key { break-before: page; }
  .ws .key li { margin: 4px 0; }
  .ws .m { background: none; border: 0; padding: 0; font-size: 20px; color: #000; }
}

/* ---------- math keys + live preview under the problem box ---------- */
.preview { max-width: 640px; margin: 8px auto 0; min-height: 30px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 14px; }
.hero.small .preview, .hero.small .keys { margin-left: 0; justify-content: flex-start; }
.preview .m { margin: 0; padding: 0 12px; font-size: 25px; }
.preview:empty { display: none; }
.hint { font-size: 14px; color: var(--muted); }
.hint.ok { color: #1e8449; font-weight: 600; }
.hint a { color: inherit; }
.keys { max-width: 720px; margin: 8px auto 0; }
.krow { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.hero.small .krow { justify-content: flex-start; }
.krow.more { margin-top: 6px; }
.key { min-width: 42px; height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card);
       font: 600 17px/1 Inter, sans-serif; color: var(--ink); cursor: pointer; touch-action: manipulation; }
.key:hover { border-color: var(--ink-2); }
.key:active { background: var(--hl-soft); }
.tog-more { font-size: 14px; color: var(--muted); }
@media (max-width: 640px) {
  .key { min-width: 38px; height: 40px; padding: 0 8px; font-size: 16px; }
  .krow { gap: 5px; }
}
