/**
 * UI Animations
 * UI动画样式
 * 
 * Features:
 * - Button hover animations
 * - Card hover effects
 * - Link underline animations
 * - Form input focus animations
 * - Loading animations
 * - Scroll reveal animations
 * 
 * @package DUX
 * @since 9.6
 */

/* ========================================
   CSS Variables
   ======================================== */

:root {
    --animation-duration: 0.3s;
    --animation-timing: cubic-bezier(0.4, 0, 0.2, 1);
    --hover-lift: translateY(-2px);
    --hover-scale: scale(1.05);
}

/* ========================================
   Button Animations
   ======================================== */

/* Primary buttons */
.btn,
.submit,
button[type="submit"],
input[type="submit"],
.wp-block-button__link {
    position: relative;
    overflow: hidden;
    transition: all var(--animation-duration) var(--animation-timing);
}

.btn:hover,
.submit:hover,
button[type="submit"]:hover,
input[type="submit"]:hover,
.wp-block-button__link:hover {
    transform: var(--hover-lift);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active,
.submit:active,
button[type="submit"]:active,
input[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Button ripple effect */
.btn::before,
.submit::before,
button[type="submit"]::before,
input[type="submit"]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before,
.submit:active::before,
button[type="submit"]:active::before,
input[type="submit"]:active::before {
    width: 300px;
    height: 300px;
}

/* ========================================
   Card Hover Effects
   ======================================== */

/* Article cards */
.excerpt,
.post-list article,
.widget li {
    transition: all var(--animation-duration) var(--animation-timing);
}

.excerpt:hover,
.post-list article:hover {
    transform: var(--hover-lift);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Thumbnail zoom effect */
.excerpt .focus,
.post-list .focus,
.thumbnail {
    overflow: hidden;
}

.excerpt .focus img,
.post-list .focus img,
.thumbnail img {
    transition: transform 0.6s var(--animation-timing);
}

.excerpt:hover .focus img,
.post-list:hover .focus img,
.thumbnail:hover img {
    transform: scale(1.1);
}

/* ========================================
   Link Animations
   ======================================== */

/* Underline animation */
.content a:not(.btn),
.widget a:not(.btn) {
    position: relative;
    text-decoration: none;
    transition: color var(--animation-duration);
}

.content a:not(.btn)::after,
.widget a:not(.btn)::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--tb--main);
    transition: width var(--animation-duration) var(--animation-timing);
}

.content a:not(.btn):hover::after,
.widget a:not(.btn):hover::after {
    width: 100%;
}

/* Navigation links */
.nav a,
.menu a {
    position: relative;
    transition: color var(--animation-duration);
}

.nav a::before,
.menu a::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--tb--main);
    transform: translateX(-50%);
    transition: width var(--animation-duration) var(--animation-timing);
}

.nav a:hover::before,
.menu a:hover::before,
.nav .current-menu-item a::before,
.menu .current-menu-item a::before {
    width: 100%;
}

/* ========================================
   Form Input Animations
   ======================================== */

/* Input focus effect */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="number"],
textarea,
select {
    transition: all var(--animation-duration) var(--animation-timing);
    border: 1px solid #ddd;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
    border-color: var(--tb--main);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    transform: translateY(-1px);
}

/* Label float animation */
.form-group {
    position: relative;
}

.form-group label {
    position: absolute;
    top: 12px;
    left: 12px;
    transition: all var(--animation-duration) var(--animation-timing);
    pointer-events: none;
    color: #999;
}

.form-group input:focus + label,
.form-group input:not(:placeholder-shown) + label,
.form-group textarea:focus + label,
.form-group textarea:not(:placeholder-shown) + label {
    top: -8px;
    left: 8px;
    font-size: 12px;
    color: var(--tb--main);
    background: #fff;
    padding: 0 4px;
}

/* ========================================
   Loading Animations
   ======================================== */

/* Spinner */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading,
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--tb--main);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Pulse animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Skeleton loading */
@keyframes skeleton-loading {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

/* ========================================
   Scroll Reveal Animations
   ======================================== */

/* Fade in from bottom */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s var(--animation-timing);
}

/* Fade in from left */
@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in-left {
    animation: fadeInLeft 0.6s var(--animation-timing);
}

