/*
STORYSCROLLING STYLES
====================
Estilos para animaciones de scroll inspiradas en Apple.com
Diseñado para ser fácil de mantener y modificar
*/

/* Variables para animaciones */
:root {
  --story-duration: 0.8s;
  --story-easing: cubic-bezier(0.4, 0, 0.2, 1);
  --story-distance: 30px;
  --story-scale: 0.95;
  --story-delay-base: 100ms;
}

/* Estados iniciales para elementos animados */
[data-story-animation] {
  will-change: transform, opacity;
}

/* Prevenir flash de contenido no animado */
.story-loading [data-story-animation] {
  opacity: 0;
  visibility: hidden;
}

/* 
ANIMACIONES PRINCIPALES
======================
*/

/* Fade Up - Aparece desde abajo con fade */
[data-story-animation="fadeUp"] {
  transition: all var(--story-duration) var(--story-easing);
}

/* Slide animations - Aparece desde los lados */
[data-story-animation="slide"] {
  transition: all var(--story-duration) var(--story-easing);
}

/* Scale animations - Aparece escalando */
[data-story-animation="scale"] {
  transition: all var(--story-duration) var(--story-easing);
}

/* 
ANIMACIONES DE TEXTO
===================
*/

/* Contenedor para texto que se revela palabra por palabra */
[data-text-reveal] {
  overflow: hidden;
}

.word-reveal {
  display: inline-block;
  will-change: transform, opacity;
  transition: all 0.4s var(--story-easing);
}

/* Palabras que se destacan progresivamente */
.highlight-word {
  display: inline;
  will-change: background-color, color, padding;
  transition: all 0.6s var(--story-easing);
  border-radius: 4px;
}

.highlight-word.animated {
  background: rgba(78, 205, 196, 0.15);
  color: #4ecdc4;
  padding: 2px 6px;
  box-shadow: 0 0 0 1px rgba(78, 205, 196, 0.1);
}

/* 
EFECTOS ESPECIALES
==================
*/

/* Parallax sutil para elementos hero */
[data-parallax] {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* Efecto de typing para títulos */
.typing-effect {
  overflow: hidden;
  border-right: 2px solid #4ecdc4;
  white-space: nowrap;
  animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: #4ecdc4; }
}

/* 
ELEMENTOS ESPECÍFICOS DEL PORTFOLIO
===================================
*/

/* Hero section con animaciones escalonadas */
.hero-content > * {
  opacity: 0;
  transform: translateY(var(--story-distance));
  transition: all var(--story-duration) var(--story-easing);
}

.hero-content.animated > * {
  opacity: 1;
  transform: translateY(0);
}

.hero-content.animated > *:nth-child(1) { transition-delay: 0ms; }
.hero-content.animated > *:nth-child(2) { transition-delay: 100ms; }
.hero-content.animated > *:nth-child(3) { transition-delay: 200ms; }
.hero-content.animated > *:nth-child(4) { transition-delay: 300ms; }
.hero-content.animated > *:nth-child(5) { transition-delay: 400ms; }
.hero-content.animated > *:nth-child(6) { transition-delay: 500ms; }

/* Project cards con efecto de revelación */
.project-card {
  opacity: 0;
  transform: translateY(var(--story-distance)) scale(var(--story-scale));
  transition: all var(--story-duration) var(--story-easing);
}

.project-card.story-animated {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Efecto especial para cards destacadas */
.project-card.featured {
  position: relative;
  overflow: hidden;
}

.project-card.featured::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 107, 157, 0.1), transparent);
  transition: left 0.8s ease;
}

.project-card.featured.story-animated::before {
  left: 100%;
}

/* Skills categories con animación de escala */
.skill-category {
  opacity: 0;
  transform: scale(var(--story-scale));
  transition: all var(--story-duration) var(--story-easing);
}

.skill-category.story-animated {
  opacity: 1;
  transform: scale(1);
}

/* Timeline items con animación alternada */
.timeline-item {
  opacity: 0;
  transition: all var(--story-duration) var(--story-easing);
}

.timeline-item:nth-child(odd) {
  transform: translateX(-var(--story-distance));
}

.timeline-item:nth-child(even) {
  transform: translateX(var(--story-distance));
}

.timeline-item.story-animated {
  opacity: 1;
  transform: translateX(0);
}

/* 
EFECTOS DE HOVER MEJORADOS
==========================
*/

/* Hover con micro-animaciones */
.project-card:hover {
  transform: translateY(-8px) scale(1.02);
  transition: all 0.3s var(--story-easing);
}

.skill-category:hover {
  transform: scale(1.05) translateY(-4px);
  transition: all 0.3s var(--story-easing);
}

/* 
ANIMACIONES DE CARGA
====================
*/

/* Skeleton loading para contenido que se carga dinámicamente */
.skeleton {
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.05) 25%, 
    rgba(255, 255, 255, 0.1) 50%, 
    rgba(255, 255, 255, 0.05) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
}

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

/* 
UTILIDADES PARA DESARROLLADORES
===============================
*/

/* Clases para marcar elementos manualmente */
.story-fade-up {
  /* Marcador para auto-detección */
}

.story-slide-left {
  /* Marcador para auto-detección */
}

.story-slide-right {
  /* Marcador para auto-detección */
}

.story-scale {
  /* Marcador para auto-detección */
}

.story-text-reveal {
  /* Marcador para auto-detección */
}

/* Delays manuales */
.story-delay-1 { transition-delay: calc(var(--story-delay-base) * 1) !important; }
.story-delay-2 { transition-delay: calc(var(--story-delay-base) * 2) !important; }
.story-delay-3 { transition-delay: calc(var(--story-delay-base) * 3) !important; }
.story-delay-4 { transition-delay: calc(var(--story-delay-base) * 4) !important; }
.story-delay-5 { transition-delay: calc(var(--story-delay-base) * 5) !important; }

/* 
RESPONSIVE ADAPTATIONS
======================
*/

@media (max-width: 768px) {
  :root {
    --story-distance: 20px;
    --story-duration: 0.6s;
  }
  
  /* Simplificar animaciones en móvil */
  .timeline-item:nth-child(odd),
  .timeline-item:nth-child(even) {
    transform: translateY(var(--story-distance));
  }
  
  .timeline-item.story-animated {
    transform: translateY(0);
  }
}

@media (max-width: 480px) {
  :root {
    --story-distance: 15px;
    --story-duration: 0.4s;
  }
}

/* 
ACCESIBILIDAD
=============
*/

@media (prefers-reduced-motion: reduce) {
  :root {
    --story-duration: 0.01ms;
    --story-distance: 0px;
    --story-scale: 1;
  }
  
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  [data-story-animation] {
    opacity: 1 !important;
    transform: none !important;
  }
  
  .typing-effect {
    animation: none;
    border-right: none;
    white-space: normal;
  }
}

/* 
DEBUG MODE
==========
*/

.story-debug [data-story-animation] {
  outline: 2px dashed rgba(255, 107, 157, 0.5);
  position: relative;
}

.story-debug [data-story-animation]::after {
  content: attr(data-story-animation);
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(255, 107, 157, 0.8);
  color: white;
  padding: 2px 6px;
  font-size: 10px;
  font-family: monospace;
  z-index: 1000;
}

