/*
 * TAG Legal Desk v2.1: Fred thinks first (register J211 more and J212; js\v21_think.js, js\v21_withfred.js). Theme
 * tokens only, no inline styles (the page's policy), light and dark from the same tokens.
 *   The think lock: under the stage words on the card and the band, three short bars (done, now, to come) and "1 of 3".
 *     The bar for now has a soft light passing along it; still under reduced motion, Calm, the quiet states, a day that
 *     matters and print.
 *   The settle: a card Fred has just finished working out gets a soft green edge that glows in once, and a small
 *     "Ready" in the counts chip's place (the chip keeps its room, so nothing moves), for a few seconds (the page takes
 *     them off). Still states keep the edge and the word with no glow.
 *   How I got here: in place of the Why, open by default. The lines are a short path (a dot for each, joined by a thin
 *     line, the last dot filled: the decision). Pointing at a line to tell Fred turns each into a button.
 *   The correction box shows the line it is about.
 * High contrast, forced colours and print have plain rules at the end.
 */

/* ---------- the think lock: the three steps ---------- */
.thk-steps { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: .75rem; line-height: 1.0625rem; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.thk-bars { display: inline-flex; align-items: center; gap: 3px; flex: none; }
.thk-bar { position: relative; display: block; width: 16px; height: 5px; border-radius: 3px; overflow: hidden; background: color-mix(in srgb, var(--fca-c, var(--info)) 20%, transparent); }
.thk-bar.thk-done { background: color-mix(in srgb, var(--fca-c, var(--info)) 70%, transparent); }
.thk-bar.thk-now { background: var(--fca-c, var(--info)); }
/* The soft light passing along the bar Fred is on (a slow sweep, never a flash). */
.thk-bar.thk-now::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -60%; width: 60%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--solid) 75%, transparent), transparent);
  animation: thk-sweep 1.6s cubic-bezier(.4, 0, .2, 1) infinite;
}
@keyframes thk-sweep { from { transform: translateX(0); } to { transform: translateX(270%); } }
.fca-lock .fca-words .thk-steps { margin-top: 1px; }
.fca-band .thk-bandsteps { margin: 4px 0 2px; }
.fca-band .thk-steps { font-size: .8125rem; gap: 10px; color: var(--ink); }
.fca-band .thk-bar { width: 26px; height: 6px; }

/* ---------- the settle: the card is ready ---------- */
.card > .thk-ready {
  position: absolute; inset: 0; z-index: 1; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ok) 72%, transparent);
}
.card.thk-settle-in > .thk-ready { animation: thk-glow 1.8s cubic-bezier(.2, .8, .2, 1) 1 both; }
@keyframes thk-glow {
  0% { box-shadow: inset 0 0 0 2px transparent, inset 0 0 0 0 transparent; }
  30% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ok) 90%, transparent), inset 0 0 22px 4px color-mix(in srgb, var(--ok) 24%, transparent); }
  100% { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--ok) 72%, transparent), inset 0 0 0 0 transparent; }
}
/* "Ready" takes the counts chip's place for its few seconds: the chip keeps its room (hidden), so nothing moves. */
.card.thk-settle > .side > .prep { visibility: hidden; }
.thk-ready-tag {
  position: absolute; top: 0; right: 0; display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px 3px 7px; border-radius: 999px;
  background: color-mix(in srgb, var(--ok) 14%, var(--solid)); color: var(--ink); box-shadow: 0 0 0 1px color-mix(in srgb, var(--ok) 45%, transparent);
  font-size: .75rem; line-height: 1.125rem; font-weight: 700; white-space: nowrap;
}
/* A card with no counts column (it has none to share): the word sits at the top right. */
.thk-ready-tag.thk-float { top: 8px; right: 10px; }
.thk-ready-tag .ico { color: var(--ok); stroke-width: 2.4; }
.card.thk-settle-in .thk-ready-tag { animation: thk-tag .5s cubic-bezier(.2, .8, .2, 1) .1s 1 both; }
@keyframes thk-tag { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ---------- How I got here (J212), in place of the Why ---------- */
details.why.hig > summary .hig-mark {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--solid); color: var(--info); box-shadow: 0 0 0 1px color-mix(in srgb, var(--info) 40%, transparent);
}
details.why.hig > summary .hig-mark svg { width: 15px; height: 15px; }
details.why.hig .hig-body { padding-top: 12px; }
.hig-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.hig-line { position: relative; margin: 0; padding: 5px 4px 5px 30px; font-size: .9375rem; line-height: 1.45rem; color: var(--ink); }
/* The path: a thin line through every dot, from the first to the last. */
.hig-line::before { content: ''; position: absolute; left: 9px; top: 0; bottom: 0; width: 2px; border-radius: 1px; background: color-mix(in srgb, var(--brand-text) 24%, transparent); }
.hig-line:first-child::before { top: 16px; }
.hig-line.hig-last::before { bottom: calc(100% - 16px); }
.hig-lines > .hig-line:only-child::before { display: none; }
.hig-dot {
  position: absolute; left: 4px; top: 10px; width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box;
  background: var(--solid); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--brand-text) 62%, transparent);
}
.hig-last .hig-dot { background: var(--brand-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-text) 18%, transparent); }
.hig-last > .hig-t, .hig-last .hig-pick .hig-t { font-weight: 600; }
.hig-t { display: block; }

