/* =============================================================================
   10_ui_kit.css — StatsPoint component kit (UI redesign Phase 0c).

   Port of the approved mockup kit docs/design/mockups/sp.css under the
   `.sp-ui-*` prefix, plus the Instagram-style post anatomy (`.sp-post*`) from
   docs/design/mockups/feed_desktop.html / feed_mobile.html. Reference shots:
   docs/design/mockups/shots/mk-*.png. Program doc: docs/ui_redesign_kickoff.md.

   INERT until Phase 1: no DOM carries any `.sp-ui-*` / `.sp-post*` class yet
   (verified repo-wide before landing), and the token blocks only declare
   `--sp-ui-*` custom properties nobody consumes. Zero visual change by
   construction; the parity gate (scripts/parity_screenshots.py) verifies.

   Theming:
   - Dark is the :root default (dark-first product); light values apply under
     the bootstrap route stamp `body.sp-route-theme-light`
     (assets/00_theme_bootstrap.js) and the scaffold pair
     `body:has(.sp-page-shell.sp-theme-light)` (utils/page_scaffold.py).
     Pages outside those stamps read dark until their migration stage wires a
     scope — acceptable while inert.
   - Accent and its derivatives come from assets/00_tokens.css.
   - Scale tokens (--sp-font-*, --sp-space-*, --sp-radius-*, --sp-z-*,
     --sp-ease, --sp-dur-*) come from assets/05_page_chrome.css (Phase 0b).

   Convention: classes only, never ids (docs/page_scaffold.md).
   ============================================================================= */

/* ---- Kit tokens: DARK (default) ------------------------------------------- */
:root {
  --sp-ui-bg: #0b0f17;
  --sp-ui-surface: #121a29;
  --sp-ui-surface-2: #1a2438;
  --sp-ui-border: #263450;
  --sp-ui-text: #edf2fa;
  --sp-ui-muted: #8ca0be;
  --sp-ui-ok: #35c08e;
  --sp-ui-danger: #f16a5e;
  /* export-canvas backdrop — content stays authored-dark in BOTH themes */
  --sp-ui-canvas: #0a0d14;
  --sp-ui-canvas-text: #e8edf6;
  --sp-ui-canvas-muted: #71809a;
  --sp-ui-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.25);
  --sp-ui-shadow-2: 0 6px 24px rgba(0, 0, 0, 0.35);
  /* accent fallbacks (sky) — live values derived under .sp-accent-theme */
  --sp-ui-accent: var(--sp-accent);
  --sp-ui-accent-strong: var(--sp-accent-hover);
  --sp-ui-accent-soft: color-mix(in srgb, var(--sp-accent) 14%, transparent);
}

/* ---- Kit tokens: LIGHT ----------------------------------------------------- */
body.sp-route-theme-light,
body:where([data-sp-has~="page-shell-light"]):not(.sp-s):not(.sp-s) {
  --sp-ui-bg: #f5f7fc;
  --sp-ui-surface: #ffffff;
  --sp-ui-surface-2: #ebf0f9;
  --sp-ui-border: #d9e2f2;
  --sp-ui-text: #111826;
  --sp-ui-muted: #5c6e8c;
  --sp-ui-ok: #177a56;
  --sp-ui-danger: #c2372b;
  --sp-ui-shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06);
  --sp-ui-shadow-2: 0 10px 28px rgba(16, 24, 40, 0.1);
}

