/**
 * Section: Timeline
 * Variants: [data-variant="light"] (default), [data-variant="dark"], [data-variant="muted"]
 */

.timeline {
  padding-block: var(--section-py);
  background: var(--color-bg);
}

.timeline[data-variant="dark"]  { background: var(--color-bg-dark); }
.timeline[data-variant="muted"] { background: var(--color-bg-subtle); }

/* ─── Header ─────────────────────────────────── */

.timeline__header {
  text-align: center;
  max-width: 640px;
  margin: 0 auto var(--space-16);
}

.timeline__heading {
  color: var(--color-text);
  margin-top: var(--space-3);
  margin-bottom: var(--space-4);
}

.timeline[data-variant="dark"] .timeline__heading {
  color: var(--color-text-on-dark);
}

.timeline__subtext {
  font-size: var(--text-md);
  color: var(--color-text-subtle);
  line-height: var(--leading-relaxed);
}

.timeline[data-variant="dark"] .timeline__subtext {
  color: rgba(255, 255, 255, 0.55);
}

/* ─── List / spine ───────────────────────────── */

.timeline__list {
  position: relative;
  max-width: 960px;
  margin-inline: auto;
}

/* Center vertical spine - desktop */
.timeline__list::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--color-border);
  transform: translateX(-50%);
}

.timeline[data-variant="dark"] .timeline__list::before {
  background: rgba(255, 255, 255, 0.1);
}

/* ─── Event ──────────────────────────────────── */

.timeline-event {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 2px 1fr;
  gap: var(--space-8);
  align-items: center;
  padding-block: var(--space-8);
}

/* Pin every child to row 1 so explicit grid-column assignments don't get
   displaced by auto-placement cursor advancing past usable cells on
   alternating-side rows (the fix for misaligned even-row dates). */
.timeline-event > * { grid-row: 1; }

/* Left-side event (odd) */
.timeline-event:nth-child(odd) .timeline-event__meta  { grid-column: 1; text-align: right; justify-self: end; }
.timeline-event:nth-child(odd) .timeline-event__card  { grid-column: 3; }

/* Right-side event (even) */
.timeline-event:nth-child(even) .timeline-event__meta { grid-column: 3; text-align: left; justify-self: start; }
.timeline-event:nth-child(even) .timeline-event__card { grid-column: 1; }

/* ─── Node ───────────────────────────────────── */

.timeline-event__node {
  grid-column: 2;
  width: 14px;
  height: 14px;
  justify-self: center;
  border-radius: 50%;
  background: var(--color-accent);
  border: 3px solid var(--color-bg);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.timeline[data-variant="dark"] .timeline-event__node {
  background: var(--color-accent);
  border-color: var(--color-bg-dark);
  box-shadow: 0 0 0 2px rgba(205, 250, 137, 0.3);
}

.timeline[data-variant="muted"] .timeline-event__node {
  border-color: var(--color-bg-subtle);
}

/* ─── Date ───────────────────────────────────── */

.timeline-event__date {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  padding: var(--space-2) var(--space-4);
  background: var(--color-bg-subtle);
  border-radius: var(--radius-full);
}

.timeline[data-variant="dark"] .timeline-event__date {
  color: var(--color-text-on-dark);
  background: rgba(255, 255, 255, 0.06);
}

.timeline[data-variant="muted"] .timeline-event__date {
  background: var(--color-bg);
}

/* ─── Card ───────────────────────────────────── */

.timeline-event__card {
  padding: var(--space-6);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: box-shadow var(--transition-normal);
}

.timeline-event__card:hover {
  box-shadow: var(--shadow-md);
}

.timeline[data-variant="dark"] .timeline-event__card {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
}

.timeline[data-variant="dark"] .timeline-event__card:hover {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.timeline-event__title {
  font-family: var(--font-body);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
}

.timeline[data-variant="dark"] .timeline-event__title {
  color: var(--color-text-on-dark);
}

.timeline-event__text {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-text-subtle);
}

.timeline[data-variant="dark"] .timeline-event__text {
  color: rgba(255, 255, 255, 0.55);
}

/* ─── Responsive: left-aligned on mobile ─────── */

@media (max-width: 809px) {
  .timeline { padding-block: var(--section-py-sm); }
  .timeline__header { margin-bottom: var(--space-10); }

  .timeline__list::before {
    left: 7px;
    transform: none;
  }

  .timeline-event {
    grid-template-columns: 16px 1fr;
    gap: var(--space-4);
    padding-block: var(--space-5);
  }

  .timeline-event__node {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    margin-top: var(--space-2);
  }

  .timeline-event:nth-child(odd) .timeline-event__meta,
  .timeline-event:nth-child(even) .timeline-event__meta,
  .timeline-event:nth-child(odd) .timeline-event__card,
  .timeline-event:nth-child(even) .timeline-event__card {
    grid-column: 2;
    text-align: left;
    justify-self: start;
  }

  .timeline-event__meta {
    margin-bottom: var(--space-2);
  }
}
