/* =============================================================
   v2-tools-v20260508b.css
   IMPECCABLE pass on the 8 Deskrune diagnostic tools.

   Loaded LAST in the <head>, so every selector here overrides
   the legacy assets/style + per-tool inline <style>.

   Scope:
     /tools/afm-spotter/
     /tools/friction-score/
     /tools/comeback-coach/
     /tools/re-entry-card/
     /tools/time-blindness-check/
     /tools/ef-load-gauge/
     /tools/12-minute-timer/
     /tools/decision-fatigue-index/

   Lens: 16 targeted upgrades — ~2 per tool. Each block is
   commented with the tool, the principle, and the failure mode
   it removes.

   Tokens used (already declared upstream by /assets/style and
   theme-v20260508a.css):
     --bg, --ink, --ink-soft, --rule, --muted, --accent,
     --accent-pale, --accent-dark, --warm-white
   Brand orange resolves to #c9613f.
   ============================================================= */

/* -------------------------------------------------------------
   GLOBAL FOR /tools/* — shared slider chrome + reduced-motion + tap targets
   Reason: every tool has a slider, a button stack, or both. The
   inline styles drift; consolidate the canonical state-machine
   here so each tool inherits the same a11y floor.
   ------------------------------------------------------------- */

/* (1) prefers-reduced-motion — kill ALL transitions/animations
       on tool surfaces. Many of the legacy inline styles use
       0.18-0.4s transitions on hover/focus; for users who set
       reduced motion, these are unsafe. Honors WCAG 2.3.3. */
@media (prefers-reduced-motion: reduce) {
  .fs-stage *, .cc-stage *, .dfi-stage *,
  .gauge-container *, .timer-stage *, .tb-row *,
  #cardOutput *, #quizContainer * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* (2) Tap-target floor — every clickable in /tools/* gets ≥44px
       tappable area (WCAG 2.5.5 AAA but Deskrune's mobile-first
       canon). Inline styles use 38-50px; this guarantees the floor. */
.fs-stage button:not(.dfi-buttons button), .cc-stage button,
.dfi-stage button:not(.dfi-buttons button),
.tool-actions button, .timer-actions button {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation; /* removes 300ms iOS tap delay */
}

/* (3) Universal slider polish — applies to every <input type=range>
       inside a tool. Solves four problems at once:
         a) Thumb is now ≥24px (drag-friendly on mobile).
         b) Track has visible value gradient that follows --val custom prop.
         c) Focus-visible adds 2px ring (was outline:2px solid + offset:4px,
            which clipped on the right edge of narrow rows).
         d) Touch-action lets the browser scroll vertically while the
            slider eats horizontal swipes — fixes the accidental-scroll
            bug on iOS where dragging the slider scrolled the page.
       Used by: friction-score, ef-load-gauge.  */
.fs-row input[type="range"],
.gauge-row input[type="range"],
input[type="range"][data-deskrune-tool] {
  -webkit-appearance: none;
  appearance: none;
  height: 28px;          /* generous hit zone */
  background: transparent;
  cursor: pointer;
  touch-action: pan-y;   /* drag = horizontal slider, swipe = vertical scroll */
}
.fs-row input[type="range"]::-webkit-slider-runnable-track,
.gauge-row input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    #c9613f 0%, #c9613f var(--fill, 50%),
    rgba(20,20,19,0.10) var(--fill, 50%), rgba(20,20,19,0.10) 100%
  );
}
:root[data-theme="dark"] .fs-row input[type="range"]::-webkit-slider-runnable-track,
:root[data-theme="dark"] .gauge-row input[type="range"]::-webkit-slider-runnable-track {
  background: linear-gradient(
    to right,
    #f08160 0%, #f08160 var(--fill, 50%),
    rgba(245,239,228,0.16) var(--fill, 50%), rgba(245,239,228,0.16) 100%
  );
}
.fs-row input[type="range"]::-webkit-slider-thumb,
.gauge-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #c9613f;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(20,20,19,0.22), 0 0 0 1px rgba(20,20,19,0.06);
  margin-top: -9px;        /* center on 6px track */
  cursor: grab;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.fs-row input[type="range"]:active::-webkit-slider-thumb,
