/*
 * TAG Legal Desk v2.1, J155 (29 Sep 2026): the Ask {ai} orb, its chat and "Reading database" (js/v21_askorb.js).
 * A layer of its own above everything on the desk (the job layer 30, sheets 81, popovers 90, toasts 95), under only
 * the cover (150) and the welfare band over it (160). The layer itself lets every pointer through; only the orb and
 * its chat take them. The orb's colours are tokens here per theme; the canvas reads them. Positions come from the
 * page through the CSSOM (no style attributes). Reduced motion, the Motion setting and Calm stop every animation;
 * high contrast and forced colours draw a plain solid orb instead of the liquid one.
 */

.v21ao-layer {
  position: fixed; inset: 0; z-index: 120; pointer-events: none;
  --v21ao-hi: #E9FFF3; --v21ao-mid: #5FC78F; --v21ao-deep: #1E5A34; --v21ao-glow: rgba(72, 190, 128, .75); --v21ao-swirl: #9BF0D0;
}
.v21ao-layer[hidden] { display: none; }
:root[data-theme="dark"] .v21ao-layer, :root[data-theme="night_shift"] .v21ao-layer { --v21ao-hi: #F0FFF7; --v21ao-mid: #6FD9A0; --v21ao-deep: #1B4D2E; --v21ao-glow: rgba(111, 217, 160, .85); --v21ao-swirl: #B7FFE2; }
:root[data-theme="eucalypt"] .v21ao-layer { --v21ao-hi: #EEFFF4; --v21ao-mid: #6DBF95; --v21ao-deep: #2B5A40; --v21ao-glow: rgba(109, 191, 149, .7); --v21ao-swirl: #A8EFCB; }
:root[data-theme="harbour"] .v21ao-layer { --v21ao-hi: #EAF8FF; --v21ao-mid: #4FA9C9; --v21ao-deep: #1D4E63; --v21ao-glow: rgba(79, 169, 201, .75); --v21ao-swirl: #9BE3FA; }
:root[data-theme="wattle_gold"] .v21ao-layer { --v21ao-hi: #FFF8E2; --v21ao-mid: #7CC08F; --v21ao-deep: #2E5A34; --v21ao-glow: rgba(214, 178, 72, .65); --v21ao-swirl: #F4E3A6; }

/* ---------------------------------------------------------------- the orb */

.v21ao-dock { position: absolute; left: 0; top: 0; width: 60px; height: 60px; pointer-events: auto; }
.v21ao-orb {
  position: relative; display: block; width: 60px; height: 60px; margin: 0; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--brand-ink); cursor: grab; touch-action: none; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
.v21ao-dragging .v21ao-orb { cursor: grabbing; }
.v21ao-orb:focus-visible { outline: 3px solid var(--focus); outline-offset: 6px; }
.v21ao-cv { position: absolute; left: -20px; top: -20px; width: 100px; height: 100px; pointer-events: none; }
/* The plain orb: no canvas, high contrast and forced colours. */
.v21ao-core {
  position: absolute; inset: 4px; display: none; place-items: center; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, var(--v21ao-hi), var(--v21ao-mid) 45%, var(--v21ao-deep));
  box-shadow: 0 0 18px var(--v21ao-glow); color: #fff;
}
.v21ao-nocanvas .v21ao-cv { display: none; }
.v21ao-nocanvas .v21ao-core { display: grid; }

/* ---------------------------------------------------------------- "Reading database" */

.v21ao-think {
  position: absolute; left: 0; top: 0; transform: translateX(-50%); z-index: 1; pointer-events: none;
  padding: 5px 12px; border-radius: 999px; background: var(--glass-2); border: 1px solid var(--glass-rim);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap;
  color: var(--brand-text); text-shadow: 0 0 6px var(--v21ao-glow), 0 0 14px var(--v21ao-glow);
  font-variant-numeric: tabular-nums; animation: v21ao-flicker 1.4s steps(1, end) infinite;
}
.v21ao-think[hidden] { display: none; }
.v21ao-think-t { position: relative; display: inline-block; }
/* Two offset copies of the scrambling words give the glitch; they come from data-text, never from markup. */
.v21ao-think::before, .v21ao-think::after {
  content: attr(data-text); position: absolute; left: 12px; top: 5px; pointer-events: none; opacity: .55;
}
.v21ao-think::before { color: var(--v21ao-mid); transform: translate(-1px, 0); animation: v21ao-slice 0.9s steps(2, end) infinite; }
.v21ao-think::after { color: var(--accent); transform: translate(1px, 0); animation: v21ao-slice 1.1s steps(2, end) infinite reverse; }
.v21ao-think.v21ao-still { animation: none; }
.v21ao-think.v21ao-still::before, .v21ao-think.v21ao-still::after { content: none; animation: none; }
@keyframes v21ao-flicker {
  0%, 100% { opacity: 1; }
  47% { opacity: 1; }
  48% { opacity: .72; }
  50% { opacity: 1; }
  83% { opacity: .85; }
}
@keyframes v21ao-slice {
  0% { clip-path: inset(0 0 60% 0); }
  50% { clip-path: inset(55% 0 0 0); }
  100% { clip-path: inset(20% 0 40% 0); }
}

/* ---------------------------------------------------------------- the chat beside the orb */

.v21ao-panel {
  position: absolute; left: 0; top: 0; width: min(380px, calc(100vw - 16px)); height: min(560px, calc(100vh - 16px));
  display: flex; flex-direction: column; pointer-events: auto; border-radius: 20px; overflow: hidden; overflow: clip; box-shadow: var(--shadow-2);
}
.v21ao-panel[hidden] { display: none; }
.v21ao-head { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--glass-rim); }
.v21ao-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 1rem; font-weight: 800; color: var(--ink); }
.v21ao-head .btn-icon { flex: none; min-height: 44px; }
.v21ao-mute { position: relative; }
.v21ao-mute.is-muted::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 2px; border-radius: 2px;
  background: currentColor; transform: translate(-50%, -50%) rotate(-45deg); pointer-events: none;
}
.v21ao-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 12px; }
.v21ao-scroll .v21af-drawer { min-height: 100%; }
.v21ao-about { margin: 0; font-size: .75rem; font-weight: 700; color: var(--brand-text); }
.v21ao-more { display: grid; gap: 8px; justify-items: start; max-width: 100%; }
.v21ao-more[hidden] { display: none; }
.v21ao-pick .chip { min-height: 44px; cursor: pointer; }
.v21ao-pick .chip .lbl { white-space: normal; text-align: left; }
.v21ao-src { cursor: default; }
/* A line not reached yet takes no room (the answer grows as it types); the caret sits on the line being typed. */
.v21ao-typing:empty:not(.v21ao-now) { display: none; }
.v21ao-typing.v21ao-now { min-height: 1.5em; }
.v21ao-typing.v21ao-now::after { content: ""; display: inline-block; width: .5em; height: 1em; margin-left: 2px; vertical-align: -2px; border-radius: 1px; background: var(--brand-text); opacity: .5; animation: v21ao-caret 1s steps(1, end) infinite; }
@keyframes v21ao-caret { 50% { opacity: 0; } }

