/* Stroke hunt: "Which stroke types can you find?" (Starter Sections 2 and 3).
   Markup is built by assets/stroke-hunt.js.
   ① Look: the characters on warm paper; tap one to watch it being written.
   ② Pick: the stroke tray. After Check every tile names its stroke; the colours are the
      plain ones a learner already reads: green found, gold missed, red wrongly picked. */

.hunt {
  --hunt-ink: #38322d;
  --hunt-muted: var(--muted, #64748b);
  --hunt-accent: var(--green, #1e3a8a);          /* the lesson's own accent */
  --hunt-accent-soft: var(--green-soft, #eff6ff);
  /* picked tiles and their tick: teal (Yi's choice, 2026-09-30; was navy, then pink) */
  --hunt-pick: #2a8c86;
  --hunt-pick-rgb: 42, 140, 134;
  --hunt-pick-soft: #eaf7f5;
  --hunt-ok: #a6642a;   --hunt-ok-tint: #fcf4ee;
  --hunt-miss: #c9922f; --hunt-miss-tint: #fbf1dc;
  --hunt-bad: #b33a32;  --hunt-bad-tint: #fbeae9;
  display: grid;
  gap: 14px;
  margin: 4px 0 6px;
}

/* the ① / ② label row */
.hunt-step {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 0 0 14px;
  color: var(--hunt-muted);
  font-size: 13px;
  line-height: 1.4;
}
.hunt-step b {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--hunt-ink);
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.hunt-step b i {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--hunt-ink);
  color: #fff;
  font-size: 11px;
  font-style: normal;
  letter-spacing: 0;
}

/* ── ① Look: the characters on warm paper ── */
.hunt-look {
  padding: 16px 20px 18px;
  border: 1px solid #ece4d3;
  border-radius: 20px;
  background:
    radial-gradient(120% 100% at 0% 0%, rgba(255, 255, 255, 0.85), transparent 55%),
    linear-gradient(180deg, #fbf8f1, #f4eee1);
}
.hunt-board {
  display: grid;
  grid-template-columns: repeat(var(--chars, 4), minmax(0, 118px));
  justify-content: center;
  gap: clamp(12px, 3.2vw, 30px);
}
.hunt-spec {
  display: grid;
  justify-items: center;
  gap: 8px;
}
.hunt-char {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #e8dfcc;
  border-radius: 18px;
  background: #fffdf8;
  box-shadow: 0 12px 24px -16px rgba(70, 50, 20, 0.45), inset 0 1px 0 #ffffff;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.hunt-char:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 30px -18px rgba(70, 50, 20, 0.55), inset 0 1px 0 #ffffff;
}
.hunt-char:focus-visible { outline: 2px solid var(--hunt-accent); outline-offset: 3px; }
.hunt-glyph { width: 86%; height: 86%; display: block; }
.hunt-glyph svg { width: 100%; height: 100%; display: block; }
/* a small replay mark, shown on hover */
.hunt-char::after {
  content: "\21BB";
  position: absolute;
  top: 6px;
  right: 9px;
  color: #b5a687;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.hunt-char:hover::after,
.hunt-char:focus-visible::after { opacity: 1; }
.hunt-py {
  color: var(--hunt-muted);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* ── ② Pick: the stroke tray ── */
.hunt-pick {
  padding: 16px 20px 14px;
  border: 1px solid #ebe7de;
  border-radius: 20px;
  background: #ffffff;
}
.hunt-tray {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr));
  gap: 12px;
}
.hunt-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  border: 1px solid #e8e3d8;
  border-radius: 16px;
  background: linear-gradient(180deg, #fffefb, #f9f6ee);
  box-shadow: 0 8px 16px -12px rgba(50, 38, 15, 0.4);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease, background-color 0.16s ease;
}
.hunt-ink {
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.hunt-ink svg { width: 60%; height: 60%; display: block; }
.hunt-tile:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--hunt-pick-rgb), 0.45);
  box-shadow: 0 14px 22px -14px rgba(50, 38, 15, 0.5);
}
.hunt-tile:focus-visible { outline: 2px solid var(--hunt-pick); outline-offset: 3px; }

/* the seal in the corner: ✓ when picked, then the verdict after Check */
.hunt-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--hunt-pick);
  box-shadow: 0 4px 10px rgba(var(--hunt-pick-rgb), 0.4);
  color: #fff;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
  transform: scale(0);
  transition: transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.hunt-badge::before { content: "\2713"; }

