/*
  Force Plate Intelligence card (Version 3 Milestone 4.4).

  Loaded after styles/v3-app-shell.css in v3.html, so the --v3-* custom
  properties are already in scope — this file defines none of its own and
  introduces no second design system. Every colour, space, radius, and focus
  treatment below is either a --v3-* token or one of the four semantic tints
  the Version 3 surfaces already use for matched/clean/caution/error states
  (see v3-force-measurement-import.css and v3-match-review.css).

  Scoped entirely under .v3-hawkin-* so it cannot bleed into the rest of the
  shell, and it styles only the markup dashboards/forceMeasurement/
  hawkinIntelligenceRenderer.js emits. It changes no data contract: the card's
  numbers, ordering, and wording are the deterministic result's, and nothing
  here is generated, inferred, or conditional on a value.

  ## What the outcome colours mean, and what they must not imply

  A matched rule is *"a configured threshold was exceeded"* — an exception
  worth a coach's attention, never a clinical judgement — so it carries the
  brand maroon accent the rest of Version 3 uses for emphasis, not an alarm
  red. `notMatched` is green because "we checked and it was within the
  configured threshold" is genuinely the clean answer. Suppressed is amber
  because "we could not check" is a caution about the data, not about the
  athlete. Only an evaluation failure is red, because only that is a fault.
*/

/* ---------------------------------------------------------------------- */
/* Card shell                                                             */
/* ---------------------------------------------------------------------- */

/*
  ## Why this card must be able to shrink to nothing

  The card is a sibling of the Force Measurement tables inside
  `[data-force-measurement-root]`, a shared column flex container. A grid or
  flex item's automatic minimum size is its **min-content width**, and an
  ancestor track cannot shrink below it -- so an item that refuses to get
  narrower does not overflow itself, it widens everything it shares a container
  with. That is the only way a fully namespaced stylesheet can damage a layout
  it never selects, and it is what happened at 1024px: the card held a
  min-content floor of roughly 400px built from fixed grid minimums and two
  unbreakable strings, the shared ancestor was forced wider than the viewport,
  and the tables -- whose cells are `white-space: nowrap` -- were laid out in a
  container wider than the screen and collided.

  The tables were already immune because `.v3-fm-table-wrap` is an
  `overflow-x: auto` scroll container, which collapses min-content to zero.
  This card takes the other available route: **every grid track, flex item, and
  string in it can shrink**, so its min-content contribution is one word wide
  and it can never widen an ancestor again.

  Three rules enforce that, and none may be removed without reintroducing the
  defect:

  - `min-width: 0` on the card and on every flex/grid child that holds text.
  - `minmax(min(Npx, 100%), 1fr)` rather than `minmax(Npx, 1fr)`, so a track
    keeps its preferred width when there is room and gives it up when there is
    not.
  - No `white-space: nowrap` on anything longer than a short label.
*/

.v3-hawkin-intelligence {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-4);
  padding: var(--v3-space-5);
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-md);
  background: var(--v3-surface);
  min-width: 0;
  max-width: 100%;
}

/* Every descendant that participates in a flex or grid layout. Without this a
   single long word anywhere in the card re-establishes the floor. */
.v3-hawkin-intelligence *,
.v3-hawkin-intelligence *::before,
.v3-hawkin-intelligence *::after {
  min-width: 0;
}

.v3-hawkin-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--v3-space-2) var(--v3-space-4);
  padding-bottom: var(--v3-space-3);
  border-bottom: 1px solid var(--v3-border);
}

.v3-hawkin-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

/* The standing statement that these boundaries are unreviewed. It is part of
   the card's meaning, so it is legible rather than fine print. */
.v3-hawkin-ruleset {
  margin: 0;
  font-size: 0.78rem;
  color: var(--v3-text-muted);
  overflow-wrap: anywhere;
}

.v3-hawkin-intelligence h4 {
  margin: var(--v3-space-2) 0 0;
  font-size: 0.88rem;
  font-weight: 700;
}

/* ---------------------------------------------------------------------- */
/* Overall status and the count strip                                     */
/* ---------------------------------------------------------------------- */

.v3-hawkin-summary {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-3);
}

.v3-hawkin-status {
  margin: 0;
  padding: var(--v3-space-2) var(--v3-space-3);
  border-left: 4px solid var(--v3-border-strong);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface-muted);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--v3-text);
}

.v3-hawkin-intelligence[data-status="findings"] .v3-hawkin-status {
  border-left-color: var(--v3-maroon);
  background: #fbeef2;
  color: var(--v3-maroon-dark);
}

.v3-hawkin-intelligence[data-status="no_findings"] .v3-hawkin-status {
  border-left-color: #3d8b5f;
  background: #e6f4ea;
  color: #1e5631;
}

.v3-hawkin-intelligence[data-status="all_suppressed"] .v3-hawkin-status {
  border-left-color: #d9b26a;
  background: #fdf3df;
  color: #6b4700;
}