/* ---- Brand aliases ----------------------------------------------------- */
.sp-accent-theme {
  --sp-ui-accent: var(--sp-accent-primary, var(--sp-accent));
  --sp-ui-accent-strong: color-mix(in srgb, var(--sp-accent-primary, var(--sp-accent)) 82%, #ffffff 18%);
  --sp-ui-accent-soft: color-mix(in srgb, var(--sp-accent-primary, var(--sp-accent)) 14%, transparent);
}
body.sp-route-theme-light .sp-accent-theme,
body:where([data-sp-has~="page-shell-light"]):not(.sp-s):not(.sp-s) .sp-accent-theme {
  --sp-ui-accent-strong: var(--sp-accent-primary, var(--sp-accent));
  --sp-ui-accent-soft: color-mix(in srgb, var(--sp-accent-primary, var(--sp-accent)) 11%, transparent);
}

/* ---- Buttons ---------------------------------------------------------------- */
.sp-ui-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--sp-radius-pill, 999px);
  font-family: var(--sp-font-sans, "Manrope", sans-serif);
  font-weight: var(--sp-font-weight-bold, 700);
  font-size: 13.5px;
  padding: 8px 16px;
  border: 1px solid transparent;
  cursor: pointer;
}
.sp-ui-btn--primary {
  background: var(--sp-ui-accent);
  color: var(--sp-on-accent);
}
.sp-ui-btn--secondary {
  background: transparent;
  color: var(--sp-ui-text);
  border-color: var(--sp-ui-border);
}
.sp-ui-btn--ghost {
  background: transparent;
  color: var(--sp-ui-muted);
}
.sp-ui-btn--danger {
  background: var(--sp-ui-danger);
  color: #ffffff;
}
.sp-ui-btn--sm {
  padding: 5px 12px;
  font-size: 12.5px;
}
.sp-ui-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sp-ui-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--sp-radius-pill, 999px);
  border: 1px solid var(--sp-ui-border);
  background: transparent;
  color: var(--sp-ui-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sp-ui-icon-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Segmented -------------------------------------------------------------- */
.sp-ui-seg {
  display: inline-flex;
  background: var(--sp-ui-surface-2);
  border: 1px solid var(--sp-ui-border);
  border-radius: var(--sp-radius-pill, 999px);
  padding: 3px;
}
.sp-ui-seg button,
.sp-ui-seg .sp-ui-seg__item {
  border: 0;
  background: transparent;
  color: var(--sp-ui-muted);
  font-family: var(--sp-font-sans, "Manrope", sans-serif);
  font-weight: var(--sp-font-weight-bold, 700);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--sp-radius-pill, 999px);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sp-ui-seg button.sp-ui-seg__item--on,
.sp-ui-seg .sp-ui-seg__item--on {
  background: var(--sp-ui-surface);
  color: var(--sp-ui-text);
  box-shadow: var(--sp-ui-shadow-1);
  border: 1px solid var(--sp-ui-border);
}
.sp-ui-seg button svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}
.sp-ui-seg--block {
  display: flex;
}
.sp-ui-seg--block button,
.sp-ui-seg--block .sp-ui-seg__item {
  flex: 1;
  justify-content: center;
}

/* ---- Chip -------------------------------------------------------------------- */
.sp-ui-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  border-radius: var(--sp-radius-pill, 999px);
  border: 1px solid var(--sp-ui-border);
  background: var(--sp-ui-surface);
  color: var(--sp-ui-muted);
  font-weight: var(--sp-font-weight-bold, 700);
  font-size: 12.5px;
  white-space: nowrap;
}
.sp-ui-chip--on {
  background: var(--sp-ui-accent);
  border-color: var(--sp-ui-accent);
  color: #ffffff;
}

/* ---- Select pill -------------------------------------------------------------- */
.sp-ui-select-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: var(--sp-radius-pill, 999px);
  border: 1px solid var(--sp-ui-border);
  background: var(--sp-ui-surface);
  color: var(--sp-ui-text);
  font-weight: var(--sp-font-weight-bold, 700);
  font-size: 13px;
}
.sp-ui-select-pill__label {
  color: var(--sp-ui-muted);
  font-weight: 600;
}
.sp-ui-select-pill svg {
  width: 12px;
  height: 12px;
  stroke: var(--sp-ui-muted);
  stroke-width: 2.4;
  fill: none;
  stroke-linecap: round;
}

