/* ========================================================================
   Engagement Timeline — polished v2
   Drop-in upgrade for the timeline section. Loaded after styles-v3.css.
   ======================================================================== */

.timeline-section {
  background:
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(42, 157, 143, 0.06), transparent 70%),
    linear-gradient(180deg, #f7faf8 0%, #ffffff 100%);
  padding: 110px 24px 96px;
  position: relative;
}

.timeline-eyebrow-row {
  align-items: center;
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
}

.timeline-eyebrow-row .eyebrow { margin: 0; }

.timeline-eyebrow-bar {
  background: linear-gradient(90deg, var(--brand-mid), transparent);
  border-radius: 1px;
  flex: 1;
  height: 1px;
  max-width: 260px;
}

/* Stat row above the chart */
.timeline-stats {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 32px auto 40px;
  max-width: var(--max);
}

.timeline-stat {
  border-right: 1px solid var(--line);
  padding: 18px 22px;
}

.timeline-stat:last-child { border-right: none; }

.timeline-stat-label {
  color: var(--muted);
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.timeline-stat-value {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1;
}

.timeline-stat-value small {
  color: var(--brand-mid);
  font-size: 13px;
  font-weight: 600;
  margin-left: 4px;
}

@media (max-width: 760px) {
  .timeline-stats { grid-template-columns: 1fr 1fr; }
  .timeline-stat:nth-child(2) { border-right: none; }
  .timeline-stat:nth-child(1), .timeline-stat:nth-child(2) { border-bottom: 1px solid var(--line); }
}

/* Frame upgrades */
.timeline-frame {
  border-radius: 20px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 1) inset,
    0 30px 70px rgba(15, 26, 26, 0.09);
}

/* Now-playhead — moves through weeks */
.timeline-playhead {
  bottom: 0;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  transition: left 0.5s cubic-bezier(0.34, 1.4, 0.52, 1), opacity 0.3s ease;
  width: 2px;
  z-index: 4;
}

.timeline-playhead.is-positioned { opacity: 1; }

.timeline-playhead::before {
  background: linear-gradient(180deg, transparent 0%, rgba(42, 157, 143, 0.55) 18%, rgba(42, 157, 143, 0.55) 82%, transparent 100%);
  bottom: 0;
  content: "";
  left: 0;
  position: absolute;
  top: 0;
  width: 2px;
}

.timeline-playhead-flag {
  background: var(--ink);
  border: 2px solid var(--brand-mid);
  border-radius: 999px;
  color: #fff;
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 800;
  left: 50%;
  letter-spacing: 0.14em;
  padding: 4px 10px;
  position: absolute;
  text-transform: uppercase;
  top: -10px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.timeline-playhead-flag::after {
  background: var(--brand-mid);
  border-radius: 50%;
  bottom: -3px;
  content: "";
  height: 6px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%);
  width: 6px;
}

/* Axis — clickable scrub */
.timeline-axis-weeks { cursor: pointer; }

.timeline-axis-week {
  padding: 14px 0 14px 8px;
  position: relative;
  transition: color 0.2s ease;
}

.timeline-axis-week:hover { color: var(--brand-mid); }

.timeline-axis-week.is-now {
  color: var(--brand-mid);
  font-weight: 800;
}

/* Bar enhancements — icon + week range */
.timeline-bar {
  align-items: center;
  display: flex;
  font-size: 12.5px;
  gap: 10px;
  padding: 0 12px;
  position: relative;
  transition: transform 0.4s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.timeline-bar-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Tight bars (span < 3 weeks) — hide chrome so the label survives */
.timeline-bar.is-tight .timeline-bar-icon,
.timeline-bar.is-tight .timeline-bar-weeks { display: none; }
.timeline-bar.is-tight { padding: 0 10px; }

.timeline-bar::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  content: "";
  height: 100%;
  left: -100%;
  position: absolute;
  top: 0;
  width: 50%;
  transition: left 0.6s ease;
}

.timeline-bar:hover::after { left: 150%; }

.timeline-bar.is-passed {
  filter: saturate(0.6);
  opacity: 0.78;
}

.timeline-bar.is-passed .timeline-bar-check {
  display: inline-flex;
}

.timeline-bar-check {
  align-items: center;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  color: #1D6D68;
  display: none;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 900;
  height: 18px;
  justify-content: center;
  width: 18px;
}

.timeline-bar-icon {
  align-items: center;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  display: inline-flex;
  flex-shrink: 0;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.timeline-bar-icon svg {
  height: 14px;
  stroke: #fff;
  stroke-width: 1.8;
  width: 14px;
}

.timeline-bar-weeks {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-left: auto;
  padding: 3px 8px;
  text-transform: uppercase;
}

@media (max-width: 760px) {
  .timeline-bar-weeks, .timeline-bar-icon { display: none; }
}

/* Milestone diamonds along the rows */
.timeline-milestone {
  align-items: center;
  background: #fff;
  border: 2px solid var(--brand-mid);
  border-radius: 4px;
  cursor: help;
  display: inline-flex;
  height: 12px;
  justify-content: center;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%) rotate(45deg);
  transition: all 0.2s ease;
  width: 12px;
  z-index: 3;
}

.timeline-milestone:hover {
  background: var(--brand-mid);
  transform: translate(-50%, -50%) rotate(45deg) scale(1.25);
}

