/**
 * 마이랭킹 2026 - 인터렉티브 애니메이션
 * Dynamic & Interactive Effects
 */

/* ===== CSS Variables for Animations ===== */
:root {
    --animation-fast: 0.15s;
    --animation-normal: 0.3s;
    --animation-slow: 0.5s;
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ===== Page Load Animations ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

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

/* Page content animation - 부드럽게 나타나기만 */
.home-container {
    animation: fadeIn 0.5s var(--ease-smooth);
}

.result-container {
    animation: fadeIn 0.4s var(--ease-smooth);
}

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

/* ===== Logo Animation ===== */
.home-logo h1 {
    background: linear-gradient(135deg, #1a73e8, #4285f4, #1a73e8);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

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

.result-logo h2 {
    transition: transform var(--animation-normal) var(--ease-bounce);
}

.result-logo:hover h2 {
    transform: scale(1.05);
}

/* ===== Search Box Interactions ===== */
.search-box {
    transition: all var(--animation-normal) var(--ease-smooth);
}

.search-box:focus-within {
    transform: scale(1.02);
}

.search-box .search-icon {
    transition: all var(--animation-normal) var(--ease-smooth);
}

.search-box:focus-within .search-icon {
    color: #1a73e8;
    transform: scale(1.1);
}

.search-box .search-submit {
    transition: all var(--animation-fast) var(--ease-bounce);
}

.search-box .search-submit:hover {
    transform: scale(1.15);
}

.search-box .search-submit:active {
    transform: scale(0.95);
}

/* Search input typing effect */
.search-box input[type="text"]:focus {
    animation: inputFocus 0.3s var(--ease-smooth);
}

@keyframes inputFocus {
    0% { padding-left: 0; }
    50% { padding-left: 4px; }
    100% { padding-left: 0; }
}

/* ===== Button Interactions ===== */
.btn {
    position: relative;
    overflow: hidden;
    transition: all var(--animation-normal) var(--ease-smooth);
}

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

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

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.3);
}

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

.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(26, 115, 232, 0.4);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ===== Quick Links Interactions ===== */
.quick-link {
    transition: all var(--animation-normal) var(--ease-out-back);
}

.quick-link:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 8px 25px rgba(32,33,36,0.15);
    border-color: #1a73e8;
}

.quick-link:hover .link-icon {
    transform: scale(1.2);
    animation: iconBounce 0.5s var(--ease-bounce);
}

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

.quick-link .link-icon {
    transition: all var(--animation-normal) var(--ease-bounce);
}

/* ===== Card Animations ===== */
.card {
    transition: all var(--animation-normal) var(--ease-smooth);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(60,64,67,0.2), 0 4px 8px rgba(60,64,67,0.1);
}

.result-card {
    transition: all var(--animation-normal) var(--ease-smooth);
}

.result-card:hover {
    transform: translateX(8px);
    box-shadow: 0 4px 20px rgba(32,33,36,0.15);
    border-left: 3px solid #1a73e8;
}

/* ===== Table Row Animations ===== */
.result-table tbody tr {
    transition: all var(--animation-normal) var(--ease-smooth);
}

.result-row:hover {
    background: linear-gradient(90deg, #f8f9fa 0%, #fff 100%);
}

.result-row:hover + .result-row-detail {
    background: linear-gradient(90deg, #f0f4f8 0%, #fafafa 100%);
}

/* ===== Swimmer/Team Name Hover ===== */
.swimmer-name, .result-name {
    position: relative;
    transition: all var(--animation-fast) var(--ease-smooth);
}

.swimmer-name::after, .result-name::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, #1a73e8, #4285f4);
    transition: width var(--animation-normal) var(--ease-smooth);
}

.swimmer-name:hover::after, .result-name:hover::after {
    width: 100%;
}

.swimmer-name:hover, .result-name:hover {
    color: #1557b0;
}

/* ===== Filter Chips ===== */
.filter-chip {
    transition: all var(--animation-fast) var(--ease-bounce);
}

.filter-chip:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.filter-chip:active {
    transform: scale(0.95);
}

.filter-chip.active {
    animation: chipActivate 0.3s var(--ease-bounce);
}

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

/* ===== Badge Shine Effect ===== */
.badge {
    position: relative;
    overflow: hidden;
    transition: all var(--animation-normal) var(--ease-smooth);
}

.badge::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 40%,
        rgba(255,255,255,0.8) 50%,
        transparent 60%
    );
    transform: translateX(-100%);
    transition: none;
}

.badge:hover::after {
    animation: shine 0.6s ease;
}

@keyframes shine {
    to { transform: translateX(100%); }
}

/* ===== Medal Animations ===== */
.medal {
    transition: all var(--animation-normal) var(--ease-bounce);
}

