/* Learn (learn.js): the strategy list, a lesson with its worked example, and practice. Built on
   site.css's tokens and board.css's board, so a lesson board is the real board on paper in both
   themes. Each group (the solving skills, then each difficulty) wears one player color (--tc),
   as tiles with white digits. */
:root { --pat: #1b5fd1; --pat-alt: #c24f00; --good: #1f6b45; --bad: #b3261e; --pick: #19635a; }
.learn-main { padding-bottom: 64px; }
.learn-loading { padding: 40px 0; text-align: center; }

/* ---------------------------------------------------------------- the list */
.learn-head .lead { max-width: 30em; }
.meter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0 0; }
.meter-tiles { display: grid; grid-template-columns: repeat(21, 14px); gap: 4px; }
.meter-tiles i { height: 14px; border-radius: 4px; background: var(--surface); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--tc) 55%, var(--line)); }
.meter-tiles i.on { background: var(--tc); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .2); }
.meter b { font-family: var(--display); font-weight: 600; font-size: 19px; }
@media (max-width: 420px) { .meter-tiles { grid-template-columns: repeat(21, 11px); gap: 3px; } .meter-tiles i { height: 11px; border-radius: 3px; } }

/* the skills' mark beside their name, where a difficulty has its squares */
.lv.scan { display: inline-block; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; }
.tier-head h2 .lv.scan { width: 17px; height: 17px; }

