/* scenes/timeline.css — one customer's complete story: a vertical spine of chat, call summary,
   follow-up and CRM events, ending in the next step still open. All selectors scoped under
   [data-app-scene="timeline"]. Tokens (--showcase-*) come from the host, see scenes/README.md. */

[data-app-scene="timeline"] {
  --tl-green: oklch(.72 .16 150);
  --tl-green-tint: oklch(.72 .16 150 / .16);
  --tl-amber: oklch(.8 .15 80);
  --tl-amber-tint: oklch(.8 .15 80 / .16);
  --tl-blue-tint: oklch(.66 .18 263 / .16);
  --tl-fs-name: 11px;
  --tl-fs-label: 8px;
  --tl-fs-body: 9px;
  --tl-fs-meta: 7px;
  --tl-ease: cubic-bezier(.22, 1, .36, 1);
}

[data-app-scene="timeline"] .app-preview--timeline { display: flex; flex-direction: column; }
[data-app-scene="timeline"] .app-preview--timeline .app-preview-topbar { flex: none; }

/* ---------- scaffolding ---------- */
[data-app-scene="timeline"] .tl-body {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- customer header ---------- */
[data-app-scene="timeline"] .tl-customer {
  display: flex;
  flex: none;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--showcase-line);
  background: oklch(.13 .01 264 / .7);
}
[data-app-scene="timeline"] .tl-avatar {
  display: grid;
  flex: none;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  background: oklch(.28 .09 264 / .65);
  color: oklch(.85 .1 263);
  font-size: var(--tl-fs-meta);
  font-weight: 700;
  letter-spacing: 0;
}
[data-app-scene="timeline"] img.tl-avatar { object-fit: cover; border: 1px solid var(--showcase-line); }
/* Signed-in user in the shared topbar: styled to match the initials badge it replaces. */
[data-app-scene="timeline"] img.app-user {
  width: 23px;
  height: 23px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--showcase-line);
}
/* Hawre Salih inline where he's named: call summary, follow-up owner. */
[data-app-scene="timeline"] .tl-rep { display: inline-flex; align-items: center; gap: 4px; margin-inline-start: 3px; vertical-align: middle; }
[data-app-scene="timeline"] .tl-rep-avatar {
  display: grid;
  flex: none;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: oklch(.28 .09 264 / .65);
  color: oklch(.85 .1 263);
  font-size: 6px;
  font-weight: 700;
}
[data-app-scene="timeline"] img.tl-rep-avatar { object-fit: cover; border: 1px solid var(--showcase-line); }
[data-app-scene="timeline"] .tl-customer-info { display: flex; min-width: 0; flex-direction: column; gap: 3px; }
[data-app-scene="timeline"] .tl-customer-name {
  overflow: hidden;
  color: var(--showcase-text);
  font-size: var(--tl-fs-name);
  font-weight: 700;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}
[data-app-scene="timeline"] .tl-channels { display: flex; align-items: center; gap: 9px; }
[data-app-scene="timeline"] .tl-channel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--showcase-muted);
  font-size: var(--tl-fs-meta);
  font-weight: 500;
}
[data-app-scene="timeline"] .tl-channel-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--showcase-blue); }
[data-app-scene="timeline"] .tl-channel-dot--call { background: oklch(.66 .18 263 / .55); }

[data-app-scene="timeline"] .tl-pill {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 5px;
  margin-inline-start: auto;
  padding: 5px 9px;
  border: 1px solid oklch(.8 .15 80 / .35);
  border-radius: 999px;
  background: var(--tl-amber-tint);
  color: var(--tl-amber);
  font-size: var(--tl-fs-meta);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
[data-app-scene="timeline"] .tl-pill svg { width: 9px; height: 9px; stroke-width: 2; }

/* ---------- the spine ---------- */
[data-app-scene="timeline"] .tl-scroll {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--showcase-line) transparent;
}
[data-app-scene="timeline"] .tl-scroll::-webkit-scrollbar { width: 5px; }
[data-app-scene="timeline"] .tl-scroll::-webkit-scrollbar-track { background: transparent; }
[data-app-scene="timeline"] .tl-scroll::-webkit-scrollbar-thumb { background: var(--showcase-line); border-radius: 3px; }

