/*
 * TAG Legal Desk v2.1: with Fred for corrective action (register J190, js\v21_withfred.js). Theme tokens only, no
 * inline styles (the page's policy). The lock's colour is the desk's own information blue (--fca-c, from --info), so it
 * reads as the AI's and never as a person's colour.
 * The card: frosted glass over the whole card (the card keeps its size and place), the AI's robot in a round frame at
 * the left where the glyph is, and the words on a small plate with a faint scanline texture. Now and then the words
 * glitch slightly: two faint coloured copies torn into thin bands and a letter or two nudged by 1 px (the page picks the
 * moment at random and never makes more than 3 changes in a second, WCAG 2.3.1). The words themselves never move more
 * than 1 px and are always there to read.
 * Still (no glitch at all): reduced motion (the setting or the computer's), Calm, the quiet states (a welfare message,
 * the quiet period, the nobody band: data-quiet), a day that matters, High contrast (no coloured copies) and print.
 * Reduced glass, reduced transparency and forced colours each have plain rules below.
 */

/* ---------- the card ---------- */
/* The colours live on the lock itself, so the frost that fades away after the lock lifts (the card no longer locked)
   keeps them to the end. */
.card.fca-on, .card > .fca-lock { --fca-c: var(--info); --fca-ga: var(--info); --fca-gb: var(--danger); }
.card.is-fred { cursor: pointer; }
.card.is-fred:hover { transform: none; }
.card.is-fred .card-hit:focus-visible { outline-offset: -3px; }
.card > .fca-lock {
  position: absolute; inset: 0; z-index: 0; border-radius: inherit; pointer-events: none;
  user-select: none; -webkit-user-select: none; -webkit-user-drag: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--fca-c) 38%, transparent);
}
.card > .fca-lock.fca-in > .fca-frost, .card > .fca-lock.fca-in > .fca-face, .card > .fca-lock.fca-in > .fca-i { opacity: 0; }
/* Review 2 (M2): the frost and the face keep the card's rounded shape themselves, so the i's tip is free to open below
   the card; the lock itself no longer cuts anything off. */
.fca-lock .fca-frost {
  position: absolute; inset: 0; border-radius: inherit; overflow: hidden;
  background: linear-gradient(120deg, color-mix(in srgb, var(--fca-c) 24%, var(--glass-1)), color-mix(in srgb, var(--fca-c) 10%, var(--glass-1)) 62%, color-mix(in srgb, var(--fca-c) 18%, var(--glass-1)));
  -webkit-backdrop-filter: blur(7px) saturate(1.2); backdrop-filter: blur(7px) saturate(1.2);
}
.fca-lock .fca-face { position: relative; box-sizing: border-box; display: flex; align-items: center; gap: 14px; height: 100%; padding: 12px 20px; min-width: 0; overflow: hidden; border-radius: inherit; }
.fca-lock .fca-bot, .fca-band .fca-bot {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  background: var(--solid); color: var(--fca-c);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--fca-c) 72%, transparent), 0 0 12px 1px color-mix(in srgb, var(--fca-c) 40%, transparent);
}
.fca-bot .v21-robot-mark { display: block; transition: none; }
.fca-bot.fca-gl .v21-robot-mark { transform: translateX(1px); }
.fca-bot.fca-gl .rm-dot { opacity: .4; }
.fca-lock .fca-words {
  display: grid; gap: 2px; min-width: 0; max-width: 100%; padding: 6px 12px; border-radius: 12px;
  background-color: color-mix(in srgb, var(--solid) 86%, transparent);
  background-image: repeating-linear-gradient(to bottom, transparent 0 2px, color-mix(in srgb, var(--fca-c) 7%, transparent) 2px 3px);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--fca-c) 35%, transparent);
}
.fca-lock .fca-say { font-size: .9375rem; line-height: 1.25rem; font-weight: 700; color: var(--ink); }
/* The second line: what Fred is doing (J204: shown on the face), or the why when he says nothing more. One line on a
   wide screen and two on a phone (it has the room), never more, so the card keeps its size; the tip has it all. */
