/*
 * TAG Legal Desk v2.1, wp9_colours: the greyed board cards, Your colour in Settings, and the held job glow.
 * Tokens only, no inline styles (the page's policy). The colours come from the root custom properties --v21-dc-<id>
 * (js\v21_colours.js sets them through the CSSOM from js\v21_colours_data.js) and, on a card, --v21-mc (my colour)
 * and --v21-hc (the holder's colour), each read with a fallback so a colour token the page does not know never takes
 * the frost or the edge away. Only opacity animates, and nothing moves with reduced motion, Calm or the quiet period.
 * Colour is never the only sign: every greyed card has its chip and a dashed edge, a held card has its holder chip,
 * and a chosen swatch has its tick. The greyed cards follow the v2.1 switch (data-v21-core), so with v2.1 off the
 * board is the Friday board.
 */

/* ---------- the board: greyed cards (sending, inside the 10 minute Pull back hold, or waiting on a scheduled send) */
/* The two states share the Sending card's rules in desk.css; is-scheduled is new (js\board.js, only while v2.1 is on). */
:root[data-v21-core="on"] .card.is-scheduled { cursor: default; }
:root[data-v21-core="on"] .card.is-scheduled:hover { transform: none; }
:root[data-v21-core="on"] .card.is-scheduled .frost { opacity: .55; }
:root[data-v21-core="on"] .card.is-scheduled .side { visibility: hidden; }
:root[data-v21-core="on"] .card.is-sending, :root[data-v21-core="on"] .card.is-scheduled { border-style: dashed; border-color: var(--edge-strong); }
/* Desaturated, still readable: the frost already lowers the contrast, so the text is not faded any further. */
:root[data-v21-core="on"] .card.is-sending > .glyph, :root[data-v21-core="on"] .card.is-sending > .body, :root[data-v21-core="on"] .card.is-scheduled > .glyph, :root[data-v21-core="on"] .card.is-scheduled > .body { filter: grayscale(1); }
/* The chip says what is happening. ink-2 on solid-2 is 7 to 1 or more in every theme (tests\v21_colours.test.js). */
.card .holder.going { background: var(--solid-2); color: var(--ink-2); box-shadow: 0 0 0 1px var(--glass-rim), var(--shadow-1); }
.card .holder.going .ico { color: var(--ink-2); }
:root[data-theme="high_contrast"] .card .holder.going { background: #FFFFFF; color: #000000; box-shadow: inset 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .card .holder.going .ico { color: #000000; }
@media (max-width: 599px) { :root[data-v21-core="on"] .card.is-scheduled .side { display: none; } }

/* ---------- the board: my card glows in my colour ---------- */
.card.v21-mine,
.card.v21-dc.is-checking {
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 2px var(--v21-mc, var(--brand)), 0 0 18px 2px color-mix(in srgb, var(--v21-mc, var(--brand)) 40%, transparent), var(--shadow-1);
}
/* "Take a closer look" keeps its amber edge on my own card too. */
.card.closer.v21-mine {
  box-shadow: inset 3px 0 0 var(--warn), inset 0 1px 0 var(--glass-hi), 0 0 0 2px var(--v21-mc, var(--brand)), 0 0 18px 2px color-mix(in srgb, var(--v21-mc, var(--brand)) 40%, transparent), var(--shadow-1);
}
/* Behind the words: the card is its own stacking context (contain: paint), so z-index -1 keeps the glow above the
   card's glass and below the glyph, the text and the side. */
.card .v21-glow {
  position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--v21-mc, var(--brand)) 55%, transparent), inset 0 0 26px 2px color-mix(in srgb, var(--v21-mc, var(--brand)) 30%, transparent);
  opacity: .8;
  animation: v21-dc-breathe 3.6s ease-in-out infinite alternate;
}
@keyframes v21-dc-breathe { from { opacity: .45; } to { opacity: 1; } }

/* ---------- the board: a colleague's card carries their hue while it is locked out ---------- */
.card.v21-hue {
  box-shadow: inset 0 1px 0 var(--glass-hi), 0 0 0 1px color-mix(in srgb, var(--v21-hc, transparent) 50%, var(--glass-rim)), var(--shadow-1);
}
/* "Take a closer look" keeps its amber edge on a colleague's card too, and the holder's edge sits just inside it. */
.card.closer.v21-hue {
  box-shadow: inset 3px 0 0 var(--warn), inset 0 1px 0 var(--glass-hi), 0 0 0 1px color-mix(in srgb, var(--v21-hc, transparent) 50%, var(--glass-rim)), var(--shadow-1);
}
.card.v21-hue .frost { background: color-mix(in srgb, var(--v21-hc, transparent) 10%, var(--glass-2)); }
.card .v21-edge { position: absolute; left: 0; top: 0; bottom: 0; width: 5px; z-index: 1; pointer-events: none; background: var(--v21-hc, var(--edge-strong)); }
.card.closer .v21-edge { left: 3px; }

