/* ============================================================================
 * components/validation.css — ForceX Data Quality surface (shared)
 * ============================================================================
 * Depends on: core/tokens.css, components/panels.css
 *
 * Platform trust surface per fx-env-pln-validation-surface.md.
 * Terminology cascade (locked, plan §0):
 *   Public:   Data Quality  (umbrella)
 *   Sub:      Monetary / Address / Block & Write Integrity  (domains)
 *   Control:  Ledger Validation Rule (LVR)  (e.g. FX-LVR-001)
 *   Engine:   Validation  (internal only — filenames kept per cascade)
 *
 * Components:
 *   .fx-dq-card              — compact card (Level 1)
 *   .fx-dq-card--summary-band— chain-overview spacing-richer variant
 *   .fx-drawer            — full-detail drawer (Level 2)
 *   .fx-drawer-backdrop          — scrim behind drawer
 *   .fx-drawer-section            — collapsible domain section
 *   .fx-drawer-item           — collapsible control row
 *
 * State variants (suffix on .fx-dq-card):
 *   --validated  (green)   --warning  (yellow)  --pending  (muted)
 *   --not-applicable (muted, no badge)  --missing (muted, no badge)
 * ========================================================================== */


/* ── Compact card (Level 1) ───────────────────────────────────────────── */

.fx-dq-card {
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  /* 4px colored strip on left — state indicator */
  border-left-width: 4px;
  border-left-style: solid;
  border-left-color: var(--muted);  /* default; state variants override */
}
.fx-dq-card--validated      { border-left-color: var(--green); }
.fx-dq-card--warning        { border-left-color: var(--yellow); }
.fx-dq-card--pending,
.fx-dq-card--not-applicable,
.fx-dq-card--missing        { border-left-color: var(--muted); }

/* 1. Eyebrow row — DATA QUALITY + status badge on right */
.fx-dq-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.fx-dq-eyebrow-label {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--muted);
}

/* Status badge — inherits existing ForceX badge tokens */
.fx-dq-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  line-height: 1.2;
}
.fx-dq-badge--validated { background: var(--green-bg);  color: var(--green); }
.fx-dq-badge--warning   { background: var(--yellow-bg); color: var(--yellow); }
.fx-dq-badge--pending   { background: var(--surface2);  color: var(--muted2); }
/* not_applicable and missing render NO badge — per plan §9 */

/* 2. Primary summary line (state sentence) */
.fx-dq-summary {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-2);
}

/* 3. Secondary trust lines (short statements) */
.fx-dq-trust-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
}
.fx-dq-trust-lines:last-child { margin-bottom: 0; }

/* Summary messaging block (plan §6.1 block 3) — three lines:
 *   line 1: primary (semibold) — surface-aware opening statement
 *   lines 2+: secondary (regular) — cadence count + node cross-check
 * Separates from the action row with generous bottom margin. */
.fx-dq-summary-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
}
.fx-dq-summary-line {
  font-weight: var(--weight-regular);
  color: var(--muted2);
}
.fx-dq-summary-line--primary {
  font-weight: var(--weight-semibold);
  color: var(--text);
}

/* 4. Action row — two tertiary pill buttons */
.fx-dq-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.fx-dq-action {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--muted2);
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--motion-base), border-color var(--motion-base);
}
.fx-dq-action:hover,
.fx-dq-action:focus-visible {
  color: var(--accent-lt);
  border-color: var(--accent-lt);
  outline: none;
  text-decoration: none; /* prevent browser default underline on <a> variant */
}
.fx-dq-action:focus-visible {
  outline: 2px solid var(--accent-lt);
  outline-offset: 2px;
}

/* ── Chain-overview summary band (§5.1 variant) ───────────────────────── */
/* Spacing-richer variant of the same shell. Content: domain chips row +
 * per-domain one-line meanings + single "View data quality details" CTA. */
.fx-dq-card--summary-band {
  padding: var(--space-5) var(--space-6);
}
/* Domain chip row — anti-squeeze (plan §10.5 platform rule):
 * all three fit on one row OR all three stack vertically.
 * Never a 2+1 orphan wrap. Chips size to their content (no stretch),
 * aligned to the row start. Below 680px container width, the row
 * collapses to a single full-width column.
 */
