/**
 * CSS Animations & Transitions for lewisngugi.com
 * Implementation Date: 2025-10-15
 * Based on: animations.dev best practices
 * 
 * Table of Contents:
 * 1. Keyframe Animations
 * 2. Phase 1 - High Priority Animations
 * 3. Phase 2 - Medium Priority Animations
 * 4. Phase 3 - Polish & Playful Interactions
 * 5. Phase 4 - Accessibility & Performance
 * 6. Utility Classes
 */

/* ========================================
   1. KEYFRAME ANIMATIONS
   ======================================== */

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

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

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

@keyframes blink {
  0%, 100% {
    transform: scaleY(1);
  }
  50% {
    transform: scaleY(0.1);
  }
}

@keyframes shake {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-5deg);
  }
  75% {
    transform: rotate(5deg);
  }
}

@keyframes imageLoad {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   2. PHASE 1 - HIGH PRIORITY ANIMATIONS
   ======================================== */

/* ===== NAVIGATION ENHANCEMENTS ===== */

/* Navigation underline animation */
.main-nav a {
  position: relative;
  transition: color 0.2s ease;
}

.main-nav a:hover::after,
.main-nav a:focus::after {
  width: 100%;
}

/* Enhanced sticky nav on scroll */
.main-nav {
  transition: background-color 0.3s ease,
              backdrop-filter 0.3s ease,
              box-shadow 0.3s ease;
}

.main-nav.scrolled {
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* ===== CASE STUDY CARDS (index.html) ===== */

.article-overview .item-article {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s ease;
  border-radius: 8px;
  will-change: transform;
}

.article-overview .item-article:hover {
  transform: translateY(-4px);
}

.article-overview .item-article:not(:hover) {
  will-change: auto;
}

/* ===== PROJECT IMAGES ===== */

.article-overview figure img {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.3s ease;
  will-change: transform;
}

.article-overview .item-article:hover figure img {
  transform: scale(1.07);
}

.article-overview figure img:not(:hover) {
  will-change: auto;
}

/* Global figure image hover */
figure img {
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.3s ease;
}

figure:hover img {
  transform: scale(1.01);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

/* ===== ARTICLE ENTRIES (writing.html) ===== */

.article-entry {
  position: relative;
  transition: background-color 0.2s ease,
              transform 0.2s ease;
  border-radius: 8px;
  padding: 12px;
  margin-left: -12px;
  margin-right: -12px;
}

.article-entry::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleX(0);
  width: 4px;
  height: 60%;
  background: #BE3455;
  border-radius: 0 2px 2px 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: left;
}

.article-entry:hover::before {
  transform: translateY(-50%) scaleX(1);
}

.article-entry:hover {
  transform: translateX(4px);
}

/* ===== CONTACT LINKS (contact.html) ===== */

.article-overview article.flex.w-100.mv3 {
  transition: transform 0.2s ease,
              background-color 0.2s ease;
  border-radius: 12px;
  padding: 16px;
  margin-left: -16px;
  margin-right: -16px;
}

.article-overview article.flex.w-100.mv3:hover {
  transform: translateX(8px);
}

/* Contact link emojis */
.article-overview article.flex.w-100.mv3 > a > div:first-child p {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
}

.article-overview article.flex.w-100.mv3:hover > a > div:first-child p {
  transform: scale(1.2) rotate(10deg);
}

/* ========================================
   3. PHASE 2 - MEDIUM PRIORITY ANIMATIONS
   ======================================== */

/* ===== HERO SECTION (index.html) ===== */

.welcome h1 {
  animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.welcome > p {
  animation: fadeIn 0.8s ease-out 0.2s backwards;
}

/* ===== WORK EXPERIENCE ITEMS ===== */

.article-overview .flex.flex-col.gap-3 > div {
  transition: transform 0.2s ease,
              background-color 0.2s ease;
  border-radius: 8px;
  padding: 12px;
  margin-left: -12px;
  margin-right: -12px;
}

.article-overview .flex.flex-col.gap-3 > div:hover {
  transform: translateX(8px);

}

/* ===== CLIENT LOGOS ===== */

.flex.mb-6.flex-wrap.items-center img {
  transition: transform 0.25s ease,
              opacity 0.25s ease,
              filter 0.25s ease;
  filter: grayscale(100%) opacity(0.7);
}

.flex.mb-6.flex-wrap.items-center img:hover {
  transform: scale(1.1);
  filter: grayscale(0%) opacity(1);
}

/* ===== ARTICLE PREVIEW BUTTONS (writing.html) ===== */

.article-preview-btn {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.2s ease,
              background-color 0.2s ease;
  border-radius: 50%;
  padding: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  margin-left: 8px;
}

.article-preview-btn:hover {
  transform: scale(1.15);
}

.article-preview-btn:active {
  transform: scale(0.95);
}

.preview-eye-icon {
  transition: transform 0.3s ease;
  display: block;
}

.article-preview-btn:hover .preview-eye-icon {
  animation: blink 0.6s ease-in-out;
}

/* ===== YEAR HEADERS (writing.html) ===== */

.article-overview .pt3 h3 {
  transition: color 0.3s ease;
  position: relative;
  display: inline-block;
}

.article-overview .pt3 h3::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 2px;
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.article-overview .pt3 h3:hover::after {
  width: 60px;
}

/* ========================================
   4. PHASE 3 - POLISH & PLAYFUL INTERACTIONS
   ======================================== */

/* ===== HubSpot SVG LOGO ===== */

.welcome h1 svg {
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-block;
}

.welcome h1 span:hover svg {
  transform: scale(1.1) rotate(5deg);
}

/* ===== EXTERNAL LINK ARROWS ===== */

.article-overview .item-article a .arrow svg,
.article-entry a .ph2.arrow svg {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.article-overview .item-article a:hover .arrow svg,
.article-entry:hover a .ph2.arrow svg {
  transform: translate(4px, -4px);
}

/* Contact page arrows */
.article-overview article.flex.w-100.mv3 .arrow svg {
  transition: transform 0.2s ease;
}

.article-overview article.flex.w-100.mv3:hover .arrow svg {
  transform: translate(4px, -4px);
}

/* ===== LOCK ICON (Protected Content) ===== */

.item-article .welcome svg[viewBox*="24"] {
  transition: transform 0.3s ease;
}

.item-article:hover .welcome svg[viewBox*="24"] {
  animation: shake 0.5s ease-in-out;
}

/* ===== BOOKMARK SECTION ===== */

#consuming-articles article {
  transition: background-color 0.2s ease,
              transform 0.2s ease;
  border-radius: 8px;
  padding: 8px;
  margin-left: -8px;
  margin-right: -8px;
}

#consuming-articles article:hover {
  transform: translateX(4px);
}

/* Loading state pulse */
#consuming-articles[data-loading="true"] {
  animation: pulse 1.5s ease-in-out infinite;
}

/* ===== SPOTIFY EMBED ===== */

.article-overview iframe {
  transition: transform 0.3s ease,
              box-shadow 0.3s ease;
  border-radius: 12px;
}

.article-overview .item-article:hover iframe {
  transform: translateY(-2px);
}

/* ===== FOOTER ===== */

footer.signoff {
  animation: fadeInUp 0.6s ease-out;
}

/* ===== GLOBAL IMAGE LOADING ===== */

img {
  animation: imageLoad 0.4s ease-out;
}

/* ========================================
   5. PHASE 4 - ACCESSIBILITY & PERFORMANCE
   ======================================== */

/* ===== REDUCED MOTION SUPPORT ===== */

@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;
  }
  
  /* Keep essential focus indicators */
  .main-nav a:focus::after {
    transition-duration: 0.01ms !important;
    width: 100%;
  }
}

/* ===== GPU ACCELERATION HINTS ===== */

.article-overview .item-article,
.article-entry,
figure img,
.main-nav a::after,
.article-preview-btn {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  perspective: 1000px;
  -webkit-perspective: 1000px;
}

/* ===== SMOOTH SCROLLING ===== */

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ========================================
   6. UTILITY CLASSES
   ======================================== */

/* Animation delay utilities */
.anim-delay-1 {
  animation-delay: 0.1s;
}

.anim-delay-2 {
  animation-delay: 0.2s;
}

.anim-delay-3 {
  animation-delay: 0.3s;
}

.anim-delay-4 {
  animation-delay: 0.4s;
}

/* Hover lift utility */
.hover-lift {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.hover-lift:hover {
  transform: translateY(-4px);
}

/* Hover scale utility */
.hover-scale {
  transition: transform 0.3s ease;
}

.hover-scale:hover {
  transform: scale(1.05);
}

/* Focus visible enhancement */
*:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
  border-radius: 2px;
}

/* ========================================
   END OF ANIMATIONS.CSS
   ======================================== */