.hunt-tile.selected {
  border-color: var(--hunt-pick);
  background: var(--hunt-pick-soft);
  box-shadow: 0 0 0 1px var(--hunt-pick), 0 12px 20px -14px rgba(var(--hunt-pick-rgb), 0.6);
  animation: hunt-pop 0.24s ease;
}
.hunt-tile.selected.is-match .hunt-badge { transform: scale(1); }
@keyframes hunt-pop {
  0% { transform: scale(0.95); }
  60% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* after Check: the answer key, in the tray's own "picked" look. Every stroke type that IS in
   the characters is ringed and ticked, whether or not the learner picked it; the one that is not
   fades back. Same tiles, same size, same places, no names. */
.hunt.is-checked .hunt-tile:hover { transform: none; }
.hunt-tile.correct,
.hunt-tile.missed {
  border-color: var(--hunt-pick);
  background: var(--hunt-pick-soft);
  box-shadow: 0 0 0 1px var(--hunt-pick), 0 12px 20px -14px rgba(var(--hunt-pick-rgb), 0.6);
}
.hunt-tile.correct .hunt-badge,
.hunt-tile.missed .hunt-badge { transform: scale(1); }
.hunt-tile.missed { animation: hunt-pop 0.24s ease; }   /* the ones the learner had not picked tick in */
.hunt-tile.wrong,
.hunt-tile.absent {
  border-color: #eeeae2;
  background: #fbfaf7;
  box-shadow: none;
}
.hunt-tile.wrong .hunt-ink,
.hunt-tile.absent .hunt-ink { opacity: 0.35; }
.hunt-tile.flash { animation: hunt-flash 0.6s ease; }
@keyframes hunt-flash {
  0% { box-shadow: 0 0 0 0 var(--hc, rgba(179, 58, 50, 0.45)); }
  100% { box-shadow: 0 0 0 12px transparent; }
}

/* the tray's foot: running count + Check */
.hunt-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f0ede4;
}
.hunt-count {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--hunt-muted);
  font-size: 13.5px;
}
.hunt-count::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d8d2c4;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}
.hunt-count.has { color: var(--hunt-ink); font-weight: 600; }
.hunt-count.has::before {
  background: var(--hunt-pick);
  box-shadow: 0 0 0 4px var(--hunt-pick-soft);
}
.hunt-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 22px 11px 24px;
  border: 0;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0)),
    var(--hunt-accent);
  box-shadow: 0 12px 22px -12px rgba(30, 58, 138, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  color: #ffffff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.hunt-check::after { content: "\2192"; transition: transform 0.15s ease; }
.hunt-check:hover:not(:disabled) { transform: translateY(-1px); }
.hunt-check:hover:not(:disabled)::after { transform: translateX(3px); }
.hunt-check:focus-visible { outline: 2px solid var(--hunt-accent); outline-offset: 3px; }
.hunt-check:disabled { opacity: 0.38; box-shadow: none; cursor: default; }
.hunt.is-checked .hunt-check { opacity: 0.55; }
.hunt.is-checked .hunt-check::after { content: "\2713"; }

@media (max-width: 640px) {
  .hunt-look, .hunt-pick { padding: 14px 14px 16px; border-radius: 16px; }
  .hunt-board { grid-template-columns: repeat(var(--chars, 4), minmax(0, 1fr)); gap: 10px; }
  .hunt-char { border-radius: 14px; }
  .hunt-tray { grid-template-columns: repeat(var(--cols-sm, 4), minmax(0, 1fr)); gap: 10px; }
  .hunt-check { padding: 10px 18px 10px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .hunt-tile, .hunt-char, .hunt-badge, .hunt-check { transition: none; }
  .hunt-tile.selected, .hunt-tile.flash, .hunt-cpath.glow { animation: none; }
}

/* after Check: each stroke type in its own colour (stroke-hunt.js lays its own SVG over the
   hanzi-writer drawing), the tiles in the same colours */
.hunt-glyph { position: relative; }
.hunt-color {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.hunt-color.on { opacity: 1; }
.hunt-glyph.has-colour-overlay .hunt-hw { visibility: hidden; }
.hunt-cpath {
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 0;
  stroke-opacity: 0;
  transition: opacity 0.25s ease;
}
.hunt-ink path { transition: fill 0.5s ease; }
/* tapping a tile: everything else dims, that stroke type glows */
.hunt-board.is-focus .hunt-cpath { opacity: 0.14; }
.hunt-board.is-focus .hunt-cpath.on { opacity: 1; }
.hunt-cpath.glow { animation: hunt-glow 1.1s ease; }
@keyframes hunt-glow {
  0% { stroke-width: 0; stroke-opacity: 0.5; }
  45% { stroke-width: 80px; stroke-opacity: 0.3; }
  100% { stroke-width: 0; stroke-opacity: 0; }
}
