/* ========================================
   3D ANIMATIONS & EFFECTS
   Thu vien hieu ung 3D cho website
   ======================================== */

/* ============ 3D PERSPECTIVE CONTAINER ============ */
.perspective-container {
    perspective: 1000px;
    perspective-origin: center;
}

/* ============ 3D CARD EFFECTS ============ */

/* 3D Flip Card */
.card-3d-flip {
    perspective: 1000px;
    height: 200px;
}

.card-3d-flip .card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.card-3d-flip:hover .card-inner {
    transform: rotateY(180deg);
}

.card-3d-flip .card-front,
.card-3d-flip .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 1rem;
    overflow: hidden;
}

.card-3d-flip .card-back {
    transform: rotateY(180deg);
}

/* 3D Hover Tilt Effect */
.card-3d-tilt {
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.card-3d-tilt:hover {
    transform: perspective(1000px) rotateX(5deg) rotateY(-5deg) scale3d(1.02, 1.02, 1.02);
}

.card-3d-tilt::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, transparent 50%, rgba(0, 0, 0, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    border-radius: inherit;
}

.card-3d-tilt:hover::before {
    opacity: 1;
}

/* 3D Pop Effect */
.card-3d-pop {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.card-3d-pop:hover {
    transform: perspective(1000px) translateZ(30px) rotateX(-2deg);
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 30px rgba(102, 126, 234, 0.3);
}

/* ============ FLOATING ANIMATIONS ============ */

/* Floating Up & Down */
@keyframes float3d {

    0%,
    100% {
        transform: translateY(0) translateZ(0);
    }

    50% {
        transform: translateY(-15px) translateZ(10px);
    }
}

.float-3d {
    animation: float3d 3s ease-in-out infinite;
    transform-style: preserve-3d;
}

/* Floating with Rotation */
@keyframes floatRotate3d {
    0% {
        transform: translateY(0) rotateY(0deg) rotateX(0deg);
    }

    25% {
        transform: translateY(-10px) rotateY(5deg) rotateX(2deg);
    }

    50% {
        transform: translateY(-20px) rotateY(0deg) rotateX(-2deg);
    }

    75% {
        transform: translateY(-10px) rotateY(-5deg) rotateX(2deg);
    }

    100% {
        transform: translateY(0) rotateY(0deg) rotateX(0deg);
    }
}

.float-rotate-3d {
    animation: floatRotate3d 4s ease-in-out infinite;
    transform-style: preserve-3d;
}

/* Levitate Effect */
@keyframes levitate3d {

    0%,
    100% {
        transform: translateY(0) rotateX(0deg) scale(1);
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    50% {
        transform: translateY(-20px) rotateX(5deg) scale(1.02);
        box-shadow: 0 25px 40px rgba(0, 0, 0, 0.15);
    }
}

.levitate-3d {
    animation: levitate3d 3s ease-in-out infinite;
    transform-style: preserve-3d;
}

/* ============ 3D BUTTON EFFECTS ============ */

/* 3D Push Button */
.btn-3d-push {
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.15s ease;
    box-shadow:
        0 6px 0 #5568d3,
        0 8px 10px rgba(0, 0, 0, 0.3);
}

.btn-3d-push:hover {
    transform: translateY(-2px);
    box-shadow:
        0 8px 0 #5568d3,
        0 12px 15px rgba(0, 0, 0, 0.3);
}

.btn-3d-push:active {
    transform: translateY(4px);
    box-shadow:
        0 2px 0 #5568d3,
        0 4px 6px rgba(0, 0, 0, 0.3);
}

/* 3D Flip Button */
.btn-3d-flip {
    perspective: 1000px;
    position: relative;
    overflow: hidden;
}

.btn-3d-flip .btn-text {
    display: block;
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.btn-3d-flip:hover .btn-text {
    transform: rotateX(360deg);
}

/* 3D Glow Button */
.btn-3d-glow {
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.3s ease;
}

.btn-3d-glow::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #667eea, #764ba2, #667eea);
    background-size: 200% 200%;
    border-radius: inherit;
    z-index: -1;
    filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
    animation: glowRotate 3s linear infinite;
}

.btn-3d-glow:hover::before {
    opacity: 1;
}

.btn-3d-glow:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 30px rgba(102, 126, 234, 0.4);
}

@keyframes glowRotate {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* ============ 3D ICON EFFECTS ============ */

/* 3D Spinning Icon */
@keyframes spin3d {
    0% {
        transform: rotateY(0deg);
    }

    100% {
        transform: rotateY(360deg);
    }
}

.icon-3d-spin {
    animation: spin3d 3s linear infinite;
    transform-style: preserve-3d;
}

.icon-3d-spin:hover {
    animation: spin3d 0.5s linear infinite;
}

/* 3D Bounce Icon */
@keyframes bounce3d {

    0%,
    100% {
        transform: translateY(0) rotateX(0deg) scale(1);
    }

    25% {
        transform: translateY(-15px) rotateX(-15deg) scale(1.1);
    }

    50% {
        transform: translateY(0) rotateX(0deg) scale(1);
    }

    75% {
        transform: translateY(-8px) rotateX(-8deg) scale(1.05);
    }
}

.icon-3d-bounce {
    animation: bounce3d 2s ease-in-out infinite;
    transform-style: preserve-3d;
}

/* 3D Pulse Icon */
@keyframes pulse3d {

    0%,
    100% {
        transform: scale3d(1, 1, 1);
    }

    50% {
        transform: scale3d(1.15, 1.15, 1.15);
    }
}

.icon-3d-pulse {
    animation: pulse3d 1.5s ease-in-out infinite;
    transform-style: preserve-3d;
}

/* ============ 3D PODIUM EFFECTS ============ */

/* 3D Podium Card */
.podium-3d {
    transform-style: preserve-3d;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.podium-3d:hover {
    transform: perspective(1000px) rotateY(-8deg) rotateX(5deg) translateZ(20px);
}

/* First Place - Gold Shine */
.podium-3d.gold::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
            transparent 30%,
            rgba(255, 215, 0, 0.4) 50%,
            transparent 70%);
    animation: goldShine 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes goldShine {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }

    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

/* ============ 3D TEXT EFFECTS ============ */

/* 3D Text Shadow */
.text-3d {
    text-shadow:
        1px 1px 0 #5568d3,
        2px 2px 0 #4458c3,
        3px 3px 0 #3348b3,
        4px 4px 0 #2238a3,
        5px 5px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.text-3d:hover {
    transform: translateY(-3px);
    text-shadow:
        1px 1px 0 #5568d3,
        2px 2px 0 #4458c3,
        3px 3px 0 #3348b3,
        4px 4px 0 #2238a3,
        5px 5px 0 #1128a3,
        6px 6px 0 #0018b3,
        7px 7px 20px rgba(0, 0, 0, 0.4);
}

/* 3D Rotating Text */
@keyframes rotateText3d {
    0% {
        transform: rotateX(0deg);
    }

    100% {
        transform: rotateX(360deg);
    }
}

.text-3d-rotate {
    display: inline-block;
    transform-style: preserve-3d;
}

.text-3d-rotate:hover {
    animation: rotateText3d 1s ease-in-out;
}

/* ============ 3D BACKGROUND EFFECTS ============ */

/* Moving 3D Background Particles */
.bg-3d-particles {
    position: relative;
    overflow: hidden;
}

.bg-3d-particles::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(102, 126, 234, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(118, 75, 162, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 40% 40%, rgba(102, 126, 234, 0.2) 0%, transparent 30%);
    animation: moveParticles3d 15s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes moveParticles3d {
    0% {
        transform: translateX(0) translateY(0) scale(1);
    }

    33% {
        transform: translateX(30px) translateY(-30px) scale(1.1);
    }

    66% {
        transform: translateX(-20px) translateY(20px) scale(0.95);
    }

    100% {
        transform: translateX(10px) translateY(-10px) scale(1.05);
    }
}

/* ============ 3D AVATAR EFFECTS ============ */

/* 3D Avatar Hover */
.avatar-3d {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.avatar-3d:hover {
    transform: perspective(500px) rotateY(15deg) rotateX(-5deg) scale(1.1);
    box-shadow:
        -10px 10px 20px rgba(0, 0, 0, 0.2),
        0 0 30px rgba(102, 126, 234, 0.4);
}

/* Floating Avatar Ring */
.avatar-3d-ring {
    position: relative;
}

.avatar-3d-ring::before {
    content: '';
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 3px solid transparent;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: ringRotate3d 2s linear infinite;
}

.avatar-3d-ring::after {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border: 2px solid transparent;
    border-bottom-color: #764ba2;
    border-radius: 50%;
    animation: ringRotate3d 3s linear infinite reverse;
}

@keyframes ringRotate3d {
    0% {
        transform: rotateZ(0deg);
    }

    100% {
        transform: rotateZ(360deg);
    }
}

/* ============ 3D PAGE TRANSITIONS ============ */

/* Page Slide In 3D */
@keyframes slideIn3d {
    0% {
        opacity: 0;
        transform: perspective(1000px) translateZ(-300px) rotateY(-10deg);
    }

    100% {
        opacity: 1;
        transform: perspective(1000px) translateZ(0) rotateY(0deg);
    }
}

.page-3d-enter {
    animation: slideIn3d 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Content Reveal 3D */
@keyframes reveal3d {
    0% {
        opacity: 0;
        transform: perspective(1000px) rotateX(-90deg);
        transform-origin: top center;
    }

    100% {
        opacity: 1;
        transform: perspective(1000px) rotateX(0deg);
    }
}

.reveal-3d {
    animation: reveal3d 0.7s ease-out forwards;
}

/* Stagger Children Animation */
.stagger-3d>*:nth-child(1) {
    animation-delay: 0.1s;
}

.stagger-3d>*:nth-child(2) {
    animation-delay: 0.2s;
}

.stagger-3d>*:nth-child(3) {
    animation-delay: 0.3s;
}

.stagger-3d>*:nth-child(4) {
    animation-delay: 0.4s;
}

.stagger-3d>*:nth-child(5) {
    animation-delay: 0.5s;
}

.stagger-3d>*:nth-child(6) {
    animation-delay: 0.6s;
}

/* ============ 3D MEDAL EFFECTS ============ */

/* Rotating Medal */
.medal-3d {
    transform-style: preserve-3d;
    animation: medalFloat 3s ease-in-out infinite;
}

@keyframes medalFloat {

    0%,
    100% {
        transform: translateY(0) rotateY(0deg);
    }

    25% {
        transform: translateY(-5px) rotateY(15deg);
    }

    50% {
        transform: translateY(-10px) rotateY(0deg);
    }

    75% {
        transform: translateY(-5px) rotateY(-15deg);
    }
}

.medal-3d:hover {
    animation: medalSpin 0.5s ease-in-out;
}

@keyframes medalSpin {
    0% {
        transform: rotateY(0deg);
    }

    100% {
        transform: rotateY(360deg);
    }
}

/* ============ 3D LOADING EFFECTS ============ */

/* 3D Cube Loader */
.loader-3d-cube {
    width: 40px;
    height: 40px;
    transform-style: preserve-3d;
    animation: cubeRotate 2s linear infinite;
}

@keyframes cubeRotate {
    0% {
        transform: rotateX(0deg) rotateY(0deg);
    }

    100% {
        transform: rotateX(360deg) rotateY(360deg);
    }
}

/* 3D Dots Loader */
.loader-3d-dots {
    display: flex;
    gap: 8px;
}

.loader-3d-dots span {
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    animation: dotBounce3d 1.4s ease-in-out infinite;
}

.loader-3d-dots span:nth-child(1) {
    animation-delay: 0s;
}

.loader-3d-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.loader-3d-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce3d {

    0%,
    80%,
    100% {
        transform: translateY(0) scale(1);
    }

    40% {
        transform: translateY(-20px) scale(1.2);
    }
}

/* ============ MOBILE OPTIMIZATION FOR 3D ============ */
@media (max-width: 768px) {

    /* Reduce animation intensity on mobile for performance */
    .float-3d,
    .float-rotate-3d,
    .levitate-3d {
        animation-duration: 4s;
    }

    .card-3d-tilt:hover,
    .card-3d-pop:hover,
    .podium-3d:hover {
        transform: scale(1.02);
    }

    .medal-3d {
        animation-duration: 4s;
    }

    /* Disable complex 3D transforms on touch devices */
    .avatar-3d:hover {
        transform: scale(1.05);
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {

    .float-3d,
    .float-rotate-3d,
    .levitate-3d,
    .icon-3d-spin,
    .icon-3d-bounce,
    .icon-3d-pulse,
    .medal-3d,
    .avatar-3d-ring::before,
    .avatar-3d-ring::after {
        animation: none;
    }

    .card-3d-flip:hover .card-inner,
    .card-3d-tilt:hover,
    .card-3d-pop:hover,
    .btn-3d-flip:hover .btn-text,
    .text-3d-rotate:hover {
        transform: none;
    }
}