/* ============================================================
   quests.css — TO LEARN LIST (#card-todo) motion + quest / XP read-outs
   Module "quests" of the dashboard motion layer. Prefix: qs-
   Contract: company/engineer/tools/dashboard-motion-contract.md
   Colours come from the theme tokens only (with the contract fallbacks);
   anything drawn over #dash-stage is white.
   The base page CSS is injected after this file, so every rule that has to
   win over a base rule is scoped with #card-todo (id specificity).
   ============================================================ */

#card-todo,
.qs-fx {
  --qs-accent: var(--brand, #FF52A2);
  --qs-ink: var(--ink, #006D40);
  --qs-fill: var(--fill, #006D40);
  --qs-line: var(--line, #006D40);
  --qs-bg: var(--bg, #FFFEEF);
  --qs-surface: var(--surface, #FFFFFF);
  --qs-out: cubic-bezier(.16, 1, .3, 1);    /* fast attack, long settle */
  --qs-io: cubic-bezier(.65, 0, .35, 1);    /* symmetric, for draws and sweeps */
  --qs-back: cubic-bezier(.3, 1.45, .45, 1); /* small overshoot */
}

/* ------------------------------------------------------------
   Rows — resting, hover / focus, completed
   ------------------------------------------------------------ */
#card-todo .todo-row {
  position: relative;
  transition: transform .34s var(--qs-out), box-shadow .34s var(--qs-out), background-color .45s var(--qs-out);
}
/* hover effects are for real pointers only: on a touch screen :hover sticks to the last tapped row */
@media (hover: hover) {
  #card-todo .todo-row:hover {
    transform: translate3d(0, -1px, 0);
    box-shadow: 0 0 0 1px var(--qs-line);
    box-shadow: 0 0 0 1px var(--qs-line), 0 0 0 5px color-mix(in srgb, var(--qs-accent) 13%, transparent);
  }
}
/* Keyboard focus gets the same lift, through :has(:focus-visible) and not through focus-within: a mouse
   click focuses the button too, and the row would stay "hovered" until the next click elsewhere.
   Kept apart from the :hover rules so a browser without :has() only loses this variant. */
#card-todo .todo-row:has(:focus-visible) {
  transform: translate3d(0, -1px, 0);
  box-shadow: 0 0 0 1px var(--qs-line);
  box-shadow: 0 0 0 1px var(--qs-line), 0 0 0 5px color-mix(in srgb, var(--qs-accent) 13%, transparent);
}
#card-todo .todo-row.is-done {
  background-color: var(--qs-bg);
  background-color: color-mix(in srgb, var(--qs-bg) 62%, var(--qs-surface));
}

/* status LED on the left edge: draws in when the row is completed */
#card-todo .todo-row::before {
  content: '';
  position: absolute;
  left: 4px;
  top: 50%;
  width: 3px;
  height: 24px;
  margin-top: -12px;
  border-radius: 3px;
  background: var(--qs-accent);
  opacity: 0;
  transform: scaleY(0);
  transition: transform .26s var(--qs-io), opacity .26s var(--qs-io);
  pointer-events: none;
}
#card-todo .todo-row.is-done::before {
  opacity: 1;
  transform: scaleY(1);
  transition: transform .5s var(--qs-out) .14s, opacity .2s var(--qs-out) .14s;
}

/* one light sweep across the row when it is completed */
#card-todo .todo-row::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(100deg, transparent 0 36%, color-mix(in srgb, var(--qs-accent) 16%, transparent) 50%, transparent 64% 100%) no-repeat;
  background-size: 260% 100%;
  background-position: 106% 0;
}
#card-todo .todo-row.qs-swept::after {
  animation: qs-sweep .85s var(--qs-io) both;
}
@keyframes qs-sweep {
  0%   { opacity: 1; background-position: 106% 0; }
  100% { opacity: 1; background-position: -6% 0; }
}

