/* ===== PREMIUM TIMELINE ENHANCEMENTS ===== */

/* --- 1. Alternating left/right layout on desktop --- */
@media (min-width: 769px) {
  .timeline {
    max-width: 760px;
    padding-left: 0;
    position: relative;
  }

  .timeline::before {
    left: 50%;
    transform: translateX(-50%);
    width: 2px;
    background: linear-gradient(180deg,
      transparent 0%,
      rgba(var(--accent-rgb, 255, 51, 51), 0.15) 8%,
      rgba(var(--accent-rgb, 255, 51, 51), 0.25) 50%,
      rgba(var(--accent-rgb, 255, 51, 51), 0.15) 92%,
      transparent 100%
    );
    box-shadow:
      0 0 10px rgba(var(--accent-rgb, 255, 51, 51), 0.12),
      0 0 20px rgba(var(--accent-rgb, 255, 51, 51), 0.06);
  }

  /* Progress fill line — overlays the base line, grows with scroll */
  .timeline::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    width: 2px;
    height: 0%;
    background: linear-gradient(180deg,
      rgba(var(--accent-rgb, 255, 51, 51), 0.9) 0%,
      rgba(var(--accent-rgb, 255, 51, 51), 0.7) 60%,
      rgba(var(--accent-rgb, 255, 51, 51), 0.8) 100%
    );
    box-shadow:
      0 0 8px rgba(var(--accent-rgb, 255, 51, 51), 0.5),
      0 0 20px rgba(var(--accent-rgb, 255, 51, 51), 0.25),
      0 0 40px rgba(var(--accent-rgb, 255, 51, 51), 0.1);
    transition: height 0.3s ease-out;
    z-index: 1;
  }

  .timeline.tl-progress::after {
    height: var(--tl-progress, 0%);
  }

  /* Items sit at 45% width, alternating sides */
  .timeline-item {
    width: 45%;
    margin-bottom: 60px;
    padding-left: 0;
  }

  /* Odd items — LEFT side */
  .timeline-item:nth-child(odd) {
    margin-left: 0;
    margin-right: auto;
    text-align: right;
    padding-right: 36px;
  }

  /* Even items — RIGHT side */
  .timeline-item:nth-child(even) {
    margin-left: auto;
    margin-right: 0;
    text-align: left;
    padding-left: 36px;
  }

  /* Reposition dots to center line */
  .timeline-item:nth-child(odd)::before {
    left: auto;
    right: -5px;
    transform: translateX(50%);
  }

  .timeline-item:nth-child(even)::before {
    left: -5px;
    transform: translateX(-50%);
  }

  /* Connector lines from dots to content — odd (left side) */
  .timeline-item:nth-child(odd)::after {
    content: '';
    position: absolute;
    top: 31px;
    right: -5px;
    width: 32px;
    height: 1px;
    background: linear-gradient(90deg,
      rgba(var(--accent-rgb, 255, 51, 51), 0.4),
      rgba(var(--accent-rgb, 255, 51, 51), 0.15),
      transparent
    );
    transform-origin: right center;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    opacity: 0.6;
  }

  /* Connector lines from dots to content — even (right side) */
  .timeline-item:nth-child(even)::after {
    content: '';
    position: absolute;
    top: 31px;
    left: -5px;
    width: 32px;
    height: 1px;
    background: linear-gradient(270deg,
      rgba(var(--accent-rgb, 255, 51, 51), 0.4),
      rgba(var(--accent-rgb, 255, 51, 51), 0.15),
      transparent
    );
    transform-origin: left center;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    opacity: 0.6;
  }

  /* Hover: extend connector lines */
  .timeline-item:nth-child(odd):hover::after,
  .timeline-item:nth-child(even):hover::after {
    width: 42px;
    opacity: 1;
  }

  /* Hover: direction-aware shift */
  .timeline-item:nth-child(odd):hover {
    transform: translateX(-6px);
  }

  .timeline-item:nth-child(even):hover {
    transform: translateX(6px);
  }

  /* Year underline direction — reversed for left-side items */
  .timeline-item:nth-child(odd) .timeline-year::after {
    left: auto;
    right: 0;
  }
}