.v3-hawkin-intelligence[data-status="error"] .v3-hawkin-status {
  border-left-color: #c07070;
  background: #fdecea;
  color: #7a1f1f;
}

.v3-hawkin-counts {
  display: grid;
  /* `min(140px, 100%)`: 140px when the container can afford it, and the
     container's own width when it cannot. A bare 140px would be a floor. */
  grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr));
  gap: var(--v3-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.v3-hawkin-counts li {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-1);
  padding: var(--v3-space-3);
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface-muted);
}

.v3-hawkin-counts span {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--v3-text-muted);
}

.v3-hawkin-counts strong {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--v3-text);
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------- */
/* Highest priority findings                                              */
/* ---------------------------------------------------------------------- */

.v3-hawkin-findings-priority {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.v3-hawkin-priority-finding {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--v3-space-1) var(--v3-space-3);
  padding: var(--v3-space-3) var(--v3-space-4);
  border: 1px solid var(--v3-border);
  border-left: 4px solid var(--v3-maroon);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface);
}

.v3-hawkin-priority-finding .v3-hawkin-finding-name {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.v3-hawkin-priority-value {
  grid-column: 1 / -1;
  font-size: 0.95rem;
  color: var(--v3-text);
  overflow-wrap: anywhere;
}

/* The two measurements a percentage change came from. A percentage alone does
   not say what moved, so this line is part of the finding, not decoration. */
.v3-hawkin-priority-movement {
  grid-column: 1 / -1;
  font-size: 0.88rem;
  color: var(--v3-text);
  overflow-wrap: anywhere;
}

.v3-hawkin-priority-evidence {
  grid-column: 1 / -1;
  font-size: 0.8rem;
  color: var(--v3-text-muted);
}

/* ---------------------------------------------------------------------- */
/* Outcome badges, shared by both finding lists                           */
/* ---------------------------------------------------------------------- */

.v3-hawkin-finding-outcome {
  display: inline-block;
  align-self: start;
  padding: 2px var(--v3-space-2);
  border: 1px solid var(--v3-border-strong);
  border-radius: 999px;
  background: var(--v3-surface-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--v3-text-muted);
  /* "Configured threshold exceeded" is ~190px unbreakable. It wraps rather
     than setting a floor under the whole panel; a two-line pill at a narrow
     width is a far smaller cost than a corrupted dashboard. */
  overflow-wrap: anywhere;
}

.v3-hawkin-priority-finding .v3-hawkin-finding-outcome,
.v3-hawkin-finding[data-outcome="matched"] .v3-hawkin-finding-outcome {
  border-color: #d8b3bf;
  background: #fbeef2;
  color: var(--v3-maroon-dark);
}

.v3-hawkin-finding[data-outcome="notMatched"] .v3-hawkin-finding-outcome {
  border-color: #9fcbb0;
  background: #e6f4ea;
  color: #1e5631;
}

.v3-hawkin-finding[data-outcome="suppressed"] .v3-hawkin-finding-outcome {
  border-color: #d9b26a;
  background: #fdf3df;
  color: #6b4700;
}

.v3-hawkin-finding[data-outcome="error"] .v3-hawkin-finding-outcome {
  border-color: #c07070;
  background: #fdecea;
  color: #7a1f1f;
}

/* An unconfirmed unit is stated rather than printed beside the number
   (D-CMC-3), so the note must read as a caveat and not as a unit. */
.v3-hawkin-unit-note {
  font-size: 0.72rem;
  font-style: italic;
  color: var(--v3-text-muted);
  /* The longest string on the card at ~230px. It was the single largest
     contributor to the min-content floor; it must wrap. */
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------- */
/* Suggested actions                                                      */
/* ---------------------------------------------------------------------- */

.v3-hawkin-recommendations {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.v3-hawkin-recommendation {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--v3-space-2) var(--v3-space-3);
  padding: var(--v3-space-3) var(--v3-space-4);
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface-muted);
}

.v3-hawkin-recommendation-action {
  font-weight: 600;
  color: var(--v3-text);
}

.v3-hawkin-recommendation-meta {
  font-size: 0.78rem;
  color: var(--v3-text-muted);
  overflow-wrap: anywhere;
}

/* Every recommendation surface states that it is a suggestion for staff
   review (PERFORMANCE_KNOWLEDGE_MODEL.md §21). It is never de-emphasised to
   the point of disappearing. */
.v3-hawkin-disclaimer {
  margin: 0;
  font-size: 0.8rem;
  color: var(--v3-text-muted);
}

/* ---------------------------------------------------------------------- */
/* Rules that could not be evaluated                                      */
/* ---------------------------------------------------------------------- */

.v3-hawkin-suppressed-rules {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.v3-hawkin-suppressed-rule {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--v3-space-1) var(--v3-space-3);
  padding: var(--v3-space-2) var(--v3-space-3);
  border-bottom: 1px solid var(--v3-border);
}

.v3-hawkin-suppressed-rule:last-child {
  border-bottom: 0;
}

.v3-hawkin-suppressed-name {
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.v3-hawkin-suppressed-reason {
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b4700;
}

/* ---------------------------------------------------------------------- */
/* All rule results, and per-finding evidence                             */
/* ---------------------------------------------------------------------- */

.v3-hawkin-all-results,
.v3-hawkin-provenance {
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface-muted);
}

.v3-hawkin-all-results > summary,
.v3-hawkin-provenance > summary,
.v3-hawkin-evidence > summary {
  padding: var(--v3-space-2) var(--v3-space-3);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--v3-text-muted);
  cursor: pointer;
}

