/* =====================================================
   Kfz-Werkstatt Sankt Ingbert - Animations Stylesheet
   ===================================================== */

/* =====================================================
   Base Animation Classes
   ===================================================== */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Staggered animations for grids */
.animate-on-scroll:nth-child(1) { transition-delay: 0ms; }
.animate-on-scroll:nth-child(2) { transition-delay: 100ms; }
.animate-on-scroll:nth-child(3) { transition-delay: 200ms; }
.animate-on-scroll:nth-child(4) { transition-delay: 300ms; }
.animate-on-scroll:nth-child(5) { transition-delay: 400ms; }
.animate-on-scroll:nth-child(6) { transition-delay: 500ms; }

/* =====================================================
   Hero Animations
   ===================================================== */
.animate-fade-in {
    animation: fadeIn 0.8s ease forwards;
}

.animate-slide-up {
    opacity: 0;
    transform: translateY(40px);
    animation: slideUp 0.8s ease forwards;
}

.delay-1 { animation-delay: 0.2s; }
.delay-2 { animation-delay: 0.4s; }
.delay-3 { animation-delay: 0.6s; }
.delay-4 { animation-delay: 0.8s; }

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

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

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

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

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

/* =====================================================
   Scale Animations
   ===================================================== */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

/* =====================================================
   Pulse Animations
   ===================================================== */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(196, 30, 30, 0.5);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(196, 30, 30, 0);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

.pulse-glow {
    animation: pulseGlow 2s infinite;
}

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

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

/* =====================================================
   Shake Animation
   ===================================================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s ease;
}

/* =====================================================
   Rotate Animations
   ===================================================== */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

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

.rotate {
    animation: rotate 10s linear infinite;
}

.rotate-reverse {
    animation: rotateReverse 10s linear infinite;
}

/* =====================================================
   Typing Animation
   ===================================================== */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 100% {
        border-color: transparent;
    }
    50% {
        border-color: var(--color-accent);
    }
}

.typing {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--color-accent);
    animation: typing 3s steps(30) forwards, blink 0.8s step-end infinite;
}

/* =====================================================
   Gradient Animation
   ===================================================== */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-animate {
    background-size: 200% 200%;
    animation: gradientShift 5s ease infinite;
}

/* =====================================================
   Loading Animations
   ===================================================== */
@keyframes spinnerRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
}

/* Dots Loading */
@keyframes dotsLoading {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.dots-loading {
    display: inline-flex;
    gap: 6px;
}

.dots-loading span {
    width: 8px;
    height: 8px;
    background: var(--color-accent);
    border-radius: 50%;
    animation: dotsLoading 1.4s ease-in-out infinite both;
}

.dots-loading span:nth-child(1) { animation-delay: -0.32s; }
.dots-loading span:nth-child(2) { animation-delay: -0.16s; }
.dots-loading span:nth-child(3) { animation-delay: 0s; }

/* =====================================================
   Progress Bar Animation
   ===================================================== */
@keyframes progressFill {
    from {
        width: 0;
    }
}

.progress-bar {
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-accent), var(--color-accent-light));
    border-radius: var(--radius-full);
    animation: progressFill 1.5s ease forwards;
}

/* =====================================================
   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.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ripple:active::after {
    width: 300px;
    height: 300px;
}

/* =====================================================
   Hover Effects
   ===================================================== */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.hover-glow {
    transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
    box-shadow: var(--shadow-glow);
}

.hover-scale {
    transition: transform var(--transition-base);
}

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

.hover-rotate {
    transition: transform var(--transition-base);
}

.hover-rotate:hover {
    transform: rotate(5deg);
}

/* =====================================================
   Text Effects
   ===================================================== */
