/* ==========================================
   BuildFolio — Animations & Transitions
   ========================================== */

/* --- Keyframes --- */
@keyframes loadingFill {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

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

@keyframes fadeSlideOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-12px);
    }
}

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

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

@keyframes tagPop {
    0% {
        opacity: 0;
        transform: scale(0.8);
    }
    60% {
        transform: scale(1.05);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

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

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

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

/* --- Applied Animation Classes --- */

/* Section list item entrance */
.section-list-item {
    animation: fadeSlideIn 0.25s ease backwards;
}
.section-list-item:nth-child(1) { animation-delay: 0ms; }
.section-list-item:nth-child(2) { animation-delay: 40ms; }
.section-list-item:nth-child(3) { animation-delay: 80ms; }
.section-list-item:nth-child(4) { animation-delay: 120ms; }
.section-list-item:nth-child(5) { animation-delay: 160ms; }
.section-list-item:nth-child(6) { animation-delay: 200ms; }
.section-list-item:nth-child(7) { animation-delay: 240ms; }
.section-list-item:nth-child(8) { animation-delay: 280ms; }

/* Dropdown animation */
.add-section-dropdown.open {
    animation: fadeSlideIn 0.2s ease;
}

/* Button hover effects */
.btn-primary {
    position: relative;
    overflow: hidden;
}
.btn-primary::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}
.btn-primary:hover::after {
    width: 300px;
    height: 300px;
}

/* Form input focus animation */
.form-input,
.form-textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}
.form-input:focus,
.form-textarea:focus {
    transform: translateY(-1px);
}

/* Image upload hover */
.image-upload-area {
    transition: all 0.3s ease;
}
.image-upload-area:hover .upload-placeholder svg {
    animation: bounceIn 0.5s ease;
}

/* Export option hover animations */
.export-option {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.export-option .export-icon {
    transition: transform 0.3s ease;
}
.export-option:hover .export-icon {
    transform: scale(1.15);
}

/* Preview device button */
.preview-device {
    transition: all 0.2s ease;
}
.preview-device:active {
    transform: scale(0.93);
}

/* Section nav item hover effect */
.section-list-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    transition: height 0.2s ease;
}
.section-list-item.active::before {
    height: 60%;
}

/* Loading skeleton */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-surface) 25%,
        var(--bg-surface-hover) 50%,
        var(--bg-surface) 75%
    );
    background-size: 400% 100%;
    animation: shimmer 1.5s ease infinite;
    border-radius: var(--radius-md);
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-secondary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Logo pulse on hover */
.logo:hover .logo-icon {
    animation: pulse 1s ease infinite;
}

/* Form content transition */
.form-content.switching {
    animation: fadeSlideOut 0.15s ease forwards;
}

/* Repeater entry removal */
.repeater-entry.removing {
    animation: fadeSlideOut 0.25s ease forwards;
    overflow: hidden;
}

/* Accent color glow on header */
.app-header::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(var(--accent-rgb), 0.3),
        transparent
    );
}

/* Save button animation */
.btn-save-pulse {
    animation: pulse 0.4s ease;
}
