/* ============================================================
   unified-inbox.css — "One Unified Inbox" story page.
   Scope: .cxp-inbox only. Metaphor: a confluence — eight channel
   tributaries flowing in from the edges and merging into one calm
   river that becomes the spine of a real patient thread.
   Mood: airy water, blue→teal, no rainbow (teal family + indigo + ink).
   CSS-only animation: SVG stroke draw-in (gated on the .ios "in"
   class app.js applies) + a gentle looping current. Under
   prefers-reduced-motion the river is fully drawn and still.
   Tokens inherited from styles.css; teal accents match comms.css.
   ============================================================ */

.cxp-inbox {
  --ui-teal: #5a82c2;
  --ui-teal-deep: #3d63a4;
  --ui-teal-lite: #8aa6dd;
  --ui-teal-wash: color-mix(in srgb, #5a82c2 7%, #fff);
  position: relative;
  isolation: isolate;
  overflow-x: clip;
}

.cxp-inbox .h2 {
  font-size: clamp(26px, 3vw, 40px);
  font-weight: 500;
  letter-spacing: -0.028em;
  line-height: 1.16;
  color: var(--ink);
}

/* ============================================================
   1 · HERO — the confluence
   ============================================================ */
.cxp-inbox .ui-hero {
  position: relative;
  padding-top: clamp(140px, 16vw, 196px);
  background:
    radial-gradient(90% 52% at 50% 0%, var(--periwinkle) 0%, transparent 62%),
    linear-gradient(180deg, #fff 0%, #f3fbf9 62%, var(--ui-teal-wash) 100%);
}

.cxp-inbox .ui-hero-copy {
  text-align: center;
  max-width: 820px;
}

.cxp-inbox .ui-back {
  display: inline-block;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-40);
  margin-bottom: 26px;
  transition: color 0.18s;
}
.cxp-inbox .ui-back:hover {
  color: var(--ui-teal-deep);
}

.cxp-inbox .ui-eyebrow {
  color: var(--ui-teal-deep);
}

.cxp-inbox .ui-title {
  margin: 16px 0 18px;
}
.cxp-inbox .ui-title em {
  font-style: normal;
  background: linear-gradient(120deg, var(--ui-teal-deep), var(--indigo));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.cxp-inbox .ui-lead {
  max-width: 60ch;
  margin-inline: auto;
}

.cxp-inbox .ui-hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 30px;
}

/* --- the confluence scene ------------------------------------ */
.cxp-inbox .riv-scene {
  position: relative;
  max-width: 1240px;
  margin: clamp(28px, 4vw, 52px) auto 0;
  padding: 44px clamp(8px, 2vw, 20px) 0;
}

/* faint ripple rings around the confluence point */
.cxp-inbox .riv-scene::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 64%;
  width: min(520px, 70vw);
  aspect-ratio: 2.6 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background:
    radial-gradient(closest-side, color-mix(in srgb, var(--ui-teal) 14%, transparent) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.cxp-inbox .riv-svg {
  display: block;
  width: 100%;
  height: auto;
  position: relative;
  z-index: 1;
}

/* wide soft "water" bed under each line */
.cxp-inbox .riv-glow {
  fill: none;
  stroke: var(--ui-teal-lite);
  stroke-width: 11;
  stroke-linecap: round;
  opacity: 0;
  transition: opacity 1.1s ease calc(0.25s + var(--i, 0) * 0.1s);
}
.cxp-inbox .riv-glow--stem {
  stroke-width: 22;
}
.cxp-inbox .riv-scene.in .riv-glow {
  opacity: 0.14;
}

/* the drawn river lines — hidden until .in, then draw headwater→confluence */
.cxp-inbox .riv-draw {
  fill: none;
  stroke: url(#uiRiver);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.cxp-inbox .riv-draw--stem {
  stroke: url(#uiStem);
  stroke-width: 6.5;
}
.cxp-inbox .riv-scene.in .riv-draw {
  animation: ui-draw 1s cubic-bezier(0.55, 0.06, 0.25, 1) forwards;
  animation-delay: calc(var(--i, 0) * 0.13s);
}
@keyframes ui-draw {
  to {
    stroke-dashoffset: 0;
  }
}

/* the gentle current — short dashes drifting downstream forever */
.cxp-inbox .riv-cur {
  fill: none;
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-dasharray: 0.045 0.115;
  stroke-dashoffset: 0;
  opacity: 0;
  mix-blend-mode: overlay;
}
.cxp-inbox .riv-cur--stem {
  stroke-width: 2.6;
  stroke-dasharray: 0.06 0.1;
}
.cxp-inbox .riv-scene.in .riv-cur {
  animation:
    ui-flow 4.7s linear infinite,
    ui-cur-in 0.8s ease forwards;
  animation-delay: calc(0.8s + var(--i, 0) * 0.13s);
}
@keyframes ui-flow {
  to {
    stroke-dashoffset: -1;
  }
}
@keyframes ui-cur-in {
  to {
    opacity: 0.75;
  }
}

/* --- headwater channel chips --------------------------------- */
.cxp-inbox .riv-chips {
  position: absolute;
  inset: 0 clamp(8px, 2vw, 20px) auto;
  height: 0;
  z-index: 2;
}
.cxp-inbox .riv-chip {
  position: absolute;
  top: 30px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink-70);
  padding: 6px 12px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-1);
}
.cxp-inbox .riv-chip--high {
  top: 6px;
}
.cxp-inbox .riv-chip--first {
  transform: translateX(-8%);
}
.cxp-inbox .riv-chip--last {
  transform: translateX(-92%);
}
.cxp-inbox .riv-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--ui-teal-lite), var(--ui-teal-deep));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-teal) 16%, transparent);
}
/* stagger the chip reveal beyond the shared d1..d5 ladder */
.cxp-inbox .riv-chip.ios {
  transition-delay: calc(0.15s + var(--i, 0) * 0.09s);
}