.fca-lock .fca-why, .fca-lock .fca-doing { font-size: .8125rem; line-height: 1.125rem; font-weight: 600; color: var(--ink-2); min-width: 0; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; line-clamp: 1; }
.fca-lock .fca-doing { color: var(--ink); }
/* Which job it is, small and quiet under the why (the card itself is under the frost). */
.fca-lock .fca-job { font-size: .75rem; line-height: 1.0625rem; color: var(--ink-3); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- the words and the glitch ---------- */
.fca-say { position: relative; display: block; margin: 0; }
.fca-say .fca-w { display: inline-block; white-space: nowrap; }
.fca-say .fca-l { display: inline-block; }
.fca-say .fca-l.fca-up { transform: translateY(-1px); }
.fca-say .fca-l.fca-dn { transform: translateY(1px); }
/* Two faint copies of the words, torn into thin bands, only for the moment of a glitch. */
.fca-say::before, .fca-say::after {
  content: attr(data-glitch); position: absolute; left: 0; top: 0; right: 0; opacity: 0; pointer-events: none;
}
.fca-say.fca-g1::before { opacity: .62; color: var(--fca-ga, var(--info)); transform: translateX(-2px); clip-path: inset(10% 0 58% 0); }
.fca-say.fca-g1::after { opacity: .5; color: var(--fca-gb, var(--danger)); transform: translateX(2px); clip-path: inset(60% 0 12% 0); }
.fca-say.fca-g2::before { opacity: .55; color: var(--fca-gb, var(--danger)); transform: translateX(1.5px); clip-path: inset(34% 0 40% 0); }
.fca-say.fca-g2::after { opacity: .5; color: var(--fca-ga, var(--info)); transform: translateX(-2px); clip-path: inset(0 0 78% 0); }

/* Still: reduced motion, Calm, the quiet states, a day that matters, High contrast (no copies) and print. */
:root[data-motion="reduced"] .fca-say::before, :root[data-motion="reduced"] .fca-say::after,
:root[data-calm="on"] .fca-say::before, :root[data-calm="on"] .fca-say::after,
:root[data-quiet="on"] .fca-say::before, :root[data-quiet="on"] .fca-say::after,
:root[data-day-matters] .fca-say::before, :root[data-day-matters] .fca-say::after,
:root[data-theme="high_contrast"] .fca-say::before, :root[data-theme="high_contrast"] .fca-say::after { display: none; }
:root[data-motion="reduced"] .fca-say .fca-l, :root[data-calm="on"] .fca-say .fca-l, :root[data-quiet="on"] .fca-say .fca-l, :root[data-day-matters] .fca-say .fca-l,
:root[data-motion="reduced"] .fca-bot .v21-robot-mark, :root[data-calm="on"] .fca-bot .v21-robot-mark, :root[data-quiet="on"] .fca-bot .v21-robot-mark, :root[data-day-matters] .fca-bot .v21-robot-mark { transform: none; }
:root[data-motion="reduced"] .fca-bot .rm-dot, :root[data-calm="on"] .fca-bot .rm-dot, :root[data-quiet="on"] .fca-bot .rm-dot, :root[data-day-matters] .fca-bot .rm-dot { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .fca-say::before, :root:not([data-motion="full"]) .fca-say::after { display: none; }
  :root:not([data-motion="full"]) .fca-say .fca-l, :root:not([data-motion="full"]) .fca-bot .v21-robot-mark { transform: none; }
  :root:not([data-motion="full"]) .fca-bot .rm-dot { opacity: 1; }
}

/* ---------- the job, read only: the band at the top ---------- */
.fca-band {
  --fca-c: var(--info); --fca-ga: var(--info); --fca-gb: var(--danger);
  position: relative; z-index: 3; flex: none; display: flex; align-items: center; gap: 14px; padding: 12px 16px;
  background-color: color-mix(in srgb, var(--fca-c) 12%, var(--solid));
  background-image: repeating-linear-gradient(to bottom, transparent 0 2px, color-mix(in srgb, var(--fca-c) 6%, transparent) 2px 3px);
  border-bottom: 1px solid color-mix(in srgb, var(--fca-c) 40%, transparent);
  box-shadow: inset 4px 0 0 var(--fca-c);
}
.fca-band:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.fca-band .fca-bot { width: 48px; height: 48px; }
.fca-band .fca-bandw { min-width: 0; flex: 1; }
.fca-band .fca-say { font-size: 1.0625rem; line-height: 1.5rem; font-weight: 700; color: var(--ink); }
.fca-band .fca-why { margin: 2px 0 0; font-size: .875rem; line-height: 1.25rem; font-weight: 600; color: var(--ink); }
.fca-band .fca-ro { margin: 2px 0 0; font-size: .8125rem; line-height: 1.1875rem; color: var(--ink-2); }
.job-panel.fca-locked .ed-region { cursor: default; }
/* Every action off shows as off: faded, and the pointer says no. Reading (the whys, the files, the thread) stays as it is. */
.job-panel.fca-locked .fca-off { cursor: not-allowed; opacity: .45; filter: saturate(.35); }
.job-panel.fca-locked .ask textarea.fca-off { background: var(--solid-2); }
@media (min-width: 600px) { .fca-band { padding: 12px 24px; } }

/* "Fred corrected this: ..." in the job's own What changed strip. */
.changed.fca-corrected h3 { display: flex; align-items: center; gap: 8px; }
.changed.fca-corrected .fca-bot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: var(--info); background: color-mix(in srgb, var(--info) 12%, var(--solid)); }

