/* Timeline - dynamic height & year positions via timeline.js */
.timeline {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px 0 40px;
  min-height: 2400px; /* fallback, JS sets based on cards */
  /* Center axis: vertical line + dashed ticks (12px period) */
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 9px,
    #94a3b8 9px,
    #94a3b8 12px
  );
  background-size: 2px 100%;
  background-position: center top;
  background-repeat: repeat-y;
}

/* Year ruler - positions set by JS based on card density */
.timeline-ruler {
  position: absolute;
  left: 50%;
  margin-left: 12px;
  top: 20px;
  width: 36px;
  height: 100%;
  min-height: 2400px;
  z-index: 3;
  pointer-events: none;
}

/* Year positions set inline from card boundaries (non-uniform) */
.timeline-year {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 600;
  color: #9ca3af;
  letter-spacing: 0.05em;
  transform: translateY(-50%);
  white-space: nowrap;
}

.timeline-items {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  min-height: 2400px;
  z-index: 2;
}

/* Items positioned by start date */
.timeline-item {
  position: absolute;
  display: grid;
  grid-template-columns: 1fr 100px 1fr; /* wider center gap: cards away from axis */
  align-items: start;
  gap: 0;
  padding: 0 0 20px 0;
  width: 100%;
  box-sizing: border-box;
}

/* Odd: card on left, circle in center */
.timeline-item:nth-child(odd) .timeline-content {
  grid-column: 1;
  grid-row: 1;
  justify-self: end;
  max-width: 100%;
}

.timeline-item:nth-child(odd) .timeline-circle-left {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.timeline-item:nth-child(odd) .timeline-circle-right {
  display: none;
}

/* Even: circle in center, card on right */
.timeline-item:nth-child(even) .timeline-content {
  grid-column: 3;
  grid-row: 1;
  justify-self: start;
  max-width: 100%;
}

.timeline-item:nth-child(even) .timeline-circle-right {
  grid-column: 2;
  grid-row: 1;
  justify-self: center;
}

.timeline-item:nth-child(even) .timeline-circle-left {
  display: none;
}

/* Circle - top edge aligns with card top (event start point) */
.timeline-circle-left,
.timeline-circle-right {
  width: 25px;
  height: 25px;
  min-width: 25px;
  min-height: 25px;
  background-color: white;
  border: 4px solid #2196F3;
  border-radius: 50%;
  margin-top: 0; /* align circle top with card top */
  z-index: 2;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.timeline-content {
  width: calc(100% - 20px);
  max-width: 380px; /* slightly narrower so cards stay clear of center */
}

.timeline-item .timeline-content h3 {
  margin: 0;
}

.timeline-item .timeline-content p {
  margin: 0;
}

h2 {
  text-align: center;
  font-size: 2em;
  margin-bottom: 40px;
}

/* Responsive - flow layout on mobile, no scale */
@media screen and (max-width: 768px) {
  .timeline {
    min-height: auto;
    background-position: 30px top;
    background-image: repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 8px,
      #94a3b8 8px,
      #94a3b8 10px
    );
  }

  .timeline-ruler {
    display: none;
  }

  .timeline-items {
    position: relative;
    top: 0;
    min-height: 0;
  }

  .timeline-item {
    position: relative !important;
    top: auto !important;
    margin-bottom: 2.5rem;
  }

  .timeline-item:last-child {
    margin-bottom: 0;
  }

  .timeline-circle-left,
  .timeline-circle-right {
    margin-top: 0.5rem;
  }

  .timeline-item {
    grid-template-columns: 60px 1fr;
  }

  .timeline-item:nth-child(odd) .timeline-content,
  .timeline-item:nth-child(even) .timeline-content {
    grid-column: 2;
    justify-self: start;
  }

  .timeline-item:nth-child(odd) .timeline-circle-left,
  .timeline-item:nth-child(even) .timeline-circle-right {
    grid-column: 1;
    grid-row: 1;
  }

  .timeline-item:nth-child(odd) .timeline-circle-right,
  .timeline-item:nth-child(even) .timeline-circle-left {
    display: none;
  }

  .timeline-content {
    width: 100%;
    max-width: none;
  }
}