[data-app-scene="timeline"] .tl-spine { display: flex; flex-direction: column; gap: 9px; padding: 11px 12px 4px; }
[data-app-scene="timeline"] .tl-item,
[data-app-scene="timeline"] .tl-open {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  column-gap: 8px;
  align-items: start;
}
[data-app-scene="timeline"] .tl-marker { position: relative; align-self: stretch; min-height: 100%; }
[data-app-scene="timeline"] .tl-line {
  position: absolute;
  inset-inline-start: 50%;
  top: 0;
  bottom: -9px;
  width: 2px;
  margin-inline-start: -1px;
  background: var(--showcase-line);
  transform: scaleY(1);
  transform-origin: top;
  transition: transform .4s var(--tl-ease);
}
[data-app-scene="timeline"] .tl-line.is-priming { transform: scaleY(0); }
[data-app-scene="timeline"] .tl-dot {
  position: absolute;
  inset-inline-start: 50%;
  top: 12px;
  z-index: 1;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--showcase-blue);
  box-shadow: 0 0 0 3px var(--showcase-bg);
}
[data-app-scene="timeline"] .tl-dot--open { background: var(--tl-amber); }

/* ---------- cards ---------- */
[data-app-scene="timeline"] .tl-card {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--showcase-line);
  border-radius: 8px;
  background: var(--showcase-panel);
}
[data-app-scene="timeline"] .tl-card--agent { border-color: oklch(.42 .09 263 / .7); background: oklch(.2 .04 264 / .8); }
[data-app-scene="timeline"] .tl-card-head { display: flex; align-items: center; gap: 6px; }
[data-app-scene="timeline"] .tl-time {
  margin-inline-start: auto;
  color: var(--showcase-muted);
  font-size: var(--tl-fs-meta);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
[data-app-scene="timeline"] .tl-text {
  margin: 5px 0 0;
  color: oklch(.85 .01 264);
  font-size: var(--tl-fs-body);
  font-weight: 400;
  line-height: 1.5;
}
[data-app-scene="timeline"] .tl-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 5px 0 0;
  color: var(--showcase-muted);
  font-size: var(--tl-fs-meta);
  font-weight: 500;
}
[data-app-scene="timeline"] .tl-meta svg { width: 8px; height: 8px; stroke-width: 2.2; }
[data-app-scene="timeline"] .tl-meta b { font-weight: 700; font-variant-numeric: tabular-nums; }
[data-app-scene="timeline"] .tl-meta--done { color: var(--tl-green); }
[data-app-scene="timeline"] .tl-meta--done svg { color: var(--tl-green); }

[data-app-scene="timeline"] .tl-call-line { margin: 5px 0 0; color: var(--showcase-text); font-size: var(--tl-fs-body); font-weight: 600; }

/* Teaser <-> bullets: a wrapper animating grid-template-rows 0fr/1fr, never a hard show/hide,
   so expanding the call summary never snaps the follow-up and CRM entries below it. */
[data-app-scene="timeline"] .tl-call-teaser-fold,
[data-app-scene="timeline"] .tl-call-bullets-fold {
  display: grid;
  overflow: hidden;
  transition: grid-template-rows .4s var(--tl-ease), opacity .3s var(--tl-ease);
}
[data-app-scene="timeline"] .tl-call-teaser-fold > *,
[data-app-scene="timeline"] .tl-call-bullets-fold > * {
  min-height: 0;
  overflow: hidden;
}
[data-app-scene="timeline"] .tl-call-teaser-fold { grid-template-rows: 0fr; margin-top: 5px; opacity: 0; }
[data-app-scene="timeline"] .tl-call-bullets-fold { grid-template-rows: 1fr; margin-top: 6px; opacity: 1; }
[data-app-scene="timeline"] .tl-card.is-call-pending .tl-call-teaser-fold { grid-template-rows: 1fr; opacity: 1; }
[data-app-scene="timeline"] .tl-card.is-call-pending .tl-call-bullets-fold { grid-template-rows: 0fr; opacity: 0; }

[data-app-scene="timeline"] .tl-call-teaser {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--showcase-muted);
  font-size: var(--tl-fs-meta);
  font-weight: 500;
}
[data-app-scene="timeline"] .tl-call-teaser svg { width: 9px; height: 9px; stroke-width: 2; color: var(--showcase-blue); }
[data-app-scene="timeline"] .tl-call-bullets { display: flex; flex-direction: column; gap: 3px; margin: 0; padding: 0; list-style: none; }
[data-app-scene="timeline"] .tl-call-bullets li {
  position: relative;
  padding-inline-start: 10px;
  color: oklch(.82 .01 264);
  font-size: var(--tl-fs-meta);
  font-weight: 400;
  line-height: 1.5;
  opacity: 1;
}
[data-app-scene="timeline"] .tl-call-bullets li::before {
  position: absolute;
  inset-inline-start: 0;
  top: .55em;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--showcase-blue);
  content: "";
}