.text-shimmer {
    background: linear-gradient(
        90deg,
        var(--color-text) 0%,
        var(--color-accent) 50%,
        var(--color-text) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s linear infinite;
}

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

/* =====================================================
   Image Effects
   ===================================================== */
.img-zoom {
    overflow: hidden;
}

.img-zoom img {
    transition: transform var(--transition-slow);
}

.img-zoom:hover img {
    transform: scale(1.1);
}

.img-reveal {
    position: relative;
    overflow: hidden;
}

.img-reveal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-accent);
    transform-origin: left;
    animation: imgReveal 1s ease forwards;
}

@keyframes imgReveal {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* =====================================================
   Counter Animation
   ===================================================== */
.counter {
    font-variant-numeric: tabular-nums;
}

/* =====================================================
   Scroll Progress Bar
   ===================================================== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--color-accent), var(--color-accent-light));
    z-index: 9999;
    transition: width 0.1s linear;
}

/* =====================================================
   Page Transition
   ===================================================== */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg);
    z-index: 9999;
    pointer-events: none;
    transform: translateY(100%);
    transition: transform 0.5s ease;
}

.page-transition.active {
    transform: translateY(0);
}

/* =====================================================
   Notification Animation
   ===================================================== */
@keyframes notificationSlide {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.notification {
    animation: notificationSlide 0.3s ease forwards;
}

.notification.hide {
    animation: notificationSlide 0.3s ease reverse forwards;
}

/* =====================================================
   Modal Animation
   ===================================================== */
.modal-backdrop {
    opacity: 0;
    transition: opacity var(--transition-base);
}

.modal-backdrop.active {
    opacity: 1;
}

.modal-content {
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    transition: all var(--transition-base);
}

.modal-backdrop.active .modal-content {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* =====================================================
   Accordion Animation
   ===================================================== */
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-base);
}

.accordion-item.active .accordion-content {
    max-height: 500px;
}

.accordion-icon {
    transition: transform var(--transition-fast);
}

.accordion-item.active .accordion-icon {
    transform: rotate(180deg);
}

/* =====================================================
   Tab Animation
   ===================================================== */
.tab-content {
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-base);
    display: none;
}

.tab-content.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* =====================================================
   Skeleton Loading
   ===================================================== */
@keyframes skeletonLoading {
    0% {
        background-position: -200px 0;
    }
    100% {
        background-position: calc(200px + 100%) 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-card) 0%,
        var(--color-bg-light) 50%,
        var(--color-bg-card) 100%
    );
    background-size: 200px 100%;
    animation: skeletonLoading 1.5s ease infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
}

.skeleton-title {
    height: 24px;
    width: 60%;
    margin-bottom: 12px;
}

.skeleton-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.skeleton-image {
    height: 200px;
}

/* =====================================================
   Parallax Styles
   ===================================================== */
.parallax {
    will-change: transform;
}

/* =====================================================
   Modern Gradient Animations
   ===================================================== */
@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.gradient-flow {
    background: linear-gradient(135deg, #C41E1E, #E04040, #C41E1E);
    background-size: 200% 200%;
    animation: gradientFlow 4s ease infinite;
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(196, 30, 30, 0.3),
                    0 0 40px rgba(220, 50, 50, 0.2);
    }
    50% {
        box-shadow: 0 0 40px rgba(196, 30, 30, 0.5),
                    0 0 80px rgba(220, 50, 50, 0.3);
    }
}

.glow-pulse {
    animation: glowPulse 3s ease-in-out infinite;
}

/* =====================================================
   3D Transform Animations
   ===================================================== */
@keyframes float3D {
    0%, 100% {
        transform: translateY(0) rotateX(0deg) rotateY(0deg);
    }
    25% {
        transform: translateY(-10px) rotateX(2deg) rotateY(2deg);
    }
    50% {
        transform: translateY(-5px) rotateX(0deg) rotateY(-2deg);
    }
    75% {
        transform: translateY(-15px) rotateX(-2deg) rotateY(0deg);
    }
}

.float-3d {
    animation: float3D 6s ease-in-out infinite;
    transform-style: preserve-3d;
}