.fx-dq-domain-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
@media (max-width: 680px) {
  .fx-dq-domain-chips {
    flex-direction: column;
    align-items: stretch;
  }
}
.fx-dq-domain-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--muted2);
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  flex: 0 0 auto;           /* size to content — no stretch */
  white-space: nowrap;      /* don't wrap chip label */
  justify-content: flex-start;
}
.fx-dq-domain-chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
}
.fx-dq-domain-chip--pass .fx-dq-domain-chip-dot { background: var(--green); }
.fx-dq-domain-chip--warn .fx-dq-domain-chip-dot { background: var(--yellow); }
.fx-dq-domain-meanings {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  line-height: var(--leading-normal);
  margin-bottom: var(--space-4);
}
.fx-dq-domain-meaning-title {
  color: var(--text);
  font-weight: var(--weight-semibold);
  margin-right: var(--space-2);
}


/* ── Drawer / Mobile full-screen (Level 2) ────────────────────────────── */

.fx-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  animation: fx-drawer-fade-in 200ms ease forwards;
}
@keyframes fx-drawer-fade-in { to { opacity: 1; } }

.fx-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9001;
  width: min(480px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--border2);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  animation: fx-drawer-slide-in 280ms var(--easing-base) forwards;
  overflow: hidden;
}
@keyframes fx-drawer-slide-in { to { transform: translateX(0); } }

.fx-drawer.closing {
  animation: fx-drawer-slide-out 220ms var(--easing-base) forwards;
}
@keyframes fx-drawer-slide-out { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
  .fx-drawer-backdrop,
  .fx-drawer,
  .fx-drawer.closing { animation-duration: 1ms; }
}

/* Drawer header */
.fx-drawer-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.fx-drawer-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.fx-drawer-title {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
  color: var(--text);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}
.fx-drawer-close {
  background: transparent;
  border: none;
  color: var(--muted2);
  font-size: var(--text-lg);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: var(--radius-sm);
}
.fx-drawer-close:hover { color: var(--text); }
.fx-drawer-close:focus-visible {
  outline: 2px solid var(--accent-lt);
  outline-offset: 2px;
}
.fx-drawer-state {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  margin-bottom: var(--space-2);
}
.fx-drawer-counts {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  margin-bottom: var(--space-3);
}
.fx-drawer-blurb {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
}
.fx-drawer-header-action {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--accent-lt);
  text-decoration: none;
}
.fx-drawer-header-action:hover { color: var(--text); }

/* Drawer body — scrollable */
.fx-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-6) var(--space-8);
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}

/* ── Domain section (collapsible) ─────────────────────────────────────── */
.fx-drawer-section {
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) 0;
}
.fx-drawer-section:last-child { border-bottom: none; }

.fx-drawer-section-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--text);
  min-height: 44px;  /* tap target */
}
.fx-drawer-section-header:focus-visible {
  outline: 2px solid var(--accent-lt);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}
.fx-drawer-section-title {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-tight);
  min-width: 0;
}
.fx-drawer-section-state {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--muted2);
}
.fx-drawer-chevron-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--muted);
  transition: transform var(--motion-base);
}
.fx-drawer-section[aria-expanded="true"] .fx-drawer-chevron-svg,
.fx-drawer-section-header[aria-expanded="true"] .fx-drawer-chevron-svg {
  transform: rotate(180deg);
}
.fx-drawer-section-desc {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  line-height: var(--leading-normal);
  margin-top: var(--space-2);
}
.fx-drawer-section-body {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* ── Control row (collapsible) ────────────────────────────────────────── */
.fx-drawer-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}
.fx-drawer-item-header {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  background: transparent;
  border: none;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font-family: inherit;
  min-height: 44px;  /* tap target */
}
.fx-drawer-item-header:hover { background: var(--surface2); }
.fx-drawer-item-header:focus-visible {
  outline: 2px solid var(--accent-lt);
  outline-offset: -2px;
}