#card-todo .todo-main,
#card-todo .todo-meter {
  transition: opacity .4s var(--qs-out);
}
#card-todo .todo-row.is-done .todo-main,
#card-todo .todo-row.is-done .todo-meter {
  opacity: .6;
}

/* the strike-through is drawn instead of popping in */
#card-todo .todo-task {
  background: linear-gradient(currentColor, currentColor) no-repeat 0 58% / 0% 1.5px;
  transition: background-size .3s var(--qs-io);
}
#card-todo .todo-row.is-done .todo-task {
  text-decoration: none;
  background-size: 100% 1.5px;
  transition: background-size .46s var(--qs-io) .1s;
}

/* kanji tile */
#card-todo .todo-mono {
  transition: box-shadow .34s var(--qs-out);
}
#card-todo .todo-mono > span {
  transition: transform .4s var(--qs-out);
}
@media (hover: hover) {
  #card-todo .todo-row:hover .todo-mono {
    box-shadow: inset 0 0 0 1px var(--qs-line);
  }
  #card-todo .todo-row:hover .todo-mono > span {
    transform: scale(1.12);
  }
}
#card-todo .todo-row:has(:focus-visible) .todo-mono {
  box-shadow: inset 0 0 0 1px var(--qs-line);
}
#card-todo .todo-row:has(:focus-visible) .todo-mono > span {
  transform: scale(1.12);
}

/* ------------------------------------------------------------
   Intro — rows scan in, fills grow, numbers count (JS drives --qs-p)
   ------------------------------------------------------------ */
#card-todo.qs-pre .todo-row {
  opacity: 0;
}
/* fill backwards only: quests.js swaps .qs-pre for .qs-in, the first keyframe keeps a waiting row hidden,
   and a row is released (no clip, no pinned transform) the moment its own scan-in ends */
#card-todo.qs-in .todo-row {
  animation: qs-row-in .66s var(--qs-out) backwards;
  animation-delay: calc(var(--qs-i, 0) * 85ms);
}
@keyframes qs-row-in {
  0%   { opacity: 0; transform: translate3d(-16px, 0, 0); clip-path: inset(0 100% 0 0 round 16px); }
  55%  { opacity: 1; }
  100% { opacity: 1; transform: translate3d(0, 0, 0); clip-path: inset(0 0 0 0 round 16px); }
}

#card-todo .todo-pct {
  font-variant-numeric: tabular-nums;
}
#card-todo .todo-fill {
  position: relative;
  overflow: hidden;
}
/* growth is a clip, not a width tween: no layout, and the leading edge stays round */
#card-todo .todo-row.qs-grow .todo-fill {
  clip-path: inset(0 calc((1 - var(--qs-p, 0)) * 100%) 0 0 round 999px);
  will-change: clip-path;
}
/* white-hot leading edge while the bar is still moving */
#card-todo .todo-row.qs-grow .todo-fill::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--qs-p, 0) * 100% - 16px);
  width: 16px;
  background: linear-gradient(90deg, transparent, var(--qs-surface));
  opacity: calc((1 - var(--qs-p, 0)) * 2.4);
  pointer-events: none;
}
/* shimmer travelling along the fill */
#card-todo .todo-fill::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 46%;
  background: linear-gradient(90deg, transparent, var(--qs-surface), transparent);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--qs-surface) 82%, transparent), transparent);
  transform: translate3d(-110%, 0, 0);
  opacity: 0;
  pointer-events: none;
}
#card-todo.qs-in .todo-fill::after {
  animation: qs-glint 1.2s var(--qs-io) both;
  animation-delay: calc(var(--qs-i, 0) * 90ms + 520ms);
}
#card-todo.qs-live .todo-row:not(.is-done) .todo-fill::after {
  animation: qs-glint-idle 6.6s var(--qs-io) infinite;
  animation-delay: calc(var(--qs-i, 0) * .6s + 1.4s);
}
@media (hover: hover) {
  #card-todo.qs-live .todo-row:not(.is-done):hover .todo-fill::after {
    animation: qs-glint .95s var(--qs-io) both;
  }
}
#card-todo.qs-live .todo-row:not(.is-done):has(:focus-visible) .todo-fill::after {
  animation: qs-glint .95s var(--qs-io) both;
}
@keyframes qs-glint {
  0%   { transform: translate3d(-110%, 0, 0); opacity: 0; }
  12%  { opacity: 1; }
  88%  { opacity: 1; }
  100% { transform: translate3d(230%, 0, 0); opacity: 0; }
}
@keyframes qs-glint-idle {
  0%        { transform: translate3d(-110%, 0, 0); opacity: 0; }
  2%        { opacity: .85; }
  15%       { opacity: .85; }
  17%, 100% { transform: translate3d(230%, 0, 0); opacity: 0; }
}