/* --- the record everything lands on -------------------------- */
.cxp-inbox .riv-record {
  position: absolute;
  left: 50%;
  top: 65%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px 9px 9px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-2);
  white-space: nowrap;
}
/* keep .ios's translateY entrance from fighting the centering transform */
.cxp-inbox .riv-record.ios {
  transform: translate(-50%, calc(-50% + 18px));
}
.cxp-inbox .riv-record.ios.in {
  transform: translate(-50%, -50%);
}
.cxp-inbox .riv-record-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(140deg, var(--ui-teal), var(--indigo));
}
.cxp-inbox .riv-record-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.cxp-inbox .riv-record-meta {
  font-size: 11px;
  color: var(--ui-teal-deep);
  letter-spacing: 0.02em;
}

/* ============================================================
   2 · THE BRAIDED THREAD
   ============================================================ */
.cxp-inbox .ui-thread {
  background: linear-gradient(180deg, var(--ui-teal-wash), #fff 26%, var(--paper));
}

.cxp-inbox .ui-flow {
  position: relative;
  max-width: 760px;
  margin: clamp(36px, 5vw, 64px) auto 0;
}

/* the river continues: the thread's spine */
.cxp-inbox .ui-spine {
  position: absolute;
  left: 50%;
  top: -8px;
  bottom: -8px;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(
    180deg,
    var(--ui-teal-lite),
    var(--ui-teal) 40%,
    var(--indigo) 100%
  );
  border-radius: 2px;
  opacity: 0.5;
}

.cxp-inbox .ui-msgs {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 2.6vw, 30px);
}

.cxp-inbox .ui-msg {
  position: relative;
  display: flex;
}
.cxp-inbox .ui-msg.is-out {
  justify-content: flex-start;
}
.cxp-inbox .ui-msg.is-in {
  justify-content: flex-end;
}
.cxp-inbox .ui-msg.is-sys {
  justify-content: center;
}

.cxp-inbox .ui-node {
  position: absolute;
  left: 50%;
  top: 22px;
  width: 11px;
  height: 11px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--ui-teal);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ui-teal) 12%, transparent);
  z-index: 1;
}
.cxp-inbox .ui-msg.is-sys .ui-node {
  top: 50%;
  transform: translate(-50%, -50%);
  border-color: var(--ink-40);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ink) 6%, transparent);
}