/* ---------- Apply corrective action (beside Send) and its box ---------- */
.job-bar .fca-fix { min-height: 56px; padding: 0 18px; border-radius: 16px; font-size: 1rem; color: var(--ink); flex: none; display: inline-flex; align-items: center; gap: 8px; }
.job-bar .fca-fix:hover { background: var(--glass-2); }
.job-bar .fca-fix .fca-bot { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--info); background: color-mix(in srgb, var(--info) 12%, var(--solid)); }
.fca-fix-short { display: none; }
.pop.fca-pop { width: min(420px, calc(100vw - 24px)); }
.fca-form { display: grid; gap: 0; }
.fca-form .fca-q { display: block; font-size: 1rem; font-weight: 700; margin: 0 0 10px; }
.fca-form .fca-what {
  box-sizing: border-box; width: 100%; min-height: 104px; max-height: 40vh; resize: vertical; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--edge-strong); background: var(--solid); color: var(--ink); font: inherit; font-size: .9375rem; line-height: 1.4;
}
.fca-form .fca-what:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.fca-form .fca-what[aria-invalid="true"] { border-color: var(--danger); }
.pop .fca-form .fca-hint { margin: 8px 0 0; font-size: .8125rem; line-height: 1.1875rem; color: var(--ink-2); }
.pop .fca-form .fca-err { margin: 8px 0 0; font-size: .8125rem; line-height: 1.1875rem; font-weight: 700; color: var(--danger); }
.pop .fca-form .fca-err:empty { display: none; }
.fca-form .row { margin-top: 12px; align-items: center; }
.fca-form .fca-count { margin-right: auto; font-size: .75rem; color: var(--ink-3); }
.fca-form .fca-go .ringspin { display: inline-block; width: 14px; height: 14px; margin-right: 6px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; animation: spin .8s linear infinite; }
:root[data-motion="reduced"] .fca-form .fca-go .ringspin, :root[data-calm="on"] .fca-form .fca-go .ringspin { animation: none; }

/* ---------- phone width ---------- */
@media (max-width: 599px) {
  .fca-lock .fca-face { padding: 10px 12px; gap: 10px; }
  .fca-lock .fca-bot { width: 34px; height: 34px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--fca-c) 72%, transparent), 0 0 10px 1px color-mix(in srgb, var(--fca-c) 36%, transparent); }
  .fca-lock .fca-words { padding: 5px 10px; }
  .fca-lock .fca-why, .fca-lock .fca-doing { -webkit-line-clamp: 2; line-clamp: 2; }
  .fca-band { gap: 12px; }
  .fca-band .fca-bot { width: 40px; height: 40px; }
  .job-bar .fca-fix { flex: 1 1 auto; padding: 0 14px; justify-content: center; }
  .job-bar .fca-fix .fca-bot { width: 24px; height: 24px; }
  .job-bar .fca-fix-long { display: none; }
  .job-bar .fca-fix-short { display: inline; }
}

