/**
 * DENTAL IMPLANT 3D ANIMATIONS CSS
 * QClay-inspired visual effects for teeth, implants, and injectables
 * 
 * @package DrNaela
 * @version 2.0.0
 */

/* ====================
   3D INTERACTIVE IMPLANT ROTATION
   ==================== */

.implant-3d-interactive {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    cursor: grab;
    transform-style: preserve-3d;
}

.implant-3d-interactive:active {
    cursor: grabbing;
}

.implant-3d-interactive img {
    width: 100%;
    height: auto;
    border-radius: var(--radius-lg);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-style: preserve-3d;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.shine-effect {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: var(--radius-lg);
    pointer-events: none;
    transition: background 0.3s ease;
}

/* ====================
   SCROLL-BASED IMPLANT ASSEMBLY
   ==================== */

.implant-assembly-section {
    position: relative;
    min-height: 150vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
    overflow: hidden;
}

.implant-assembly-container {
    position: sticky;
    top: 20vh;
    width: 100%;
    max-width: 800px;
    height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.jawbone,
.implant-fixture,
.implant-abutment,
.implant-crown {
    position: absolute;
    transition: all 0.3s ease-out;
}

.jawbone {
    width: 600px;
    height: auto;
    opacity: 0;
    z-index: 1;
}

.implant-fixture {
    width: 100px;
    height: auto;
    opacity: 0;
    z-index: 2;
}

.implant-abutment {
    width: 80px;
    height: auto;
    opacity: 0;
    z-index: 3;
}

.implant-crown {
    width: 120px;
    height: auto;
    opacity: 0;
    z-index: 4;
}

.assembly-complete .jawbone,
.assembly-complete .implant-fixture,
.assembly-complete .implant-abutment,
.assembly-complete .implant-crown {
    filter: drop-shadow(0 0 20px rgba(136, 201, 193, 0.6));
    animation: assembly-glow 2s ease-in-out infinite;
}

@keyframes assembly-glow {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(136, 201, 193, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 40px rgba(136, 201, 193, 1));
    }
}

/* ====================
   BEFORE/AFTER SLIDER
   ==================== */

.before-after-implant {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    overflow: hidden;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.before-after-implant img {
    width: 100%;
    height: auto;
    display: block;
}

.before-after-implant .before {
    position: relative;
    z-index: 1;
}

.before-after-implant .after {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    clip-path: inset(0 50% 0 0);
    transition: clip-path 0.1s ease;
}

.slider-handle {
    position: absolute;
    top: 0;
    left: 50%;
    width: 4px;
    height: 100%;
    background: white;
    cursor: ew-resize;
    z-index: 3;
    transform: translateX(-50%);
    transition: left 0.1s ease;
}

.slider-handle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-handle::after {
    content: '⇔';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: #2E5090;
    font-weight: bold;
    z-index: 1;
}

/* ====================
   ANIMATED IMPLANT SEQUENCE
   ==================== */

.implant-sequence-animation {
    position: relative;
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    height: 500px;
}

.implant-sequence-animation .sequence-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.implant-sequence-animation.playing .stage-1 {
    animation: stage-fade-in 1s ease 0s forwards;
}

.implant-sequence-animation.playing .stage-2 {
    animation: stage-fade-in 1s ease 1.5s forwards, drill-in 1s ease 1.5s;
}

.implant-sequence-animation.playing .stage-3 {
    animation: stage-fade-in 0.5s ease 3s forwards;
}

.implant-sequence-animation.playing .stage-4 {
    animation: stage-fade-in 0.8s ease 4s forwards, slide-down 0.8s ease 4s;
}

.implant-sequence-animation.playing .stage-5 {
    animation: stage-fade-in 1s ease 5.5s forwards, crown-place 1s ease 5.5s;
}

.implant-sequence-animation.playing .stage-6 {
    animation: stage-fade-in 1s ease 7s forwards, zoom-out 1s ease 7s;
}

@keyframes stage-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes drill-in {
    from {
        transform: translate(-50%, -150%) rotate(360deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(0deg);
    }
}

@keyframes slide-down {
    from {
        transform: translate(-50%, -100%);
    }
    to {
        transform: translate(-50%, -50%);
    }
}

@keyframes crown-place {
    from {
        transform: translate(-50%, -120%) scale(0.6);
    }
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes zoom-out {
    from {
        transform: translate(-50%, -50%) scale(1.3);
    }
    to {
        transform: translate(-50%, -50%) scale(1);
    }
}

/* ====================
   IMPLANT PARTICLES
   ==================== */

.implant-card-premium {
    position: relative;
    overflow: hidden;
}

.implant-particle {
    position: absolute;
    background: radial-gradient(circle, rgba(136, 201, 193, 0.8) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    animation: particle-float 1s ease-out forwards;
    z-index: 10;
}

@keyframes particle-float {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* ====================
   TOOTH WAVE ANIMATION
   ==================== */

.tooth-grid-animation {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 1rem;
    padding: 2rem;
}

.tooth-item {
    width: 100%;
    aspect-ratio: 1;
    background: white;
    border-radius: 50% 50% 45% 45%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
    position: relative;
}

.tooth-item::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    width: 50%;
    height: 20%;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.9), transparent);
    border-radius: 50%;
}

.tooth-item.wave-bounce {
    animation: tooth-bounce 0.5s ease;
}

@keyframes tooth-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

/* ====================
   INJECTABLE VIAL ANIMATION
   ==================== */

.injectable-vial-container {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    align-items: flex-end;
    padding: 2rem;
}

.vial {
    width: 80px;
    height: 120px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(240, 240, 240, 0.9) 100%);
    border-radius: 8px 8px 4px 4px;
    position: relative;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.vial::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    width: 20%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
}

.vial::after {
    content: '';
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 20px;
    background: linear-gradient(to bottom, #d0d0d0, #a0a0a0);
    border-radius: 4px 4px 0 0;
}

.liquid-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40%;
    background: linear-gradient(180deg, rgba(136, 201, 193, 0.3) 0%, rgba(136, 201, 193, 0.8) 100%);
    transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vial-lift {
    transform: translateY(-15px) scale(1.05);
}

.vial-label {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    font-weight: 600;
    color: #2E5090;
}

/* ====================
   360° TOOTH ROTATION
   ==================== */

.tooth-360-rotation {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    cursor: grab;
    user-select: none;
}

.tooth-360-rotation:active {
    cursor: grabbing;
}

.tooth-360-rotation img {
    width: 100%;
    height: auto;
    position: absolute;
    top: 0;
    left: 0;
    transition: opacity 0.1s ease;
}

/* ====================
   HOVER EFFECTS FOR YOUR PHOTOS
   ==================== */

.implant-photo-card {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.implant-photo-card:hover {
    transform: translateY(-15px) scale(1.02);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.25);
}

.implant-photo-card img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.6s ease;
}

.implant-photo-card:hover img {
    transform: scale(1.1);
}

.implant-photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    color: white;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.implant-photo-card:hover .implant-photo-overlay {
    transform: translateY(0);
}

/* ====================
   PULSE EFFECT
   ==================== */

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    border: 3px solid rgba(136, 201, 193, 0.8);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse-ring-animation 2s ease-out infinite;
}

@keyframes pulse-ring-animation {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* ====================
   FLOATING INSTRUMENTS
   ==================== */

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

.floating-instrument:nth-child(2) {
    animation-delay: 0.5s;
}

.floating-instrument:nth-child(3) {
    animation-delay: 1s;
}

@keyframes float-instrument {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-15px) rotate(2deg);
    }
    50% {
        transform: translateY(0) rotate(0deg);
    }
    75% {
        transform: translateY(-10px) rotate(-2deg);
    }
}

/* ====================
   GLOWING IMPLANT
   ==================== */

.glowing-implant {
    animation: glow-pulse 3s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(136, 201, 193, 0.5));
}

@keyframes glow-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(136, 201, 193, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(136, 201, 193, 1));
    }
}

/* ====================
   MORPHING BACKGROUND
   ==================== */

.morphing-bg {
    background: linear-gradient(45deg, #2E5090, #88C9C1, #E8B4A8, #2E5090);
    background-size: 400% 400%;
    animation: morphing-gradient 15s ease infinite;
}

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

/* ====================
   RESPONSIVE
   ==================== */

@media (max-width: 768px) {
    .tooth-grid-animation {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }
    
    .vial {
        width: 60px;
        height: 90px;
    }
    
    .implant-assembly-section {
        min-height: 100vh;
    }
    
    .jawbone {
        width: 90vw;
    }
    
    .slider-handle::before {
        width: 40px;
        height: 40px;
    }
    
    .slider-handle::after {
        font-size: 18px;
    }
}

/* ====================
   ACCESSIBILITY
   ==================== */

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

/* ====================
   PRINT
   ==================== */

@media print {
    .implant-particle,
    .shine-effect,
    .pulse-ring,
    .slider-handle {
        display: none;
    }
}

