/*
 * TAG Legal Desk v2.1: Leaf Token coins that fly to the winner, the counter by their avatar, the win announcements at
 * the far bottom left and the bigger pop (register J149, js\v21_coins.js). Theme tokens only, no inline styles (the
 * page's policy): every place comes through the CSSOM, and only transform and opacity animate. Everything here is game
 * art (data-v21="game"), so the core's quiet rule hides it while a welfare message is open, in the quiet period and
 * under the nobody band. Reduced motion and Calm: the page flies nothing and shows the number still. High contrast:
 * black on white, the coins black and white. Forced colours: plain outlines.
 */

/* ---------- the coins, the bonus label and the prize in flight (in the fx layer) ---------- */
.fx-layer .kcn-coin, .fx-layer .kcn-prize, .fx-layer .kcn-tag {
  position: absolute; left: 0; top: 0; pointer-events: none; will-change: transform, opacity; opacity: 0;
}
.fx-layer .kcn-coin { width: 22px; height: 22px; filter: drop-shadow(0 1px 1px rgba(0,0,0,.28)); }
.fx-layer .kcn-coin > img, .fx-layer .kcn-coin > svg, .fx-layer .kcn-prize > img, .fx-layer .kcn-prize > svg { display: block; width: 100%; height: 100%; }
.fx-layer .kcn-coin.is-bonus { filter: drop-shadow(0 0 5px #F2D16B) drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.fx-layer .kcn-prize { width: 34px; height: 34px; filter: drop-shadow(0 0 8px #F2D16B) drop-shadow(0 2px 3px rgba(0,0,0,.3)); }
.fx-layer .kcn-tag {
  padding: 2px 10px; border-radius: 999px; white-space: nowrap; font-size: .8125rem; line-height: 1.25rem; font-weight: 800;
  background: var(--solid); color: var(--info); box-shadow: 0 0 0 2px var(--info), var(--shadow-1);
}
/* The drawn Leaf Token (when the art library's picture is not in): a gold coin with a gum leaf on its face. */
.kcn-coin-svg .kcn-coin-rim { fill: #B8901F; }
.kcn-coin-svg .kcn-coin-face { fill: #E9C349; stroke: #F6DE8A; stroke-width: .8; }
.kcn-coin-svg .kcn-coin-leaf { fill: #4F7F5C; }
.kcn-coin-svg .kcn-coin-rib { stroke: #E9C349; stroke-width: .8; fill: none; stroke-linecap: round; }
/* The drawn prizes: a medal, a gum nut, a wrapped gift. */
.kcn-prize-svg .kcn-p-ribbon { fill: #3F6B9E; }
.kcn-prize-svg .kcn-p-gold { fill: #E0B53A; stroke: #A88420; stroke-width: 1; }
.kcn-prize-svg .kcn-p-star { fill: #FFF6D6; }
.kcn-prize-svg .kcn-p-nut { fill: #8A6A45; }
.kcn-prize-svg .kcn-p-cap { fill: #5E4A33; }
.kcn-prize-svg .kcn-p-stem { stroke: #5E4A33; stroke-width: 1.6; stroke-linecap: round; fill: none; }
.kcn-prize-svg .kcn-p-box { fill: #5E8C6A; }
.kcn-prize-svg .kcn-p-lid { fill: #4F7F5C; }
.kcn-prize-svg .kcn-p-bow { fill: none; stroke: #E9C349; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- the halo that bursts where coins leave or a prize lands ---------- */
.fx-layer .kcn-burst {
  position: absolute; left: 0; top: 0; width: 64px; height: 64px; border-radius: 50%; pointer-events: none; opacity: 0;
  box-shadow: 0 0 0 3px #E9C349, 0 0 18px 4px rgba(233,195,73,.6);
}
.fx-layer .kcn-burst.is-prize { width: 88px; height: 88px; }

/* ---------- the counter by the avatar: +1, +2, +3 up to the total ---------- */
.fx-layer .kcn-count {
  position: absolute; left: 0; top: 0; z-index: 3; pointer-events: none; transform-origin: 30% 50%;
  min-width: 26px; padding: 1px 8px; border-radius: 999px; text-align: center; white-space: nowrap;
  font-size: .875rem; line-height: 1.25rem; font-weight: 800; font-variant-numeric: tabular-nums;
  background: var(--solid); color: var(--ink); box-shadow: 0 0 0 2px #E9C349, var(--shadow-2);
}
.fx-layer .kcn-count.is-mine { color: var(--brand-text); }

/* ---------- the thin win announcements at the far bottom left ---------- */
/* Under the toasts and any sheet (z-index 54), and lifted above the held-email dock the way the toasts are. */
.kcn-wins {
  position: fixed; left: 12px; bottom: 12px; z-index: 54; display: flex; flex-direction: column; align-items: flex-start;
  gap: 6px; max-width: min(440px, calc(100vw - 24px)); pointer-events: none;
}
.kcn-wins:empty { display: none; }
body.has-leaving .kcn-wins { bottom: calc(28px + var(--leave-h, 0px)); }
body.job-open .kcn-wins { display: none; }
.kcn-win {
  display: flex; align-items: center; gap: 8px; max-width: 100%; padding: 3px 14px 3px 5px; border-radius: 999px;
  background: var(--solid); color: var(--ink); box-shadow: 0 0 0 1px var(--glass-rim), var(--shadow-1);
  font-size: .8125rem; line-height: 1.25rem; font-weight: 600;
}
.kcn-win.is-prize { box-shadow: 0 0 0 1px #E9C349, var(--shadow-1); }
.kcn-win-pic { flex: none; display: grid; place-items: center; width: 22px; height: 22px; }
.kcn-win-pic > img, .kcn-win-pic > svg { display: block; width: 20px; height: 20px; }
.kcn-win-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 599px) {
  .kcn-wins { left: 8px; bottom: 8px; }
  body.has-leaving .kcn-wins { bottom: calc(22px + var(--leave-h, 0px)); }
  .kcn-win { font-size: .75rem; line-height: 1.125rem; }
}

/* ---------- the pop's words, even more obvious (js\v21_sending.js adds kcn-pop) ---------- */
.fx-layer .v21-pop-at.kcn-pop .v21-pop-words {
  font-size: 1.75rem; line-height: 2.25rem; padding: 10px 26px;
  box-shadow: 0 0 0 3px #E9C349, 0 0 28px 8px rgba(233,195,73,.5), var(--shadow-2);
}
.fx-layer .v21-pop-at.kcn-pop .v21-pop-words b { font-size: 2.375rem; }
@media (max-width: 599px) {
  .fx-layer .v21-pop-at.kcn-pop .v21-pop-words { font-size: 1.25rem; line-height: 1.75rem; padding: 6px 16px; }
  .fx-layer .v21-pop-at.kcn-pop .v21-pop-words b { font-size: 1.625rem; }
}

/* ---------- High contrast, forced colours, Calm ---------- */
:root[data-theme="high_contrast"] .fx-layer .kcn-count,
:root[data-theme="high_contrast"] .fx-layer .kcn-tag,
:root[data-theme="high_contrast"] .kcn-win { background: #FFFFFF; color: #000000; box-shadow: inset 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .fx-layer .kcn-burst { box-shadow: 0 0 0 3px #000000; }
:root[data-theme="high_contrast"] .fx-layer .kcn-coin, :root[data-theme="high_contrast"] .fx-layer .kcn-prize { filter: none; }
:root[data-theme="high_contrast"] .kcn-coin-svg .kcn-coin-rim { fill: #000000; }
:root[data-theme="high_contrast"] .kcn-coin-svg .kcn-coin-face { fill: #FFFFFF; stroke: #000000; }
:root[data-theme="high_contrast"] .kcn-coin-svg .kcn-coin-leaf { fill: #000000; }
:root[data-theme="high_contrast"] .kcn-coin-svg .kcn-coin-rib { stroke: #FFFFFF; }
:root[data-theme="high_contrast"] .fx-layer .v21-pop-at.kcn-pop .v21-pop-words { box-shadow: inset 0 0 0 3px #000000; }
@media (forced-colors: active) {
  .fx-layer .kcn-count, .fx-layer .kcn-tag, .kcn-win { border: 2px solid CanvasText; box-shadow: none; }
  .fx-layer .kcn-burst { border: 3px solid CanvasText; box-shadow: none; }
  .fx-layer .kcn-coin, .fx-layer .kcn-prize { filter: none; forced-color-adjust: none; }
}
/* Calm: nothing flies (the page shows the number only); the counter and the lines stand still. */
:root[data-calm="on"] .fx-layer .kcn-coin, :root[data-calm="on"] .fx-layer .kcn-prize,
:root[data-calm="on"] .fx-layer .kcn-tag, :root[data-calm="on"] .fx-layer .kcn-burst { display: none !important; }
@media print { .kcn-wins { display: none; } }