/* --- 2. Enhanced dots/nodes with animated rings --- */
.timeline-item::before {
  width: 11px;
  height: 11px;
  z-index: 2;
  border: 2px solid rgba(var(--accent-rgb, 255, 51, 51), 0.8);
  background: #0a0a0f;
  transition: box-shadow 0.4s ease, background 0.4s ease, border-color 0.4s ease, transform 0.4s ease;
}

/* Dot lights up when scrolled past */
.timeline-item.revealed::before {
  background: #ff3333;
  animation: dotPulseEnhanced 2s ease-out 0.3s;
}

@keyframes dotPulseEnhanced {
  0% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb, 255, 51, 51), 0.7),
                0 0 12px rgba(var(--accent-rgb, 255, 51, 51), 0.5),
                0 0 24px rgba(var(--accent-rgb, 255, 51, 51), 0.2);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(var(--accent-rgb, 255, 51, 51), 0),
                0 0 12px rgba(var(--accent-rgb, 255, 51, 51), 0.5),
                0 0 24px rgba(var(--accent-rgb, 255, 51, 51), 0.2);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(var(--accent-rgb, 255, 51, 51), 0),
                0 0 10px rgba(var(--accent-rgb, 255, 51, 51), 0.5),
                0 0 20px rgba(var(--accent-rgb, 255, 51, 51), 0.2);
  }
}

/* --- 3. Premium hover states — card-like elevation with border glow --- */
.timeline-item {
  padding: 20px 24px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1),
              background 0.4s ease,
              border-color 0.4s ease,
              box-shadow 0.5s ease;
}

.timeline-item:hover {
  background: rgba(var(--accent-rgb, 255, 51, 51), 0.03);
  border-color: rgba(var(--accent-rgb, 255, 51, 51), 0.15);
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.3),
    0 0 30px rgba(var(--accent-rgb, 255, 51, 51), 0.06),
    inset 0 1px 0 rgba(var(--accent-rgb, 255, 51, 51), 0.08);
}

