/**
 * UI Variant Pilot — variant B signal console (WS7 task 7.3b, 2026-11 review
 * remediation). Design doc: docs/plans/2026-11-27-ws7-pilot-design.md §Addendum
 * (source of record: knowledge K-cmd-app-ui-direction-mockups-canvas-…).
 *
 * Variant B is the signal console in ConcreteInfo colours:
 *   dark #0d0b09 top bar · one bordered KPI strip · grey-header panels with
 *   6 px radii · dense rows · dot+label status · Inter/JetBrains Mono (7.2/7.3
 *   type wiring) · #c93a18 for text+buttons, #e5461f decoration only.
 *
 * EVERY rule in this sheet is scoped under [data-ui="b"] (rendered on <html>
 * by includes/header.php). Variant A resolves none of these selectors — the
 * `.ui-num` block below defines nothing outside [data-ui="b"] either — so A
 * renders exactly as today (byte-equivalent; re-verified by the A-side
 * assertions in tests/playwright/ui-pilot.js).
 *
 * Markup hooks (variant-inert, no effect in A):
 *   .ci-pilot   — page root of the four pilot screens; scopes the Tailwind
 *                 utility-card overrides to those screens only.
 *   .ci-kpis    — a KPI/stat card grid that becomes one bordered strip in B.
 *   .ci-status  — a status chip; data-tone="success|warning|danger|info"
 *                 picks the dot/text colours. Emits from PHP pages and
 *                 CICompliance.statusBadge().
 *
 * Standalone sheet in the appearance.css / theme-studio.css tier, NOT a
 * core-bundle manifest member: the bundle's variant styles are the token
 * DEFINITIONS (design-tokens.css, synced via build-bundle.php in 7.2), while
 * token CONSUMERS ride the standalone links. Loads AFTER tailwind-output.css
 * (header.php order), which settles specificity ties with utility classes.
 *
 * @author Amit Haridas, ConcreteInfo
 */

/* ═══════════════════════════════════════════════════════════════════════════
   1. NUMERIC TYPE CONVENTION (7.3 first pass — unchanged)
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"] .ui-num {
  font-family: var(--font-family-ui-b-mono);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. B(-CI) PALETTE TOKENS
   From the mockup record. #c93a18 is the AA (5.12:1) text/button colour;
   #e5461f stays decoration-only; muted warm grey #6b6767 is used where the
   ground is light. No page CSS hardcodes these — everything consumes the
   tokens below.
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"] {
  --ui-b-ground: #0d0b09;             /* near-black warm ground / top bar */
  --ui-b-topbar-bg: var(--ui-b-ground);
  --ui-b-topbar-text: #f5f4f2;        /* 16.9:1 on the top bar */
  --ui-b-topbar-text-muted: #a8a4a0;  /* 7.8:1 on the top bar (secondary) */
  --ui-b-topbar-border: #292522;
  --ui-b-topbar-brand: hsl(var(--color-brand-h), 80%, 60%); /* AA brand on dark */

  --ui-b-panel-radius: 6px;           /* grey-header panel corners */
  --ui-b-panel-header-bg: #e9e8e7;    /* light tint of the #6b6767 family */
  --ui-b-panel-header-bg-hover: #dedcd9;
  --ui-b-panel-header-bg-dark: #262421; /* warm dark grey for theme_mode dark */

  --ui-b-action: #c93a18;             /* text + buttons, AA 5.12:1 on white */
  --ui-b-brand: #e5461f;              /* decoration only — never text on light */
  --ui-b-muted: #6b6767;              /* muted warm grey, light grounds only */

  --ui-b-dot-success: #1a7a56;  --ui-b-text-success: #1a7a56; /* 5.3:1 */
  --ui-b-dot-warning: #e7b008;  --ui-b-text-warning: #8a6400; /* dot fails AA as text */
  --ui-b-dot-danger: #ef4343;   --ui-b-text-danger: #b42323;  /* dot fails AA as text */
  --ui-b-dot-info: #0da2e7;     --ui-b-text-info: var(--color-info); /* dot = mockup tone (graphic); text = AA token (≈4.8:1 on white) */

  --kpi-value-size-b: 0.85em;         /* big mono numerals ~15% smaller */
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. DARK TOP BAR — the app's global page-header chrome
   The authed layout has no separate top bar; the per-page sticky header
   (`sticky top-0 z-30 bg-white …`, includes/header.php-era idiom used by 77
   pages incl. the pilot screens) IS the top navigation/header chrome, so B
   darkens that pattern globally via its utility chain — no markup fork. The
   mobile bottom nav intentionally stays light (it does not pair with the top
   bar visually). Works in dark mode too: the near-black bar keeps the light
   text the dark utilities already apply.
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"] div.sticky.top-0.z-30.bg-white {
  background-color: var(--ui-b-topbar-bg);
  border-bottom-color: var(--ui-b-topbar-border);
  color: var(--ui-b-topbar-text);
}