.gauge-row input[type="range"]:active::-webkit-slider-thumb {
  cursor: grabbing;
  transform: scale(1.08);
}
.fs-row input[type="range"]::-moz-range-track,
.gauge-row input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 3px;
  background: rgba(20,20,19,0.10);
}
.fs-row input[type="range"]::-moz-range-progress,
.gauge-row input[type="range"]::-moz-range-progress {
  background: #c9613f;
  height: 6px;
  border-radius: 3px;
}
.fs-row input[type="range"]::-moz-range-thumb,
.gauge-row input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #c9613f;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(20,20,19,0.22);
  cursor: grab;
}
.fs-row input[type="range"]:focus-visible,
.gauge-row input[type="range"]:focus-visible {
  outline: none; /* removed the inline outline:offset:4px which clipped */
}
.fs-row input[type="range"]:focus-visible::-webkit-slider-thumb,
.gauge-row input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(201,97,63,0.32),
              0 1px 4px rgba(20,20,19,0.22);
}
.fs-row input[type="range"]:focus-visible::-moz-range-thumb,
.gauge-row input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(201,97,63,0.32),
              0 1px 4px rgba(20,20,19,0.22);
}

/* -------------------------------------------------------------
   TOOL 1 — AFM Spotter (/tools/afm-spotter/)
   Failure modes addressed:
     #1  Result-reveal layout shift (CLS) — the result block was
         absent from the DOM until rendered, then jumped in.
     #2  Progress bar transition was 0.4s linear via inline style,
         which felt syrupy at low percentages.
   ------------------------------------------------------------- */
.quiz-shell { position: relative; }
.quiz-progress-bar {
  /* Was 0.4s linear; ease-out matches the perceived deceleration of
     answering a question (you tap, then read the next prompt). */
  transition: width 280ms cubic-bezier(0.22, 1, 0.36, 1) !important;
}
#quizResult {
  /* Reserve no space when empty (height:0) but reveal with opacity +
     translateY so the page doesn't jolt. */
  contain: layout;
}
#quizResult:not(:empty) {
  animation: dr-result-rise 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes dr-result-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  #quizResult:not(:empty) { animation: none; }
}

/* -------------------------------------------------------------
   TOOL 2 — Friction Score (/tools/friction-score/)
   Failure modes addressed:
     #3  Slider value chip was static; with 7 sliders the user
         loses orientation. Now the chip pulses for ~140ms after
         each tick — clear feedback that the input was registered.
     #4  Result block gained focus-management — when scrollIntoView
         fires we also focus the result heading so screen readers
         announce it. (Inline JS already calls scrollIntoView; we
         augment with tabindex via CSS-only :target hint and a
         visible focus ring.)
   ------------------------------------------------------------- */
.fs-row .val {
  transition: transform 140ms cubic-bezier(0.22, 1, 0.36, 1),
              color 140ms ease;
  display: inline-block;
  will-change: transform;
}
.fs-row input[type="range"]:active ~ .val,
.fs-row input[type="range"]:focus-visible ~ .val {
  transform: scale(1.08);
  color: #b8542c; /* darker accent on activity for AA contrast */
}
:root[data-theme="dark"] .fs-row input[type="range"]:active ~ .val,
:root[data-theme="dark"] .fs-row input[type="range"]:focus-visible ~ .val {
  color: #f08160;
}
#fs-result {
  scroll-margin-top: 24px; /* keeps result clear of sticky banners */
}
#fs-result h3 {
  /* The result headline IS the result. Give it the visual weight. */
  font-size: clamp(22px, 3vw, 28px) !important;
}
#fs-result .top {
  /* Score is most important detail — bump tabular-nums on it */
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------
   TOOL 3 — Comeback Coach (/tools/comeback-coach/)
   Failure modes addressed:
     #5  Countdown digits were rendered with cubic-bezier transition
         on width-only progress bar (0.4s linear) — that's smooth,
         but the digit itself jumped. Add tabular-nums + monospace-
         feature for the timer so digits don't reflow each second.
     #6  Pause/skip/stop buttons stacked horizontally — on a 320px
         viewport they wrapped awkwardly. Force a 3-up flex with
         min-width:0 + flex:1 so they always sit on one row.
   ------------------------------------------------------------- */