/* ------------------------------------------------------------
   Checkbox — hover preview, press, tick draw, burst, focus ring
   ------------------------------------------------------------ */
#card-todo .todo-check {
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .26s var(--qs-out), color .2s var(--qs-out), box-shadow .26s var(--qs-out), transform .2s var(--qs-out);
}
@media (hover: hover) {
  #card-todo .todo-check:hover {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--qs-accent) 18%, transparent);
  }
}
#card-todo .todo-check:active {
  transform: scale(.86);
}
#card-todo .todo-check:focus-visible,
#card-todo .todo-go:focus-visible {
  outline: 2px solid var(--qs-accent);
  outline-offset: 3px;
  animation: qs-focus .32s var(--qs-out);
}
@keyframes qs-focus {
  0% { outline-offset: 9px; outline-color: transparent; }
}

#card-todo .todo-tick {
  stroke-dasharray: 20 20;
  stroke-dashoffset: 20;
  transition: stroke-dashoffset .26s var(--qs-io);
}
#card-todo .todo-check[aria-pressed="true"] .todo-tick {
  stroke-dashoffset: 0;
}
/* ghost tick while hovering an open quest (suppressed right after a toggle until the pointer leaves);
   real pointers only, a touch "hover" would stick */
@media (hover: hover) {
  #card-todo .todo-check[aria-pressed="false"]:not(.qs-cool):hover {
    color: var(--qs-line);
    color: color-mix(in srgb, var(--qs-ink) 30%, transparent);
  }
  #card-todo .todo-check[aria-pressed="false"]:not(.qs-cool):hover .todo-tick {
    stroke-dashoffset: 0;
  }
}
#card-todo .todo-check.qs-on {
  animation: qs-check-on .5s var(--qs-back) both;
}
#card-todo .todo-check.qs-on .todo-tick {
  transition: none;
  animation: qs-tick-in .42s var(--qs-io) .08s both;
}
#card-todo .todo-check.qs-off {
  animation: qs-check-off .34s var(--qs-out) both;
}
#card-todo .todo-check.qs-off .todo-tick {
  transition: none;
  animation: qs-tick-out .2s cubic-bezier(.5, 0, .75, 0) both;
}
/* Keyboard toggle: keep qs-focus in the list. Otherwise taking .qs-on / .qs-off away again would swap
   animation-name back to qs-focus and the lock-on ring would replay a moment after every Space / Enter. */
#card-todo .todo-check.qs-on:focus-visible {
  animation: qs-focus .32s var(--qs-out), qs-check-on .5s var(--qs-back) both;
}
#card-todo .todo-check.qs-off:focus-visible {
  animation: qs-focus .32s var(--qs-out), qs-check-off .34s var(--qs-out) both;
}
@keyframes qs-check-on {
  0%   { transform: scale(.8); }
  100% { transform: scale(1); }
}
@keyframes qs-check-off {
  0%   { transform: scale(.9); }
  100% { transform: scale(1); }
}
@keyframes qs-tick-in {
  0%   { stroke-dashoffset: 20; }
  100% { stroke-dashoffset: 0; }
}
@keyframes qs-tick-out {
  0%   { stroke-dashoffset: 0; }
  100% { stroke-dashoffset: 20; }
}