.timeline-item:hover::before {
  background: var(--accent, #ff5555);
  border-color: var(--accent, #ff5555);
  transform: scale(1.3);
  box-shadow:
    0 0 14px rgba(var(--accent-rgb, 255, 51, 51), 0.8),
    0 0 30px rgba(var(--accent-rgb, 255, 51, 51), 0.4),
    0 0 50px rgba(var(--accent-rgb, 255, 51, 51), 0.15);
}

@media (min-width: 769px) {
  .timeline-item:nth-child(odd):hover::before {
    transform: translateX(50%) scale(1.3);
  }
  .timeline-item:nth-child(even):hover::before {
    transform: translateX(-50%) scale(1.3);
  }
}

/* --- 4. Pulsing "current" indicator on last timeline item (The Future) --- */
.timeline-item:last-child::before {
  border-color: rgba(var(--accent-rgb, 255, 51, 51), 0.9);
  background: transparent;
  animation: currentPulse 2.5s ease-in-out infinite;
}

.timeline-item:last-child.revealed::before {
  background: transparent;
  animation: currentPulse 2.5s ease-in-out infinite;
}

@keyframes currentPulse {
  0%, 100% {
    border-color: rgba(var(--accent-rgb, 255, 51, 51), 0.8);
    box-shadow:
      0 0 8px rgba(var(--accent-rgb, 255, 51, 51), 0.4),
      0 0 20px rgba(var(--accent-rgb, 255, 51, 51), 0.15),
      0 0 0 0 rgba(var(--accent-rgb, 255, 51, 51), 0.3);
  }
  50% {
    border-color: rgba(var(--accent-rgb, 255, 51, 51), 1);
    box-shadow:
      0 0 14px rgba(var(--accent-rgb, 255, 51, 51), 0.7),
      0 0 30px rgba(var(--accent-rgb, 255, 51, 51), 0.3),
      0 0 0 8px rgba(var(--accent-rgb, 255, 51, 51), 0);
  }
}

/* "The Future" label shimmer effect */
.timeline-item:last-child .timeline-year {
  background: linear-gradient(90deg,
    #ff3333 0%,
    #ff8844 40%,
    #ff3333 80%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: futureShimmer 4s ease-in-out infinite;
}

@keyframes futureShimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* --- 5. Mobile adjustments — keep stacked layout --- */
@media (max-width: 768px) {
  .timeline {
    padding-left: 34px;
  }

  .timeline-item::before {
    left: -28px;
    top: 24px;
  }

  .timeline-item {
    padding: 16px 18px;
    margin-bottom: 40px;
  }

  /* Mobile connector lines from dot to card */
  .timeline-item::after {
    content: '';
    position: absolute;
    top: 28px;
    left: -18px;
    width: 16px;
    height: 1px;
    background: linear-gradient(90deg,
      rgba(var(--accent-rgb, 255, 51, 51), 0.3),
      transparent
    );
  }

  /* Progress line on mobile — stays left */
  .timeline::after {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    width: 1px;
    height: 0%;
    background: linear-gradient(180deg,
      rgba(var(--accent-rgb, 255, 51, 51), 0.9),
      rgba(var(--accent-rgb, 255, 51, 51), 0.7)
    );
    box-shadow:
      0 0 6px rgba(var(--accent-rgb, 255, 51, 51), 0.4),
      0 0 14px rgba(var(--accent-rgb, 255, 51, 51), 0.15);
    transition: height 0.3s ease-out;
    z-index: 1;
  }

  .timeline.tl-progress::after {
    height: var(--tl-progress, 0%);
  }
}

/* --- 6. Active item highlight (IntersectionObserver-driven) --- */
.timeline-item.tl-active {
  background: rgba(var(--accent-rgb, 255, 51, 51), 0.05);
  border-color: rgba(var(--accent-rgb, 255, 51, 51), 0.2);
  box-shadow:
    0 4px 24px rgba(0, 0, 0, 0.25),
    0 0 40px rgba(var(--accent-rgb, 255, 51, 51), 0.08),
    inset 0 1px 0 rgba(var(--accent-rgb, 255, 51, 51), 0.1);
}

.timeline-item.tl-active::before {
  background: var(--accent, #ff5555);
  border-color: var(--accent, #ff5555);
  box-shadow:
    0 0 12px rgba(var(--accent-rgb, 255, 51, 51), 0.7),
    0 0 24px rgba(var(--accent-rgb, 255, 51, 51), 0.35),
    0 0 48px rgba(var(--accent-rgb, 255, 51, 51), 0.12);
  transform: scale(1.2);
}

@media (min-width: 769px) {
  .timeline-item:nth-child(odd).tl-active::before {
    transform: translateX(50%) scale(1.2);
  }
  .timeline-item:nth-child(even).tl-active::before {
    transform: translateX(-50%) scale(1.2);
  }
}

.timeline-item.tl-active .timeline-year {
  color: var(--accent, #ff5555);
  text-shadow: 0 0 16px rgba(var(--accent-rgb, 255, 51, 51), 0.4);
}

.timeline-item.tl-active .timeline-text {
  color: rgba(255, 255, 255, 0.9);
}

/* Smooth transitions for active state */
.timeline-item .timeline-year,
.timeline-item .timeline-text {
  transition: color 0.4s ease, text-shadow 0.4s ease;
}

/* --- 7. Scroll percentage indicator --- */
.tl-percent {
  position: sticky;
  top: 80px;
  float: right;
  margin-right: -60px;
  font-family: 'Inter', sans-serif;
  font-size: 0.6rem;
  font-weight: 300;
  letter-spacing: 0.15em;
  color: var(--accent, #ff5555);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 5;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(var(--accent-rgb, 255, 51, 51), 0.3);
}

@media (max-width: 900px) {
  .tl-percent {
    display: none;
  }
}
