/*
 * The Digital Press: Animation System
 * Rowe Innovations, LLC
 *
 * Motion inspired by letterpress mechanics: ink spreading, type settling, paper lifting.
 */

/* ============================================
   Scroll Reveal - Ink Spreading
   ============================================ */

.fade-in {
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity var(--transition-duration-slow) var(--transition-smooth),
    transform var(--transition-duration-slow) var(--transition-smooth);
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered delays for multiple elements */
.fade-in:nth-child(1) { transition-delay: 0s; }
.fade-in:nth-child(2) { transition-delay: 0.1s; }
.fade-in:nth-child(3) { transition-delay: 0.2s; }
.fade-in:nth-child(4) { transition-delay: 0.3s; }
.fade-in:nth-child(5) { transition-delay: 0.4s; }

/* ============================================
   Headline Reveal - Word by Word
   ============================================ */

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

.headline-word {
  display: inline-block;
  opacity: 0;
  animation: pressReveal 0.6s var(--transition-smooth) forwards;
}

.headline-word:nth-child(1) { animation-delay: 0.1s; }
.headline-word:nth-child(2) { animation-delay: 0.2s; }
.headline-word:nth-child(3) { animation-delay: 0.3s; }
.headline-word:nth-child(4) { animation-delay: 0.4s; }
.headline-word:nth-child(5) { animation-delay: 0.5s; }
.headline-word:nth-child(6) { animation-delay: 0.6s; }
.headline-word:nth-child(7) { animation-delay: 0.7s; }
.headline-word:nth-child(8) { animation-delay: 0.8s; }

/* ============================================
   Card Hover - Letterpress Lift
   ============================================ */

.card {
  transition:
    transform var(--transition-duration-normal) var(--transition-smooth),
    box-shadow var(--transition-duration-normal) var(--transition-smooth);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

/* ============================================
   Button Press - Physical Feedback
   ============================================ */

.btn,
.btn-primary,
.btn-accent {
  position: relative;
  transition:
    transform var(--transition-duration-fast) var(--transition-smooth),
    box-shadow var(--transition-duration-fast) var(--transition-smooth);
}

.btn:active,
.btn-primary:active,
.btn-accent:active {
  transform: translateY(1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Link Hover - Kerning Shift
   ============================================ */

/* Already defined in typography.css, but adding subtle underline animation */

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

a.link-animated {
  position: relative;
  border-bottom: none;
}

a.link-animated::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--color-accent);
  transition: width var(--transition-duration-normal) var(--transition-smooth);
}

a.link-animated:hover::after {
  width: 100%;
}

/* ============================================
   Image Fade In - Development Reveal
   ============================================ */

img {
  opacity: 0;
  transform: scale(0.98);
  transition:
    opacity var(--transition-duration-slow) var(--transition-smooth),
    transform var(--transition-duration-slow) var(--transition-smooth);
}

img.loaded {
  opacity: 1;
  transform: scale(1);
}

/* ============================================
   Section Transitions - Page Rhythm
   ============================================ */

section {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity var(--transition-duration-slow) var(--transition-smooth),
    transform var(--transition-duration-slow) var(--transition-smooth);
}

section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================
   Nav Scroll - Paper Lift Effect
   ============================================ */

nav {
  transition:
    box-shadow var(--transition-duration-normal) var(--transition-smooth),
    background-color var(--transition-duration-normal) var(--transition-smooth);
}

nav.scrolled {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  background-color: rgba(250, 249, 249, 0.95);
  backdrop-filter: blur(8px);
}

/* ============================================
   Loading States - Ink Pooling
   ============================================ */

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.loading {
  animation: pulse 1.5s ease-in-out infinite;
}

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

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-gray-light) 0%,
    var(--color-paper-dark) 50%,
    var(--color-gray-light) 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
}

/* ============================================
   Focus States - Accessibility
   ============================================ */

*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  transition: outline-offset var(--transition-duration-fast) var(--transition-smooth);
}

*:focus-visible:hover {
  outline-offset: 4px;
}

/* ============================================
   Smooth Scrolling
   ============================================ */

html {
  scroll-behavior: smooth;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================
   Page Load Animation
   ============================================ */

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

body {
  animation: pageLoad 0.6s var(--transition-smooth);
}