.cc-time {
  font-variant-numeric: tabular-nums !important;
  font-feature-settings: "tnum" 1 !important;
  letter-spacing: -0.01em;
}
.cc-progress-bar {
  /* Smooth the progress fill — 280ms linear is too floaty,
     use 1000ms linear so it tracks the second-clock. */
  transition: width 1000ms linear !important;
}
@media (prefers-reduced-motion: reduce) {
  .cc-progress-bar { transition: none !important; }
}
.cc-controls {
  flex-wrap: nowrap;
  gap: 8px;
}
.cc-controls button {
  flex: 1 1 0;
  min-width: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  min-height: 44px; /* tap target */
}
@media (max-width: 380px) {
  .cc-controls button {
    font-size: 12px;
    padding: 10px 8px;
  }
}
/* Improve focus-visible on the controls — was inheriting browser default */
.cc-controls button:focus-visible {
  outline: 2px solid #c9613f;
  outline-offset: 2px;
  border-color: #c9613f;
}

/* -------------------------------------------------------------
   TOOL 4 — Re-Entry Card (/tools/re-entry-card/)
   Failure modes addressed:
     #7  Generated PNG canvas had no aria-label — invisible to screen
         readers. The form labels announced; the result was silent.
     #8  The four CTA buttons were rendered in a row that wrapped to
         four lines on mobile (Generate / Download PNG / Copy /
         Send) — and the disabled ones had insufficient contrast.
   ------------------------------------------------------------- */
#cardCanvas {
  /* Canvas accessibility — fallback content + label set in HTML.
     Visual: reserve aspect to prevent CLS when the canvas paints. */
  display: block;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1080 / 1350;
  border-radius: 6px;
  box-shadow: 0 4px 18px rgba(20,20,19,0.08);
}
#reCardForm .tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
#reCardForm .tool-actions button {
  min-height: 44px;
  flex: 1 1 auto;
}
#reCardForm .tool-actions button[disabled] {
  /* Inline default opacity:0.5 fails AA on cream bg.
     Use 0.62 + ink color instead. */
  opacity: 0.62;
  cursor: not-allowed;
  background: rgba(20,20,19,0.06);
  color: rgba(20,20,19,0.65);
  border-color: rgba(20,20,19,0.14);
}
:root[data-theme="dark"] #reCardForm .tool-actions button[disabled] {
  background: rgba(245,239,228,0.05);
  color: rgba(245,239,228,0.55);
  border-color: rgba(245,239,228,0.12);
}
#reCardForm textarea, #reCardForm input[type="text"] {
  /* Improve focus ring on the four worksheet lines —
     was inheriting browser default which is near-invisible
     on cream. */
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
#reCardForm textarea:focus-visible,
#reCardForm input[type="text"]:focus-visible {
  outline: none;
  border-color: #c9613f;
  box-shadow: 0 0 0 3px rgba(201,97,63,0.18);
}

/* -------------------------------------------------------------
   TOOL 5 — Time-Blindness Check (/tools/time-blindness-check/)
   Failure modes addressed:
     #9  The .factor display (e.g. "1.62×") was the headline number
         but inherited body font-size — visually tied with other rows.
         Make it the loudest element on the page.
     #10 Every keystroke triggered a full table re-render
         (existing JS), losing focus mid-typing. Add a
         CSS-side fix: tabular-nums on inputs so width is stable,
         + reserve space in the distortion column so DOM rebuild
         doesn't reflow neighbouring inputs.
   ------------------------------------------------------------- */