/* ---------- still: reduced motion, Calm and the quiet period ---------- */
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .card .v21-glow { animation: none; opacity: .8; }
}
:root[data-motion="reduced"] .card .v21-glow,
:root[data-calm="on"] .card .v21-glow,
:root[data-quiet="on"] .card .v21-glow { animation: none; opacity: .8; }

/* ---------- High contrast: solid rings, no soft glow, no tint (the amber closer look edge stays) ---------- */
:root[data-theme="high_contrast"] .card.v21-mine,
:root[data-theme="high_contrast"] .card.v21-dc.is-checking { box-shadow: 0 0 0 3px var(--v21-mc, var(--brand)); }
:root[data-theme="high_contrast"] .card.closer.v21-mine { box-shadow: inset 3px 0 0 var(--warn), 0 0 0 3px var(--v21-mc, var(--brand)); }
:root[data-theme="high_contrast"] .card .v21-glow { display: none; }
:root[data-theme="high_contrast"] .card.v21-hue { box-shadow: 0 0 0 2px var(--v21-hc, var(--edge-strong)); }
:root[data-theme="high_contrast"] .card.closer.v21-hue { box-shadow: inset 3px 0 0 var(--warn), 0 0 0 2px var(--v21-hc, var(--edge-strong)); }
:root[data-theme="high_contrast"] .card.v21-hue .frost { background: var(--glass-2); }
:root[data-theme="high_contrast"] .card .v21-edge { width: 7px; }

/* ---------- forced colours: the system draws the ring and the edge ---------- */
@media (forced-colors: active) {
  .card.v21-mine, .card.v21-dc.is-checking { outline: 3px solid Highlight; outline-offset: -3px; }
  .card .v21-glow { display: none; }
  .card .v21-edge { forced-color-adjust: none; background: CanvasText; }
}

/* ---------- Settings: Your colour ---------- */
.v21-dc-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.v21-dc-sw { display: grid; justify-items: center; align-content: start; gap: 6px; min-height: 44px; padding: 8px 4px; border: 0; border-radius: 14px; background: transparent; color: var(--ink-2); font-size: .8125rem; font-weight: 700; line-height: 1.2; text-align: center; }
.v21-dc-sw:hover { background: var(--brand-soft); color: var(--ink); }
.v21-dc-sw:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.v21-dc-sw[aria-checked="true"] { background: var(--brand-soft); color: var(--ink); }
.v21-dc-dot { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--v21-sw, var(--brand)); color: var(--p-ink); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }
.v21-dc-dot .v21-dc-tick { opacity: 0; }
.v21-dc-sw[aria-checked="true"] .v21-dc-dot { box-shadow: 0 0 0 2px var(--solid), 0 0 0 4px var(--v21-sw, var(--brand)); }
.v21-dc-sw[aria-checked="true"] .v21-dc-tick { opacity: 1; }
.v21-dc-nm { display: block; max-width: 100%; overflow-wrap: anywhere; }
.v21-dc-who { display: block; max-width: 100%; overflow-wrap: anywhere; font-size: .75rem; font-weight: 600; color: var(--ink-2); }
.v21-dc-who[hidden] { display: none; }
.v21-dc-row { flex-wrap: wrap; }
.v21-dc-preview { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: .875rem; color: var(--ink-2); }
.v21-dc-note { margin: 0; }
/* The chosen mark is never an outline: the outline is the focus ring, and focus always sits on the chosen swatch. */
:root[data-theme="high_contrast"] .v21-dc-dot { box-shadow: inset 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .v21-dc-sw[aria-checked="true"] { box-shadow: inset 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .v21-dc-sw:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }
@media (forced-colors: active) {
  .v21-dc-dot { forced-color-adjust: none; border: 1px solid CanvasText; }
  /* A border (box-shadow is dropped here), with the padding trimmed so the swatch does not move. */
  .v21-dc-sw[aria-checked="true"] { border: 2px solid Highlight; padding: 6px 2px; }
  .v21-dc-sw:focus-visible { outline: 3px solid CanvasText; outline-offset: 3px; }
}