/* Fade in from right */
@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.fade-in-right {
    animation: fadeInRight 0.6s var(--animation-timing);
}

/* Scale in */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.scale-in {
    animation: scaleIn 0.4s var(--animation-timing);
}

/* ========================================
   Icon Animations
   ======================================== */

/* Icon hover */
.tbfa,
.fa,
.icon {
    transition: all var(--animation-duration) var(--animation-timing);
}

a:hover .tbfa,
a:hover .fa,
a:hover .icon,
button:hover .tbfa,
button:hover .fa,
button:hover .icon {
    transform: scale(1.1);
}

/* Icon spin */
@keyframes icon-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.icon-spin {
    animation: icon-spin 1s linear infinite;
}

/* Icon bounce */
@keyframes icon-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.icon-bounce {
    animation: icon-bounce 0.6s ease-in-out;
}

/* ========================================
   Modal Animations
   ======================================== */

/* Modal fade in */
@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal,
.popup,
.dialog {
    animation: modalFadeIn 0.3s var(--animation-timing);
}

/* Backdrop fade */
@keyframes backdropFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-backdrop,
.popup-backdrop,
.overlay {
    animation: backdropFadeIn 0.3s ease;
}

/* ========================================
   Notification Animations
   ======================================== */

/* Slide in from top */
@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification,
.alert,
.toast {
    animation: slideInDown 0.4s var(--animation-timing);
}

/* Slide out to top */
@keyframes slideOutUp {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-100%);
    }
}

.notification.hide,
.alert.hide,
.toast.hide {
    animation: slideOutUp 0.4s var(--animation-timing);
}

/* ========================================
   Progress Bar Animation
   ======================================== */

@keyframes progress {
    0% { width: 0; }
}

.progress-bar {
    animation: progress 1s var(--animation-timing);
}

/* Indeterminate progress */
@keyframes indeterminate {
    0% { left: -35%; right: 100%; }
    60% { left: 100%; right: -90%; }
    100% { left: 100%; right: -90%; }
}

.progress-indeterminate::before {
    content: '';
    position: absolute;
    background: var(--tb--main);
    top: 0;
    bottom: 0;
    animation: indeterminate 2s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
}

/* ========================================
   Tooltip Animations
   ======================================== */

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tooltip,
[data-tooltip]::after {
    animation: tooltipFadeIn 0.2s ease;
}

/* ========================================
   Accordion Animations
   ======================================== */

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s var(--animation-timing);
}

.accordion-item.active .accordion-content {
    max-height: 1000px;
}

.accordion-toggle::after {
    content: '+';
    transition: transform var(--animation-duration);
}

.accordion-item.active .accordion-toggle::after {
    transform: rotate(45deg);
}

/* ========================================
   Tab Animations
   ======================================== */

.tab-content {
    animation: fadeInUp 0.4s var(--animation-timing);
}

.tab-indicator {
    transition: all var(--animation-duration) var(--animation-timing);
}

/* ========================================
   Dropdown Animations
   ======================================== */

.dropdown-menu,
.sub-menu {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--animation-duration) var(--animation-timing);
}

.dropdown.open .dropdown-menu,
.menu-item:hover .sub-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* ========================================
   Stagger Animation
   ======================================== */

.stagger-item {
    opacity: 0;
    animation: fadeInUp 0.6s var(--animation-timing) forwards;
}

.stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-item:nth-child(6) { animation-delay: 0.6s; }

/* ========================================
   Accessibility
   ======================================== */

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Performance Optimizations
   ======================================== */

/* GPU acceleration for animations */
.btn,
.excerpt,
.thumbnail img,
.modal,
.dropdown-menu {
    will-change: transform;
}

/* Contain layout shifts */
.excerpt,
.post-list article {
    contain: layout style paint;
}

/* ========================================
   Dark Mode Support
   ======================================== */

.darking .skeleton {
    background: linear-gradient(90deg, #2a2a2a 25%, #3a3a3a 50%, #2a2a2a 75%);
}

.darking input:focus,
.darking textarea:focus,
.darking select:focus {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.2);
}

.darking .form-group input:focus + label,
.darking .form-group textarea:focus + label {
    background: #1a1a1a;
}
