/*
 * TAG Legal Desk v2.1: the sending cards, the sender's own controls and the pop (registers J104 and J120,
 * js\v21_sending.js). Tokens only, no inline styles (the page's policy): the page writes two custom properties through
 * the CSSOM each second, --v21-p (how far the card has blurred out, 0 to 1) and --v21-left (how much of its bar is
 * left, 1 to 0); a one second linear transition makes both move smoothly, so the card slowly blurs out.
 * A sending card keeps the greyed look of styles\v21_colours.css (the dashed edge, the frost, the grey). J120: its glyph
 * and words blur from 0 to 6 px and fade from 1 to 0.35 as its time runs down (softly blurred from the press: 1.2 px
 * by the end of the Undo window, then on to fully blurred out at its time). The chip (the countdown and "Sent by"),
 * the bar and the sender's own buttons and line are never blurred or faded: they sit above the blur and the frost, so
 * the chip keeps the greyed chip's contrast (ink-2 on solid-2) in every theme. Reduced motion and Calm: no transition
 * (the page steps the blur once a minute). High contrast: the words blur but never fade, the frost is lighter, and the
 * bar, the buttons and the line are solid black on white. Forced colours: no blur and no fade. The pop, its leaves and
 * its words sit in the fx layer, never in the card list, so nothing in the list moves for them; only transform and
 * opacity animate there.
 */

/* ---------- the sending card on every board ---------- */
:root[data-v21-core="on"] .card.is-sending.v21-sending > .glyph,
:root[data-v21-core="on"] .card.is-sending.v21-sending > .body {
  filter: grayscale(1) blur(calc(var(--v21-p, 0) * 6px));
  opacity: calc(1 - var(--v21-p, 0) * .65);
  transition: filter 1s linear, opacity 1s linear;
}
/* The countdown's digits keep one width, so "Leaves in 7:42" never jitters as it ticks; "Sent by" sits after a rule. */
.card .holder.going .v21-cd { font-variant-numeric: tabular-nums; white-space: nowrap; }
.card .holder.going .v21-by { white-space: nowrap; font-weight: 600; padding-left: 10px; border-left: 1px solid var(--edge-strong); }
.card .holder.going .v21-by[hidden] { display: none; }
/* The countdown always stays whole. At phone width the chip is too narrow for both parts on one line ("Leaves in
   under a minute", then "Sent by Robin"), so "Sent by" takes its own line under the countdown, never cut short. */
.card .holder.going .v21-cd { flex: 0 0 auto; }
@media (max-width: 599px) {
  .card .holder.going { flex-wrap: wrap; row-gap: 0; border-radius: 18px; }
  .card .holder.going .v21-by { flex: 1 0 100%; padding-left: 28px; border-left: 0; }
}

/* The bar along the foot of the card: full in the 8 second Undo window, then it drains once, over the hold. */
.card.v21-sending > .v21-drain {
  position: absolute; left: 16px; right: 16px; bottom: 6px; z-index: 2; height: 4px; border-radius: 2px;
  overflow: hidden; pointer-events: none; background: color-mix(in srgb, var(--ink-2) 20%, transparent);
}
.card.v21-sending > .v21-drain[hidden] { display: none; }
.card.v21-sending > .v21-drain > i {
  display: block; width: 100%; height: 100%; border-radius: inherit; background: var(--brand-text);
  transform-origin: 0 50%; transform: scaleX(var(--v21-left, 1)); transition: transform 1s linear;
}

