/* Portfolio Animations - Phase 3: Advanced Polish */
/* Efficient, minimal, dynamic - no layout breaking */

/* ===== REMOVED OLD VIEW INDICATOR ===== */

/* ===== PHASE 3: ADVANCED POLISH ===== */

/* 1. View Transition Animations */
.timeline-container, .grid-container {
  animation: viewFadeIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes viewFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 2. Timeline Cascade - Opt-in with .cascade-in class */
.timeline-item.cascade-in {
  opacity: 0; transform: translateX(30px);
  animation: cascadeIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.timeline-item.cascade-in:nth-child(1) { animation-delay: 0.1s; }
.timeline-item.cascade-in:nth-child(2) { animation-delay: 0.15s; }
.timeline-item.cascade-in:nth-child(3) { animation-delay: 0.2s; }
.timeline-item.cascade-in:nth-child(4) { animation-delay: 0.25s; }
.timeline-item.cascade-in:nth-child(5) { animation-delay: 0.3s; }
.timeline-item.cascade-in:nth-child(6) { animation-delay: 0.35s; }
.timeline-item.cascade-in:nth-child(n+7) { animation-delay: 0.4s; }

@keyframes cascadeIn {
  to { opacity: 1; transform: translateX(0); }
}

/* 3. Enhanced Orb - Pulse and Trail */
.timeline-position-orb {
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  animation: orbPulse 3s ease-in-out infinite;
}

.timeline-position-orb.moving {
  animation: orbMove 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes orbPulse {
  0%, 100% { box-shadow: 0 0 12px var(--fg); }
  50% { box-shadow: 0 0 20px var(--fg), 0 0 40px rgba(255,255,255,0.3); }
}

@keyframes orbMove {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); box-shadow: 0 0 25px var(--fg); }
  100% { transform: scale(1); }
}

/* 4. Skeleton Loading States */
.loading-skeleton {
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.timeline-skeleton .project-card {
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.1);
  position: relative; overflow: hidden;
}

.timeline-skeleton .project-card::before {
  content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  background-size: 200% 100%; animation: shimmer 1.5s infinite;
}

/* 5. Scroll-Triggered Entrance */
.timeline-item.in-view {
  animation: slideInView 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideInView {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 6. Present Moment Breathing */
.project-card.present-moment {
  animation: breathe 4s ease-in-out infinite;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); box-shadow: none; }
  50% { transform: scale(1.02); box-shadow: 0 0 20px rgba(128,128,128,0.3); }
}

/* ===== ENHANCED HOVER EFFECTS - DESKTOP ONLY ===== */
/* Hover animations only on devices that support hover */
@media (hover: hover) {
  /* Timeline hover - right edge indents, left stays aligned */
  .project-card:not(.present-moment) {
    transition: margin-right 0.3s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }

  /* Right edge moves inward by increasing right margin */
  .project-card:not(.present-moment):hover {
    margin-right: calc(var(--right-padding) + 15px);
    box-shadow: 0 0 20px rgba(255,255,255,0.15);
  }

  /* Tail stays connected - no width change needed */
  .project-card:not(.present-moment):hover::after {
    opacity: 1;
  }

  .grid-card {
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .grid-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 15px 35px rgba(0,0,0,0.4);
  }

  /* Enhanced Timeline Marker */
  .timeline-marker {
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .timeline-marker:hover {
    transform: translateY(-50%) scale(1.15);
    box-shadow: 0 0 20px var(--fg);
  }

  /* Enhanced Buttons */
  button, .splash-btn {
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative; overflow: hidden;
  }

  button::before, .splash-btn::before {
    content: ''; position: absolute; top: 50%; left: 50%;
    width: 0; height: 0; background: rgba(255,255,255,0.1);
    border-radius: 50%; transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
  }

  button:hover::before, .splash-btn:hover::before {
    width: 200%; height: 200%;
  }

  button:hover, .splash-btn:hover {
    transform: translateY(-2px);
  }

  #controls button {
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  }

  #controls button:hover {
    transform: scale(1.1) rotate(5deg);
  }
}

/* Touch device specific styles */
@media (pointer: coarse) {
  /* Simplify animations on touch devices */
  .project-card:not(.present-moment) {
    transition: box-shadow 0.2s ease;
  }
  
  .grid-card {
    transition: transform 0.2s ease;
  }
  
  .timeline-marker {
    transition: all 0.2s ease;
  }
  
  /* Active states for touch feedback */
  .project-card:active {
    box-shadow: 0 0 10px rgba(255,255,255,0.2);
  }
  
  .grid-card:active {
    transform: scale(0.98);
  }
  
  button:active, .splash-btn:active {
    transform: scale(0.95);
    opacity: 0.9;
  }
}

.timeline-marker.active {
  animation: markerPulse 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes markerPulse {
  0% { transform: translateY(-50%) scale(1); }
  50% { transform: translateY(-50%) scale(1.3); box-shadow: 0 0 25px var(--fg); }
  100% { transform: translateY(-50%) scale(1); }
}

/* Enhanced Input Focus */
input[type="text"] {
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
}

input[type="text"]:focus {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.2), 0 0 20px rgba(255,255,255,0.1);
  transform: scale(1.02);
}

/* Enhanced Card Expansion */
.project-card.expanded {
  animation: cardExpand 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cardExpand {
  from { transform: scale(0.98); box-shadow: none; }
  to { transform: scale(1); box-shadow: 0 0 30px rgba(255,255,255,0.2); }
}

/* Enhanced Overlays */
.grid-overlay, .media-overlay {
  animation: overlayIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes overlayIn {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to { opacity: 1; backdrop-filter: blur(8px); }
}

.overlay-card {
  animation: modalIn 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(50px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ===== MOBILE PERFORMANCE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
  /* Reduce animation complexity on mobile */
  * {
    animation-duration: 0.2s !important;
    transition-duration: 0.15s !important;
  }
  
  /* Disable complex animations */
  .timeline-item.cascade-in {
    animation: none;
    opacity: 1;
    transform: none;
  }
  
  .timeline-position-orb {
    animation: none;
  }
  
  .project-card.present-moment {
    animation: breatheMobile 4s ease-in-out infinite;
  }
  
  @keyframes breatheMobile {
    0%, 100% { opacity: 0.9; }
    50% { opacity: 1; }
  }
  
  /* Simplify overlay animations */
  .grid-overlay, .media-overlay {
    animation: fadeIn 0.2s ease;
  }
  
  @keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
  }
  
  .overlay-card {
    animation: slideUp 0.25s ease;
  }
  
  @keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  
  /* Disable will-change on mobile for performance */
  .timeline-item, .grid-card, .project-card, .timeline-marker {
    will-change: auto !important;
  }
}

/* ===== PERFORMANCE & ACCESSIBILITY ===== */
.timeline-item, .grid-card, .project-card, .timeline-marker {
  will-change: auto;
}

@media (hover: hover) {
  .timeline-item:hover, .grid-card:hover, .project-card:hover, .timeline-marker:hover {
    will-change: transform, box-shadow;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* Very small device optimizations */
@media (max-width: 375px) {
  /* Further simplify animations */
  * {
    animation: none !important;
    transition-duration: 0.1s !important;
  }
  
  /* Keep only essential transitions */
  button, .splash-btn, .project-card, .grid-card {
    transition: opacity 0.1s ease !important;
  }
}