/* Status icon — leading circle */
.fx-drawer-status {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-bold);
  line-height: 1;
  margin-top: 2px;
}
.fx-drawer-status--pass    { background: var(--green-bg);  color: var(--green); }
.fx-drawer-status--warn    { background: var(--yellow-bg); color: var(--yellow); }
.fx-drawer-status--pending { background: var(--surface2);  color: var(--muted); }
/* 'due' — cadence-driven check awaiting its next scheduled run (LVR-014).
 * Distinct from generic 'pending' so drawer rows communicate that the check
 * is scheduled-but-not-yet-run, not indefinitely waiting. */
.fx-drawer-status--due     { background: var(--accent-bg); color: var(--accent-lt); }

.fx-drawer-item-main {
  flex: 1;
  min-width: 0;
}
.fx-drawer-item-top {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.fx-drawer-item-code {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--muted);
  letter-spacing: var(--tracking-wide);
}
.fx-drawer-item-title {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text);
}
.fx-drawer-item-meaning {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  line-height: var(--leading-normal);
  word-break: break-word;
}

.fx-drawer-item-body {
  display: none;
  padding: var(--space-4) var(--space-4) var(--space-4) calc(var(--space-4) + 18px + var(--space-3));
  border-top: 1px solid var(--border);
}
.fx-drawer-item[aria-expanded="true"] .fx-drawer-item-body,
.fx-drawer-item.is-open .fx-drawer-item-body {
  display: block;
}

.fx-dq-field {
  margin-top: var(--space-3);
}
.fx-dq-field-label {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--muted);
  display: block;
  margin-bottom: 2px;
}
.fx-dq-field-value {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text);
  line-height: var(--leading-relaxed);
}
.fx-dq-field-value.fx-dq-value-muted { color: var(--muted2); }

/* Technical basis — single-step disclosure inside the expanded row body.
 * The label + text are always rendered together when the row is expanded.
 * Visually grouped with a subtle background panel to read as one unit
 * distinct from the row's collapsed content above it. */
.fx-drawer-tech-basis-label {
  display: block;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--space-3);
}
.fx-drawer-tech-basis-text {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--muted2);
  line-height: var(--leading-relaxed);
  padding: var(--space-4);
  background: var(--surface2);
  border-radius: var(--radius-sm);
}

/* Row expand chevron — bottom-right of each row header. Rotates when
 * aria-expanded flips to true. Gives a clear affordance that the row
 * expands. Explicit width/height so it renders regardless of the SVG's
 * intrinsic sizing. */
.fx-drawer-item-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--muted2);
  margin-left: var(--space-3);
  flex-shrink: 0;
  align-self: center;
  transition: transform var(--motion-base), color var(--motion-base);
}
.fx-drawer-item-chevron svg,
.fx-drawer-item-chevron .fx-drawer-chevron-svg {
  width: 18px;
  height: 18px;
  display: inline-flex;
}
.fx-drawer-item-header:hover .fx-drawer-item-chevron { color: var(--text); }
.fx-drawer-item-header[aria-expanded="true"] .fx-drawer-item-chevron {
  transform: rotate(180deg);
  color: var(--accent-lt);
}


/* ── Mobile: full-screen view ≤768px ──────────────────────────────────── */

@media (max-width: 768px) {
  .fx-drawer {
    width: 100vw;
    left: 0;
    right: 0;
    border-left: none;
  }

  .fx-dq-card {
    padding: var(--space-4);
  }
  .fx-dq-card--summary-band {
    padding: var(--space-4) var(--space-4);
  }

  /* Stack eyebrow + badge if crowded */
  .fx-dq-eyebrow {
    flex-wrap: wrap;
  }

  /* Action row: full-width buttons per §12 */
  .fx-dq-actions {
    flex-direction: column;
    gap: var(--space-2);
  }
  .fx-dq-action {
    width: 100%;
    text-align: center;
  }

  /* Drawer body: tighter padding */
  .fx-drawer-body {
    padding: var(--space-3) var(--space-4) var(--space-8);
  }
  .fx-drawer-header {
    padding: var(--space-4) var(--space-4);
  }
}