/* =====================================================
   Blur In Animation
   ===================================================== */
@keyframes blurIn {
    from {
        opacity: 0;
        filter: blur(20px);
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        filter: blur(0);
        transform: scale(1);
    }
}

.blur-in {
    animation: blurIn 0.8s ease forwards;
}

/* =====================================================
   Bounce Elastic Animation
   ===================================================== */
@keyframes bounceElastic {
    0% {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    60% {
        opacity: 1;
        transform: translateY(-10px) scale(1.02);
    }
    80% {
        transform: translateY(5px) scale(0.98);
    }
    100% {
        transform: translateY(0) scale(1);
    }
}

.bounce-elastic {
    animation: bounceElastic 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* =====================================================
   Shine Effect
   ===================================================== */
@keyframes shine {
    0% {
        left: -100%;
    }
    100% {
        left: 150%;
    }
}

.shine-effect {
    position: relative;
    overflow: hidden;
}

.shine-effect::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.3),
        transparent
    );
    transform: skewX(-25deg);
}

.shine-effect:hover::after {
    animation: shine 0.8s ease;
}

/* =====================================================
   Card Flip Animation
   ===================================================== */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

/* =====================================================
   Text Reveal Animation
   ===================================================== */
@keyframes textReveal {
    0% {
        clip-path: polygon(0 0, 0 0, 0 100%, 0 100%);
    }
    100% {
        clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
    }
}

.text-reveal {
    animation: textReveal 1s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

/* =====================================================
   Morph Animation
   ===================================================== */
@keyframes morph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    25% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
    50% {
        border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%;
    }
    75% {
        border-radius: 60% 40% 60% 30% / 70% 30% 50% 60%;
    }
}

.morph-shape {
    animation: morph 8s ease-in-out infinite;
}

/* =====================================================
   Staggered Reveal
   ===================================================== */
.stagger-reveal > * {
    opacity: 0;
    transform: translateY(30px);
}

.stagger-reveal.animated > *:nth-child(1) { animation: slideUp 0.6s ease 0.1s forwards; }
.stagger-reveal.animated > *:nth-child(2) { animation: slideUp 0.6s ease 0.2s forwards; }
.stagger-reveal.animated > *:nth-child(3) { animation: slideUp 0.6s ease 0.3s forwards; }
.stagger-reveal.animated > *:nth-child(4) { animation: slideUp 0.6s ease 0.4s forwards; }
.stagger-reveal.animated > *:nth-child(5) { animation: slideUp 0.6s ease 0.5s forwards; }
.stagger-reveal.animated > *:nth-child(6) { animation: slideUp 0.6s ease 0.6s forwards; }

/* =====================================================
   Enhanced Stagger for Grids (up to 12 items)
   ===================================================== */
.animate-on-scroll:nth-child(7) { transition-delay: 600ms; }
.animate-on-scroll:nth-child(8) { transition-delay: 700ms; }
.animate-on-scroll:nth-child(9) { transition-delay: 800ms; }
.animate-on-scroll:nth-child(10) { transition-delay: 900ms; }
.animate-on-scroll:nth-child(11) { transition-delay: 1000ms; }
.animate-on-scroll:nth-child(12) { transition-delay: 1100ms; }

.stagger-reveal.animated > *:nth-child(7) { animation: slideUp 0.6s ease 0.7s forwards; }
.stagger-reveal.animated > *:nth-child(8) { animation: slideUp 0.6s ease 0.8s forwards; }
.stagger-reveal.animated > *:nth-child(9) { animation: slideUp 0.6s ease 0.9s forwards; }
.stagger-reveal.animated > *:nth-child(10) { animation: slideUp 0.6s ease 1.0s forwards; }
.stagger-reveal.animated > *:nth-child(11) { animation: slideUp 0.6s ease 1.1s forwards; }
.stagger-reveal.animated > *:nth-child(12) { animation: slideUp 0.6s ease 1.2s forwards; }

