﻿/* kc-v2 v1.5.7 -- progress */
/* kc-v2 progress bar -- determinate progress through a known-length operation.
 *
 * Full class contract and conventions: see README.md and kc-v2-base.css.
 *
 * Added in 1.5.3 for the Annual Reconciliation upload (KENT-69), which is the first screen in the
 * redesign that reports progress at all: it uploads up to five PDFs of up to 500MB each, one after
 * another, and without a bar the page looks hung for minutes. Nothing else in the library needed one,
 * and no Figma frame specifies it -- the visual treatment below is developer judgment, built from the
 * existing tokens rather than invented values, and is FLAGGED FOR DESIGN REVIEW.
 *
 * DETERMINATE ONLY. There is no indeterminate/striped-animation variant, because the one consumer
 * always knows its percentage (bytes sent over bytes total). Bootstrap's .progress-bar-striped.active
 * is what this replaces, and that animation was decoration -- it ran at a fixed rate regardless of
 * what the upload was doing, which is worse than no motion at all.
 *
 * ---------------------------------------------------------------------------
 * Markup
 * ---------------------------------------------------------------------------
 *   <div class="kc-v2-progress" role="progressbar"
 *        aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"
 *        aria-labelledby="theLabelId">
 *     <span class="kc-v2-progress__bar" style="width: 0%"></span>
 *   </div>
 *
 * role and the aria-value* attributes go on the TRACK, not the fill: the track is the element that
 * represents the whole measure, and the fill is a presentational child. Putting them on the fill is
 * the common mistake -- it announces a widget whose own width is the value it is reporting.
 *
 * The percentage is set as an inline width by the caller, because the value is only known at runtime.
 * That is the one place this library expects an inline style, and it is why the fill declares no width
 * of its own beyond the 0 default.
 */

.kc-v2-progress {
  box-sizing: border-box;
  display: block;
  overflow: hidden;
  width: 100%;
  height: 8px;
  border-radius: var(--kc-v2-radius-pill);
  /* ink-100, the same ground the definition-list rules use -- a track is a groove, not a control, so
     it takes the lightest fill in the scale rather than a bordered box. */
  background-color: var(--kc-v2-ink-100);
}

.kc-v2-progress *,
.kc-v2-progress *::before,
.kc-v2-progress *::after {
  box-sizing: border-box;
}

.kc-v2-progress__bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background-color: var(--kc-v2-blue);
  /* Linear, not eased: progress is a measurement, and an ease-out would keep drawing motion after the
     value stopped changing. 150ms is short enough that a stalled upload still looks stalled. */
  transition: width 150ms linear;
}

/* A bar that animates is the whole point, but the animation is not the information -- the width is.
   Honouring the preference costs nothing here. */
@media (prefers-reduced-motion: reduce) {
  .kc-v2-progress__bar {
    transition: none;
  }
}

/* Background fills are dropped by the OS in forced-colors mode, which would leave the track and the
   fill indistinguishable -- a progress bar that always reads as empty. A border on the track and a
   system-colour fill survive. */
@media (forced-colors: active) {
  .kc-v2-progress {
    border: 1px solid CanvasText;
  }
  .kc-v2-progress__bar {
    background-color: Highlight;
  }
}
