/* © 2026 MEK.txt. All rights reserved. Part of the MEK design system; not licensed for reuse. */
/* MEK design system · part: quests
   The gamification kit's quests: a list of goals, each with how far along it is and what it's worth, ticked off
   when done. Opt-in: link it after mek.css, with js/quests.js:
     <ul class="quests" aria-label="Today's quests">
       <li class="quest" data-quest="read" data-progress="2/3" data-reward="+50 XP">Read three articles</li> …
     </ul>
     mekQuests.progress(document.querySelector(".quests"), "read", 3);   // 3 of 3: done, ticked, two blinks
   Needs the core box and meter. In the mek.parts layer, so a project's CSS wins. */

@layer mek.parts {

/* ---------- Dials ---------- */
/* on every themed area too, so a box in another theme works these out from its own colours */
:root, [data-theme] {
  --quest-done: var(--accent);         /* a done quest's box: filled */
  --quest-reward: var(--accent);       /* what it's worth, while it's still to do */
  --quest-box: var(--line);            /* a box still to tick: 400 */
}

/* ---------- Quests ----------
   Rows on 1px rules in 400, 12px above and below, 560px at most. Each: a 16px px-box, the name in 14 (900) with a
   core meter of 4px cells under it (data-progress, "2/3"), the count ("2/3") in Mono 12, 700, and the reward
   (data-reward) in Mono 12 in --quest-reward. The count and the reward keep the width of their widest, so the rows'
   columns line up. Done (data-done): the box filled in --quest-done with a check in the ground, the name 700, the
   meter full, the reward 700; only colours change, so ticking one off moves nothing. js/quests.js builds each row
   and reads it out ("Read three articles: 2 of 3, +50 XP"); completing one blinks the row twice (not under reduced
   motion) and fires mek:quest. */
.quests { display: grid; max-width: 560px; margin: 0; padding: 0; list-style: none; }
.quest { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto auto; grid-template-rows: auto auto; align-items: center; gap: 0 12px;
  padding: var(--space-3) 0; border-top: var(--stroke) solid var(--line); font-size: var(--text-sm); color: var(--text); }
.quest:last-child { border-bottom: var(--stroke) solid var(--line); }
.quest-box { grid-row: 1 / span 2; width: 16px; height: 16px; --edge: var(--quest-box); --edge-to: var(--quest-box); --fill: var(--bg); --fill-to: var(--bg); }
.quest-name { grid-area: 1 / 2; min-width: 0; overflow-wrap: anywhere; line-height: 18px; }
.quest-count, .quest-reward { grid-row: 1 / span 2; font: var(--text-crisp)/1 var(--font-mono); white-space: nowrap; text-align: right; }
.quest-count { color: var(--text-muted); min-width: 4ch; }
.quest-reward { color: var(--quest-reward); min-width: 7ch; }
.quest > .meter { grid-area: 2 / 2; margin-top: 4px; --meter-cell: 4px; --meter-gap: 1px; --meter-h: 4px; max-width: 160px; }
.quest[data-done] .quest-box { --edge: var(--quest-done); --edge-to: var(--quest-done); --fill: var(--quest-done); --fill-to: var(--quest-done); }
.quest-box > i { display: block; width: 16px; height: 16px; }
.quest[data-done] .quest-box > i { background: var(--bg);   /* the check, in the ground, over the fill, centred on whole pixels */
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15' shape-rendering='crispEdges'%3E%3Cpath d='M10 4h2v1h-2zM9 5h3v1h-3zM8 6h3v1h-3zM3 7h2v1h-2zM7 7h3v1h-3zM3 8h6v1h-6zM4 9h4v1h-4zM5 10h2v1h-2z'/%3E%3C/svg%3E") 1px 1px / 15px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 15' shape-rendering='crispEdges'%3E%3Cpath d='M10 4h2v1h-2zM9 5h3v1h-3zM8 6h3v1h-3zM3 7h2v1h-2zM7 7h3v1h-3zM3 8h6v1h-6zM4 9h4v1h-4zM5 10h2v1h-2z'/%3E%3C/svg%3E") 1px 1px / 15px no-repeat; }
.quest[data-done] .quest-name, .quest[data-done] .quest-reward { color: var(--text-muted); }
.quest.just { animation: mek-blink var(--dur-beat) steps(1, end) 4; }

}