/* ---------------------------------------------------------------- reduced motion, the Motion setting and Calm */

@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .v21ao-think, :root:not([data-motion="full"]) .v21ao-typing::after { animation: none; }
  :root:not([data-motion="full"]) .v21ao-think::before, :root:not([data-motion="full"]) .v21ao-think::after { content: none; }
}
:root[data-motion="reduced"] .v21ao-think, :root[data-motion="reduced"] .v21ao-typing::after,
:root[data-calm="on"] .v21ao-think, :root[data-calm="on"] .v21ao-typing::after { animation: none; }
:root[data-motion="reduced"] .v21ao-think::before, :root[data-motion="reduced"] .v21ao-think::after,
:root[data-calm="on"] .v21ao-think::before, :root[data-calm="on"] .v21ao-think::after { content: none; }
/* Every answer appears whole there, so there is no caret. */
:root[data-motion="reduced"] .v21ao-typing.v21ao-now::after, :root[data-calm="on"] .v21ao-typing.v21ao-now::after { content: none; }
@media (prefers-reduced-motion: reduce) { :root:not([data-motion="full"]) .v21ao-typing.v21ao-now::after { content: none; } }

/* ---------------------------------------------------------------- high contrast and forced colours */

:root[data-theme="high_contrast"] .v21ao-cv { display: none; }
:root[data-theme="high_contrast"] .v21ao-core { display: grid; background: #0B2A10; box-shadow: none; border: 3px solid #000; color: #fff; }
:root[data-theme="high_contrast"] .v21ao-think { background: #fff; border: 2px solid #000; color: #000; text-shadow: none; animation: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
:root[data-theme="high_contrast"] .v21ao-think::before, :root[data-theme="high_contrast"] .v21ao-think::after { content: none; }
:root[data-theme="high_contrast"] .v21ao-panel { border: 2px solid #000; }
:root[data-theme="high_contrast"] .v21ao-about { color: #000; }
@media (forced-colors: active) {
  .v21ao-cv { display: none; }
  .v21ao-core { display: grid; background: ButtonFace; color: ButtonText; border: 2px solid ButtonText; box-shadow: none; forced-color-adjust: none; }
  .v21ao-think { border: 1px solid CanvasText; text-shadow: none; animation: none; }
  .v21ao-think::before, .v21ao-think::after { content: none; }
  .v21ao-panel { border: 1px solid CanvasText; }
  .v21ao-mute.is-muted::after { background: ButtonText; }
}

/* ---------------------------------------------------------------- phone widths (390 px, no page scroll sideways) */

@media (max-width: 599px) {
  .v21ao-panel { border-radius: 16px; }
  .v21ao-scroll { padding: 10px; }
}
