/* Home hero: the doctor and the Rx pad, the dotted word stream, the phone on a dose call,
   the Care cards, and the "made for" strip of people. Loads after components.css and
   care-card.css, so the rules here win. Tokens only. */

/* Skin tone for the line drawings, mixed from two tokens. */
.ct-hero2, .ct-people { --ct-skin: color-mix(in srgb, var(--status-later) 48%, var(--color-surface)); }

/* ---------- Layout: one centred composition inside the content width ---------- */
.ct-hero2 {
  position: relative;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-7);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-8);
  row-gap: var(--space-5);
  align-items: center;
}
.ct-hero2__copy { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-4); min-width: 0; }
.ct-hero2__title { font-size: clamp(2rem, 3.6vw, 3.25rem); }
.ct-hero2__one { margin-top: 0; text-wrap: balance; }
.ct-hero2__lead { max-width: 48ch; margin-top: calc(-1 * var(--space-2)); }
.ct-hero2__visual { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; min-width: 0; }

/* The doctor sits where the stream starts: under the headline on wide screens,
   above the phone on narrow ones. Only one of the two is shown. */
.ct-hero2__rx { width: 100%; pointer-events: none; }
.ct-hero2__rx--wide { padding-top: var(--space-5); margin-bottom: calc(-1 * var(--space-2)); }
.ct-hero2__rx--narrow { display: none; }
.ct-doc { display: block; height: auto; overflow: visible; }
.ct-doc--wide { width: 200px; }
.ct-doc--narrow { width: 148px; }

