/* ── HOW IT WORKS ── */
.how-section {
  background: transparent;
  padding: 80px 40px;
  z-index: 10;
}

/* No italic, unified color for all text inside this section */
.how-section em {
  font-style: normal;
  color: inherit;
}

.how-header {
  margin-bottom: 64px;
  text-align: center;
}
.how-header .lead {
  margin-top: 12px;
  color: var(--text);
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}

/* ── TIMELINE — 4 equal steps + infinity endpoint ── */
.timeline {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  position: relative;
}

/* Infinity endpoint: same row as timeline cards */
.tl-end-item {
  display: flex;
  margin-top: 0;
}

/* Position infinity visually over the 4th column without affecting grid flow */
.tl-end-item {
  position: absolute;
  top: 6px; /* nudge down to match dot vertical position */
  left: 100%; /* align with end of 4th connector (right edge of timeline) */
  transform: translateX(-50%);
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ── TIMELINE ITEM ── */
.timeline-item {
  display: flex;
  flex-direction: column;
  /* Controlled by GSAP: starts invisible */
  opacity: 0;
  transform: translateY(24px);
  will-change: opacity, transform;
}

/* ── NODE row: dot-wrap on left, connector extends right ── */
.tl-node {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

/* Dot + number stacked */
.tl-dot-wrap {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
}

.tl-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  background: var(--bg);
  transition: border-color 0.3s, background 0.3s, box-shadow 0.3s;
}

.tl-num {
  font-family: var(--ff-d);
  font-size: 12px;
  color: var(--text);
  letter-spacing: 0.05em;
  opacity: 1;
}

/* Animated connector line — horizontal, fills remaining width */
.tl-connector {
  flex: 1;
  height: 14px;
  display: block;
  overflow: visible;
  pointer-events: none;
  margin-left: 6px;
}
.tl-connector-line {
  stroke: var(--border2);
  stroke-width: 1.5;
  stroke-linecap: round;
  fill: none;
  /* stroke-dasharray and stroke-dashoffset set by JS */
}

/* ── STEP BODY ── */
.tl-body {
  flex: 1;
  padding: 20px 16px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tl-icon  { font-size: 26px }

.tl-title {
  font-family: var(--ff-d);
  font-size: 20px;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text);
}

.tl-desc {
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}

.tl-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

/* Infinity endpoint — no body content, just the symbol */
.tl-end-item .tl-body { display: none }

/* Infinity symbol */
.tl-infinity {
  font-size: 26px;
  line-height: 1;
  color: rgba(139, 92, 246, 0.4);
  transition: color 0.3s, text-shadow 0.3s;
  user-select: none;
}

/* ── PER-STEP DOT COLORS ── */
.timeline-item:nth-child(1) .tl-dot        { border-color: var(--g) }
.timeline-item:nth-child(2) .tl-dot        { border-color: var(--a) }
.timeline-item:nth-child(3) .tl-dot        { border-color: var(--b) }
.timeline-item:nth-child(4) .tl-dot        { border-color: var(--r) }

.timeline-item:nth-child(1) .tl-connector-line { stroke: rgba(26, 125, 26, 0.35) }
.timeline-item:nth-child(2) .tl-connector-line { stroke: rgba(245, 168, 0, 0.35) }
.timeline-item:nth-child(3) .tl-connector-line { stroke: rgba(58, 127, 213, 0.35) }
.timeline-item:nth-child(4) .tl-connector-line { stroke: rgba(176, 48, 16, 0.35) }

/* ── RESPONSIVE ── */
@media (max-width: 960px) {
  .how-section { padding: 60px 20px }
  .timeline    { grid-template-columns: repeat(2, 1fr); gap: 32px 0 }
  .how-header  { margin-bottom: 48px }
  .tl-end-item { display: none }
}
@media (max-width: 600px) {
  .how-section { padding: 40px 20px }
  .timeline {
    grid-template-columns: 1fr;
    gap: 28px 0;
    position: relative;
    padding-left: 0;
  }
  .tl-connector { display: none }

  /* Timeline item container */
  .timeline-item {
    display: grid;
    grid-template-columns: 48px auto 1fr;
    grid-template-rows: auto auto auto;
    align-items: center;
    column-gap: 16px;
    row-gap: 12px;
    position: relative;
    opacity: 1;
    transform: none;
  }

  /* Vertical connecting line */
  .timeline-item::before {
    content: '';
    position: absolute;
    left: 23px;
    top: 64px; /* 48px dot height + 16px gap */
    bottom: -12px; /* -28px gap + 16px padding */
    width: 2px;
    z-index: 0;
    border-radius: 2px; /* make ends slightly rounded like stroke-linecap: round */
  }
  
  .timeline-item:nth-child(1)::before { background: var(--g); opacity: 0.8; }
  .timeline-item:nth-child(2)::before { background: var(--a); opacity: 0.8; }
  .timeline-item:nth-child(3)::before { background: var(--b); opacity: 0.8; }
  .timeline-item:nth-child(4)::before { 
    background: var(--r); 
    opacity: 0.8; 
    bottom: -20px; /* Adjust for infinity icon to maintain 16px visual gap */
  }

  .timeline-item:last-of-type::before {
    display: none;
  }

  .tl-node, .tl-body {
    display: contents;
  }

  /* Dot wrapper and dot */
  .tl-dot-wrap {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 2;
  }

  .tl-dot {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2.5px solid;
    background: var(--bg);
    position: absolute;
    top: 0;
    left: 0;
  }

  .tl-num {
    font-size: 16px;
    font-weight: 500;
    opacity: 1;
    color: inherit;
    position: relative;
    z-index: 1;
  }

  /* Icon and title stay on first row */
  .tl-icon {
    grid-column: 2;
    grid-row: 1;
    font-size: 24px;
    line-height: 1.2;
  }

  .tl-title {
    grid-column: 3;
    grid-row: 1;
    font-size: 18px;
    font-weight: 500;
    color: var(--text);
    margin: 0;
    line-height: 1.2;
  }

  /* Description and tags */
  .tl-desc {
    grid-column: 2 / -1;
    grid-row: 2;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    margin: 0;
  }

  .tl-tags {
    grid-column: 2 / -1;
    grid-row: 3;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .tech-tag {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* Infinity endpoint — just the symbol */
  .tl-end-item {
    display: grid;
    grid-template-columns: 48px auto 1fr;
    column-gap: 16px;
    opacity: 1;
    transform: none;
    position: relative;
    z-index: 2;
    margin-top: 0;
    left: auto;
  }

  .tl-end-item::before {
    display: none;
  }

  .tl-end-item .tl-dot-wrap {
    display: flex;
    background: transparent;
    border: none;
  }

  .tl-infinity {
    font-size: 32px;
    color: rgba(139, 92, 246, 0.5);
    line-height: 1;
  }

  .tl-end-item .tl-body {
    display: none;
  }
}