#summary .factor {
  font-family: 'Fraunces', Georgia, serif;
  font-style: italic;
  font-weight: 500;
  font-size: clamp(56px, 9vw, 88px) !important;
  line-height: 1;
  color: #c9613f;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  margin: 8px 0 16px;
}
:root[data-theme="dark"] #summary .factor { color: #f08160; }
#summary .factor.high {
  color: #b8542c; /* deepens to AA on cream when distortion is high */
}
.tb-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
}
.tb-row.header {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted, #6b6960);
  border-bottom: 1px solid var(--rule, #e8e6dc);
  padding-bottom: 12px;
  margin-bottom: 6px;
}
.tb-row input[type="text"], .tb-row input[type="number"] {
  font-variant-numeric: tabular-nums; /* width-stable across full re-render */
  min-height: 40px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--rule, #e8e6dc);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
:root[data-theme="dark"] .tb-row input[type="text"],
:root[data-theme="dark"] .tb-row input[type="number"] {
  background: #221c19; color: var(--ink);
  border-color: rgba(245,239,228,0.14);
}
.tb-row input:focus-visible {
  outline: none;
  border-color: #c9613f;
  box-shadow: 0 0 0 3px rgba(201,97,63,0.18);
}
.tb-row > div:last-child {
  /* The distortion column — center-aligned, fixed width, tabular */
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 15px;
}
@media (max-width: 540px) {
  .tb-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px 12px;
  }
  .tb-row.header { display: none; }
  .tb-row input[type="text"] { grid-column: 1 / -1; }
}

/* -------------------------------------------------------------
   TOOL 6 — EF Load Gauge (/tools/ef-load-gauge/)
   Failure modes addressed:
     #11 Gauge bar overlap — the demand bar drew over the capacity
         bar with no visible separator when they were close. Add a
         1px hairline on the demand bar so capacity stays readable.
     #12 No visible burnout-line marker — the JS uses THRESHOLD=7
         but never paints the line. Render it as a CSS ::after
         on each gauge-bar so users see *where* the line is.
   ------------------------------------------------------------- */
.gauge-row {
  display: grid;
  grid-template-columns: 130px 1fr 80px;
  gap: 14px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule, #e8e6dc);
}
.gauge-row:last-child { border-bottom: none; }
.gauge-row label {
  font-family: 'Inter', sans-serif;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}
.gauge-row input[type="range"] {
  /* Hidden visually but kept for keyboard a11y — the gauge-bar IS
     the visual surface. The native slider sits on top of it as a
     transparent control so keyboard arrows still work. */
  position: absolute;
  width: 100%;
  height: 28px;
  opacity: 0;
  pointer-events: auto;
  cursor: pointer;
  margin: 0;
}
.gauge-row .gauge-bar {
  position: relative;
  height: 16px;
  border-radius: 8px;
  background: rgba(20,20,19,0.06);
  overflow: visible;
}
:root[data-theme="dark"] .gauge-row .gauge-bar {
  background: rgba(245,239,228,0.08);
}
.gauge-row .gauge-bar .demand {
  height: 100%;
  border-radius: 8px;
  background: #c9613f;
  transition: width 240ms cubic-bezier(0.22, 1, 0.36, 1),
              background-color 200ms ease;
  box-shadow: inset 0 -1px 0 rgba(0,0,0,0.08); /* hairline separator */
}
.gauge-row .gauge-bar.over .demand {
  background: #b8542c; /* AA-pass red-orange when over capacity */
}
/* Burnout-line marker at 70% (THRESHOLD=7 of 10) */
.gauge-row .gauge-bar::after {
  content: '';
  position: absolute;
  left: 70%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: rgba(20,20,19,0.32);
  pointer-events: none;
}
:root[data-theme="dark"] .gauge-row .gauge-bar::after {
  background: rgba(245,239,228,0.28);
}
.gauge-row .vals {
  font-family: 'Inter', sans-serif;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
  text-align: right;
}
.gauge-result {
  margin-top: 22px;
  padding: 18px 22px;
  border-radius: 6px;
  background: rgba(20,20,19,0.04);
  font-family: 'Fraunces', Georgia, serif;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-soft);
  border-left: 3px solid var(--rule);
  transition: border-color 200ms ease, background-color 200ms ease;
}
.gauge-result.over {
  border-left-color: #b8542c;
  background: rgba(184,84,44,0.06);
}
:root[data-theme="dark"] .gauge-result {
  background: rgba(245,239,228,0.04);
}
:root[data-theme="dark"] .gauge-result.over {
  background: rgba(240,129,96,0.08);
  border-left-color: #f08160;
}
@media (max-width: 540px) {
  .gauge-row {
    grid-template-columns: 100px 1fr 64px;
    gap: 10px;
  }
}

