/**
 * AnalyticSafe Animations
 * Rich animations, micro-interactions, scroll triggers
 */

/* ============================================
   BASE ANIMATION CLASSES
   ============================================ */

/* Fade animations */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn 0.8s ease forwards;
}

.animate-fade-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeUp 0.8s ease forwards;
}

.animate-fade-down {
    opacity: 0;
    transform: translateY(-30px);
    animation: fadeDown 0.8s ease forwards;
}

.animate-fade-left {
    opacity: 0;
    transform: translateX(30px);
    animation: fadeLeft 0.8s ease forwards;
}

.animate-fade-right {
    opacity: 0;
    transform: translateX(-30px);
    animation: fadeRight 0.8s ease forwards;
}

/* Scale animations */
.animate-scale-in {
    opacity: 0;
    transform: scale(0.9);
    animation: scaleIn 0.6s ease forwards;
}

/* Keyframes */
@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeDown {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

@keyframes scaleIn {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   SCROLL-TRIGGERED ANIMATIONS
   ============================================ */

/* Elements that animate on scroll */
[data-animate] {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

[data-animate].is-visible {
    opacity: 1;
    transform: translateY(0);
}

[data-animate="fade"] {
    transform: none;
}

[data-animate="scale"] {
    transform: scale(0.95);
}

[data-animate="scale"].is-visible {
    transform: scale(1);
}

[data-animate="slide-left"] {
    transform: translateX(60px);
}

[data-animate="slide-left"].is-visible {
    transform: translateX(0);
}

[data-animate="slide-right"] {
    transform: translateX(-60px);
}

[data-animate="slide-right"].is-visible {
    transform: translateX(0);
}

/* ============================================
   HOVER EFFECTS
   ============================================ */

/* Button hover effect */
.btn {
    position: relative;
    overflow: hidden;
}

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

.btn:hover::before {
    width: 300px;
    height: 300px;
}

/* Card hover lift */
.post-card,
.featured-card {
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 0.4s ease,
                border-color 0.3s ease;
}

.post-card:hover,
.featured-card:hover {
    transform: translateY(-4px);
}

/* Link underline animation */
.post-content a {
    position: relative;
    text-decoration: none;
    background-image: linear-gradient(var(--color-accent), var(--color-accent));
    background-size: 100% 1px;
    background-position: 0 100%;
    background-repeat: no-repeat;
    transition: background-size 0.3s ease;
}

.post-content a:hover {
    background-size: 100% 2px;
}

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Logo hover */
.logo-link:hover .logo-icon {
    animation: logoPulse 0.5s ease;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Nav link underline slide */
.nav-link::after {
    transition: width 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Arrow animations */
.post-card-read-more svg,
.featured-read-more svg,
.section-link svg,
.post-item-arrow svg {
    transition: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1);
}

/* Tag hover */
.tag {
    transition: background 0.2s ease, transform 0.2s ease;
}

.tag:hover {
    transform: translateY(-2px);
}

/* ============================================
   HEADER ANIMATIONS
   ============================================ */

/* Header show/hide on scroll */
.site-header {
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                box-shadow 0.3s ease;
}

.site-header.is-hidden {
    transform: translateY(-100%);
}

.site-header.is-scrolled {
    box-shadow: 0 1px 20px rgba(0, 0, 0, 0.08);
}

/* Mobile menu animation */
.header-nav {
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                opacity 0.3s ease;
}

@media (max-width: 768px) {
    .header-nav {
        opacity: 0;
    }
    
    .header-nav.is-open {
        opacity: 1;
    }
    
    .header-nav .nav-item {
        opacity: 0;
        transform: translateX(20px);
        transition: opacity 0.3s ease, transform 0.3s ease;
    }
    
    .header-nav.is-open .nav-item {
        opacity: 1;
        transform: translateX(0);
    }
    
    .header-nav.is-open .nav-item:nth-child(1) { transition-delay: 0.1s; }
    .header-nav.is-open .nav-item:nth-child(2) { transition-delay: 0.15s; }
    .header-nav.is-open .nav-item:nth-child(3) { transition-delay: 0.2s; }
    .header-nav.is-open .nav-item:nth-child(4) { transition-delay: 0.25s; }
    .header-nav.is-open .nav-item:nth-child(5) { transition-delay: 0.3s; }
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

/* Smooth page load */
body {
    animation: pageLoad 0.5s ease;
}

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

/* ============================================
   DECORATIVE ANIMATIONS
   ============================================ */

/* Featured card decoration */
.decoration-circle {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.decoration-lines span {
    animation: lineGrow 2s ease-in-out infinite;
}

.decoration-lines span:nth-child(1) { animation-delay: 0s; }
.decoration-lines span:nth-child(2) { animation-delay: 0.2s; }
.decoration-lines span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lineGrow {
    0%, 100% {
        transform: scaleX(1);
        opacity: 0.5;
    }
    50% {
        transform: scaleX(1.2);
        opacity: 0.8;
    }
}

/* Feature icons */
.feature-icon {
    transition: transform 0.4s cubic-bezier(0.23, 1, 0.32, 1),
                background 0.3s ease;
}

.feature-item:hover .feature-icon {
    transform: scale(1.1) rotate(-5deg);
    background: var(--color-mint);
}

/* ============================================
   LOADING STATES
   ============================================ */

/* Skeleton loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-border-light) 25%,
        var(--color-bg) 50%,
        var(--color-border-light) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

/* ============================================
   SPECIAL EFFECTS
   ============================================ */

/* Gradient text effect for hero */
.hero-title-accent {
    background: linear-gradient(135deg, var(--color-accent) 0%, #ff8a5c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Subtle parallax effect class */
.parallax-subtle {
    transform: translateZ(0);
    will-change: transform;
}

/* Focus states */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Smooth scrollbar */
@media (min-width: 769px) {
    ::-webkit-scrollbar {
        width: 10px;
    }
    
    ::-webkit-scrollbar-track {
        background: var(--color-bg);
    }
    
    ::-webkit-scrollbar-thumb {
        background: var(--color-border);
        border-radius: 5px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: var(--color-text-light);
    }
}

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

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    [data-animate] {
        opacity: 1;
        transform: none;
    }
}