/* ---------- The doctor (line art) ---------- */
.ct-doc { stroke: var(--color-ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.ct-doc .d-soft { fill: var(--color-primary-soft); }
.ct-doc .d-coat { fill: var(--color-surface); }
.ct-doc .d-teal { fill: var(--color-primary); }
.ct-doc .d-skin { fill: var(--ct-skin); }
.ct-doc .d-hair { fill: var(--color-ink); }
.ct-doc .d-thin { stroke-width: 1.4; }
.ct-doc .d-steth { stroke: var(--color-primary); stroke-width: 2; }
.ct-doc .d-steth-head { fill: var(--color-primary); stroke: var(--color-primary); }
.ct-doc .d-arm-o { stroke-width: 12; }
.ct-doc .d-arm { stroke: var(--color-surface); stroke-width: 7.6; }
.ct-doc .d-paper { fill: var(--color-surface); }
.ct-doc .d-clip { fill: var(--color-border-strong); }
.ct-doc .d-rx { fill: var(--color-primary); stroke: none; font-family: var(--font-serif); font-style: italic; font-weight: var(--weight-bold); font-size: var(--text-md); }
.ct-doc .d-ink { stroke: var(--color-primary); stroke-width: 1.8; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
.ct-doc .d-desk { fill: var(--color-border); }
.ct-doc .d-pen { stroke: var(--color-primary); stroke-width: 3; }
.ct-doc__anchor { fill: none; stroke: none; }
.ct-doc__writing { transform-box: fill-box; transform-origin: center; }
.ct-doc__pen { transform-box: fill-box; transform-origin: 30% 80%; }

/* write: the three lines draw in, one after another, while the pen moves */
[data-phase="write"] .ct-doc .d-ink { stroke-dashoffset: 0; transition: stroke-dashoffset 520ms var(--ease-in-out); }
[data-phase="write"] .ct-doc .d-ink:nth-child(2) { transition-delay: 560ms; }
[data-phase="write"] .ct-doc .d-ink:nth-child(3) { transition-delay: 1120ms; }
[data-phase="write"] .ct-doc__pen { animation: ct-pen 420ms var(--ease-in-out) 4 alternate; }
@keyframes ct-pen { from { transform: translate(-3px, 1px) rotate(-4deg); } to { transform: translate(2px, -1px) rotate(3deg); } }
/* send: the handwriting lifts off the pad as the words leave along the stream */
[data-phase="send"] .ct-doc .d-ink,
[data-phase="call"] .ct-doc .d-ink,
[data-phase="fade"] .ct-doc .d-ink { stroke-dashoffset: 0; }
[data-phase="send"] .ct-doc__writing,
[data-phase="call"] .ct-doc__writing,
[data-phase="fade"] .ct-doc__writing { opacity: 0; transform: translate(10px, -12px) scale(0.96); transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out); }
[data-phase="static"] .ct-doc .d-ink { stroke-dashoffset: 0; }

/* ---------- The dotted stream from the pad to the phone ---------- */
.ct-flow { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 2; opacity: 0; transition: opacity 300ms var(--ease-out); }
.ct-flow.is-ready { opacity: 1; }
.ct-flow__dots { fill: none; stroke: var(--color-border-strong); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 0 8; }
.ct-flow__dots--lit { stroke: var(--color-primary); opacity: 0; transition: opacity 400ms var(--ease-out); }
.ct-flow__reveal { fill: none; stroke: var(--color-surface); stroke-width: 12; stroke-dasharray: 1 1; stroke-dashoffset: 1; }
[data-phase="send"] .ct-flow__dots--lit,
[data-phase="call"] .ct-flow__dots--lit,
[data-phase="static"] .ct-flow__dots--lit { opacity: 1; animation: ct-flow-march 700ms linear infinite; }
[data-phase="send"] .ct-flow__reveal { stroke-dashoffset: 0; transition: stroke-dashoffset 2600ms var(--ease-in-out); }
[data-phase="call"] .ct-flow__reveal,
[data-phase="fade"] .ct-flow__reveal,
[data-phase="static"] .ct-flow__reveal { stroke-dashoffset: 0; }
@keyframes ct-flow-march { to { stroke-dashoffset: -16; } }
.ct-flow__words { fill: var(--color-primary); stroke: none; font-family: var(--font-sans); font-size: var(--text-sm); font-weight: var(--weight-bold); letter-spacing: 0.01em; white-space: pre; }
[data-phase="static"] .ct-flow__words { display: none; }
.ct-flow__in { fill: var(--color-primary); stroke: var(--color-primary-soft); stroke-width: 4; paint-order: stroke; }

/* ---------- Phone ---------- */
.ct-hcall { display: grid; grid-template-columns: auto auto; grid-template-areas: none; column-gap: var(--space-5); row-gap: 0; align-items: center; justify-content: center; min-height: 500px; }
.ct-hcall__phone { position: relative; grid-area: auto; width: 248px; min-height: 480px; aspect-ratio: 9 / 19.5; }
.ct-hcall__phone::before,
.ct-hcall__phone::after {
  content: ""; position: absolute; width: 3px; border-radius: var(--radius-sm); background: var(--color-ink); pointer-events: none;
}
.ct-hcall__phone::before { left: -3px; top: 22%; height: 14%; }
.ct-hcall__phone::after { right: -3px; top: 26%; height: 10%; }
.ct-hcall__screen { position: relative; }
.ct-hcall__sub { min-height: 2.5em; }
.ct-hcall[data-state="idle"] .ct-hcall__state { color: var(--color-ink-muted); }
.ct-hcall__bubble { transition: transform 320ms var(--ease-in-out); animation-timing-function: var(--ease-out); }
.ct-hcall[data-state="listening"] .ct-hcall__bubble { transform: translateY(-44px); }

/* Voice overlay: rises over the foot of the screen while the patient speaks, fades when Care Taker speaks */
.ct-hcall__voice {
  position: absolute; left: 0; right: 0; bottom: 0; height: 108px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1);
  background: color-mix(in srgb, var(--color-accent-soft) 92%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--color-accent) 45%, transparent);
  opacity: 0; transform: translateY(28px);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
  pointer-events: none;
}
.ct-hcall[data-state="listening"] .ct-hcall__voice { opacity: 1; transform: none; transition-duration: 340ms; }
.ct-hcall__foot > * { transition: opacity 200ms var(--ease-out); }
.ct-hcall[data-state="listening"] .ct-hcall__foot > * { opacity: 0; }
.ct-hcall__wave { display: block; width: 78%; height: 40px; overflow: hidden; }
.ct-hcall__wave svg { display: block; width: 200%; max-width: none; height: 100%; }
.ct-hcall__wave path { fill: none; stroke-linecap: round; }
.ct-hcall__wave-a { stroke: var(--status-later); stroke-width: 2.5; }
.ct-hcall__wave-b { stroke: var(--color-accent); stroke-width: 2; opacity: 0.8; transform: scaleY(0.55); transform-origin: center; transform-box: view-box; }
.ct-hcall[data-state="listening"] .ct-hcall__wave svg { animation: ct-wave-run 1.2s linear infinite; }
@keyframes ct-wave-run { to { transform: translateX(-50%); } }
.ct-hcall__voice-label { display: inline-flex; align-items: center; gap: var(--space-1); font-size: var(--text-xs); font-weight: var(--weight-bold); color: var(--color-ink); }