/* ---- Card / avatar ------------------------------------------------------------ */
.sp-ui-card {
  background: var(--sp-ui-surface);
  border: 1px solid var(--sp-ui-border);
  border-radius: var(--sp-radius-lg, 16px);
  box-shadow: var(--sp-ui-shadow-1);
}
.sp-ui-avatar {
  width: 30px;
  height: 30px;
  border-radius: var(--sp-radius-pill, 999px);
  background: linear-gradient(135deg, var(--sp-accent-hover), var(--sp-accent-hover));
  color: #ffffff;
  font-size: 11.5px;
  font-weight: var(--sp-font-weight-heavy, 800);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ---- Switch -------------------------------------------------------------------- */
.sp-ui-switch {
  width: 34px;
  height: 20px;
  border-radius: var(--sp-radius-pill, 999px);
  background: var(--sp-ui-surface-2);
  border: 1px solid var(--sp-ui-border);
  position: relative;
  flex: none;
}
.sp-ui-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--sp-ui-muted);
}
.sp-ui-switch--on {
  background: var(--sp-ui-accent);
  border-color: var(--sp-ui-accent);
}
.sp-ui-switch--on::after {
  left: auto;
  right: 2px;
  background: #ffffff;
}

/* ---- Field ---------------------------------------------------------------------- */
.sp-ui-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sp-ui-field__label {
  font-size: 12.5px;
  font-weight: var(--sp-font-weight-bold, 700);
  color: var(--sp-ui-muted);
}
.sp-ui-field__control {
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--sp-ui-border);
  background: var(--sp-ui-surface-2);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 9px;
  font-size: 13.5px;
  color: var(--sp-ui-text);
}
.sp-ui-field__control--placeholder {
  color: var(--sp-ui-muted);
}
.sp-ui-field__control svg {
  width: 14px;
  height: 14px;
  stroke: var(--sp-ui-muted);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}
.sp-ui-field__tail {
  margin-left: auto;
}

/* ---- Text utilities --------------------------------------------------------------- */
.sp-ui-mono {
  font-family: var(--sp-font-mono, ui-monospace, monospace);
  font-variant-numeric: tabular-nums;
}
.sp-ui-muted {
  color: var(--sp-ui-muted);
}

/* ---- Inspector rows (builder, Phase 2c) --------------------------------------------- */
.sp-ui-insp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 2px 0;
}
.sp-ui-insp-row__label {
  font-size: 13px;
  font-weight: var(--sp-font-weight-bold, 700);
  color: var(--sp-ui-text);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-ui-insp-row__hint {
  font-size: 11px;
  color: var(--sp-ui-muted);
  font-weight: var(--sp-font-weight-medium, 500);
}
.sp-ui-num-input {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 9px;
  border-radius: var(--sp-radius-sm, 8px);
  border: 1px solid var(--sp-ui-border);
  background: var(--sp-ui-surface-2);
  font-family: var(--sp-font-mono, ui-monospace, monospace);
  font-size: 12.5px;
  color: var(--sp-ui-text);
}
.sp-ui-num-input span {
  color: var(--sp-ui-muted);
  font-size: 10.5px;
}
.sp-ui-swatch-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border-radius: var(--sp-radius-sm, 8px);
  border: 1px solid var(--sp-ui-border);
  background: var(--sp-ui-surface-2);
  font-family: var(--sp-font-mono, ui-monospace, monospace);
  font-size: 12px;
  color: var(--sp-ui-text);
}
.sp-ui-swatch-pill i {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--sp-ui-border);
  display: inline-block;
}
.sp-ui-sec-label {
  font-family: var(--sp-font-mono, ui-monospace, monospace);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sp-ui-muted);
  font-weight: var(--sp-font-weight-bold, 700);
  margin: 16px 0 6px;
}