/* message cards — each pulled toward its bank of the river */
.cxp-inbox .ui-card {
  width: min(46%, 340px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--r-mid);
  box-shadow: var(--shadow-1);
  padding: 14px 16px 15px;
}
.cxp-inbox .ui-msg.is-in .ui-card {
  background: linear-gradient(180deg, #fff, var(--ui-teal-wash));
  border-color: color-mix(in srgb, var(--ui-teal) 22%, var(--line));
}
.cxp-inbox .ui-card header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.cxp-inbox .ui-card time {
  font-size: 10.5px;
  color: var(--ink-40);
}
.cxp-inbox .ui-card p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-70);
}
.cxp-inbox .ui-quote {
  font-style: italic;
  color: var(--ink-60);
}
.cxp-inbox .ui-status {
  margin-top: 10px !important;
  padding-top: 10px;
  border-top: 1px dashed var(--line-2, var(--line));
  font-size: 12px !important;
  color: var(--ink-60) !important;
}
.cxp-inbox .ui-status b {
  color: var(--ui-teal-deep);
  font-weight: 600;
}

/* channel tags */
.cxp-inbox .ui-chan {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ui-teal-deep);
}
.cxp-inbox .ui-chan::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ui-teal);
}
.cxp-inbox .ui-chan--call {
  color: var(--indigo);
}
.cxp-inbox .ui-chan--call::before {
  background: var(--indigo);
}
.cxp-inbox .ui-chan--vm {
  color: var(--ui-teal-deep);
}
.cxp-inbox .ui-chan--fax {
  color: var(--ink-60);
}
.cxp-inbox .ui-chan--fax::before {
  background: var(--ink-40);
}
.cxp-inbox .ui-chan--staff {
  color: var(--indigo);
}
.cxp-inbox .ui-chan--staff::before {
  background: var(--indigo);
}

/* system event lines — quiet captions riding the spine */
.cxp-inbox .ui-sysline {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 0;
  padding: 7px 16px;
  font-size: 13px;
  color: var(--ink-60);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-1);
}
.cxp-inbox .ui-sysline time {
  font-size: 10.5px;
  color: var(--ink-40);
}

.cxp-inbox .ui-thread-foot {
  text-align: center;
  margin: clamp(28px, 4vw, 44px) auto 0;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--ui-teal-deep);
}

/* ============================================================
   3 · WHY IT MATTERS — editorial ledger
   ============================================================ */
.cxp-inbox .ui-why {
  background: #fff;
}
.cxp-inbox .ui-why-grid {
  display: grid;
  grid-template-columns: 5fr 7fr;
  gap: clamp(36px, 6vw, 88px);
  align-items: start;
}
.cxp-inbox .ui-why-head {
  position: sticky;
  top: 120px;
}
.cxp-inbox .ui-why-head h2 {
  margin: 14px 0 12px;
}

.cxp-inbox .ui-ledger {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}
.cxp-inbox .ui-row {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 8px;
  padding: clamp(20px, 2.4vw, 28px) 2px;
  border-bottom: 1px solid var(--line);
  transition: padding-left 0.22s ease;
}
.cxp-inbox .ui-row:hover {
  padding-left: 10px;
}
.cxp-inbox .ui-num {
  font-size: 12px;
  color: var(--ui-teal-deep);
  padding-top: 5px;
  letter-spacing: 0.06em;
}
.cxp-inbox .ui-row h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}
.cxp-inbox .ui-row p {
  margin: 0;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--ink-60);
  max-width: 52ch;
}

/* ============================================================
   4 · ONE WORKSPACE — statement band
   ============================================================ */
.cxp-inbox .ui-band {
  text-align: center;
  background:
    radial-gradient(70% 90% at 50% 110%, color-mix(in srgb, var(--ui-teal) 10%, transparent) 0%, transparent 70%),
    linear-gradient(180deg, var(--paper), var(--periwinkle));
  border-block: 1px solid var(--line);
}

/* the eight names, converging typographically */
.cxp-inbox .ui-band-line {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 0;
  margin: 0 auto 26px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-40);
}
.cxp-inbox .ui-band-line span {
  padding: 0 14px;
}
.cxp-inbox .ui-band-line span + span {
  border-left: 1px solid var(--line-2, var(--line));
}

.cxp-inbox .ui-band-title {
  max-width: 21ch;
  margin: 0 auto;
  font-size: clamp(28px, 3.6vw, 48px);
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.14;
  color: var(--navy, var(--ink));
}
.cxp-inbox .ui-band-title em {
  font-style: normal;
  color: var(--ui-teal-deep);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--ui-teal) 40%, transparent);
  text-decoration-thickness: 3px;
  text-underline-offset: 7px;
}
.cxp-inbox .ui-band-sub {
  max-width: 56ch;
  margin: 20px auto 0;
}

