/* Apple-Style Premium Animations & Effects */

/* ============================================
   SMOOTH TRANSITIONS & ANIMATIONS
   ============================================ */

/* Global smooth transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Apple's signature easing curves */
:root {
    --ease-in-out-apple: cubic-bezier(0.42, 0, 0.58, 1);
    --ease-out-apple: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-apple: cubic-bezier(0.32, 0, 0.67, 0);
    --spring-apple: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   GLASSMORPHISM EFFECTS
   ============================================ */

.glass-effect {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.dark .glass-effect {
    background: rgba(31, 41, 55, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Header glassmorphism */
header {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(30px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

.dark header {
    background: rgba(31, 41, 55, 0.8) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2) !important;
}

/* ============================================
   SMOOTH SCROLL ANIMATIONS
   ============================================ */

html {
    scroll-behavior: smooth;
}

/* Fade in on scroll */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* ============================================
   CLEAN TOOL CARD ANIMATIONS
   ============================================ */

.tool-card {
    background: white;
    transition: all 0.2s ease !important;
    transform: translateY(0);
    will-change: transform, box-shadow;
}

.dark .tool-card {
    background: rgba(31, 41, 55, 0.8);
}

.tool-card:hover {
    transform: translateY(-4px) !important;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1) !important;
}

.dark .tool-card:hover {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3) !important;
}

/* Card icon - subtle scale */
.tool-card-icon {
    transition: transform 0.2s ease;
    display: inline-block;
}

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

/* Card title - simple color change */
.tool-card-title {
    transition: color 0.2s ease;
}

.tool-card:hover .tool-card-title {
    color: #6366f1;
}

.dark .tool-card:hover .tool-card-title {
    color: #818cf8;
}

/* ============================================
   CLEAN BUTTON ANIMATIONS
   ============================================ */

.btn, .category-btn {
    transition: all 0.15s ease;
}

.btn:hover, .category-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.btn:active, .category-btn:active {
    transform: translateY(0);
}

/* ============================================
   CLEAN SEARCH BAR ANIMATION
   ============================================ */

#searchInput {
    transition: all 0.2s ease;
}

#searchInput:focus {
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.15);
}

/* No pulse animation - clean */

/* ============================================
   CLEAN CATEGORY HEADER ANIMATIONS
   ============================================ */

#categoryIcon {
    /* No animation - simple and clean */
}

#categoryTitle {
    animation: fadeInUp 0.4s ease both;
}

#categoryDescription {
    animation: fadeInUp 0.4s ease 0.1s both;
}

#categoryToolCount {
    animation: fadeInUp 0.4s ease 0.2s both;
}

/* ============================================
   PARALLAX SCROLL EFFECTS
   ============================================ */

.parallax-slow {
    transition: transform 0.5s var(--ease-out-apple);
}

/* ============================================
   LOADING ANIMATIONS
   ============================================ */

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

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

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

.glow-on-hover {
    position: relative;
}

.glow-on-hover::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #6366f1, #8b5cf6, #ec4899, #f59e0b, #10b981, #3b82f6);
    background-size: 400%;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.3s;
    z-index: -1;
    filter: blur(10px);
}

.glow-on-hover:hover::before {
    opacity: 0.7;
    animation: glow-rotate 8s linear infinite;
}

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

/* ============================================
   RESULT CARD ANIMATIONS
   ============================================ */

.result-card {
    animation: fadeInScale 0.5s var(--ease-out-apple);
    transition: all 0.3s var(--ease-out-apple);
}

.result-card:hover {
    transform: scale(1.05);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.result-value {
    animation: countUp 0.8s var(--ease-out-apple);
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================
   BACK TO TOP BUTTON ANIMATION
   ============================================ */

/* Back to top animations are handled in style.css */

/* ============================================
   BREADCRUMB ANIMATION
   ============================================ */

#toolView nav ol li {
    animation: slideInRight 0.4s var(--ease-out-apple);
}

#toolView nav ol li:nth-child(2) {
    animation-delay: 0.1s;
}

#toolView nav ol li:nth-child(3) {
    animation-delay: 0.2s;
}

#toolView nav ol li:nth-child(4) {
    animation-delay: 0.3s;
}

/* ============================================
   INPUT FIELD ANIMATIONS
   ============================================ */

.input-field, .output-field, .form-input, .form-select {
    transition: all 0.3s var(--ease-out-apple);
}

.input-field:focus, .output-field:focus, .form-input:focus, .form-select:focus {
    transform: scale(1.01);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1),
                0 4px 12px rgba(0, 0, 0, 0.05);
}

/* ============================================
   CLEAN STAGGER ANIMATIONS
   ============================================ */

.stagger-animation > * {
    animation: fadeInUp 0.3s ease both;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.02s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.04s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.06s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.08s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.10s; }
.stagger-animation > *:nth-child(7) { animation-delay: 0.12s; }
.stagger-animation > *:nth-child(8) { animation-delay: 0.14s; }

/* ============================================
   TOAST NOTIFICATION ANIMATION
   ============================================ */

@keyframes slideInFromRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutToRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

#toast {
    animation: slideInFromRight 0.4s var(--spring-apple);
}

#toast.hiding {
    animation: slideOutToRight 0.3s var(--ease-in-apple);
}

/* ============================================
   PAGE TRANSITION
   ============================================ */

body {
    animation: fadeIn 0.4s var(--ease-out-apple);
}

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

/* ============================================
   GRADIENT ANIMATIONS
   ============================================ */

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

.animated-gradient {
    background: linear-gradient(
        -45deg,
        #667eea 0%,
        #764ba2 25%,
        #f093fb 50%,
        #4facfe 75%,
        #667eea 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

/* ============================================
   CLEAN LOGO
   ============================================ */

header h1 {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    transition: opacity 0.2s ease;
}

header h1:hover {
    opacity: 0.8;
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* Hardware acceleration */
.tool-card,
.btn,
.category-btn,
.result-card,
.back-to-top {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ============================================
   REMOVE BUTTON ANIMATIONS (Recent & Favorites)
   ============================================ */

/* Container for recent/favorite tools */
#recentToolsList .group,
#favoritesList .group {
    position: relative;
    transition: all 0.3s var(--ease-out-apple);
}

/* Tool button in recent/favorites */
#recentToolsList .group > button:first-child,
#favoritesList .group > button:first-child {
    transition: all 0.3s var(--ease-out-apple);
}

#recentToolsList .group:hover > button:first-child,
#favoritesList .group:hover > button:first-child {
    transform: translateX(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Remove button (red cross) */
#recentToolsList .group > button:last-child,
#favoritesList .group > button:last-child {
    transition: all 0.3s var(--spring-apple);
}

#recentToolsList .group > button:last-child:hover,
#favoritesList .group > button:last-child:hover {
    background: #dc2626 !important;
    transform: translateY(-50%) scale(1.15) rotate(90deg);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

#recentToolsList .group > button:last-child:active,
#favoritesList .group > button:last-child:active {
    transform: translateY(-50%) scale(0.95) rotate(90deg);
}

/* Icon animation inside remove button */
#recentToolsList .group > button:last-child i,
#favoritesList .group > button:last-child i {
    transition: transform 0.2s var(--ease-out-apple);
}

#recentToolsList .group > button:last-child:hover i,
#favoritesList .group > button:last-child:hover i {
    transform: scale(1.2);
}

/* Fade out animation when removing */
@keyframes fadeOutRemove {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.95);
    }
    100% {
        opacity: 0;
        transform: scale(0.8) translateX(-50px);
    }
}

.removing {
    animation: fadeOutRemove 0.4s var(--ease-in-apple) forwards;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