[data-app-scene="timeline"] .tl-stage-row { display: flex; align-items: center; gap: 5px; margin: 6px 0 0; }
[data-app-scene="timeline"] .tl-stage-row svg { width: 9px; height: 9px; stroke-width: 2; color: var(--showcase-muted); }
[data-app-scene="timeline"] .tl-stage-pill {
  padding: 3px 7px;
  border: 1px solid var(--showcase-line);
  border-radius: 999px;
  color: var(--showcase-muted);
  font-size: var(--tl-fs-label);
  font-weight: 700;
}
[data-app-scene="timeline"] .tl-stage-pill--done { border-color: oklch(.72 .16 150 / .4); background: var(--tl-green-tint); color: var(--tl-green); }

/* ---------- chips ---------- */
[data-app-scene="timeline"] .tl-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: var(--tl-fs-label);
  font-weight: 700;
  letter-spacing: .01em;
}
[data-app-scene="timeline"] .tl-chip::before { width: 4px; height: 4px; border-radius: 50%; content: ""; }
[data-app-scene="timeline"] .tl-chip--blue { background: var(--tl-blue-tint); color: oklch(.78 .13 263); }
[data-app-scene="timeline"] .tl-chip--blue::before { background: var(--showcase-blue); }
[data-app-scene="timeline"] .tl-chip--amber { background: var(--tl-amber-tint); color: var(--tl-amber); }
[data-app-scene="timeline"] .tl-chip--amber::before { background: var(--tl-amber); }

/* ---------- open next step (footer) ---------- */
[data-app-scene="timeline"] .tl-open { flex: none; padding: 10px 12px 12px; }
[data-app-scene="timeline"] .tl-open-copy { display: flex; min-width: 0; flex-direction: column; gap: 2px; padding: 7px 9px; border: 1px solid oklch(.8 .15 80 / .3); border-radius: 8px; background: oklch(.16 .03 80 / .16); }
[data-app-scene="timeline"] .tl-open-copy strong { color: var(--showcase-text); font-size: var(--tl-fs-label); font-weight: 700; }
[data-app-scene="timeline"] .tl-open-copy span { color: oklch(.85 .01 264); font-size: var(--tl-fs-body); font-weight: 400; }
[data-app-scene="timeline"] .tl-open-copy em {
  color: var(--tl-amber);
  font-size: var(--tl-fs-meta);
  font-style: normal;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
[data-app-scene="timeline"] .tl-open .tl-line { bottom: auto; height: 12px; }

/* ---------- entrance (keyed on .is-scene-active, from a visible resting state) ---------- */
[data-app-scene="timeline"] .app-preview.is-scene-active .tl-customer { animation: tl-header-in .46s var(--tl-ease) both; }
[data-app-scene="timeline"] .app-preview.is-scene-active .tl-item {
  animation: tl-item-in .5s var(--tl-ease) both;
  animation-delay: calc(140ms + var(--tl-i, 0) * 90ms);
}
[data-app-scene="timeline"] .app-preview.is-scene-active .tl-open { animation: tl-open-in .48s var(--tl-ease) .68s both; }
@keyframes tl-header-in { from { opacity: .4; transform: translateY(-7px); } to { opacity: 1; transform: none; } }
@keyframes tl-item-in { from { opacity: .3; filter: blur(2px); transform: translateY(13px); } to { opacity: 1; filter: blur(0); transform: none; } }
@keyframes tl-open-in { from { opacity: .35; transform: translateY(9px); } to { opacity: 1; transform: none; } }

/* ---------- authored loop: replay classes ---------- */
[data-app-scene="timeline"] .tl-item.tl-replay { animation: tl-item-in .5s var(--tl-ease) both; }
[data-app-scene="timeline"] .tl-call-bullets.tl-reveal li { animation: tl-bullet-in .42s var(--tl-ease) both; }
[data-app-scene="timeline"] .tl-call-bullets.tl-reveal li:nth-child(2) { animation-delay: 90ms; }
[data-app-scene="timeline"] .tl-call-bullets.tl-reveal li:nth-child(3) { animation-delay: 180ms; }
@keyframes tl-bullet-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
[data-app-scene="timeline"] [data-chip].tl-pop,
[data-app-scene="timeline"] .tl-stage-pill.tl-pop { animation: tl-pop .5s var(--tl-ease); }
@keyframes tl-pop { from { transform: scale(.6); opacity: .5; } 60% { transform: scale(1.06); opacity: 1; } to { transform: scale(1); opacity: 1; } }
[data-app-scene="timeline"] .tl-open.tl-settle .tl-open-copy { animation: tl-settle-flash 1s var(--tl-ease); }
@keyframes tl-settle-flash {
  0% { box-shadow: 0 0 0 0 oklch(.8 .15 80 / .4); }
  45% { box-shadow: 0 0 0 5px oklch(.8 .15 80 / 0); }
  100% { box-shadow: 0 0 0 0 oklch(.8 .15 80 / 0); }
}

/* ---------- idle life: breathing dot on the open step, the current point pulsing ---------- */
@media (prefers-reduced-motion: no-preference) {
  [data-app-scene="timeline"] .app-preview.is-scene-active .tl-dot--open { animation: tl-breathe 2.6s ease-in-out infinite; }
  [data-app-scene="timeline"] .app-preview.is-scene-active .tl-dot.is-current::after {
    position: absolute;
    inset: -3px;
    border: 1px solid var(--showcase-blue);
    border-radius: 50%;
    content: "";
    opacity: 0;
    animation: tl-ring-ping 2.2s ease-out .4s infinite;
  }
  [data-app-scene="timeline"] .app-preview.is-scene-active .tl-dot--open.is-current::after { border-color: var(--tl-amber); }
}
@keyframes tl-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.22); } }
@keyframes tl-ring-ping { 0% { opacity: .85; transform: scale(.7); } 70%, 100% { opacity: 0; transform: scale(2.3); } }

