/* Shared "place the strokes in position + stroke order" activity.
   Used by Starter Lessons 2, 3, 6 via <div class="place-strokes" data-chars="…">.
   Relies on the lesson page's colour variables (--green, --line, --muted, …),
   with a theme.css token behind every one of them as the fallback.

   Two things worth knowing before touching colour in here:

   · The strokes themselves are NOT painted from this file. place-strokes.js:8
     holds STROKE_COLORS = ['#c14a3d','#3b82f6','#3a6ea5','#346ac0','#8a5fa8',
     '#4075c9'] — a six-colour "which stroke is this" series in which four of
     the six are the same blue. theme.css publishes that series properly as
     --t-series-1..6, ordered light-to-dark so the sequence survives greyscale
     and print. The JS belongs to the teaching-signal pass and is untouched
     here; it is reported. What this file could do was stop borrowing one of
     those hues: the stroke-order guide below was rgba(59,130,246,…), which is
     STROKE_COLORS[1] exactly — "the next stroke to place" was being drawn in
     stroke 2's identity colour. It is --t-stroke-current now, the token that
     means "the stroke being taught".

   · "hovering" and "finished" used to resolve to the same value: --green-2 on
     both .mp-tab:hover and .mp-tab.done, so a tab you were merely pointing at
     looked completed. Finished takes --t-done; hover moves a plain surface
     and no accent at all. */
.place-strokes {
  /* --t-stroke-current (#b85520, "the stroke being taught") as bare channels.
     theme.css publishes no --t-stroke-current-rgb, and the breathing guide at
     the bottom of this file pulses on ALPHA (.45 → .95), so the channels have
     to be spelled out once. Mirror of that token: move both or neither. */
  --ps-next-rgb: 184, 85, 32;
}

.place-strokes .mp-topbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.place-strokes .mp-instr { margin: 0; font-size: 13.5px; color: var(--muted, var(--t-muted)); line-height: 1.6; }
.place-strokes .mp-instr b { color: var(--green, var(--t-green-deep)); }
.place-strokes .mp-count { flex: 0 0 auto; padding: 6px 14px; border-radius: var(--t-r-pill); background: var(--t-sunk); border: 1px solid var(--line, var(--t-line)); font-size: 13px; font-weight: 800; color: var(--muted, var(--t-muted)); white-space: nowrap; }
.place-strokes .mp-count b { color: var(--green, var(--t-green-deep)); }
.place-strokes .mp-hint { margin: 0; font-size: 13px; font-weight: 700; color: var(--t-info-ink); max-height: 0; opacity: 0; overflow: hidden; transition: max-height .2s ease, opacity .2s ease, margin .2s ease; }
.place-strokes .mp-hint.show { max-height: 40px; opacity: 1; margin: -4px 0 12px; }

.place-strokes .mp-cols { display: grid; grid-template-columns: minmax(0,1.05fr) minmax(0,0.95fr); gap: 18px; align-items: stretch; }
@media (max-width: 680px) { .place-strokes .mp-cols { grid-template-columns: 1fr; } }
.place-strokes .mp-col { border: 1px solid var(--line, var(--t-line)); border-radius: 16px; background: linear-gradient(180deg,var(--t-white),var(--t-sand)); padding: 14px; display: flex; flex-direction: column; }
.place-strokes .mp-col-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; min-height: 40px; }
.place-strokes .mp-cap { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--green, var(--t-green-deep)); }
.place-strokes .mp-cap-dim { color: var(--muted, var(--t-muted)); }
.place-strokes .mp-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.place-strokes .mp-tab { display: inline-flex; align-items: center; gap: 3px; min-width: 40px; height: 40px; padding: 0 11px; border: 1.5px solid var(--line, var(--t-line)); border-radius: 12px; background: var(--t-white); font-family: var(--t-chinese); font-size: 21px; color: var(--ink, var(--t-ink)); cursor: pointer; line-height: 1; transition: border-color .15s ease, background .15s ease, transform .12s ease; }
/* hover = a plain surface, nothing that could be read as a state; active =
   "you are here" (--t-current); done = "finished" (--t-done). Three different
   values, which is the point — hover and done used to be the same one. */
.place-strokes .mp-tab:hover { background: var(--t-sunk); transform: translateY(-1px); }
.place-strokes .mp-tab.active { border-color: var(--t-current); background: var(--t-current-tint); }
.place-strokes .mp-tab.done { border-color: var(--t-done); }
/* The tick is 11px type, so it takes an ink: --t-done is 3.9:1 on the white
   tab and would fail as small text. Done-ness is carried by the border above
   and by the ✓ itself. */
.place-strokes .mp-tab-tick { font-size: 11px; color: var(--t-green-deep); font-family: var(--t-sans); }