/* ---- Topbar / bottom nav (kit chrome) ------------------------------------------------ */
.sp-ui-topbar {
  height: 56px;
  background: var(--sp-ui-surface);
  border-bottom: 1px solid var(--sp-ui-border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: var(--sp-z-modal, 100);
}
.sp-ui-topbar__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: var(--sp-font-weight-heavy, 800);
  font-size: 16.5px;
  letter-spacing: -0.01em;
}
.sp-ui-topbar__mark {
  width: 28px;
  height: 28px;
  border-radius: var(--sp-radius-sm, 8px);
  background: linear-gradient(135deg, var(--sp-ui-accent), var(--sp-accent));
  color: #ffffff;
  font-size: 12px;
  font-weight: var(--sp-font-weight-heavy, 800);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sp-ui-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 150;
  background: var(--sp-ui-surface);
  border-top: 1px solid var(--sp-ui-border);
  display: flex;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.sp-ui-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 5px 0;
  text-decoration: none;
  color: var(--sp-ui-muted);
  font-size: 10.5px;
  font-weight: var(--sp-font-weight-bold, 700);
  border-radius: 10px;
}
.sp-ui-bottom-nav__item svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sp-ui-bottom-nav__item--active {
  color: var(--sp-ui-accent-strong);
}

/* =======================================================================================
   Instagram-style post anatomy (.sp-post*) — feed/detail card, Phase 1b target DOM.
   Base = mobile full-bleed (edge-to-edge, hairline separators, no radius);
   `.sp-post--card` = desktop framed variant (480px column, border, radius 14).
   ======================================================================================= */
.sp-post {
  background: var(--sp-ui-surface);
  border-bottom: 1px solid var(--sp-ui-border);
}
.sp-post--card {
  border: 1px solid var(--sp-ui-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--sp-ui-shadow-1);
  margin-bottom: 20px;
}

.sp-post-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.sp-post-head .sp-ui-avatar,
.sp-post-avatar {
  width: 34px;
  height: 34px;
  font-size: 12px;
}
.sp-post-name {
  font-size: 13.5px;
  font-weight: var(--sp-font-weight-heavy, 800);
  display: flex;
  align-items: center;
  gap: 5px;
}
.sp-post-name svg {
  width: 13px;
  height: 13px;
  fill: var(--sp-ui-accent);
  stroke: none;
}
.sp-post-sub {
  font-size: 11.5px;
  color: var(--sp-ui-muted);
}
.sp-post-more {
  margin-left: auto;
  color: var(--sp-ui-muted);
  border: 0;
  background: none;
  padding: 6px;
  cursor: pointer;
}
.sp-post-more svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* media at NATIVE ratio (mostly portrait 9:16 video) on the authored-dark canvas */
.sp-post-media {
  position: relative;
  background: var(--sp-ui-canvas);
}
.sp-post-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
}
.sp-post-progress i,
.sp-post-progress__fill {
  display: block;
  height: 100%;
  background: var(--sp-ui-accent);
}

.sp-post-acts {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 8px 0 8px;
}
.sp-post-acts .sp-ui-icon-btn {
  border-color: transparent;
}
.sp-post-acts__right {
  margin-left: auto;
}
.sp-post-acts__count {
  font-family: var(--sp-font-mono, ui-monospace, monospace);
  font-size: 11.5px;
  color: var(--sp-ui-muted);
  margin: 0 6px 0 -2px;
}

.sp-post-likes {
  padding: 2px 14px 0;
  font-size: 13px;
  font-weight: var(--sp-font-weight-heavy, 800);
}
.sp-post-caption {
  padding: 3px 14px 6px;
  font-size: 13px;
  line-height: 1.45;
}
.sp-post-caption b {
  font-weight: var(--sp-font-weight-heavy, 800);
}
.sp-post-caption span {
  color: var(--sp-ui-muted);
}
.sp-post-openlink {
  padding: 0 14px 14px;
  font-size: 12px;
  color: var(--sp-ui-muted);
  font-weight: 600;
}