@media (prefers-reduced-motion: reduce) {
  [data-app-scene="timeline"] .app-preview.is-scene-active .tl-customer,
  [data-app-scene="timeline"] .app-preview.is-scene-active .tl-item,
  [data-app-scene="timeline"] .app-preview.is-scene-active .tl-open,
  [data-app-scene="timeline"] .tl-item.tl-replay,
  [data-app-scene="timeline"] .tl-call-bullets.tl-reveal li,
  [data-app-scene="timeline"] [data-chip].tl-pop,
  [data-app-scene="timeline"] .tl-stage-pill.tl-pop,
  [data-app-scene="timeline"] .tl-open.tl-settle .tl-open-copy { animation: none; }
  [data-app-scene="timeline"] .tl-line,
  [data-app-scene="timeline"] .tl-call-teaser-fold,
  [data-app-scene="timeline"] .tl-call-bullets-fold { transition: none; }
}

/* ---------- narrower hosts (1024 px page: 541 px host) ---------- */
@container app-scene (max-width: 620px) {
  [data-app-scene="timeline"] .tl-customer { padding: 9px 10px; }
  [data-app-scene="timeline"] .tl-spine { padding: 10px 10px 4px; }
  [data-app-scene="timeline"] .tl-open { padding: 9px 10px 11px; }
}

/* ---------- phone host (340 x 370): condensed header, type steps up one notch ---------- */
@container app-scene (max-width: 400px) {
  [data-app-scene="timeline"] {
    --tl-fs-name: 12px;
    --tl-fs-label: 9px;
    --tl-fs-body: 10px;
    --tl-fs-meta: 8px;
  }
  [data-app-scene="timeline"] .tl-customer { gap: 7px; padding: 8px 9px; }
  [data-app-scene="timeline"] .tl-avatar { width: 24px; height: 24px; }
  [data-app-scene="timeline"] .tl-channels { display: none; }
  [data-app-scene="timeline"] .tl-pill span { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  [data-app-scene="timeline"] .tl-spine { gap: 7px; padding: 9px 9px 3px; }
  [data-app-scene="timeline"] .tl-card { padding: 6px 8px; }
  [data-app-scene="timeline"] .tl-open { padding: 8px 9px 10px; }
  [data-app-scene="timeline"] .tl-open-copy span { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
}