/* ---------- the sender's own card: Undo, Pull back, Send now and one small line, sharp above the blur ---------- */
/* v21-ctl, never v21-mine: styles\v21_colours.css uses .card.v21-mine for the glow on a card I have. */
.card.v21-own > .v21-ctl {
  grid-column: 2 / -1; position: relative; z-index: 2; display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px 12px; margin: 2px 0 6px; pointer-events: none;
}
.card.v21-own > .v21-ctl[hidden] { display: none; }
.card.v21-own .v21-acts { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.card.v21-own .v21-acts .btn { pointer-events: auto; min-height: 36px; white-space: nowrap; background: var(--solid); color: var(--ink); box-shadow: 0 0 0 1px var(--glass-rim), var(--shadow-1); }
.card.v21-own .v21-acts .btn[hidden] { display: none; }
.card.v21-own .v21-acts .btn.is-armed { background: var(--warn); color: var(--solid); box-shadow: none; }
.card.v21-own .v21-acts .btn[aria-disabled="true"] { cursor: progress; opacity: .85; }
.card.v21-own .v21-line { margin: 0; flex: 1 1 240px; min-width: 0; font-size: .8125rem; line-height: 1.1875rem; font-weight: 600; color: var(--ink); }
.card.v21-own .v21-line:empty { display: none; }
@media (min-width: 600px) {
  /* The chip moves up to the top corner so the buttons have the row under the words. */
  :root[data-v21-core="on"] .card.v21-own .holder { top: 14px; transform: none; }
}
@media (pointer: coarse) {
  .card.v21-own .v21-acts .btn { min-height: 44px; }
}

/* Nothing moves: the blur, the fade and the bar step without a transition. */
:root[data-motion="reduced"][data-v21-core="on"] .card.is-sending.v21-sending > .glyph,
:root[data-motion="reduced"][data-v21-core="on"] .card.is-sending.v21-sending > .body,
:root[data-motion="reduced"] .card.v21-sending > .v21-drain > i,
:root[data-calm="on"][data-v21-core="on"] .card.is-sending.v21-sending > .glyph,
:root[data-calm="on"][data-v21-core="on"] .card.is-sending.v21-sending > .body,
:root[data-calm="on"] .card.v21-sending > .v21-drain > i { transition: none; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"])[data-v21-core="on"] .card.is-sending.v21-sending > .glyph,
  :root:not([data-motion="full"])[data-v21-core="on"] .card.is-sending.v21-sending > .body,
  :root:not([data-motion="full"]) .card.v21-sending > .v21-drain > i { transition: none; }
}

/* High contrast: the words blur out but never fade, the frost is lighter, and everything that stays sharp is solid
   black on white. */
:root[data-theme="high_contrast"][data-v21-core="on"] .card.is-sending.v21-sending > .glyph,
:root[data-theme="high_contrast"][data-v21-core="on"] .card.is-sending.v21-sending > .body { opacity: 1; }
:root[data-theme="high_contrast"][data-v21-core="on"] .card.is-sending.v21-sending > .frost { opacity: .45; }
:root[data-theme="high_contrast"] .card.v21-sending > .v21-drain { background: #CCCCCC; }
:root[data-theme="high_contrast"] .card.v21-sending > .v21-drain > i { background: #000000; }
:root[data-theme="high_contrast"] .card .holder.going .v21-by { border-left-color: #000000; }
:root[data-theme="high_contrast"] .card.v21-own .v21-acts .btn { background: #FFFFFF; color: #000000; box-shadow: inset 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .card.v21-own .v21-acts .btn.is-armed { background: #000000; color: #FFFFFF; }
:root[data-theme="high_contrast"] .card.v21-own .v21-line { color: #000000; }
@media (forced-colors: active) {
  :root[data-v21-core="on"] .card.is-sending.v21-sending > .glyph,
  :root[data-v21-core="on"] .card.is-sending.v21-sending > .body { filter: none; opacity: 1; transition: none; }
  .card.v21-sending > .v21-drain { background: Canvas; border: 1px solid CanvasText; }
  .card.v21-sending > .v21-drain > i { background: Highlight; }
  .card.v21-own .v21-acts .btn { border: 2px solid ButtonText; }
}

/* ---------- the pop (in the fx layer, over where the card was) ---------- */
.fx-layer .v21-pop-ghost {
  position: absolute; left: 0; top: 0; margin: 0; pointer-events: none;
  transform-origin: 50% 50%; will-change: transform, opacity;
}
/* The gum leaves: a long leaf pointed at both ends, with its midrib, in eucalypt greens and one Leaf Token gold. */
.fx-layer .v21-pop-leaf {
  position: absolute; left: -12px; top: -4.5px; width: 24px; height: 9px; border-radius: 100% 0;
  opacity: 0; pointer-events: none; will-change: transform, opacity;
  background: linear-gradient(160deg, transparent 46%, rgba(0,0,0,.22) 48%, rgba(0,0,0,.22) 52%, transparent 54%), var(--v21-leaf, #5E8C6A);
}
.fx-layer .v21-pop-leaf.v21-leaf-0 { --v21-leaf: #5E8C6A; }
.fx-layer .v21-pop-leaf.v21-leaf-1 { --v21-leaf: #8AAE8C; }
.fx-layer .v21-pop-leaf.v21-leaf-2 { --v21-leaf: #3F6B4D; }
.fx-layer .v21-pop-leaf.v21-leaf-3 { --v21-leaf: #C9A227; }
.fx-layer .v21-pop-at { position: absolute; left: 0; top: 0; width: 0; height: 0; pointer-events: none; }
/* The words: big and clear, "+3 for Avery". */
.fx-layer .v21-pop-words {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  display: inline-flex; align-items: baseline; gap: 8px; padding: 8px 20px; border-radius: 999px;
  background: var(--solid); color: var(--ink); box-shadow: 0 0 0 1px var(--glass-rim), var(--shadow-2);
  font-size: 1.375rem; line-height: 1.75rem; font-weight: 700; white-space: nowrap;
  max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
.fx-layer .v21-pop-words b { color: var(--brand-text); font-size: 1.75rem; font-variant-numeric: tabular-nums; }
:root[data-theme="high_contrast"] .fx-layer .v21-pop-words { background: #FFFFFF; color: #000000; box-shadow: inset 0 0 0 3px #000000; }
:root[data-theme="high_contrast"] .fx-layer .v21-pop-words b { color: #000000; }
:root[data-theme="high_contrast"] .fx-layer .v21-pop-leaf { --v21-leaf: #000000; background: #000000; }
@media (forced-colors: active) {
  .fx-layer .v21-pop-words { border: 2px solid CanvasText; }
  .fx-layer .v21-pop-leaf { background: CanvasText; forced-color-adjust: none; }
}
@media (max-width: 599px) {
  .fx-layer .v21-pop-words { font-size: 1.125rem; line-height: 1.5rem; padding: 6px 14px; }
  .fx-layer .v21-pop-words b { font-size: 1.375rem; }
  .fx-layer .v21-pop-leaf { left: -10px; top: -4px; width: 20px; height: 8px; }
}