/* Pointing at a line: each line is a button. */
.hig-lines.hig-pointing .hig-line { padding: 0; }
.hig-pick {
  position: relative; display: block; width: 100%; box-sizing: border-box; margin: 1px 0; padding: 5px 10px 5px 30px;
  border: 0; border-radius: 10px; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand-text) 16%, transparent);
}
.hig-pick:hover { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand-text); }
.hig-pick:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; background: var(--brand-soft); }
.hig-line.hig-picked .hig-pick { background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand-text); }
.hig-pick .hig-dot { left: 4px; top: 10px; }

/* Under the lines: "Something here wrong? Tell Fred", or what to do while pointing. */
.hig-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 6px 4px 2px; font-size: .8125rem; line-height: 1.1875rem; }
.hig-foot .hig-tell { font-size: .8125rem; color: var(--ink-2); text-decoration-color: color-mix(in srgb, var(--ink-2) 45%, transparent); }
.hig-foot .hig-tell .hig-tell-go { color: var(--brand-text); }
.hig-foot .hig-tell:hover { color: var(--ink); }
.hig-foot .hig-tell:disabled { opacity: .5; cursor: not-allowed; }
/* While pointing: what to do and Cancel, above the lines. */
.hig-point {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 12px 0 0; padding: 8px 12px; border-radius: 10px;
  background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand-text); font-size: .8125rem; line-height: 1.1875rem;
}
.hig-point .hig-hint { margin: 0; font-weight: 700; color: var(--ink); }
.hig-point .hig-cancel { font-size: .8125rem; }
.job-panel.fca-locked .hig-foot .fca-off { cursor: not-allowed; opacity: .45; }

/* ---------- the correction box: the line it is about ---------- */
.fca-form .fca-about { margin: 0 0 12px; padding: 8px 10px 8px 12px; border-radius: 10px; background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--brand-text); }
.pop .fca-form .fca-about-l { margin: 0 0 2px; font-size: .75rem; line-height: 1.0625rem; font-weight: 700; color: var(--ink-2); }
.fca-form .fca-about-q { margin: 0; font-size: .875rem; line-height: 1.3125rem; color: var(--ink); }