.medal:hover {
    transform: scale(1.2) rotate(10deg);
}

.medal-item {
    transition: all var(--animation-normal) var(--ease-smooth);
}

.medal-item:hover {
    transform: translateY(-5px);
}

.medal-item:hover img {
    animation: medalShine 0.5s ease;
}

@keyframes medalShine {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

/* ===== Stats Card Animations ===== */
.stat-card {
    transition: all var(--animation-normal) var(--ease-out-back);
}

.stat-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 30px rgba(26, 115, 232, 0.2);
    border-color: #1a73e8;
}

.stat-value {
    transition: all var(--animation-normal) var(--ease-smooth);
}

.stat-card:hover .stat-value {
    transform: scale(1.1);
}

/* ===== Header Animation ===== */
.swimmer-header {
    position: relative;
    overflow: hidden;
}

.swimmer-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    animation: headerGlow 4s ease-in-out infinite;
}

@keyframes headerGlow {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(10%, 10%); }
}

.swimmer-avatar {
    transition: all var(--animation-normal) var(--ease-bounce);
}

.swimmer-avatar:hover {
    transform: scale(1.1) rotate(5deg);
}

/* ===== Autocomplete Animations ===== */
.autocomplete-container.active {
    animation: dropdownOpen 0.2s var(--ease-smooth);
}

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

.autocomplete-item {
    transition: all var(--animation-fast) var(--ease-smooth);
}

.autocomplete-item:hover {
    padding-left: 24px;
    background: linear-gradient(90deg, #e8f0fe 0%, #f1f3f4 100%);
}

/* ===== Dropdown Menu Animations ===== */
.dropdown-menu.active {
    animation: dropdownOpen 0.2s var(--ease-smooth);
}

.dropdown-item {
    transition: all var(--animation-fast) var(--ease-smooth);
}

.dropdown-item:hover {
    padding-left: 24px;
}

/* ===== Loading Animations ===== */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

/* ===== Floating Animation ===== */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

/* ===== Scroll to Top Button ===== */
#toTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #1a73e8, #4285f4);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all var(--animation-normal) var(--ease-bounce);
    box-shadow: 0 4px 15px rgba(26, 115, 232, 0.4);
    z-index: 1000;
}

#toTop.visible {
    opacity: 1;
    visibility: visible;
}

#toTop:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 25px rgba(26, 115, 232, 0.5);
}

#toTop:active {
    transform: scale(0.95);
}

/* ===== New Record Badge Animation ===== */
.new-record-badge {
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 10px 3px rgba(255, 107, 107, 0.2);
    }
}

.new-record-badge.gr {
    animation: badgePulseGold 2s ease-in-out infinite;
}

@keyframes badgePulseGold {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 10px 3px rgba(255, 215, 0, 0.3);
    }
}

/* ===== Record Images Animation ===== */
.record-images {
    transition: all var(--animation-normal) var(--ease-smooth);
}

.result-row:hover .record-images {
    transform: scale(1.05);
}

.record-char {
    transition: all var(--animation-fast) var(--ease-smooth);
}

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

/* ===== Team Logo Animation ===== */
.team-logo {
    transition: all var(--animation-normal) var(--ease-bounce);
}

.team-cell:hover .team-logo {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ===== Pagination Animations ===== */
.pagination-btn {
    transition: all var(--animation-fast) var(--ease-bounce);
}

.pagination-btn:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.2);
}

.pagination-btn:active:not(:disabled) {
    transform: scale(0.95);
}

/* ===== Tab Animations ===== */
.tab {
    position: relative;
    transition: all var(--animation-normal) var(--ease-smooth);
}

.tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 3px;
    background: #1a73e8;
    transition: all var(--animation-normal) var(--ease-smooth);
    transform: translateX(-50%);
}

.tab:hover::after {
    width: 100%;
}

.tab.active::after {
    width: 100%;
}

/* ===== Load More Button ===== */
.load-more .btn {
    position: relative;
    overflow: hidden;
}

.load-more .btn::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.load-more .btn:hover::after {
    left: 100%;
}

/* ===== Ripple Effect ===== */
.ripple {
    position: relative;
    overflow: hidden;
}

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

.ripple:active::after {
    animation: rippleEffect 0.6s ease-out;
}

@keyframes rippleEffect {
    0% {
        width: 0;
        height: 0;
        opacity: 0.5;
    }
    100% {
        width: 500px;
        height: 500px;
        opacity: 0;
    }
}

/* ===== No Results Animation ===== */
.no-results {
    animation: fadeInUp 0.5s var(--ease-smooth);
}

.no-results .icon {
    animation: float 3s ease-in-out infinite;
}

/* ===== Scroll Reveal (JS 필요) ===== */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.6s var(--ease-smooth);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ===== 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;
    }
}
