/*
 * Premium Interactive Timeline for Paul Aizpiri Biography
 * Enhanced with animations, scroll effects, and visual flourishes
 */

/* ============================================
   PREMIUM INTERACTIVE TIMELINE
   ============================================ */

/* Timeline Container */
.timeline {
  position: relative;
  padding: var(--space-4xl) 0;
  scroll-snap-type: y proximity;
}

/* Central Animated Timeline Line */
.timeline::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(
    to bottom,
    var(--color-gold) 0%,
    var(--color-secondary) 50%,
    var(--color-accent) 100%
  );
  transform: translateX(-50%);
  box-shadow: 0 0 20px rgba(196, 163, 90, 0.3);
  border-radius: var(--border-radius-full);
  z-index: 1;
}

/* Drawing animation overlay */
.timeline::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 4px;
  height: 0%;
  background: linear-gradient(
    to bottom,
    rgba(196, 163, 90, 0.8) 0%,
    rgba(44, 95, 124, 0.8) 50%,
    rgba(196, 163, 90, 0.8) 100%
  );
  transform: translateX(-50%);
  animation: timeline-draw 2s ease-out forwards;
  box-shadow: 0 0 30px rgba(196, 163, 90, 0.6);
  border-radius: var(--border-radius-full);
  z-index: 2;
}

@keyframes timeline-draw {
  to {
    height: 100%;
  }
}

/* Decorative background particles */
.timeline-section {
  position: relative;
  overflow: hidden;
}

.timeline-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(196, 163, 90, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 80% 60%, rgba(44, 95, 124, 0.05) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  opacity: 0.6;
  z-index: 0;
}

/* Timeline Items */
.timeline-item {
  position: relative;
  margin-bottom: var(--space-4xl);
  display: flex;
  align-items: flex-start;
  gap: var(--space-2xl);
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  scroll-snap-align: start;
}

/* Animated entrance when in view */
.timeline-item.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* Alternate left/right layout */
.timeline-item:nth-child(even) {
  flex-direction: row-reverse;
}

.timeline-item:nth-child(odd) .timeline-content {
  transform-origin: left center;
}

.timeline-item:nth-child(even) .timeline-content {
  transform-origin: right center;
  text-align: right;
}

.timeline-item.in-view:nth-child(odd) .timeline-content {
  animation: slide-in-left 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.timeline-item.in-view:nth-child(even) .timeline-content {
  animation: slide-in-right 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slide-in-right {
  from {
    opacity: 0;
    transform: translateX(50px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Timeline Content Cards */
.timeline-content {
  flex: 1;
  max-width: calc(50% - 60px);
  background: linear-gradient(
    135deg,
    var(--color-surface) 0%,
    var(--color-surface-alt) 100%
  );
  padding: var(--space-2xl);
  border-radius: var(--border-radius-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: visible;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--color-border-light);
  z-index: 1;
}

/* Decorative corner accent */
.timeline-content::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, transparent 50%, rgba(196, 163, 90, 0.1) 100%);
  pointer-events: none;
  z-index: -1;
}

/* Connection line to marker */
.timeline-content::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40px;
  height: 2px;
  background: linear-gradient(
    to right,
    var(--color-accent),
    transparent
  );
  z-index: 0;
}

.timeline-item:nth-child(odd) .timeline-content::after {
  right: -40px;
  transform: translateY(-50%);
}

.timeline-item:nth-child(even) .timeline-content::after {
  left: -40px;
  transform: translateY(-50%) scaleX(-1);
}

/* Hover effects */
.timeline-content:hover {
  box-shadow: var(--shadow-2xl);
  transform: translateY(-8px) scale(1.02);
  border-color: var(--color-accent);
}

/* Highlight items with gradient border */
.timeline-item-highlight .timeline-content {
  background: linear-gradient(
    135deg,
    var(--color-surface) 0%,
    rgba(196, 163, 90, 0.05) 100%
  );
  border: 2px solid var(--color-accent);
  box-shadow: 0 0 30px rgba(196, 163, 90, 0.2);
}

/* Animated gradient border for highlights */
.timeline-item-highlight .timeline-content::before {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: var(--border-radius-xl);
  background: linear-gradient(135deg, var(--color-gold), var(--color-secondary), var(--color-gold));
  background-size: 200% 200%;
  opacity: 0.3;
  animation: gradient-flow 4s ease-in-out infinite;
  z-index: -2;
}

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

@keyframes border-glow {
  0%, 100% {
    opacity: 0.6;
    filter: blur(0px);
  }
  50% {
    opacity: 1;
    filter: blur(2px);
  }
}

/* Timeline Markers with pulse animation */
.timeline-marker {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 32px;
  background-color: var(--color-accent);
  border: 6px solid var(--color-surface);
  border-radius: var(--border-radius-full);
  box-shadow: 0 0 0 0 rgba(196, 163, 90, 0.7),
              0 4px 12px rgba(196, 163, 90, 0.4);
  z-index: 3;
  transition: all 0.3s ease;
  animation: pulse-marker 2s ease-in-out infinite;
  cursor: pointer;
}

@keyframes pulse-marker {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(196, 163, 90, 0.7),
                0 4px 12px rgba(196, 163, 90, 0.4);
  }
  50% {
    box-shadow: 0 0 0 15px rgba(196, 163, 90, 0),
                0 4px 20px rgba(196, 163, 90, 0.6);
  }
}

/* Larger markers for highlight events */
.timeline-item-highlight .timeline-marker {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-gold), var(--color-accent-dark));
  box-shadow: 0 0 0 0 rgba(196, 163, 90, 0.9),
              0 6px 20px rgba(196, 163, 90, 0.6);
  animation: pulse-marker-large 2s ease-in-out infinite;
}