/* ---------- still: reduced motion, Calm, the quiet states, a day that matters ---------- */
:root[data-motion="reduced"] .thk-bar.thk-now::after, :root[data-calm="on"] .thk-bar.thk-now::after,
:root[data-quiet="on"] .thk-bar.thk-now::after, :root[data-day-matters] .thk-bar.thk-now::after { animation: none; display: none; }
:root[data-motion="reduced"] .card.thk-settle-in > .thk-ready, :root[data-calm="on"] .card.thk-settle-in > .thk-ready,
:root[data-quiet="on"] .card.thk-settle-in > .thk-ready, :root[data-day-matters] .card.thk-settle-in > .thk-ready,
:root[data-motion="reduced"] .card.thk-settle-in .thk-ready-tag, :root[data-calm="on"] .card.thk-settle-in .thk-ready-tag,
:root[data-quiet="on"] .card.thk-settle-in .thk-ready-tag, :root[data-day-matters] .card.thk-settle-in .thk-ready-tag { animation: none; }
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="full"]) .thk-bar.thk-now::after { animation: none; display: none; }
  :root:not([data-motion="full"]) .card.thk-settle-in > .thk-ready, :root:not([data-motion="full"]) .card.thk-settle-in .thk-ready-tag { animation: none; }
}

/* ---------- phone width ---------- */
@media (max-width: 599px) {
  .thk-bar { width: 12px; height: 4px; }
  .fca-band .thk-bar { width: 20px; height: 5px; }
  /* The counts sit at the start of the row under the words on a phone, so "Ready" does too. */
  .card > .side > .thk-ready-tag { right: auto; left: 0; }
  .thk-ready-tag.thk-float { top: 6px; right: 8px; }
  .hig-line { padding-left: 26px; font-size: .9375rem; }
  .hig-line::before { left: 7px; }
  .hig-dot, .hig-pick .hig-dot { left: 2px; }
  .hig-pick { padding-left: 26px; }
}

/* ---------- High contrast, forced colours, print ---------- */
:root[data-theme="high_contrast"] .thk-steps { color: #000000; }
:root[data-theme="high_contrast"] .thk-bar { background: #FFFFFF; box-shadow: inset 0 0 0 1.5px #000000; }
:root[data-theme="high_contrast"] .thk-bar.thk-done, :root[data-theme="high_contrast"] .thk-bar.thk-now { background: #000000; }
:root[data-theme="high_contrast"] .thk-bar.thk-now::after { display: none; }
:root[data-theme="high_contrast"] .card > .thk-ready { box-shadow: inset 0 0 0 3px #000000; animation: none; }
:root[data-theme="high_contrast"] .thk-ready-tag { background: #FFFFFF; color: #000000; box-shadow: 0 0 0 2px #000000; animation: none; }
:root[data-theme="high_contrast"] .thk-ready-tag .ico { color: #000000; }
:root[data-theme="high_contrast"] .hig-line, :root[data-theme="high_contrast"] .hig-point .hig-hint, :root[data-theme="high_contrast"] .hig-foot .hig-tell { color: #000000; }
:root[data-theme="high_contrast"] .hig-point { background: #FFFFFF; box-shadow: inset 4px 0 0 #000000, 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .hig-line::before { background: #000000; }
:root[data-theme="high_contrast"] .hig-dot { background: #FFFFFF; box-shadow: inset 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .hig-last .hig-dot { background: #000000; box-shadow: none; }
:root[data-theme="high_contrast"] .hig-pick { box-shadow: inset 0 0 0 2px #000000; }
:root[data-theme="high_contrast"] .fca-form .fca-about { background: #FFFFFF; box-shadow: inset 4px 0 0 #000000, 0 0 0 2px #000000; }
@media (forced-colors: active) {
  .thk-bar { background: Canvas; border: 1px solid CanvasText; }
  .thk-bar.thk-done, .thk-bar.thk-now { background: CanvasText; }
  .thk-bar.thk-now::after { display: none; }
  .card > .thk-ready { box-shadow: none; border: 3px solid Highlight; animation: none; }
  .thk-ready-tag { border: 1px solid CanvasText; box-shadow: none; animation: none; }
  .hig-line::before { background: CanvasText; }
  .hig-dot { background: Canvas; border: 2px solid CanvasText; box-shadow: none; }
  .hig-last .hig-dot { background: CanvasText; }
  .hig-pick { border: 1px solid CanvasText; box-shadow: none; }
  .fca-form .fca-about, .hig-point { border: 1px solid CanvasText; box-shadow: none; }
}
@media print {
  .thk-bar.thk-now::after, .card > .thk-ready { display: none; }
  .hig-foot { display: none; }
  .hig-line::before { background: #000000; }
}
