/**
 * Enhanced Animations Library v1.0.0
 * Design System v9.0 対応
 * 
 * 目的: 全ページで使用できる高品質アニメーション
 * 機能: スクロールアニメーション、ホバーエフェクト、マイクロインタラクション
 */

/* ========================================
   Scroll-Based Animations (Intersection Observer)
   ======================================== */

/* Fade In Up - 下から上にフェードイン */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Down - 上から下にフェードイン */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fade In Left - 左からフェードイン */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Fade In Right - 右からフェードイン */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Scale In - ズームイン */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Rotate In - 回転しながらフェードイン */
@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-10deg) scale(0.95);
    }
    to {
        opacity: 1;
        transform: rotate(0) scale(1);
    }
}

/* ========================================
   Scroll Animation Classes (JavaScript制御)
   ======================================== */

.animate-on-scroll {
    opacity: 0;
    transition: none;
}

.animate-on-scroll.animated {
    animation-duration: 0.8s;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    animation-fill-mode: both;
}

.animate-fade-up.animated {
    animation-name: fadeInUp;
}

.animate-fade-down.animated {
    animation-name: fadeInDown;
}

.animate-fade-left.animated {
    animation-name: fadeInLeft;
}

.animate-fade-right.animated {
    animation-name: fadeInRight;
}

.animate-scale.animated {
    animation-name: scaleIn;
}

.animate-rotate.animated {
    animation-name: rotateIn;
}

/* Staggered Animation Delays */
.animate-delay-1 { animation-delay: 0.1s !important; }
.animate-delay-2 { animation-delay: 0.2s !important; }
.animate-delay-3 { animation-delay: 0.3s !important; }
.animate-delay-4 { animation-delay: 0.4s !important; }
.animate-delay-5 { animation-delay: 0.5s !important; }
.animate-delay-6 { animation-delay: 0.6s !important; }

/* ========================================
   3D Hover Effects
   ======================================== */

.hover-3d {
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
    perspective: 1000px;
}

.hover-3d:hover {
    transform: translateY(-8px) rotateX(5deg);
    box-shadow: 
        0 12px 40px rgba(10, 61, 61, 0.15),
        0 20px 60px rgba(10, 61, 61, 0.1);
}

/* Tilt Effect on Hover */
.hover-tilt {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.hover-tilt:hover {
    transform: perspective(1000px) rotateY(5deg) scale(1.02);
}

/* Glow Effect on Hover */
.hover-glow {
    transition: all 0.3s ease;
    position: relative;
}

.hover-glow::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: linear-gradient(135deg, #C9A961 0%, #0A3D3D 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
    filter: blur(8px);
}

.hover-glow:hover::before {
    opacity: 0.4;
}

/* ========================================
   Ripple Effect (Click Feedback)
   ======================================== */

.ripple-effect {
    position: relative;
    overflow: hidden;
}

.ripple-effect::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease, opacity 0.6s ease;
    opacity: 0;
}

.ripple-effect:active::after {
    width: 300px;
    height: 300px;
    opacity: 1;
    transition: 0s;
}

/* ========================================
   Gradient Animation (Background Flow)
   ======================================== */

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-animate {
    background-size: 200% 200%;
    animation: gradientFlow 8s ease infinite;
}

/* ========================================
   Pulse Animation (Attention Grabber)
   ======================================== */

@keyframes pulse-soft {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(10, 61, 61, 0.2);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 8px 30px rgba(10, 61, 61, 0.3);
    }
}

.pulse-soft {
    animation: pulse-soft 3s ease-in-out infinite;
}

/* ========================================
   Shimmer Effect (Loading State)
   ======================================== */

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

.shimmer {
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.3) 50%,
        rgba(255, 255, 255, 0) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* ========================================
   Float Animation (Subtle Movement)
   ======================================== */

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

.float-animation {
    animation: float 4s ease-in-out infinite;
}

/* ========================================
   Input Focus Glow
   ======================================== */

.input-glow {
    transition: all 0.3s ease;
    position: relative;
}

.input-glow:focus {
    box-shadow: 
        0 0 0 3px rgba(201, 169, 97, 0.1),
        0 0 20px rgba(201, 169, 97, 0.2),
        0 4px 12px rgba(10, 61, 61, 0.15);
    border-color: #C9A961;
}

/* ========================================
   Icon Bounce on Hover
   ======================================== */

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

.icon-bounce:hover i,
.icon-bounce:hover svg {
    animation: iconBounce 0.6s ease;
}

/* ========================================
   Slide In Progress Bar
   ======================================== */

@keyframes slideInProgress {
    from {
        width: 0%;
    }
    to {
        width: var(--progress-width, 100%);
    }
}

.progress-animate {
    animation: slideInProgress 1.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* ========================================
   Confetti Burst (Success State)
   ======================================== */

@keyframes confettiFall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(500px) rotate(360deg);
        opacity: 0;
    }
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #C9A961;
    animation: confettiFall 3s ease-out forwards;
}

/* ========================================
   Accessibility: Reduced Motion
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-on-scroll.animated {
        opacity: 1;
        animation: none;
    }
    
    .hover-3d:hover,
    .hover-tilt:hover {
        transform: none;
    }
}

/* ========================================
   Performance Optimization
   ======================================== */

.will-animate {
    will-change: transform, opacity;
}

.gpu-accelerate {
    transform: translateZ(0);
    backface-visibility: hidden;
}