@keyframes pulse-marker-large {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(196, 163, 90, 0.9),
                0 6px 20px rgba(196, 163, 90, 0.6);
  }
  50% {
    box-shadow: 0 0 0 20px rgba(196, 163, 90, 0),
                0 6px 30px rgba(196, 163, 90, 0.8);
  }
}

.timeline-marker:hover {
  transform: translateX(-50%) scale(1.3);
  box-shadow: 0 0 0 20px rgba(196, 163, 90, 0),
              0 6px 30px rgba(196, 163, 90, 0.8);
}

/* Year Display - Large and Sticky with gradient */
.timeline-year {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: var(--weight-bold);
  background: linear-gradient(135deg, var(--color-gold), var(--color-secondary));
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: var(--space-md);
  letter-spacing: -0.02em;
  display: inline-block;
  position: relative;
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
  0%, 100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.2);
  }
}

/* Timeline Title */
.timeline-title {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-md);
  color: var(--color-text-primary);
  font-weight: var(--weight-semibold);
  position: relative;
}

.timeline-item.in-view .timeline-title {
  animation: fade-slide-up 0.6s ease 0.2s forwards;
}

/* Timeline Description */
.timeline-description {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  position: relative;
}

.timeline-item.in-view .timeline-description {
  animation: fade-slide-up 0.6s ease 0.4s forwards;
}

/* Legacy timeline-date class for compatibility */
.timeline-date {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
}

@keyframes fade-slide-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scroll Progress Indicator */
.timeline-progress {
  position: fixed;
  top: var(--header-height);
  right: 2rem;
  width: 4px;
  height: calc(100vh - var(--header-height) - 4rem);
  background: var(--color-border-light);
  border-radius: var(--border-radius-full);
  z-index: var(--z-sticky);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.timeline-progress.visible {
  opacity: 1;
}

.timeline-progress-bar {
  width: 100%;
  height: 0%;
  background: linear-gradient(to bottom, var(--color-gold), var(--color-secondary));
  border-radius: var(--border-radius-full);
  transition: height 0.1s ease-out;
  box-shadow: 0 0 10px rgba(196, 163, 90, 0.5);
}

/* Decorative brush strokes - varied colors */
.timeline-item:nth-child(3n+1) .timeline-content::before {
  background: linear-gradient(135deg, transparent 50%, rgba(196, 163, 90, 0.15) 100%);
}

.timeline-item:nth-child(3n+2) .timeline-content::before {
  background: linear-gradient(135deg, transparent 50%, rgba(44, 95, 124, 0.1) 100%);
}

.timeline-item:nth-child(3n+3) .timeline-content::before {
  background: linear-gradient(135deg, transparent 50%, rgba(196, 163, 90, 0.08) 100%);
}

/* Mobile Responsive - Single Column */
@media (max-width: 768px) {
  .timeline::before,
  .timeline::after {
    left: 20px;
    transform: none;
  }

  .timeline-item {
    flex-direction: column !important;
    padding-left: 60px;
    margin-bottom: var(--space-3xl);
  }

  .timeline-item:nth-child(even) .timeline-content {
    text-align: left;
  }

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

  .timeline-content::after {
    display: none;
  }

  .timeline-marker {
    left: 20px;
    transform: translateX(-50%);
  }

  .timeline-item:nth-child(odd) .timeline-content,
  .timeline-item:nth-child(even) .timeline-content {
    animation: slide-in-mobile 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  }

  @keyframes slide-in-mobile {
    from {
      opacity: 0;
      transform: translateX(30px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }

  .timeline-progress {
    right: 1rem;
    width: 3px;
  }

  .timeline-year {
    font-size: clamp(1.5rem, 8vw, 2.5rem);
  }
}

/* Tablet adjustments */
@media (max-width: 1024px) {
  .timeline-content {
    padding: var(--space-xl);
  }

  .timeline-year {
    font-size: clamp(1.75rem, 6vw, 3rem);
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  .timeline::after {
    animation: none;
    height: 100%;
  }

  .timeline-marker {
    animation: none;
  }

  .timeline-item {
    opacity: 1;
    transform: none;
  }

  .timeline-content:hover {
    transform: none;
  }

  .timeline-year {
    animation: none;
  }
}
