/* ========================================================
   Opagio Content Widgets (Chat/Cowork Production Setup Phase W
   + HOMEPAGE-ROTATING-WIDGET-SPEC H1)
   Embeddable Academy visualisers on rostered articles (gated by
   CONTENT_WIDGETS_ENABLED, loaded per-page by
   views/partials/widgets/content-widget.ejs) and the homepage
   rotation section (gated by HOMEPAGE_WIDGET_ROTATION_ENABLED,
   loaded via the layout's extraCss slot) — NOT part of the
   core.css bundle (scripts/build-css.js CORE list). Token-only.
   Rules are scoped under .content-widget so they can never fight
   the legacy public/css/widgets.css .widget rules if a future
   page loads both.
   ======================================================== */

.content-widget .widget {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  background: var(--color-surface);
  margin: 0 auto;
  max-width: 720px;
}

.content-widget .widget__header {
  margin-bottom: var(--space-5);
}

.content-widget .widget__title {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: var(--space-1);
  color: var(--color-charcoal);
}

.content-widget .widget__subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.content-widget .widget__cta-line {
  margin: var(--space-5) 0 0;
  font-size: var(--font-size-sm);
  text-align: center;
  color: var(--color-text-muted);
}

.content-widget .widget__cta-line a {
  color: var(--color-accent-blue);
  text-decoration: none;
  font-weight: 600;
}

.content-widget .widget__cta-line a:hover {
  text-decoration: underline;
}

.content-widget__noscript {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  text-align: center;
}

/* ── S&P 500 Balance-Sheet Inversion (partials/widget-balance-sheet.ejs) ── */

.content-widget .widget--balance-sheet {
  text-align: center;
}

.content-widget .widget-bs__year {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-accent-orange);
  margin-bottom: var(--space-1);
}

.content-widget .widget-bs__bar {
  display: flex;
  height: 48px;
  border-radius: var(--border-radius);
  overflow: hidden;
  margin: var(--space-3) 0;
}

.content-widget .widget-bs__tangible {
  background: var(--color-accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.4s ease;
  min-width: 0;
  container-type: inline-size;
}

.content-widget .widget-bs__intangible {
  background: var(--color-accent-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.4s ease;
  min-width: 0;
  container-type: inline-size;
}

.content-widget .widget-bs__label {
  color: var(--color-white);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--space-1);
}

/* ── Band labels fit-or-hide (container queries) ──
   The band's own width decides what fits — a percentage threshold cannot, since
   the same 16% band is ~44px on mobile and ~100px on desktop. Names are hidden
   by default and revealed only once the band can hold "Intangible 100%"; below
   ~34px even the percentage is dropped rather than clipped mid-glyph. */

.content-widget .widget-bs__label-name { display: none; }

@container (min-width: 96px) {
  .content-widget .widget-bs__label-name { display: inline; }
}

@container (max-width: 34px) {
  .content-widget .widget-bs__label-pct { display: none; }
}

.content-widget .widget-bs__slider {
  width: 100%;
  margin: var(--space-3) 0 var(--space-2);
  accent-color: var(--color-accent-orange);
}

.content-widget .widget-bs__scale {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ── Opagio 12 mix over time (partials/widgets/widget-opagio12-mix.ejs) ── */

.cw-o12__meta {
  text-align: center;
  margin-bottom: var(--space-4);
}

.cw-o12__meta:last-of-type {
  margin-bottom: 0;
  margin-top: var(--space-4);
}

.cw-o12__meta-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.cw-o12__stage,
.cw-o12__value {
  font-size: 1.3rem;
  color: var(--color-accent-orange);
  margin-left: var(--space-2);
}

.cw-o12__rows {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.cw-o12__row {
  display: grid;
  grid-template-columns: minmax(9rem, 14rem) 1fr 2.75rem;
  align-items: center;
  gap: var(--space-3);
}

.cw-o12__name {
  font-size: var(--font-size-xs);
  color: var(--color-charcoal);
  text-align: right;
  line-height: 1.2;
}

.cw-o12__track {
  display: block;
  background: var(--color-bg-alt);
  border-radius: var(--border-radius-sm);
  height: 12px;
  overflow: hidden;
}

.cw-o12__bar {
  display: block;
  height: 100%;
  background: var(--color-accent-orange);
  border-radius: var(--border-radius-sm);
  transition: width 0.4s ease;
}

.cw-o12__pct {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-align: left;
}

.cw-o12__slider {
  width: 100%;
  margin: var(--space-2) 0;
  accent-color: var(--color-accent-orange);
}

@media (max-width: 480px) {
  .cw-o12__row {
    grid-template-columns: minmax(7rem, 9rem) 1fr 2.5rem;
    gap: var(--space-2);
  }
}

/* ── Series A bridge/dilution (partials/widgets/widget-seriesa-bridge.ejs) ── */

.cw-bridge__slider {
  width: 100%;
  margin: var(--space-3) 0;
  accent-color: var(--color-accent-orange);
}

.cw-bridge__readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-3);
  font-size: var(--font-size-sm);
}

.cw-bridge__label {
  display: block;
  color: var(--color-text-muted);
}

.cw-bridge__stat {
  display: block;
  color: var(--color-charcoal);
}

.cw-bridge__stat--accent {
  color: var(--color-accent-orange);
}

/* ── Collateral Stack (partials/widgets/widget-collateral-stack.ejs) ──
   HOMEPAGE-ROTATING-WIDGET-SPEC H1 task 1 — extracted from the Intangible
   Finance hub; the hub keeps its inline copy. Segment colours are brand
   tokens replacing the hub's raw hex values. */

.cw-stack__meta {
  text-align: center;
  margin-bottom: var(--space-4);
}

.cw-stack__meta--value {
  margin-bottom: 0;
  margin-top: var(--space-4);
}

.cw-stack__meta-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.cw-stack__stage,
.cw-stack__value {
  font-size: 1.3rem;
  color: var(--color-accent-orange);
  margin-left: var(--space-2);
}

.cw-stack__bar {
  display: flex;
  height: 48px;
  border-radius: var(--border-radius);
  overflow: hidden;
  margin: var(--space-3) 0;
}

.cw-stack__seg {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.4s ease;
  min-width: 0;
  container-type: inline-size;
}

.cw-stack__seg--tangible { background: var(--color-accent-navy); }
.cw-stack__seg--ip { background: var(--color-accent-orange); }
.cw-stack__seg--data { background: var(--color-accent-blue); }
.cw-stack__seg--revenue { background: var(--color-accent-green); }
.cw-stack__seg--goodwill { background: var(--color-accent-gold); }

.cw-stack__seg-label {
  color: var(--color-white);
  font-size: var(--font-size-xs);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--space-1);
}