/* ---------- Live Care cards beside the phone ---------- */
/* A tagline over the column; each card is a role mark, the screen the call lands on, one line and a
   state. Waiting states show a clock whose hands keep sweeping. An update crossfades the line, passes
   a light over the card, fills a hairline along its foot and runs a dot down the connector. */
.ct-hcall__aside { width: 280px; display: flex; flex-direction: column; gap: var(--space-3); }
.ct-hcall__tag {
  margin: 0 0 var(--space-1); font-family: var(--font-serif); font-size: var(--text-lg); line-height: var(--leading-tight);
  color: var(--color-ink); letter-spacing: -0.01em;
}
.ct-hcall__cards { list-style: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: column; gap: var(--space-3); }
.ct-hcall__card { position: relative; }
.ct-hcall__card::before {
  content: ""; position: absolute; right: 100%; top: 50%; width: var(--space-5);
  border-top: 2px dashed var(--color-border-strong); transition: border-color var(--dur-2) var(--ease-out);
}
.ct-hcall__card.is-on::before { border-top-color: var(--color-primary); }
/* The dot that runs from the phone to the card when the card updates. */
.ct-hcall__card::after {
  content: ""; position: absolute; top: 50%; right: calc(100% + var(--space-5)); width: var(--space-2); height: var(--space-2);
  margin-top: calc(-1 * var(--space-1) + 1px); border-radius: var(--radius-pill); background: var(--color-primary); opacity: 0;
}
.ct-hcall__card.is-pulse::after { animation: ct-live-run 520ms var(--ease-in-out) both; }
@keyframes ct-live-run {
  0% { opacity: 0; transform: translateX(0); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translateX(var(--space-5)); }
}

.ct-live {
  position: relative; overflow: hidden; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--space-3); align-items: start;
  padding: var(--space-3) var(--space-4) var(--space-4) var(--space-3); border-radius: var(--radius-lg);
  background: var(--color-surface); box-shadow: var(--shadow-1);
  opacity: 0.66; transform: translateX(calc(-1 * var(--space-1)));
  transition: opacity var(--dur-3) var(--ease-out), transform var(--dur-3) var(--ease-out), box-shadow var(--dur-3) var(--ease-out);
}
.ct-live.is-on { opacity: 1; transform: none; box-shadow: var(--shadow-2); }
.ct-live__mark {
  display: inline-grid; place-items: center; width: var(--space-7); height: var(--space-7); border-radius: var(--radius-pill);
  background: var(--color-primary-soft); color: var(--color-primary); transition: background-color var(--dur-3) var(--ease-out), color var(--dur-3) var(--ease-out);
}
.ct-live__mark .ct-icon { width: 1.35em; height: 1.35em; }
.ct-live[data-state="urgent"] .ct-live__mark { background: var(--status-urgent-bg); color: var(--status-urgent); }
.ct-live[data-state="private"] .ct-live__mark { background: var(--status-missed-bg); color: var(--status-missed); }
.ct-live__body { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); min-width: 0; }
.ct-live__top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); width: 100%; }
.ct-live__top strong { font-size: var(--text-sm); }
.ct-live__time { font-size: var(--text-xs); color: var(--color-ink-muted); }
.ct-live__text { font-size: var(--text-sm); color: var(--color-ink-muted); line-height: var(--leading-tight); }
.ct-live__text.is-in { animation: ct-live-text var(--dur-3) var(--ease-out) both; }
@keyframes ct-live-text { from { opacity: 0; transform: translateY(var(--space-1)); } to { opacity: 1; transform: none; } }
.ct-live__state { font-size: var(--text-xs); padding: 2px var(--space-2); margin-top: var(--space-1); }
.ct-live__state .ct-icon, .ct-live__state svg { width: 1.25em; height: 1.25em; flex: none; }
.ct-live__state svg { fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
/* The clock: the minute hand sweeps once every four seconds, the hour hand once a minute. */
.ct-live__minute, .ct-live__hour { transform-origin: 12px 12px; }
.ct-live__minute { animation: ct-live-sweep 4s linear infinite; }
.ct-live__hour { animation: ct-live-sweep 48s linear infinite; }
@keyframes ct-live-sweep { to { transform: rotate(360deg); } }
/* The tick draws itself in when a card is confirmed. */
.ct-live__tick path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: ct-live-draw var(--dur-3) var(--ease-out) 120ms forwards; }
@keyframes ct-live-draw { to { stroke-dashoffset: 0; } }
/* The light that passes over a card as it updates, and the hairline that fills along its foot. */
.ct-live::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: linear-gradient(100deg, transparent 30%, var(--color-primary-soft) 50%, transparent 70%);
  transform: translateX(-100%);
}
.ct-hcall__card.is-pulse .ct-live::after { animation: ct-live-sheen 900ms var(--ease-in-out) 200ms both; }
@keyframes ct-live-sheen { 0% { opacity: 1; transform: translateX(-100%); } 100% { opacity: 1; transform: translateX(100%); } }
.ct-live__bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--color-primary);
  transform: scaleX(0); transform-origin: left center; opacity: 0;
}
.ct-hcall__card.is-pulse .ct-live__bar { animation: ct-live-fill 1100ms var(--ease-out) 150ms both; }
.ct-live[data-state="urgent"] .ct-live__bar { background: var(--status-urgent); }
@keyframes ct-live-fill { 0% { opacity: 1; transform: scaleX(0); } 70% { opacity: 1; transform: scaleX(1); } 100% { opacity: 0; transform: scaleX(1); } }
.ct-hcall__card.is-pulse .ct-live[data-state="urgent"] { animation: ct-live-nudge 420ms var(--ease-in-out) 2; }
@keyframes ct-live-nudge { 0%, 100% { translate: 0; } 25% { translate: calc(-1 * var(--space-1)) 0; } 75% { translate: var(--space-1) 0; } }
.ct-dose-chip--hero {
  border: 0;
  background: transparent;
  min-height: var(--space-6);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  justify-content: center;
}