.v3-hawkin-all-results[open] > summary,
.v3-hawkin-provenance[open] > summary {
  border-bottom: 1px solid var(--v3-border);
}

.v3-hawkin-all-results > summary:focus-visible,
.v3-hawkin-provenance > summary:focus-visible,
.v3-hawkin-evidence > summary:focus-visible {
  outline: 3px solid var(--v3-focus-ring);
  outline-offset: 2px;
}

.v3-hawkin-findings {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-3);
  margin: 0;
  padding: var(--v3-space-3);
  list-style: none;
}

.v3-hawkin-finding {
  padding: var(--v3-space-3);
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface);
}

.v3-hawkin-finding-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--v3-space-2);
}

.v3-hawkin-finding-name {
  font-size: 0.88rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.v3-hawkin-suppression {
  margin: var(--v3-space-1) 0 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #6b4700;
}

.v3-hawkin-finding-values,
.v3-hawkin-evidence dl,
.v3-hawkin-provenance dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: var(--v3-space-2) var(--v3-space-4);
  margin: var(--v3-space-3) 0 0;
}

.v3-hawkin-evidence dl,
.v3-hawkin-provenance dl {
  margin: 0;
  padding: var(--v3-space-3);
}

.v3-hawkin-finding-values dt,
.v3-hawkin-evidence dt,
.v3-hawkin-provenance dt {
  margin: 0 0 var(--v3-space-1);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--v3-text-muted);
}

.v3-hawkin-finding-values dd,
.v3-hawkin-evidence dd,
.v3-hawkin-provenance dd {
  margin: 0;
  font-size: 0.88rem;
  color: var(--v3-text);
  /* recordKeys are long, opaque, and must never push the panel sideways. */
  overflow-wrap: anywhere;
}

/* Window sessions, size, and observed dates behind a change finding. Secondary
   to the value above them, but never hidden: a change nobody can trace to two
   windows is not evidence. */
.v3-hawkin-window-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--v3-text-muted);
}

.v3-hawkin-window-shortfall {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #6b4700;
}

.v3-hawkin-evidence {
  margin-top: var(--v3-space-3);
  border: 1px solid var(--v3-border);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface-muted);
}

.v3-hawkin-evidence[open] > summary {
  border-bottom: 1px solid var(--v3-border);
}

/* ---------------------------------------------------------------------- */
/* Empty, unavailable, and error states                                   */
/* ---------------------------------------------------------------------- */

/* Stated answers, never blank space: "nothing crossed a threshold" and "no
   data has been imported" are results a coach needs to be able to read. */
.v3-hawkin-empty {
  margin: 0;
  padding: var(--v3-space-4);
  border: 1px dashed var(--v3-border-strong);
  border-radius: var(--v3-radius-sm);
  background: var(--v3-surface-muted);
  color: var(--v3-text-muted);
}

.v3-hawkin-intelligence[data-status="configuration_error"] .v3-hawkin-empty,
.v3-hawkin-intelligence[data-status="evaluation_error"] .v3-hawkin-empty {
  border-style: solid;
  border-color: #e0a3a3;
  background: #fdecea;
  color: #7a1f1f;
}

.v3-hawkin-detail {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  color: #7a1f1f;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------------- */
/* Responsive: tablet and narrow desktop                                  */
/* ---------------------------------------------------------------------- */

@media (max-width: 899px) {
  .v3-hawkin-intelligence {
    padding: var(--v3-space-4);
  }

  .v3-hawkin-counts {
    grid-template-columns: repeat(auto-fit, minmax(min(120px, 100%), 1fr));
  }
}

@media (max-width: 560px) {
  .v3-hawkin-counts {
    grid-template-columns: 1fr;
  }

  .v3-hawkin-priority-finding {
    grid-template-columns: 1fr;
  }

  .v3-hawkin-finding-values,
  .v3-hawkin-evidence dl,
  .v3-hawkin-provenance dl {
    grid-template-columns: 1fr;
  }

  .v3-hawkin-recommendation,
  .v3-hawkin-suppressed-rule {
    flex-direction: column;
    align-items: flex-start;
  }
}