/* "next quest" beacon: one slow ring on the first open checkbox */
#card-todo .todo-check::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 11px;
  border: 1.5px solid var(--qs-accent);
  opacity: 0;
  pointer-events: none;
}
#card-todo.qs-live .todo-row.qs-next:not(:hover) .todo-check[aria-pressed="false"]::after {
  animation: qs-beacon 3.6s var(--qs-out) infinite;
  animation-delay: 1.2s;
}
@keyframes qs-beacon {
  0%        { transform: scale(1); opacity: 0; }
  6%        { opacity: .6; }
  42%, 100% { transform: scale(1.72); opacity: 0; }
}

/* burst (nodes are added by quests.js on toggle and removed afterwards) */
#card-todo .qs-burst {
  position: absolute;
  inset: 0;
  display: block;
  pointer-events: none;
}
#card-todo .qs-burst i {
  position: absolute;
  display: block;
}
#card-todo .qs-ring {
  inset: -2px;
  border-radius: 11px;
  border: 2px solid var(--qs-accent);
  animation: qs-ring .62s var(--qs-out) both;
}
#card-todo .qs-ring-2 {
  --qs-s: 2.75;
  border-width: 1px;
  animation-duration: .86s;
  animation-delay: .08s;
}
@keyframes qs-ring {
  0%   { transform: scale(.92); opacity: .95; }
  100% { transform: scale(var(--qs-s, 2.05)); opacity: 0; }
}
#card-todo .qs-burst-in .qs-ring {
  border-width: 1.5px;
  animation: qs-ring-in .4s var(--qs-io) both;
}
@keyframes qs-ring-in {
  0%   { transform: scale(1.9); opacity: 0; }
  45%  { opacity: .7; }
  100% { transform: scale(1); opacity: 0; }
}
#card-todo .qs-spark {
  left: 50%;
  top: 50%;
  width: 2px;
  height: 9px;
  margin: -4.5px 0 0 -1px;
  border-radius: 2px;
  background: var(--qs-accent);
  animation: qs-spark .58s var(--qs-out) both;
}
#card-todo .qs-spark-s {
  height: 5px;
  margin-top: -2.5px;
  animation-name: qs-spark-s;
  animation-delay: .05s;
}
@keyframes qs-spark {
  0%   { transform: rotate(var(--qs-a, 0deg)) translate3d(0, -12px, 0) scaleY(.2); opacity: 1; }
  45%  { transform: rotate(var(--qs-a, 0deg)) translate3d(0, -25px, 0) scaleY(1); opacity: 1; }
  100% { transform: rotate(var(--qs-a, 0deg)) translate3d(0, -31px, 0) scaleY(0); opacity: 0; }
}
@keyframes qs-spark-s {
  0%   { transform: rotate(var(--qs-a, 0deg)) translate3d(0, -12px, 0) scaleY(.2); opacity: 1; }
  45%  { transform: rotate(var(--qs-a, 0deg)) translate3d(0, -20px, 0) scaleY(1); opacity: 1; }
  100% { transform: rotate(var(--qs-a, 0deg)) translate3d(0, -24px, 0) scaleY(0); opacity: 0; }
}

/* ------------------------------------------------------------
   Go arrow
   ------------------------------------------------------------ */