/* Names live in the legend, so a band only ever carries its percentage — and
   drops even that rather than clip it when the segment is a sliver. */

@container (max-width: 34px) {
  .cw-stack__seg-pct { display: none; }
}

.cw-stack__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.cw-stack__legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.cw-stack__swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cw-stack__swatch--tangible { background: var(--color-accent-navy); }
.cw-stack__swatch--ip { background: var(--color-accent-orange); }
.cw-stack__swatch--data { background: var(--color-accent-blue); }
.cw-stack__swatch--revenue { background: var(--color-accent-green); }
.cw-stack__swatch--goodwill { background: var(--color-accent-gold); }

.cw-stack__slider {
  width: 100%;
  margin: var(--space-3) 0 var(--space-2);
  accent-color: var(--color-accent-orange);
}

/* ── Homepage rotation section (HOMEPAGE-ROTATING-WIDGET-SPEC §7) ──
   Fixed-dimension frame per widget so the layout is held pre-hydration
   (CLS-safe): min-heights sit safely under each widget's rendered height —
   they only catch the pathological unstyled flash, never trap whitespace. */

.cw-home-frame {
  margin: 0 auto;
  max-width: 720px;
}

.cw-home-frame--sp500-inversion { min-height: 260px; }
.cw-home-frame--opagio12-mix { min-height: 480px; }
.cw-home-frame--seriesa-bridge { min-height: 280px; }
.cw-home-frame--collateral-stack { min-height: 300px; }

@media (max-width: 480px) {
  .cw-home-frame--opagio12-mix { min-height: 520px; }
  .cw-home-frame--seriesa-bridge { min-height: 380px; }
}

/* ── Reduced motion (HOMEPAGE-ROTATING-WIDGET-SPEC §7) ──
   The loader already skips autoplay under prefers-reduced-motion; this stops
   the slider-driven width tweens too — values still update instantly. */

@media (prefers-reduced-motion: reduce) {
  .content-widget .widget-bs__tangible,
  .content-widget .widget-bs__intangible,
  .cw-o12__bar,
  .cw-stack__seg {
    transition: none;
  }
}