/* ---------- 960 to 1199: a slightly smaller phone and cards ---------- */
@media (max-width: 1199px) {
  .ct-hero2 { column-gap: var(--space-7); padding-left: var(--space-4); padding-right: var(--space-4); }
  .ct-hcall__phone { width: 224px; }
  .ct-hcall__aside { width: 252px; }
  .ct-hcall { column-gap: var(--space-5); }
}

/* ---------- Under 960: one column. The doctor moves above the phone ---------- */
@media (max-width: 959px) {
  .ct-hero2 { grid-template-columns: minmax(0, 1fr); padding-top: var(--space-5); row-gap: var(--space-5); }
  .ct-hero2__rx--wide { display: none; }
  .ct-flow__words { display: none; }
  .ct-hero2 { padding-left: var(--space-4); padding-right: var(--space-4); }
  .ct-hero2__rx--narrow { display: block; max-width: calc(232px + var(--space-5) + 300px); padding-top: var(--space-4); margin-bottom: var(--space-6); }
  .ct-hero2__visual { align-items: stretch; }
  .ct-hcall { grid-template-columns: auto minmax(0, 300px); }
  .ct-hcall__phone { width: 232px; }
  .ct-hcall__aside { width: auto; }
  .ct-hero2__rx--narrow { margin-left: auto; margin-right: auto; }
}

/* ---------- Phones: phone centred, cards below it on a dashed spine ---------- */
@media (max-width: 559px) {
  .ct-hero2__rx--narrow { margin-bottom: var(--space-5); }
  .ct-hcall { grid-template-columns: minmax(0, 1fr); justify-items: center; row-gap: var(--space-5); }
  .ct-hcall__phone { width: min(248px, 72vw); }
  .ct-hcall__aside { width: 100%; }
  .ct-hcall__tag { text-align: center; }
  .ct-hcall__card::after { display: none; }
  .ct-hcall__card::before { right: auto; top: auto; left: 50%; bottom: 100%; width: 0; height: var(--space-3); border-top: 0; border-left: 2px dashed var(--color-border-strong); }
  .ct-hcall__card:first-child::before { height: var(--space-5); }
  .ct-hcall__card.is-on::before { border-left-color: var(--color-primary); }
}