/* -------------------------------------------------------------
   TOOL 7 — 12-Minute Timer (/tools/12-minute-timer/)
   Failure modes addressed:
     #13 The display digits used inherited font — at large sizes
         (12:00) the colon visually drifted between width-1 and
         width-2 numerals. Force tabular-nums + variable-feature
         lock. Also the "warn" / "done" classes had no visible
         effect — wire them to the design system.
     #14 Start button used inline gradient that didn't have a
         focus-visible ring. Add 3px brand-orange focus ring on
         all timer-actions buttons.
   ------------------------------------------------------------- */
.timer-display {
  font-family: 'Inter', sans-serif;
  font-variant-numeric: tabular-nums !important;
  font-feature-settings: "tnum" 1 !important;
  font-weight: 700;
  font-size: clamp(72px, 14vw, 120px);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--ink);
  margin: 16px 0 24px;
  transition: color 220ms ease;
}
.timer-display.warn {
  color: #b8542c; /* last 60s — warmer, attention-getting but AA */
}
.timer-display.done {
  color: #2da44e; /* clear "you can stop now" green */
}
:root[data-theme="dark"] .timer-display.warn { color: #f08160; }
:root[data-theme="dark"] .timer-display.done { color: #58e67e; }
.timer-stage h3 {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted, #6b6960);
  margin: 0 0 6px;
}
.timer-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.timer-actions button {
  min-height: 44px;
}
.timer-actions button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201,97,63,0.32);
}
.timer-actions button[disabled] {
  /* WCAG 2.2 4.1.2 — disabled state must remain readable.
     Inline opacity wasn't set; default browser disabled is too pale. */
  opacity: 0.55;
  cursor: not-allowed;
}

/* -------------------------------------------------------------
   TOOL 8 — Decision Fatigue Index (/tools/decision-fatigue-index/)
   Failure modes addressed:
     #15 The score reveal was a static 56px digit — it should
         pulse-in like a verdict. Animate the score from 90% scale
         + opacity 0 to full size on render; honors reduced-motion.
     #16 The button-group selection had no focus-visible state and
         no keyboard hint. Add ring + arrow-key support announcement
         via clear focus styling.
   ------------------------------------------------------------- */
#dfi-result:not([hidden]) {
  animation: dr-result-rise 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
.dfi-score {
  font-variant-numeric: tabular-nums !important;
  letter-spacing: -0.02em;
  display: inline-block;
  animation: dr-score-pop 420ms cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes dr-score-pop {
  from { opacity: 0; transform: scale(0.92); }
  to   { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  #dfi-result:not([hidden]),
  .dfi-score { animation: none !important; }
}
.dfi-row .dfi-buttons button {
  min-height: 40px;
  position: relative;
}
.dfi-row .dfi-buttons button:focus-visible {
  outline: none;
  border-color: #c9613f;
  box-shadow: 0 0 0 3px rgba(201,97,63,0.28);
  z-index: 1;
}
.dfi-row .dfi-buttons button.selected:focus-visible {
  /* Selected + focused — keep the inverted look but add ring outside */
  box-shadow: 0 0 0 3px rgba(201,97,63,0.45);
}
.dfi-row .dfi-buttons button.selected::after {
  /* Subtle visual confirmation of selection beyond color */
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #faf9f5;
  opacity: 0.9;
}
.dfi-cta:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(201,97,63,0.32);
}

/* -------------------------------------------------------------
   END v2-tools-v20260508b.css
   16 changes total · 8 tools · ~290 lines pure-CSS overrides.
   ------------------------------------------------------------- */