/* =====================================================
   Tilt on Hover (subtle 3D perspective)
   ===================================================== */
.tilt-hover {
    transition: transform 0.4s ease;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.tilt-hover:hover {
    transform: perspective(1000px) rotateX(2deg) rotateY(-2deg) translateY(-5px);
}

/* =====================================================
   Magnetic Hover (icon/button attraction)
   ===================================================== */
@keyframes magneticPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

.magnetic-hover {
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.magnetic-hover:hover {
    animation: magneticPulse 0.4s ease;
}

/* =====================================================
   Underline Reveal (for links & headings)
   ===================================================== */
.underline-reveal {
    position: relative;
    display: inline-block;
}

.underline-reveal::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, #C41E1E, #E53535);
    border-radius: 2px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.underline-reveal:hover::after,
.underline-reveal.active::after {
    width: 100%;
}

/* =====================================================
   Card Shine Sweep (on hover)
   ===================================================== */
@keyframes shineSweep {
    0% { transform: translateX(-100%) skewX(-15deg); }
    100% { transform: translateX(300%) skewX(-15deg); }
}

.card-shine {
    position: relative;
    overflow: hidden;
}

.card-shine::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    pointer-events: none;
    transform: skewX(-15deg);
}

.card-shine:hover::after {
    animation: shineSweep 0.7s ease;
}

/* =====================================================
   Glow Border Animation
   ===================================================== */
@keyframes borderRotate {
    0% { --angle: 0deg; }
    100% { --angle: 360deg; }
}

.glow-border {
    position: relative;
}

.glow-border::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: conic-gradient(from 0deg, #C41E1E, #E53535, transparent, transparent, #C41E1E);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
    animation: spin 3s linear infinite;
}

.glow-border:hover::before {
    opacity: 0.6;
}

/* =====================================================
   Fade In Blur
   ===================================================== */
.animate-blur-in {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(20px);
    transition: opacity 0.8s ease, filter 0.8s ease, transform 0.8s ease;
}

.animate-blur-in.animated {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
}

/* =====================================================
   Slide In from Sides
   ===================================================== */
.animate-slide-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-slide-left.animated {
    opacity: 1;
    transform: translateX(0);
}

.animate-slide-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-slide-right.animated {
    opacity: 1;
    transform: translateX(0);
}

/* =====================================================
   Auto Reveal (JS-driven, applies to all pages)
   WICHTIG: Nutzt die `translate` CSS-Property (NICHT `transform`),
   damit sie nicht mit :hover/:active Transforms der Cards kollidiert.
   `translate` und `transform` sind unabhängige Properties — der
   Browser kombiniert sie automatisch.
   ===================================================== */
.reveal-fx {
    opacity: 0;
    translate: 0 24px;
    transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1),
                translate 0.7s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, translate;
}

.reveal-fx.is-revealed {
    opacity: 1;
    translate: 0 0;
}

/* Stagger innerhalb von Grid/Flex-Geschwistern */
.reveal-fx:nth-child(2)  { transition-delay: 60ms; }
.reveal-fx:nth-child(3)  { transition-delay: 120ms; }
.reveal-fx:nth-child(4)  { transition-delay: 180ms; }
.reveal-fx:nth-child(5)  { transition-delay: 240ms; }
.reveal-fx:nth-child(6)  { transition-delay: 300ms; }
.reveal-fx:nth-child(7)  { transition-delay: 360ms; }
.reveal-fx:nth-child(8)  { transition-delay: 420ms; }
.reveal-fx:nth-child(9)  { transition-delay: 480ms; }
.reveal-fx:nth-child(10) { transition-delay: 540ms; }
.reveal-fx:nth-child(11) { transition-delay: 600ms; }
.reveal-fx:nth-child(12) { transition-delay: 660ms; }

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

    .animate-on-scroll {
        opacity: 1;
        transform: none;
    }

    .reveal-fx {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .parallax {
        transform: none !important;
    }
}