.timeline-milestone-tip {
  background: var(--ink);
  border-radius: 6px;
  bottom: calc(100% + 14px);
  color: #fff;
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  left: 50%;
  letter-spacing: -0.005em;
  opacity: 0;
  padding: 6px 10px;
  pointer-events: none;
  position: absolute;
  text-transform: none;
  transform: translateX(-50%) rotate(-45deg);
  transition: opacity 0.2s ease;
  white-space: nowrap;
  z-index: 5;
}

.timeline-milestone:hover .timeline-milestone-tip { opacity: 1; }

/* Dependency hairlines — drawn dynamically from one bar's end to the next's start */
.timeline-deps {
  inset: 0;
  pointer-events: none;
  position: absolute;
  z-index: 1;
}

.timeline-deps svg {
  height: 100%;
  width: 100%;
}

.timeline-deps path {
  fill: none;
  stroke: rgba(42, 157, 143, 0.4);
  stroke-dasharray: 3 4;
  stroke-width: 1.3;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.timeline-frame.is-revealed .timeline-deps path { opacity: 1; }

/* Detail drawer — richer */
.timeline-detail {
  max-height: 0;
}

.timeline-detail.is-open {
  max-height: 460px;
}

.timeline-detail-meta {
  background: linear-gradient(180deg, rgba(42, 157, 143, 0.04), transparent);
  border-right: 1px solid var(--line);
  padding: 26px 22px 26px 28px;
  position: relative;
}

.timeline-detail-meta::before {
  background: var(--gradient-brand);
  border-radius: 0 4px 4px 0;
  content: "";
  height: 28px;
  left: 0;
  position: absolute;
  top: 30px;
  width: 3px;
}

.timeline-detail-meta .eyebrow {
  margin-bottom: 14px;
}

.timeline-detail-meta strong {
  display: block;
  margin-bottom: 6px;
}

.timeline-detail-meta small {
  display: block;
  margin-top: 2px;
}

.timeline-detail-body {
  padding: 26px 32px;
}

.timeline-detail-body h4 {
  font-size: 22px;
  letter-spacing: -0.014em;
  line-height: 1.18;
  margin: 0 0 10px;
}

.timeline-detail-body > p {
  font-size: 15px;
  line-height: 1.6;
  margin-bottom: 22px;
  max-width: 620px;
}

.timeline-detail-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
}

.timeline-detail-deliv {
  grid-template-columns: 1fr;
}

.timeline-detail-deliv li {
  align-items: flex-start;
  background: linear-gradient(180deg, #fff, #fafcfb);
  font-size: 13px;
  font-weight: 600;
  gap: 12px;
  line-height: 1.4;
  padding: 12px 14px;
  position: relative;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.timeline-detail-deliv li:hover {
  border-color: rgba(42, 157, 143, 0.4);
  transform: translateX(2px);
}

.timeline-detail-deliv li::before {
  background: var(--gradient-brand);
  height: 7px;
  margin-top: 6px;
  width: 7px;
}

.timeline-detail-deliv li small {
  color: var(--muted);
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  margin-top: 2px;
}

/* Outcomes side panel */
.timeline-outcomes {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 18px 14px;
}

.timeline-outcomes-head {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.timeline-outcomes-head svg {
  color: var(--brand-mid);
  height: 16px;
  width: 16px;
}

.timeline-outcomes-head span {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.timeline-outcomes-list {
  display: grid;
  gap: 12px;
}

.timeline-outcome {
  align-items: baseline;
  display: flex;
  gap: 10px;
}

.timeline-outcome-num {
  color: var(--brand-deep);
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.018em;
  min-width: 78px;
}

.timeline-outcome-num small {
  color: var(--brand-mid);
  font-size: 12px;
  font-weight: 700;
  margin-left: 3px;
}

.timeline-outcome-text {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

@media (max-width: 900px) {
  .timeline-detail-grid { grid-template-columns: 1fr; }
}

/* Phase nav above chart */
.timeline-phase-nav {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 14px;
}

.timeline-phase-pill {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  gap: 8px;
  letter-spacing: 0.1em;
  padding: 7px 14px;
  text-transform: uppercase;
  transition: all 0.2s ease;
}

.timeline-phase-pill:hover { color: var(--ink); }

.timeline-phase-pill.is-active {
  background: var(--ink);
  color: #fff;
}

.timeline-phase-pill-dot {
  border-radius: 50%;
  height: 6px;
  width: 6px;
}

.timeline-phase-pill[data-phase="01"] .timeline-phase-pill-dot { background: linear-gradient(135deg, #2A9D8F, #7FC174); }
.timeline-phase-pill[data-phase="02"] .timeline-phase-pill-dot { background: linear-gradient(135deg, #1D6D68, #0E4A46); }
.timeline-phase-pill[data-phase="03"] .timeline-phase-pill-dot { background: linear-gradient(135deg, #0E4A46, #1D6D68); }

.timeline-phase-spacer { flex: 1; min-width: 12px; }

.timeline-phase-controls {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.timeline-phase-control {
  align-items: center;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 14px;
  height: 28px;
  justify-content: center;
  transition: all 0.2s ease;
  width: 28px;
}

.timeline-phase-control:hover {
  border-color: var(--brand-mid);
  color: var(--brand-deep);
}

.timeline-phase-control.is-playing svg { color: var(--brand-mid); }