/* The practice sheet. theme.css §9 owns this paper site-wide, and its promise
   is the ORDERING: the frame (2.05:1 on paper) must read stronger than the
   inner guide (1.45:1), or the guide starts reading as the box. */
.place-strokes .mp-grid { position: relative; width: min(100%, 300px); aspect-ratio: 1 / 1; margin: 0 auto; align-self: center;
  border: 1.5px solid var(--t-grid-border); border-radius: 14px; background-color: var(--t-paper);
  background-image: repeating-linear-gradient(90deg, var(--t-grid-guide) 0 7px, transparent 7px 13px), repeating-linear-gradient(0deg, var(--t-grid-guide) 0 7px, transparent 7px 13px);
  background-repeat: no-repeat; background-size: 100% 1.5px, 1.5px 100%; background-position: center;
  box-shadow: 0 8px 20px rgba(var(--t-green-deep-rgb), 0.09), inset 0 1px 0 rgba(255,255,255,.85); transition: box-shadow .15s ease, border-color .15s ease; }
.place-strokes .mp-grid.drop-hot { border-color: var(--t-green-bright); box-shadow: 0 0 0 4px rgba(var(--t-green-rgb), 0.16), 0 8px 20px rgba(var(--t-green-deep-rgb), 0.12); }
.place-strokes .mp-grid svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* not yet written */
.place-strokes .mp-ghost path { fill: var(--t-stroke-ghost); }
.place-strokes .mp-placed { animation: mp-pop .35s cubic-bezier(.2,.8,.25,1) both; }
@keyframes mp-pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: scale(1); } }

.place-strokes .mp-wh-box { flex: 1; min-height: 190px; display: flex; flex-wrap: wrap; gap: 12px; align-content: flex-start;
  padding: 14px; border: 2px dashed var(--line-strong,var(--t-faint)); border-radius: 14px;
  background: linear-gradient(180deg,var(--t-cream),var(--t-sunk)); box-shadow: inset 0 2px 10px rgba(var(--t-green-deep-rgb), 0.045); }
.place-strokes .mp-tile { width: 88px; height: 88px; cursor: grab; touch-action: none; position: relative; }
/* ×N badge on chips that stand in for a repeated stroke (e.g. two 点 → one chip). */
/* White 11px type on a fill, so the fill has to be an ink: white on
   --t-green-deep is 7.9:1. It does not ask the page for --green, which is
   navy #1e3a8a on most of these lessons and a much lighter green on others. */
.place-strokes .mp-badge { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center; border-radius: var(--t-r-pill);
  background: var(--t-green-deep); color: var(--t-white); font: 800 11px/1 var(--t-sans);
  box-shadow: 0 2px 6px rgba(var(--t-green-deep-rgb), 0.3); pointer-events: none; z-index: 2; }
.place-strokes .mp-tile.dragging .mp-badge { display: none; }
.place-strokes .mp-tile svg { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); pointer-events: none; transition: filter .12s ease; }
.place-strokes .mp-tile:hover svg { filter: drop-shadow(0 3px 6px rgba(var(--t-green-deep-rgb), 0.26)); }
.place-strokes .mp-tile.dragging { cursor: grabbing; }
.place-strokes .mp-tile.dragging svg { filter: drop-shadow(0 8px 14px rgba(var(--t-green-deep-rgb), 0.3)); }
.place-strokes .mp-tile.big svg { inset: 0; width: 100%; height: 100%; opacity: .95; }
.place-strokes .mp-tile.reject { animation: mp-shake .35s ease; }
@keyframes mp-shake { 25% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }
.place-strokes .mp-tile.hintpulse { animation: mp-hintpulse .8s ease 2; }
.place-strokes .mp-tile.hintpulse svg { filter: drop-shadow(0 0 7px rgba(var(--ps-next-rgb), 0.75)); }
@keyframes mp-hintpulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* Steady "breathing" highlight on the next stroke to place (stroke-order guide):
   a glow in the STROKE's own shape — drop-shadow follows the path outline — that
   pulses in blur + brightness, with a gentle scale. No box, no circle. */
.place-strokes .mp-tile.mp-next { z-index: 3; }
.place-strokes .mp-tile.mp-next svg { animation: mp-breathe 1.5s ease-in-out infinite; }
@keyframes mp-breathe {
  0%, 100% { transform: scale(.94); filter: drop-shadow(0 0 2px rgba(var(--ps-next-rgb), 0.45)); }
  50%      { transform: scale(1.06); filter: drop-shadow(0 0 11px rgba(var(--ps-next-rgb), 0.95)) drop-shadow(0 0 5px rgba(var(--ps-next-rgb), 0.85)); }
}
