/* ============================================================
   channels.css — CxChannels: "Eight channels. One conversation."
   Copy left, braided-thread stage right. Two strands (teal over
   indigo) weave down one patient timeline; segments draw in and
   entries reveal in sequence once the stage earns `.in` from the
   global .ios observer. CSS-only. Every selector namespaced .cx-ch.
   Tokens from styles.css; teal accent vars from .cx (comms.css).
   ============================================================ */

.cx-ch {
  position: relative;
  overflow: clip;
}

/* ---- layout: copy left, stage right; stacks under 960px ---- */
.cx-ch .ch-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 500px);
  gap: clamp(40px, 5.5vw, 84px);
  align-items: start;
}

/* ============================================================
   COPY COLUMN
   ============================================================ */

/* ---- channel-chip rail ---- */
.cx-ch .ch-rail {
  list-style: none;
  margin: clamp(22px, 2.6vw, 32px) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 52ch;
}
.cx-ch .ch-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px 7px 11px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-70);
  letter-spacing: -0.005em;
  transition: border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.cx-ch .ch-chip svg {
  width: 14px;
  height: 14px;
  color: var(--ink-40);
  transition: color 0.2s ease;
  /* gentle wave: each chip's glyph warms teal once per cycle */
  animation: cxch-chip-pulse 5.6471s calc(var(--c, 0) * 0.8s) infinite;
}
.cx-ch .ch-chip:hover {
  border-color: color-mix(in srgb, var(--cx-teal, #5a82c2) 45%, var(--line));
  color: var(--ink);
  transform: translateY(-1px);
}
.cx-ch .ch-chip:hover svg {
  color: var(--cx-teal-deep, #3d63a4);
}
@keyframes cxch-chip-pulse {
  0%, 9%, 100% { color: var(--ink-40); transform: none; }
  4.5% { color: var(--cx-teal-deep, #3d63a4); transform: translateY(-1px) scale(1.12); }
}

/* ---- benefit ledger: hairline rows, not cards ---- */
.cx-ch .ch-benefits {
  list-style: none;
  margin: clamp(26px, 3vw, 38px) 0 0;
  padding: 0;
  max-width: 54ch;
}
.cx-ch .ch-benefits li {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 14px;
  padding-block: clamp(13px, 1.5vw, 17px);
  border-top: 1px solid var(--line-2);
}
.cx-ch .ch-benefits li:first-child {
  border-top: none;
  padding-top: 0;
}
.cx-ch .ch-benefits b {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.35;
}
.cx-ch .ch-benefits li > div > span {
  display: block;
  margin-top: 3px;
  font-size: 13.8px;
  line-height: 1.55;
  color: var(--ink-60);
}

/* marker: two interlocked rings — one strand teal, one indigo */
.cx-ch .ch-knot {
  position: relative;
  width: 26px;
  height: 16px;
  margin-top: 3px;
}
.cx-ch .ch-knot::before,
.cx-ch .ch-knot::after {
  content: "";
  position: absolute;
  top: 2px;
  width: 12px;
  height: 12px;
  border-radius: var(--r-pill);
}
.cx-ch .ch-knot::before {
  left: 0;
  border: 1.7px solid var(--cx-teal, #5a82c2);
}
.cx-ch .ch-knot::after {
  left: 8px;
  border: 1.7px solid color-mix(in srgb, var(--indigo) 55%, #fff);
}

/* ============================================================
   BRAIDED-THREAD STAGE
   ============================================================ */
.cx-ch .ch-stagewrap {
  position: relative;
}
/* soft backdrop halo — the one glow behind the one stage */
.cx-ch .ch-halo {
  position: absolute;
  inset: -8% -14% -4%;
  background:
    radial-gradient(60% 50% at 70% 12%, var(--periwinkle) 0%, transparent 70%),
    radial-gradient(46% 40% at 12% 78%, color-mix(in srgb, var(--cx-teal, #5a82c2) 14%, #fff) 0%, transparent 72%);
  filter: blur(28px);
  pointer-events: none;
}

.cx-ch .ch-stage {
  position: relative;
  margin: 0;
  border-radius: var(--r-xl);
  background: linear-gradient(168deg, #fff 0%, var(--paper) 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-float);
  padding: clamp(20px, 2.4vw, 30px) clamp(18px, 2.2vw, 28px) clamp(16px, 2vw, 22px);
}

/* ---- stage header: the patient, the promise ---- */
.cx-ch .ch-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line-2);
}
.cx-ch .ch-ava {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--r-pill);
  background: linear-gradient(140deg, var(--indigo), var(--cx-teal-deep, #3d63a4) 130%);
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.03em;
  display: grid;
  place-items: center;
}
.cx-ch .ch-id b {
  display: block;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
  line-height: 1.25;
}
.cx-ch .ch-id span {
  display: block;
  font-size: 12px;
  color: var(--ink-40);
  margin-top: 1px;
}
.cx-ch .ch-live {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--cx-teal-deep, #3d63a4);
  background: color-mix(in srgb, var(--cx-teal, #5a82c2) 8%, #fff);
  border: 1px solid color-mix(in srgb, var(--cx-teal, #5a82c2) 22%, #fff);
  border-radius: var(--r-pill);
  padding: 5px 11px;
}
.cx-ch .ch-live i {
  width: 6px;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--cx-teal, #5a82c2);
  animation: cxch-live 1.4118s ease-out infinite;
}
@keyframes cxch-live {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--cx-teal, #5a82c2) 38%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px transparent; }
}

/* ---- the thread ---- */
.cx-ch .ch-thread {
  list-style: none;
  margin: 0;
  padding: 14px 0 0;
}
.cx-ch .ch-ev {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  column-gap: 13px;
}
.cx-ch .ch-ev:last-child .ch-body {
  padding-bottom: 4px;
}

/* lane: braid segment + channel node. Segments stack into one braid;
   even rows are mirrored so strand ends meet and the weave continues. */
.cx-ch .ch-lane {
  position: relative;
  align-self: stretch;
}
.cx-ch .ch-braid {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}
.cx-ch .ch-braid path {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 1; /* pathLength=1; offset 0 by default = fully drawn */
}
/* one clean vertical connector down the node centers (no crossing weave) */
.cx-ch .ch-s1 {
  stroke: color-mix(in srgb, var(--cx-teal, #5a82c2) 55%, var(--line));
  opacity: 0.9;
}
/* the braid tapers out after the last entry */
.cx-ch .ch-ev:last-child .ch-braid {
  -webkit-mask-image: linear-gradient(180deg, #000 18%, transparent 78%);
  mask-image: linear-gradient(180deg, #000 18%, transparent 78%);
}

/* channel node: small glyph badge the strands pass behind */
.cx-ch .ch-node {
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 30px;
  border-radius: var(--r-pill);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
  color: var(--indigo);
  display: grid;
  place-items: center;
}
.cx-ch .ch-node svg {
  width: 14px;
  height: 14px;
}
.cx-ch .ch-ev--patient .ch-node {
  color: var(--cx-teal-deep, #3d63a4);
  border-color: color-mix(in srgb, var(--cx-teal, #5a82c2) 30%, var(--line));
}
.cx-ch .ch-ev--done .ch-node {
  background: var(--mint);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--mint) 40%, transparent);
}

/* entry body: light rows — meta line + one sentence, breathing room */
.cx-ch .ch-body {
  padding-bottom: clamp(18px, 2vw, 24px);
  min-width: 0;
}
.cx-ch .ch-meta {
  display: flex;
  align-items: baseline;
  gap: 9px;
}
.cx-ch .ch-pill {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1;
  padding: 5px 9px;
  border-radius: var(--r-pill);
  background: var(--periwinkle);
  color: var(--indigo-700);
  white-space: nowrap;
}
.cx-ch .ch-ev--patient .ch-pill {
  background: color-mix(in srgb, var(--cx-teal, #5a82c2) 10%, #fff);
  color: var(--cx-teal-deep, #3d63a4);
}
.cx-ch .ch-ev--done .ch-pill {
  background: color-mix(in srgb, var(--mint) 13%, #fff);
  color: color-mix(in srgb, var(--mint) 72%, var(--ink));
}
.cx-ch .ch-meta time {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--ink-40);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cx-ch .ch-body p {
  margin: 7px 0 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink-70);
  letter-spacing: -0.005em;
}
.cx-ch .ch-ev--patient .ch-body p {
  color: var(--ink);
}
.cx-ch .ch-ev--done .ch-body p {
  font-weight: 500;
  color: var(--ink);
}

/* caption */
.cx-ch .ch-cap {
  margin: 4px 0 0;
  padding-top: 13px;
  border-top: 1px solid var(--line-2);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-40);
  text-align: center;
}

/* ============================================================
   SEQUENCE — keyed to the global .ios observer adding `.in`
   to the stage. Fill-mode `both` carries the hidden start
   state, so nothing is hidden when animations are disabled.
   ============================================================ */
.cx-ch .ch-stage.in .ch-braid path {
  animation: cxch-draw 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
  animation-delay: calc(0.12s + var(--i, 0) * 0.28s);
}
.cx-ch .ch-stage.in .ch-node {
  animation: cxch-pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  animation-delay: calc(0.2s + var(--i, 0) * 0.28s);
}
.cx-ch .ch-stage.in .ch-body {
  animation: cxch-enter 0.3667s cubic-bezier(0.2, 0.7, 0.3, 1) both;
  animation-delay: calc(0.2s + var(--i, 0) * 0.28s);
}
@keyframes cxch-draw {
  from { stroke-dashoffset: 1; }
  to { stroke-dashoffset: 0; }
}
@keyframes cxch-pop {
  from { opacity: 0; transform: translateX(-50%) scale(0.4); }
  to { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes cxch-enter {
  from { opacity: 0; transform: translateY(9px); }
  to { opacity: 1; transform: none; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 960px) {
  .cx-ch .ch-grid {
    grid-template-columns: 1fr;
    gap: clamp(36px, 6vw, 52px);
  }
  .cx-ch .ch-stagewrap {
    max-width: 560px;
  }
}
@media (max-width: 700px) {
  .cx-ch .ch-ev {
    grid-template-columns: 36px minmax(0, 1fr);
    column-gap: 11px;
  }
  .cx-ch .ch-node {
    width: 26px;
    height: 26px;
  }
  .cx-ch .ch-node svg {
    width: 12px;
    height: 12px;
  }
  .cx-ch .ch-meta {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .cx-ch .ch-live span {
    display: none;
  }
  .cx-ch .ch-rail,
  .cx-ch .ch-benefits {
    max-width: none;
  }
  .cx-ch .ch-stage {
    padding: 16px 14px 14px;
  }
}
@media (max-width: 460px) {
  .cx-ch .ch-id b {
    font-size: 14px;
  }
  .cx-ch .ch-body p {
    font-size: 13.5px;
  }
}

/* ============================================================
   REDUCED MOTION — everything lands drawn, visible, still
   ============================================================ */
@media (prefers-reduced-motion: reduce), (max-width: 700px) {
  .cx-ch *,
  .cx-ch *::before,
  .cx-ch *::after {
    animation: none !important;
    transition: none !important;
  }
}