#card-todo .todo-go {
  overflow: hidden;
  transition: background-color .26s var(--qs-out), color .26s var(--qs-out), box-shadow .26s var(--qs-out), transform .2s var(--qs-out);
}
#card-todo .todo-go svg {
  transition: transform .34s var(--qs-out);
}
@media (hover: hover) {
  #card-todo .todo-row:hover .todo-go svg {
    transform: translate3d(2px, 0, 0);
  }
}
#card-todo .todo-row:has(:focus-visible) .todo-go svg {
  transform: translate3d(2px, 0, 0);
}
#card-todo .todo-go:hover,
#card-todo .todo-go:focus-visible {
  background: var(--qs-fill);
  color: #FFFFFF;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--qs-accent) 18%, transparent);
}
#card-todo .todo-go:hover svg,
#card-todo .todo-go:focus-visible svg {
  animation: qs-launch .62s var(--qs-io) both;
}
#card-todo .todo-go:active {
  transform: scale(.9);
}
@keyframes qs-launch {
  0%   { transform: translate3d(2px, 0, 0); opacity: 1; }
  42%  { transform: translate3d(17px, 0, 0); opacity: 0; }
  43%  { transform: translate3d(-17px, 0, 0); opacity: 0; }
  100% { transform: translate3d(2px, 0, 0); opacity: 1; }
}

/* ------------------------------------------------------------
   All quests done — header flourish (nodes are added by quests.js)
   ------------------------------------------------------------ */
#card-todo .hud-head {
  position: relative;
}
#card-todo .hud-note {
  transition: opacity .3s var(--qs-out), transform .3s var(--qs-out);
}
#card-todo.qs-complete .hud-note {
  opacity: 0;
  transform: translate3d(0, -6px, 0);
}
#card-todo .qs-badge {
  position: absolute;
  right: 0;
  top: 50%;
  height: 22px;
  margin-top: -11px;
  padding: 0 11px 0 7px;
  display: flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  background: var(--qs-fill);
  color: #FFFFFF;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  /* hidden by opacity only: it is a live region (role=status), and one that sits behind visibility:hidden
     until the very moment its text is set is not reliably announced */
  opacity: 0;
  transform: translate3d(0, 5px, 0);
  transition: opacity .22s var(--qs-io), transform .22s var(--qs-io);
}
#card-todo .qs-badge svg {
  flex-shrink: 0;
  display: block;
}
#card-todo .qs-badge path {
  stroke-dasharray: 20 20;
  stroke-dashoffset: 20;
}
#card-todo .qs-badge::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  background: linear-gradient(100deg, transparent, color-mix(in srgb, #FFFFFF 55%, transparent), transparent);
  transform: translate3d(-120%, 0, 0);
  opacity: 0;
}
#card-todo.qs-complete .qs-badge {
  opacity: 1;
  transform: none;
  transition: none;
  animation: qs-badge-in .62s var(--qs-out) both;
}
#card-todo.qs-complete .qs-badge path {
  stroke-dashoffset: 0;
  animation: qs-tick-in .42s var(--qs-io) .3s both;
}
#card-todo.qs-complete .qs-badge::after {
  animation: qs-badge-shine 1s var(--qs-io) .42s both;
}
@keyframes qs-badge-in {
  0%   { opacity: 0; transform: translate3d(10px, 0, 0); clip-path: inset(0 0 0 100% round 999px); }
  35%  { opacity: 1; }
  100% { opacity: 1; transform: translate3d(0, 0, 0); clip-path: inset(0 0 0 0 round 999px); }
}
@keyframes qs-badge-shine {
  0%   { transform: translate3d(-120%, 0, 0); opacity: 1; }
  100% { transform: translate3d(270%, 0, 0); opacity: 1; }
}

/* a line that draws under the header, then lets go */
#card-todo .qs-headline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -7px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--qs-accent), color-mix(in srgb, var(--qs-accent) 0%, transparent));
  transform: scaleX(0);
  transform-origin: 0 50%;
  opacity: 0;
  pointer-events: none;
}
#card-todo.qs-complete .qs-headline {
  animation: qs-headline 1.5s var(--qs-out) both;
}
@keyframes qs-headline {
  0%   { transform: scaleX(0); opacity: 1; }
  50%  { transform: scaleX(1); opacity: 1; }
  100% { transform: scaleX(1); opacity: 0; }
}

