/* 10X Vital Intelligence: conversation + path widgets. Every selector is scoped to the two mounts. */
[data-widget="conversation"],
[data-widget="path"] {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}
[data-widget="conversation"] .cpw-stage,
[data-widget="path"] .cpw-stage {
  position: relative;
  width: 100%;
  overflow: hidden;
}
[data-widget="conversation"] .cpw-canvas,
[data-widget="path"] .cpw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---- conversation ---- */
[data-widget="conversation"] {
  container-type: inline-size;
  box-sizing: border-box;
  /* no plate of its own: the figure sits on the section ground, like the loop and the path rings */
  padding: 0 0 4px;
  background: none;
  border: 0;
  box-shadow: none;
}
[data-widget="conversation"] .cpw-stage {
  height: 224px;
}
@container (min-width: 760px) {
  [data-widget="conversation"] .cpw-stage { height: 228px; }
}
@container (max-width: 439px) {
  [data-widget="conversation"] .cpw-stage { height: 460px; }
}
[data-widget="conversation"] .cpw-caption {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 2px;
  font-weight: 500;
  font-family: var(--mono, "JetBrains Mono", ui-monospace, Menlo, monospace);
  font-size: 0.6875rem;
  line-height: 1.4;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted, #64748b);
  text-align: center;
}
[data-widget="conversation"] .cpw-caption::before,
[data-widget="conversation"] .cpw-caption::after {
  content: "";
  flex: 0 1 40px;
  height: 1px;
  min-width: 12px;
}
[data-widget="conversation"] .cpw-caption::before {
  background: linear-gradient(90deg, rgba(249, 115, 22, 0), rgba(249, 115, 22, .55));
}
[data-widget="conversation"] .cpw-caption::after {
  background: linear-gradient(90deg, rgba(14, 165, 233, .55), rgba(14, 165, 233, 0));
}
@container (max-width: 359px) {
  [data-widget="conversation"] .cpw-caption::before,
  [data-widget="conversation"] .cpw-caption::after { display: none; }
}

/* ---- path ---- */
[data-widget="path"] {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}
[data-widget="path"] .cpw-stage {
  aspect-ratio: 1 / 1;
}
@supports not (aspect-ratio: 1 / 1) {
  [data-widget="path"] .cpw-stage { height: 0; padding-bottom: 100%; }
}

/* ---- path stages: the stage being read fills its dot, and the rings follow it (conversation-path.js) ---- */
.path.cpw-staged .stages li::after {
  transition: background-color var(--dur-2, 250ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1)),
              border-color var(--dur-2, 250ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1)),
              box-shadow var(--dur-2, 250ms) var(--ease-in-out, cubic-bezier(.65, 0, .35, 1));
}
/* the fixed "First" fill becomes the default state: an outline until it is the stage being read */
.path.cpw-staged .stages li:first-child::after {
  background: var(--bg, #fff);
  border-color: var(--orange, #f97316);
  box-shadow: 0 0 0 0 rgba(249, 115, 22, 0);
}
.path.cpw-staged .stages li.is-active::after {
  background: var(--sky, #0ea5e9);
  border-color: var(--sky, #0ea5e9);
  box-shadow: 0 0 0 5px var(--sky-soft, #f0f9ff);
}
.path.cpw-staged .stages li:first-child.is-active::after {
  background: var(--orange, #f97316);
  border-color: var(--orange, #f97316);
  box-shadow: 0 0 0 5px var(--orange-soft, #fff7ed);
}
.path.cpw-staged .stages li:nth-child(2)::after { border-color: var(--amber, #f59e0b); }
.path.cpw-staged .stages li:nth-child(2).is-active::after {
  background: var(--amber, #f59e0b);
  border-color: var(--amber, #f59e0b);
  box-shadow: 0 0 0 5px #fef3c7;
}

/* phones: the figure sits inline above the three stages (pinning it would cover half the screen).
   The canvas takes the full column, so the outer labels have room beside the rings. */
@media (max-width: 560px) {
  .path > .widget[data-widget="path"] {
    width: 100%;
    max-width: none;
    margin: 0 auto;
  }
  .path > .widget[data-widget="path"] .cpw-stage { max-height: 340px; }
}

/* portrait tablets: the rings pin under the nav while the three stages scroll beneath, so the ring a
   stage describes stays in view while it is read (the same pattern as the loop). The canvas is as wide
   as the column (the rings stay a centred square), so every label fits on one line. An opaque band in
   the section tint, full bleed, keeps the passing text from showing through; it only feathers below. */
@media (min-width: 561px) and (max-width: 960px) and (min-height: 600px) {
  .path > .widget[data-widget="path"] {
    position: sticky;
    top: 76px;
    z-index: 1;
    width: 100%;
    max-width: none;
    /* the pin releases early, so the rings leave together with the last stage instead of covering it;
       the list's matching negative margin keeps the layout exactly where it was */
    margin-bottom: 120px;
  }
  .path > .widget[data-widget="path"] .cpw-stage {
    max-height: min(520px, 44vh);
    max-height: min(520px, 44svh);   /* svh: no resize while a phone's toolbar slides */
  }
  .path > .widget[data-widget="path"] + .stages { margin-top: -120px; }
  .path > .widget[data-widget="path"]::before,
  .path > .widget[data-widget="path"]::after {
    content: "";
    position: absolute;
    left: 50%;
    width: 100vw;
    margin-left: -50vw;
    z-index: -1;
    pointer-events: none;
  }
  /* solid ground to 16px below the figure, then a short feather */
  .path > .widget[data-widget="path"]::before {
    top: -12px;
    bottom: -16px;
    background: var(--bg-alt, #f8fafc);
  }
  .path > .widget[data-widget="path"]::after {
    top: calc(100% + 16px);
    height: 12px;
    background: linear-gradient(to bottom, var(--bg-alt, #f8fafc), rgba(248, 250, 252, 0));
  }
}

@media (prefers-reduced-motion: reduce) {
  .path.cpw-staged .stages li::after { transition: none; }
}

/* forced colours: the stage being read keeps a visible fill */
@media (forced-colors: active) {
  .path.cpw-staged .stages li.is-active::after,
  .path.cpw-staged .stages li:first-child.is-active::after,
  .path.cpw-staged .stages li:nth-child(2).is-active::after {
    forced-color-adjust: none;
    background: Highlight;
    border-color: Highlight;
    box-shadow: none;
  }
}

/* wide screens: the rings stay centred beside the stages, and hold in view while the last one is read */
@media (min-width: 961px) and (min-height: 700px) {
  .path > .widget[data-widget="path"] {
    position: sticky;
    top: max(96px, calc(50vh - 270px));
  }
}