/* Dark-text Tailwind utilities inside the bar flip to the bar's light text
   (in dark mode the dark: variants would render light anyway — same outcome). */
[data-ui="b"] div.sticky.top-0.z-30.bg-white
  :is(.text-gray-900, .text-gray-800, .text-gray-700, .text-gray-600) {
  color: var(--ui-b-topbar-text);
}
[data-ui="b"] div.sticky.top-0.z-30.bg-white :is(.text-gray-500, .text-gray-400) {
  color: var(--ui-b-topbar-text-muted);
}
/* Brand text/icons on the dark bar use the AA-on-dark brand tint, not #c93a18
   (3.8:1) and not #e5461f (2.6:1). */
[data-ui="b"] div.sticky.top-0.z-30.bg-white :is(.text-brand, .hover\:text-brand:hover) {
  color: var(--ui-b-topbar-brand);
}

/* ═══════════════════════════════════════════════════════════════════════════
   4. GREY-HEADER PANELS, 6 PX RADII
   Two card families on the pilot screens:
   a) .tf-section / .tf-card (testing-forms.css) — the collapsible entry-form
      sections. Component-level override, applies wherever the component
      renders under B.
   b) The Tailwind white-card idiom (bg-white … rounded-lg with a p-4 border-b
      header) used by pour-register/view.php + delivery-events-panel. Utility
      classes are everywhere, so these overrides are scoped to .ci-pilot page
      roots (the four pilot screens) instead of the whole app.
   Light mode: #6b6767-family grey header, dark-on-light text. Dark mode: warm
   dark-grey header so the treatment survives theme_mode dark without a clash.
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"] :is(.tf-section, .tf-card) {
  border-radius: var(--ui-b-panel-radius);
}

[data-ui="b"]:not(.dark) .tf-section-header {
  background: var(--ui-b-panel-header-bg);
  border-bottom: 1px solid var(--border-subtle);
}
[data-ui="b"]:not(.dark) .tf-section-header:hover {
  background: var(--ui-b-panel-header-bg-hover);
}
[data-ui="b"].dark .tf-section-header {
  background: var(--ui-b-panel-header-bg-dark);
  border-bottom: 1px solid var(--border-subtle);
}
[data-ui="b"].dark .tf-section-header:hover {
  background: #312d29;
}
/* Dense header row (7.2 density tokens; the 48 px touch-target minimum is a
   variant-A/mobile affordance — B is the compact desktop-density variant). */
[data-ui="b"] .tf-section-header {
  min-height: var(--table-row-height);
  padding: var(--space-density-block) var(--space-density-inline);
}
[data-ui="b"] .tf-card-header {
  background: var(--ui-b-panel-header-bg);
  border-bottom-color: var(--border-subtle);
}
[data-ui="b"].dark .tf-card-header {
  background: var(--ui-b-panel-header-bg-dark);
}

/* Tailwind utility-card panels on the pilot screens */
[data-ui="b"] .ci-pilot div.bg-white.rounded-lg {
  border-radius: var(--ui-b-panel-radius);
}
[data-ui="b"]:not(.dark) .ci-pilot div.bg-white.rounded-lg > div.p-4.border-b {
  background: var(--ui-b-panel-header-bg);
  border-bottom-color: var(--border-subtle);
}
[data-ui="b"].dark .ci-pilot div.bg-white.rounded-lg > div.p-4.border-b {
  background: var(--ui-b-panel-header-bg-dark);
  border-bottom-color: var(--border-subtle);
}

/* ═══════════════════════════════════════════════════════════════════════════
   5. ONE BORDERED KPI STRIP
   .ci-kpis marks a KPI/stat card grid (pour-view summary, IS 456 acceptance
   stats, pour-card delivery reconciliation, fresh-test results summary). B
   collapses the separate rounded cards into a single bordered strip with
   1 px internal dividers: the container paints the divider colour, the gap
   is 1 px, children repaint the surface — dividers stay perfect however the
   grid wraps. Column tracks keep each grid's own responsive utilities.
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"] .ci-kpis {
  gap: 1px;
  background: var(--border-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--ui-b-panel-radius);
  overflow: hidden;
}
[data-ui="b"] .ci-kpis > * {
  background: var(--bg-elevated);
  border-radius: 0;
  border-width: 0;
  box-shadow: none;
  padding: var(--spacing-1-5) var(--spacing-2-5);
  text-align: left;
}
/* Pour-summary cells are div.bg-white.rounded-lg, so the §4 panel-radius rule
   (higher specificity) would re-round them — square them back off; the strip
   container owns the corner radius and clips it via overflow:hidden. */