/* ---------- High contrast, reduced glass, forced colours, print ---------- */
:root[data-theme="high_contrast"] .fca-lock { box-shadow: inset 0 0 0 2px #000000, inset 6px 0 0 var(--info); }
:root[data-theme="high_contrast"] .fca-lock .fca-frost { background: #FFFFFF; -webkit-backdrop-filter: none; backdrop-filter: none; box-shadow: inset 6px 0 0 var(--info); }
:root[data-theme="high_contrast"] .job-panel.fca-locked .fca-off { opacity: .55; filter: none; }
:root[data-theme="high_contrast"] .fca-lock .fca-bot, :root[data-theme="high_contrast"] .fca-band .fca-bot { background: #FFFFFF; color: #000000; box-shadow: 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .fca-lock .fca-words { background: #FFFFFF; box-shadow: 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .fca-lock .fca-say, :root[data-theme="high_contrast"] .fca-lock .fca-why, :root[data-theme="high_contrast"] .fca-lock .fca-doing, :root[data-theme="high_contrast"] .fca-lock .fca-job { color: #000000; }
:root[data-theme="high_contrast"] .fca-band { background: #FFFFFF; border-bottom: 2px solid #000000; box-shadow: inset 6px 0 0 var(--info); }
:root[data-theme="high_contrast"] .job-bar .fca-fix { border: 2px solid #000000; background: #FFFFFF; color: #000000; }
:root[data-theme="high_contrast"] .job-bar .fca-fix .fca-bot, :root[data-theme="high_contrast"] .changed.fca-corrected .fca-bot { background: #FFFFFF; color: #000000; box-shadow: inset 0 0 0 1.5px #000000; }
:root[data-glass="reduced"] .fca-lock .fca-frost { background: color-mix(in srgb, var(--fca-c) 16%, var(--solid)); -webkit-backdrop-filter: none; backdrop-filter: none; }
@media (prefers-reduced-transparency: reduce) {
  .fca-lock .fca-frost { background: color-mix(in srgb, var(--fca-c) 16%, var(--solid)); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .fca-lock .fca-words { background-color: var(--solid); }
}
@media (forced-colors: active) {
  .card > .fca-lock { border: 2px dashed CanvasText; box-shadow: none; }
  .fca-lock .fca-frost { background: Canvas; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .fca-lock .fca-bot, .fca-band .fca-bot, .fca-lock .fca-words { border: 1px solid CanvasText; box-shadow: none; }
  .fca-say::before, .fca-say::after { display: none; }
  .fca-band { border: 2px solid CanvasText; box-shadow: none; }
}
@media print {
  .fca-say::before, .fca-say::after { display: none; }
  .fca-say .fca-l { transform: none; }
  .fca-lock .fca-frost { background: #FFFFFF; -webkit-backdrop-filter: none; backdrop-filter: none; }
  .fca-lock .fca-words, .fca-band { background: #FFFFFF; box-shadow: none; border: 1px solid #000000; }
  .job-bar .fca-fix { display: none; }
}

/* ---------- J198: Fred's circle is moving matrix code (the robot over it), and the small "i" with what and why ---------- */
.fca-bot { position: relative; overflow: hidden; }
.fca-bot .fca-mx { position: absolute; inset: 0; width: 100%; height: 100%; display: block; border-radius: 50%; }
.fca-bot.fca-bot-mx { background: #021a0b; color: #b9ffd2; }
.fca-bot.fca-bot-mx .v21-robot-mark { position: relative; z-index: 1; opacity: .92; filter: drop-shadow(0 0 2px #021a0b); }
:root[data-theme="high_contrast"] .fca-bot .fca-mx { display: none; }
@media (forced-colors: active) { .fca-bot .fca-mx { display: none; } }
/* Review 2 (M2): the i covers the card without taking a press; its dot sits top right, and its tip opens BELOW the card
   (never over the plate, never cut off), with the card raised over the next one while it shows. The card lets go of its
   paint containment only then (desk.css .card has contain: layout paint), so the tip can reach past its edge. */
.fca-lock .fca-i { position: absolute; inset: 0; z-index: 2; pointer-events: none; border-radius: inherit; }
.fca-lock .fca-i-dot {
  position: absolute; top: 8px; right: 10px;
  display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%;
  font: 700 .75rem/1 Georgia, "Times New Roman", serif; font-style: italic;
  background: var(--solid); color: var(--fca-c); box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--fca-c) 70%, transparent);
}
.fca-lock .fca-tip {
  position: absolute; top: calc(100% + 6px); right: 8px; z-index: 5; width: max-content; max-width: min(360px, calc(100vw - 48px)); box-sizing: border-box;
  display: none; padding: 8px 12px; border-radius: 10px; background: var(--solid); color: var(--ink);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--fca-c) 40%, transparent), 0 8px 24px rgba(0, 0, 0, .18);
  font-size: .8125rem; line-height: 1.1875rem; text-align: left; white-space: normal;
}
.fca-lock .fca-tip-l { display: block; }
.fca-lock .fca-tip b { font-weight: 700; }
.card.fca-on:hover > .fca-lock .fca-tip, .card.fca-on:focus-within > .fca-lock .fca-tip, .card.fca-on:focus-visible > .fca-lock .fca-tip { display: block; }
.card.fca-on:hover, .card.fca-on:focus-within, .card.fca-on:focus-visible { contain: layout; z-index: 4; }
.card.fca-on:hover > .fca-lock .fca-i-dot, .card.fca-on:focus-within > .fca-lock .fca-i-dot { background: var(--fca-c); color: var(--solid); }
.fca-band .fca-doing { margin: 2px 0 0; font-size: .875rem; line-height: 1.25rem; font-weight: 600; color: var(--ink); }
:root[data-theme="high_contrast"] .fca-lock .fca-i-dot, :root[data-theme="high_contrast"] .fca-lock .fca-tip { background: #FFFFFF; color: #000000; box-shadow: 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .fca-band .fca-doing { color: #000000; }
@media print { .fca-lock .fca-i { display: none; } }

/* ---------- J204 more: a staff ask under the lock (js\v21_staffask.js draws it through paintCard) ---------- */
/* The frost takes every press on the ask (its Done and its note sit under it, off), and says why in a toast. */
.card.sa-card.fca-on > .fca-lock { z-index: 2; pointer-events: auto; cursor: not-allowed; }
.card.sa-card.is-fred:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

/* ---------- review 2 (L5): the button waits while Fred redoes the job or Send is on its way ---------- */
.job-bar .fca-fix:disabled, .job-bar .fca-fix.fca-wait { opacity: .5; cursor: not-allowed; }

/* ---------- review 2 (M5): "Your words from before", after the hand back ---------- */
.fca-kept { padding: 14px 16px; border-radius: 16px; background: var(--solid); box-shadow: inset 4px 0 0 var(--info), var(--shadow-1); display: grid; gap: 8px; }
.fca-kept:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }
.fca-kept .fca-kept-h { display: flex; align-items: center; gap: 8px; margin: 0; font-size: .875rem; }
.fca-kept .fca-kept-h .fca-bot { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; color: var(--info); background: color-mix(in srgb, var(--info) 12%, var(--solid)); }
.fca-kept .fca-kept-l { margin: 0; font-size: .8125rem; line-height: 1.1875rem; color: var(--ink-2); }
.fca-kept .fca-kept-e { display: grid; gap: 6px; }
.fca-kept .fca-kept-n { margin: 0; font-size: .8125rem; font-weight: 700; color: var(--ink); }
.fca-kept .fca-kept-t {
  box-sizing: border-box; width: 100%; min-height: 72px; max-height: 30vh; resize: vertical; padding: 8px 10px; border-radius: 10px;
  border: 1px solid var(--edge-strong); background: var(--solid-2); color: var(--ink); font: inherit; font-size: .875rem; line-height: 1.4;
}
.fca-kept .fca-kept-t:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.fca-kept .row { display: flex; gap: 8px; flex-wrap: wrap; }
:root[data-theme="high_contrast"] .fca-kept { background: #FFFFFF; color: #000000; box-shadow: inset 6px 0 0 var(--info), 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .fca-kept .fca-kept-l, :root[data-theme="high_contrast"] .fca-kept .fca-kept-n { color: #000000; }
:root[data-theme="high_contrast"] .fca-kept .fca-kept-t { background: #FFFFFF; color: #000000; border: 2px solid #000000; }
@media (forced-colors: active) { .fca-kept { border: 2px solid CanvasText; box-shadow: none; } }
@media print { .fca-kept .row { display: none; } }