/* ============================================================
   5 · CTA + siblings
   ============================================================ */
.cxp-inbox .ui-cta {
  background: linear-gradient(180deg, #fff, var(--ui-teal-wash));
}
.cxp-inbox .ui-cta-wrap {
  text-align: center;
  max-width: 720px;
}
.cxp-inbox .ui-cta .lead {
  margin: 14px auto 0;
  max-width: 46ch;
}
.cxp-inbox .ui-cta-btns {
  margin-top: 28px;
  display: flex;
  justify-content: center;
}

.cxp-inbox .ui-sibs {
  margin-top: clamp(36px, 4vw, 52px);
  padding-top: 24px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 28px;
}
.cxp-inbox .ui-sibs-label {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-40);
}
.cxp-inbox .ui-sibs a {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink-70);
  transition: color 0.18s;
}
.cxp-inbox .ui-sibs a:hover {
  color: var(--ui-teal-deep);
}
.cxp-inbox .ui-sibs a .arrow {
  display: inline-block;
  transition: transform 0.18s ease;
}
.cxp-inbox .ui-sibs a:hover .arrow {
  transform: translateX(3px);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .cxp-inbox .ui-why-grid {
    grid-template-columns: 1fr;
  }
  .cxp-inbox .ui-why-head {
    position: static;
  }
}

@media (max-width: 720px) {
  /* chips become a calm wrapping row above the scene */
  .cxp-inbox .riv-chips {
    position: static;
    height: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 14px;
  }
  .cxp-inbox .riv-chip,
  .cxp-inbox .riv-chip--high,
  .cxp-inbox .riv-chip--first,
  .cxp-inbox .riv-chip--last {
    position: static;
    transform: none;
  }
  .cxp-inbox .riv-chip.ios {
    transform: translateY(24px);
  }
  .cxp-inbox .riv-chip.ios.in {
    transform: none;
  }
  .cxp-inbox .riv-scene {
    padding-top: 0;
  }
  .cxp-inbox .riv-record {
    padding: 7px 12px 7px 7px;
  }
  .cxp-inbox .riv-record-meta {
    display: none;
  }

  /* thread collapses to a single left bank */
  .cxp-inbox .ui-spine {
    left: 14px;
    transform: none;
  }
  .cxp-inbox .ui-node {
    left: 14px;
  }
  .cxp-inbox .ui-msg.is-sys .ui-node {
    left: 14px;
    transform: translate(-50%, -50%);
  }
  .cxp-inbox .ui-msg,
  .cxp-inbox .ui-msg.is-in,
  .cxp-inbox .ui-msg.is-out,
  .cxp-inbox .ui-msg.is-sys {
    justify-content: flex-start;
    padding-left: 38px;
  }
  .cxp-inbox .ui-card {
    width: 100%;
  }
  .cxp-inbox .ui-sysline {
    justify-content: flex-start;
  }
}

/* ============================================================
   REDUCED MOTION — the river reads complete and still
   ============================================================ */
@media (prefers-reduced-motion: reduce), (max-width: 700px) {
  .cxp-inbox .riv-draw,
  .cxp-inbox .riv-scene.in .riv-draw {
    animation: none !important;
    stroke-dashoffset: 0 !important;
  }
  .cxp-inbox .riv-glow,
  .cxp-inbox .riv-scene.in .riv-glow {
    transition: none !important;
    opacity: 0.14 !important;
  }
  .cxp-inbox .riv-cur,
  .cxp-inbox .riv-scene.in .riv-cur {
    animation: none !important;
    opacity: 0.45 !important;
  }
  .cxp-inbox .riv-record.ios,
  .cxp-inbox .riv-record.ios.in {
    transform: translate(-50%, -50%) !important;
  }
  /* generic .ios scroll-reveal (opacity:0 base, defined in shared styles.css)
     must also arrive at its finished state on phones, not just under
     prefers-reduced-motion — the confluence chips/record read as broken
     gaps otherwise if a viewport-driven scroll trigger never fires them. */
  .cxp-inbox .ios,
  .cxp-inbox .riv-chip.ios,
  .cxp-inbox .riv-record.ios {
    opacity: 1 !important;
    transition: none !important;
  }
}