[data-ui="b"] .ci-pilot .ci-kpis > div.bg-white.rounded-lg {
  border-radius: 0;
}
/* Big display numerals: mono runs wide, so KPI values shrink ~15%
   (--kpi-value-size-b) on top of the .ui-num mono stack. */
[data-ui="b"] .ci-kpis .ui-num {
  font-size: var(--kpi-value-size-b);
}

/* ═══════════════════════════════════════════════════════════════════════════
   6. DOT+LABEL STATUS
   .ci-status + data-tone replaces the pill chip with "● Label": coloured dot
   (a real ::before circle, not a font glyph) + text, no pill background.
   Info text uses the canonical --color-info token (hsl 199 89% 36%, ≈4.8:1
   on white) instead of the mockup record's #0da2e7 (2.9:1, fails AA as text);
   the dot keeps #0da2e7 — it is a graphic and the label carries the meaning.
   Inside the dark top bar and in dark mode the label goes light and only the
   dot keeps the tone.
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"] .ci-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0;
  background: none;
  border-width: 0;
  border-radius: 0;
  box-shadow: none;
  font-family: var(--font-family-ui-b-mono); /* small badges are mono in B */
  font-variant-numeric: tabular-nums;
}
[data-ui="b"] .ci-status::before {
  content: '';
  flex: none;
  width: 0.5em;
  height: 0.5em;
  min-width: 6px;
  min-height: 6px;
  border-radius: 9999px;
  background: var(--ui-b-dot-info);
}
[data-ui="b"] .ci-status[data-tone="success"] { color: var(--ui-b-text-success); }
[data-ui="b"] .ci-status[data-tone="success"]::before { background: var(--ui-b-dot-success); }
[data-ui="b"] .ci-status[data-tone="warning"] { color: var(--ui-b-text-warning); }
[data-ui="b"] .ci-status[data-tone="warning"]::before { background: var(--ui-b-dot-warning); }
[data-ui="b"] .ci-status[data-tone="danger"] { color: var(--ui-b-text-danger); }
[data-ui="b"] .ci-status[data-tone="danger"]::before { background: var(--ui-b-dot-danger); }
[data-ui="b"] .ci-status[data-tone="info"] { color: var(--ui-b-text-info); }
[data-ui="b"] .ci-status[data-tone="info"]::before { background: var(--ui-b-dot-info); }

/* Dark-top-bar scope: light label, tone dot (after the tone rules above). */
[data-ui="b"] div.sticky.top-0.z-30.bg-white .ci-status {
  color: var(--ui-b-topbar-text);
}
/* theme_mode dark: light label keeps AA; dots keep their tones. */
[data-ui="b"].dark .ci-status {
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════════════
   7. TYPE — input VALUES in mono, KPI numerals sized in §5
   Numeric/date/time input values on the pilot screens render in the B mono
   stack (the CSS equivalent of adding .ui-num to every numeric .tf-input /
   .field__input — one rule instead of ~40 markup edits, A untouched).
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"] :is(.tf-input, .field__input):is([type="number"], [type="date"], [type="time"]) {
  font-family: var(--font-family-ui-b-mono);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════════════════
   8. DENSE ROWS
   The 7.2 density tokens are consumed by html[data-density="compact"] rules
   for .table/.btn/.card__* and the AG Grid rowHeight seam (26 px in B —
   already asserted by ui-pilot.js). The pilot screens' tables use .tf-table
   and Tailwind utility padding instead, so B retargets them onto the same
   tokens (5 px block / 8 px inline in B).
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"] .ci-pilot table :is(td, th),
[data-ui="b"] .tf-table :is(td, th) {
  padding-top: var(--space-density-block);
  padding-bottom: var(--space-density-block);
  padding-left: var(--space-density-inline);
  padding-right: var(--space-density-inline);
}

/* ═══════════════════════════════════════════════════════════════════════════
   9. PALETTE DISCIPLINE — #c93a18 for text + buttons, #e5461f decoration only
   Brand-tinted TEXT (links, IDs) and primary-button fills drop to the AA
   action colour under B in light mode; decorative fills (accents, focus
   rings, chart marks) keep #e5461f via the untouched --color-brand tokens.
   ═══════════════════════════════════════════════════════════════════════════ */

[data-ui="b"]:not(.dark) :is(.text-brand, .hover\:text-brand:hover) {
  color: var(--ui-b-action);
}
[data-ui="b"]:not(.dark) :is(.btn-primary, .btn.btn-primary) {
  background: var(--ui-b-action);
  border-color: transparent;
}
[data-ui="b"]:not(.dark) :is(.btn-primary, .btn.btn-primary):hover {
  background: color-mix(in srgb, var(--ui-b-action) 88%, #000);
}