/* ---------- Made for the people who need it most ---------- */
.ct-people__inner { max-width: var(--content-max); margin: 0 auto; padding: var(--space-8) var(--space-4); }
.ct-people__head { display: flex; flex-direction: column; align-items: center; text-align: center; }
.ct-people__head .ct-section-title-lg { max-width: none; }
.ct-people__grid { list-style: none; margin: var(--space-6) 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-5); }
.ct-people__fig { margin: 0; display: flex; flex-direction: column; gap: var(--space-3); height: 100%; }
.ct-people__media { aspect-ratio: 4 / 3; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--color-border); background: var(--color-surface-sunken); }
.ct-people__photo { display: block; width: 100%; height: 100%; object-fit: cover; }
.ct-people__fig figcaption { display: flex; flex-direction: column; gap: var(--space-1); }
.ct-people__fig figcaption strong { font-size: var(--text-md); }
.ct-people__fig figcaption span { font-size: var(--text-sm); color: var(--color-ink-muted); line-height: var(--leading-body); }

.ct-ill { display: block; width: 100%; height: 100%; stroke: var(--color-ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.ct-ill .p-wall-gold { fill: var(--color-accent-soft); stroke: none; }
.ct-ill .p-wall-teal { fill: var(--color-primary-soft); stroke: none; }
.ct-ill .p-wall-blue { fill: var(--status-unclear-bg); stroke: none; }
.ct-ill .p-wall-plum { fill: var(--status-stopped-bg); stroke: none; }
.ct-ill .p-floor { fill: var(--color-surface-sunken); stroke: none; }
.ct-ill .p-white { fill: var(--color-surface); }
.ct-ill .p-skin { fill: var(--ct-skin); }
.ct-ill .p-grey { fill: var(--color-border); }
.ct-ill .p-ink { fill: var(--color-ink); }
.ct-ill .p-teal { fill: var(--color-primary); }
.ct-ill .p-teal-soft { fill: var(--color-primary-soft); }
.ct-ill .p-gold { fill: var(--color-accent); }
.ct-ill .p-gold-soft { fill: var(--color-accent-soft); }
.ct-ill .p-red { fill: var(--status-urgent); }
.ct-ill .p-plum { fill: var(--status-stopped); }
.ct-ill .p-blue { fill: var(--status-unclear); }
.ct-ill .p-green { fill: var(--status-taken); }
.ct-ill .p-sand { fill: var(--color-border-strong); }
.ct-ill .p-dot { stroke: none; }
.ct-ill .p-limb-o { stroke-width: 12; }
.ct-ill .p-limb { stroke: var(--ct-skin); stroke-width: 7.4; }
.ct-ill .p-limb--white { stroke: var(--color-surface); }
.ct-ill .p-limb--blue { stroke: var(--status-unclear); }
.ct-ill .p-limb--plum { stroke: var(--status-stopped); }
.ct-ill .p-limb--teal { stroke: var(--color-primary); }
.ct-ill .p-sound { stroke: var(--color-primary); stroke-width: 2.6; }
.ct-ill .p-link { stroke: var(--color-primary); stroke-dasharray: 0 7; stroke-width: 3; }
.ct-ill .p-tick { stroke: var(--color-surface); stroke-width: 2.6; }
.ct-ill .p-text { fill: var(--color-ink); stroke: none; font-family: var(--font-sans); font-size: var(--text-xs); font-weight: var(--weight-bold); }
.ct-ill .p-text--muted { fill: var(--color-ink-muted); font-weight: var(--weight-medium); }

@media (max-width: 999px) { .ct-people__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 719px) { .ct-people__inner { padding: var(--space-7) var(--space-4); } }
@media (max-width: 519px) { .ct-people__grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Reduced motion: a calm, complete still ---------- */
@media (prefers-reduced-motion: reduce) {
  .ct-doc__pen, .ct-doc__writing, .ct-flow, .ct-flow__dots--lit, .ct-hcall__voice, .ct-hcall__bubble,
  .ct-hcall__card::before, .ct-hcall__card::after, .ct-live, .ct-live *, .ct-live::after { animation: none !important; transition: none !important; }
  .ct-live__tick path { stroke-dashoffset: 0; }
}