/* Continue: the next strategy on a card edged in the eight colors, its pattern as a picture */
.learn-next { position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px 22px; padding: 26px 24px 22px; box-shadow: var(--lift); }
.learn-next::before { content: ""; position: absolute; inset: 0 0 auto; height: 6px; background: linear-gradient(90deg, var(--p0) 0 12.5%, var(--p1) 0 25%, var(--p2) 0 37.5%, var(--p3) 0 50%, var(--p4) 0 62.5%, var(--p5) 0 75%, var(--p6) 0 87.5%, var(--p7) 0); }
.next-art { width: 104px; rotate: -4deg; filter: drop-shadow(0 10px 12px rgba(40, 26, 6, .2)); }
.next-art svg { display: block; width: 100%; height: auto; overflow: visible; }
.next-eyebrow { margin: 0 0 4px; font-size: 14px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.learn-next h2 { margin: 0 0 6px; font-size: clamp(26px, 4vw, 32px); }
.next-short { margin: 0 0 10px; color: var(--muted); font-size: 16px; line-height: 1.4; }
.next-short .lv { color: var(--ink); margin-right: 4px; vertical-align: 1px; }
.learn-next .s-state { justify-content: flex-start; }
.learn-next.all-done { grid-template-columns: auto minmax(0, 1fr); }
.learn-next.all-done .next-art { width: 92px; rotate: 0deg; }
.learn-rule { margin: 14px 4px 34px; color: var(--muted); font-size: 16px; max-width: 46em; }
@media (max-width: 640px) {
  .learn-next { grid-template-columns: auto minmax(0, 1fr); padding: 24px 18px 18px; column-gap: 16px; }
  .next-art { width: 76px; align-self: start; }
  .next-go { grid-column: 1 / -1; margin-top: 10px; }
}

/* the four difficulties, each a column of strategies on a computer */
.tier-groups { display: grid; gap: 30px 28px; }
@media (min-width: 900px) {
  .tier-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  /* the solving skills across the top, two columns of three, then the difficulties in pairs */
  .tier-group:first-child { grid-column: 1 / -1; }
  .tier-group:first-child .strategies { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-flow: column; grid-template-rows: repeat(3, auto); column-gap: 28px; }
}
.tier-head { display: grid; gap: 2px; margin: 0 2px 12px; }
.tier-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 24px; }
.tier-head h2 .lv { color: var(--tc); }
.tier-head p { margin: 0; color: var(--muted); font-size: 16px; }
.strategies { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.strategy { position: relative; display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 12px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.strategy:hover { border-color: color-mix(in srgb, var(--ink) 28%, var(--line)); box-shadow: var(--lift); }
.s-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.s-title { font-family: var(--display); font-size: 20px; font-weight: 600; line-height: 1.25; }
.s-short { color: var(--muted); font-size: 15px; line-height: 1.35; }
.strategy .go-arrow { margin-left: -4px; }

/* a strategy's tile: its number, outlined while new, tinted while practicing, filled and
   ticked once mastered */
.s-tile { --tc: #0B5CAD; flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; font-family: var(--display); font-size: 20px; font-weight: 600; color: var(--tc); border: 2px solid color-mix(in srgb, var(--tc) 60%, var(--surface)); background: var(--surface); }
.s-tile.st-practicing { background: color-mix(in srgb, var(--tc) 13%, var(--surface)); border-color: var(--tc); }
.s-tile.st-mastered { background: var(--tc); border-color: var(--tc); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .22); }
.s-tile svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.s-tile.big { width: 64px; height: 64px; border-radius: 19px; font-size: 28px; }
.s-tile.big svg { width: 32px; height: 32px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .s-tile:not(.st-mastered) { color: color-mix(in srgb, var(--tc) 50%, #fff); border-color: color-mix(in srgb, var(--tc) 55%, #fff); }
  :root:not([data-theme="light"]) .s-tile.st-practicing { background: color-mix(in srgb, var(--tc) 30%, var(--surface)); }
  :root:not([data-theme="light"]) .tier-head h2 .lv { color: color-mix(in srgb, var(--tc) 50%, #fff); }
}

/* where a strategy stands: New, the run as five pips, or Mastered */
.s-state { flex: none; display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 15px; font-weight: 800; color: var(--muted); white-space: nowrap; }
.s-new { padding: 3px 11px; border-radius: 999px; background: var(--surface-2); color: var(--ink); font-size: 14px; }
.s-done { color: var(--ok); }
.s-done svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.pips { display: inline-flex; gap: 4px; }
.pips i { width: 10px; height: 10px; border-radius: 3px; background: var(--surface-2); box-shadow: inset 0 0 0 1.5px var(--line); }
.pips i.on { background: var(--ok); box-shadow: none; }
@media (max-width: 420px) {
  .strategy { gap: 12px; padding: 10px 12px; }
  .strategy .go-arrow { display: none; }
  .s-run > span:last-child { display: none; }
}

/* ---------------------------------------------------------------- a lesson */
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; margin: 4px 0 6px -6px; padding: 0 10px 0 4px; border-radius: 12px; color: var(--ink); font-weight: 800; text-decoration: none; }
.back:hover { background: var(--surface-2); }
.back svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.lesson-head, .practice-head { display: flex; align-items: flex-start; gap: 18px; margin: 0 0 22px; }
.lesson-head .s-tile.big { margin-top: 4px; }
.lesson-title { flex: 1; min-width: 0; }
.lesson-state { margin-top: 10px; }
.lesson-state .s-state { justify-content: flex-start; }
.practice-head .run { margin-top: 12px; }
@media (max-width: 480px) { .lesson-head { gap: 14px; } .lesson-head .s-tile.big { width: 52px; height: 52px; font-size: 24px; border-radius: 16px; } }
.lesson-kicker { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; color: var(--muted); font-size: 15px; font-weight: 800; }
.lesson-kicker .lv { color: var(--tc); }
.lesson-head h1, .practice-head h1 { margin: 0; font-size: clamp(34px, 6vw, 50px); line-height: 1.05; letter-spacing: -.01em; }
.lesson-head .lead { margin: 6px 0 0; color: var(--muted); font-size: 19px; }
.lesson-state .s-state { font-size: 16px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lesson-kicker .lv { color: color-mix(in srgb, var(--tc) 50%, #fff); } }
.lesson { display: grid; gap: 18px; grid-template-areas: "copy" "example" "cta"; }
@media (min-width: 900px) {
  .lesson { grid-template-columns: minmax(0, 1fr) minmax(380px, 520px); grid-template-areas: "copy example" "cta example"; grid-template-rows: auto 1fr; gap: 20px 36px; align-items: start; }
}
.lesson-copy { grid-area: copy; margin: 0; padding: 22px 24px; }
.lesson-copy h2 { font-size: 21px; margin: 0 0 6px; }
.lesson-copy p { font-size: 18px; line-height: 1.6; }
.lesson-copy p:last-child { margin-bottom: 0; }
.lesson-copy h2 + p + h2 { margin-top: 20px; }
.lesson-cta { grid-area: cta; }
.lesson-cta p { margin: 12px 4px 0; font-size: 15px; }
.example { grid-area: example; margin: 0; padding: 18px; box-shadow: var(--lift); }
.card.example + .card { margin-top: 0; }
.ex-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 4px 14px; }
.ex-head h2 { margin: 0; font-size: 21px; }
.beat-pips { display: inline-flex; gap: 5px; }
.beat-pips i { width: 22px; height: 6px; border-radius: 3px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.beat-pips i.on { background: var(--pat); box-shadow: none; }
.beat-box { margin-top: 14px; }
.beat { min-height: 4.6em; margin: 0 4px 12px; font-size: 18px; line-height: 1.5; }
.beat-nav { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.beat-nav .btn svg, .feedback .btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- the lesson board */
/* board.css's grid and cells, with every pencil mark in pencil grey and a little larger, a ring
   round the pattern (dashed for coloring's other color), a wash over its rows, columns or
   boxes, and marks that cross out */
.learn-board { width: 100%; max-width: 560px; margin: 0 auto; }
.learn-board .grid { box-shadow: var(--board-shadow); }
.learn-board .cell { cursor: default; }
.learn-board .grid.tappable .cell { cursor: pointer; }
.learn-board .cell.mine { --pc: #0B5CAD; }
.learn-board .cell .notes { inset: 3px; }
.learn-board .cell .notes b { font-size: calc(100cqw / 9 * .31); color: #5b5348; position: relative; }
.learn-board .cell.unit { background: color-mix(in srgb, var(--pat) 11%, var(--paper)); }
.learn-board .cell:is(.pat, .alt) .notes { inset: 4px; }
.learn-board .cell.pat::after, .learn-board .cell.alt::after { content: ""; position: absolute; inset: 1px; border-radius: 12%; pointer-events: none; border: 3px solid var(--pat); background: color-mix(in srgb, var(--pat) 7%, transparent); }
.learn-board .cell.alt::after { border: 3px dashed var(--pat-alt); background: color-mix(in srgb, var(--pat-alt) 8%, transparent); }
/* the selected cell: a ring in ink on a pale tile, its marks left full size to tap */
.learn-board .cell.sel { background: color-mix(in srgb, var(--sel) 40%, var(--paper)); }
.learn-board .cell.sel::before { inset: 2%; background: transparent; box-shadow: inset 0 0 0 3px var(--paper-ink); animation: none; }
.learn-board .cell.sel .notes { inset: 3px; }
.learn-board .cell.sel .notes b { font-size: calc(100cqw / 9 * .31); }
/* a mark picked out: board.css's chip; crossed out: a slash through it */
.learn-board .notes b.x, .learn-board .notes b.gone, .learn-board .notes b.ok { opacity: .7; }
.learn-board .notes b.x::after, .learn-board .notes b.gone::after, .learn-board .notes b.ok::after { content: ""; position: absolute; left: -15%; right: -15%; top: 50%; height: 1.5px; margin-top: -.75px; border-radius: 1px; background: var(--paper-ink); transform: rotate(-28deg); }
.learn-board .notes b.gone { color: var(--bad); }
.learn-board .notes b.gone::after { background: var(--bad); height: 2px; }
.learn-board .notes b.ok { opacity: .8; color: var(--good); border-radius: 50%; box-shadow: 0 0 0 1.5px var(--good); }
.learn-board .notes b.ok::after { background: var(--good); }
.learn-board .notes b.no { color: var(--bad); border-radius: 50%; box-shadow: 0 0 0 2px var(--bad); background: #fff2f0; }
.learn-board .cell.put { background: color-mix(in srgb, var(--good) 14%, var(--paper)); }
.learn-board .cell.put .d { color: var(--good); font-weight: 800; }
.learn-board .cell.miss, .learn-board .cell.noc { box-shadow: inset 0 0 0 3px var(--bad); }
/* a square picked (smart notes, guess and check): a ring in the accent on a pale tile */
.learn-board .cell.pick { background: color-mix(in srgb, var(--pick) 13%, var(--paper)); }
.learn-board .cell.pick::before { content: ""; position: absolute; inset: 7%; border-radius: 22%; pointer-events: none; box-shadow: inset 0 0 0 3.5px var(--pick); }
.learn-board .cell.okc { background: color-mix(in srgb, var(--good) 14%, var(--paper)); }
/* a digit noted small (smart notes' result), and a guess to try (guess and check's) */
.learn-board .notes b.pn { color: var(--pat); font-size: calc(100cqw / 9 * .37); font-weight: 900; }
.learn-board .cell .d.guess { color: #0B5CAD; border-color: #0B5CAD; }
.learn-board .cell.miss .d { color: var(--bad); text-decoration: line-through; text-decoration-thickness: 2px; }
@media (prefers-reduced-motion: no-preference) {
  .learn-board .cell.pat::after, .learn-board .cell.alt::after { animation: chip .3s cubic-bezier(.3, 1.4, .5, 1) both; }
  .learn-board .cell.put .d { animation: place .4s cubic-bezier(.3, 1.6, .5, 1) both; }
}

/* ---------------------------------------------------------------- practice */
.run { display: inline-flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 800; font-size: 15px; }
.run .pips i { width: 14px; height: 14px; border-radius: 4px; }
.run .s-done svg { width: 18px; height: 18px; display: block; }
.practice { display: grid; gap: 18px; }
@media (min-width: 900px) { .practice { grid-template-columns: minmax(0, 560px) minmax(320px, 1fr); gap: 36px; align-items: start; } }
.prompt { margin: 0 2px 14px; font-size: 18px; font-weight: 700; line-height: 1.45; }
.practice-side { display: grid; gap: 14px; align-content: start; }
.practice-side .pad { margin: 0; }
.pad-hint { min-height: 1.4em; margin: 0; text-align: center; font-size: 15px; }
.pad-hint:empty { display: none; }
.practice-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.practice-actions .btn:only-child { grid-column: 1 / -1; }
/* a crossed-out mark's key: pressed down, with the same slash as on the board */
.key.crossed:not([disabled]) { background: var(--surface-2); box-shadow: inset 0 2px 0 var(--key-edge); transform: translateY(2px); }
.key.crossed .kd { position: relative; opacity: .6; }
.key.crossed .kd::after { content: ""; position: absolute; left: -25%; right: -25%; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 2px; background: currentColor; transform: rotate(-40deg); }
.feedback { margin: 0; padding: 18px 20px; border-left: 6px solid var(--pat); }
.feedback h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 24px; }
.feedback h2 svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.feedback p { font-size: 17px; line-height: 1.55; margin: 0 0 12px; }
.feedback.right { border-left-color: var(--ok); }
.feedback.right h2 { color: var(--ok); }
.feedback.wrong { border-left-color: var(--p1); }
.feedback .stays { font-weight: 700; color: var(--danger); }
.feedback .btn { margin-top: 4px; }
@media (max-width: 899px) {
  /* a phone: the answer comes first, right under the board */
  .practice-side { display: flex; flex-direction: column; }
}

/* ---------------------------------------------------------------- mastered */
dialog.mastered-dialog { padding: 0; max-width: min(440px, calc(100vw - 32px)); border: 0; background: transparent; overflow: visible; }
.finish.mastered { margin: 0; padding: 30px 24px 22px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); }
.finish.mastered .rosette { width: 112px; }
.finish.mastered h2 { margin-bottom: 8px; }
.mastered-actions { display: grid; gap: 10px; margin-top: 18px; }
.mastered-actions .up-next { margin: -2px 0 4px; font-size: 15px; color: var(--muted); }

.learn-missing { max-width: 560px; margin: 40px auto; padding: 28px; text-align: center; }
.learn-missing h1 { font-size: 34px; }

/* ---------------------------------------------------------------- motion */
@media (prefers-reduced-motion: no-preference) {
  .strategy { transition: border-color .15s, box-shadow .2s, transform .2s; }
  .strategy:hover { transform: translateY(-2px); }
  .tier-group .strategy { animation: arrive .4s ease-out both; }
  .meter-tiles i.on { animation: pop .4s cubic-bezier(.3, 1.6, .5, 1) both; }
}