/* one scan pass down the whole card */
#card-todo .qs-scan {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  pointer-events: none;
}
#card-todo .qs-scan i {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 30%;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--qs-accent) 11%, transparent) 80%, color-mix(in srgb, var(--qs-accent) 55%, transparent) 99%, transparent);
  transform: translate3d(0, -101%, 0);
  opacity: 0;
}
#card-todo.qs-complete .qs-scan i {
  animation: qs-scan 1.15s var(--qs-io) .08s both;
}
@keyframes qs-scan {
  0%   { transform: translate3d(0, -101%, 0); opacity: 1; }
  82%  { opacity: 1; }
  100% { transform: translate3d(0, 334%, 0); opacity: 0; }
}

/* ------------------------------------------------------------
   Stage read-outs touched on toggle (white only inside #dash-stage)
   ------------------------------------------------------------ */
#dash-xp .xp-fill.qs-tween,
#dash-quest .quest-fill.qs-tween {
  transition: width .85s cubic-bezier(.16, 1, .3, 1);
}
#dash-xp-val.qs-pop,
#dash-quest-count.qs-pop {
  display: inline-block;
  transform-origin: 50% 70%;
  animation: qs-num-pop .52s cubic-bezier(.16, 1, .3, 1) both;
}
@keyframes qs-num-pop {
  0%   { transform: translate3d(0, 4px, 0) scale(.8); opacity: .35; }
  45%  { transform: translate3d(0, 0, 0) scale(1.16); opacity: 1; }
  100% { transform: translate3d(0, 0, 0) scale(1); opacity: 1; }
}

/* ------------------------------------------------------------
   Fixed fx layer on <body>: XP chip, its trail, landing flare
   ------------------------------------------------------------ */
.qs-fx {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 90;
  pointer-events: none;
}
.qs-chip {
  position: absolute;
  left: 0;
  top: 0;
  height: 22px;
  box-sizing: border-box;
  padding: 0 9px;
  display: flex;
  align-items: center;
  border-radius: 999px;
  border: 1.5px solid #FFFFFF;
  background: var(--qs-accent);
  color: #FFFFFF;
  font-family: var(--font, 'KhaoNiaw', 'Zen Maru Gothic', sans-serif);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: .06em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  opacity: 0;
  will-change: transform, opacity;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--qs-accent) 38%, transparent), 0 8px 16px -9px var(--qs-accent);
}
.qs-chip.qs-neg {
  background: var(--qs-surface);
  color: var(--qs-ink);
  border-color: var(--qs-ink);
  box-shadow: none;
}
.qs-mote {
  position: absolute;
  left: 0;
  top: 0;
  width: 7px;
  height: 7px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid #FFFFFF;
  background: var(--qs-accent);
  opacity: 0;
  will-change: transform, opacity;
}
.qs-flare {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 2px solid #FFFFFF;
  opacity: 0;
  will-change: transform, opacity;
}
.qs-flare.qs-flare-2 {
  border-width: 1px;
}
.qs-flare.qs-flare-dot {
  width: 12px;
  height: 12px;
  border: 0;
  background: #FFFFFF;
}

/* ------------------------------------------------------------
   Reduced motion: resting states only
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  #card-todo *,
  #card-todo *::before,
  #card-todo *::after,
  #dash-xp .xp-fill.qs-tween,
  #dash-quest .quest-fill.qs-tween,
  #dash-xp-val.qs-pop,
  #dash-quest-count.qs-pop {
    animation: none !important;
    transition: none !important;
  }
  #card-todo.qs-pre .todo-row {
    opacity: 1;
  }
  #card-todo .todo-row:hover {
    transform: none;
  }
  #card-todo .todo-row:has(:focus-visible) {
    transform: none;
  }
  #card-todo .qs-burst,
  #card-todo .qs-scan,
  #card-todo .qs-headline,
  .qs-fx {
    display: none;
  }
}
