/* ==========================================================================
   RAFTAR ECOM - Animations Stylesheet
   GSAP & ScrollTrigger Animation Classes
   ========================================================================== */

/* --------------------------------------------------------------------------
   Initial States for Animations
   -------------------------------------------------------------------------- */

/* Fade animations - initial states */
.fade-in,
.fade-up,
.fade-down,
.fade-left,
.fade-right {
    opacity: 0;
}

.fade-up {
    transform: translateY(50px);
}

.fade-down {
    transform: translateY(-50px);
}

.fade-left {
    transform: translateX(50px);
}

.fade-right {
    transform: translateX(-50px);
}

/* Scale animations */
.scale-in {
    opacity: 0;
    transform: scale(0.8);
}

/* Rotate animations */
.rotate-in {
    opacity: 0;
    transform: rotate(-10deg) scale(0.9);
}

/* Split text characters/words */
.split-char,
.split-word,
.split-line {
    display: inline-block;
    opacity: 0;
    transform: translateY(100%);
}

/* Animated states (when visible) */
.is-visible {
    opacity: 1 !important;
    transform: translate(0) scale(1) rotate(0) !important;
}

/* --------------------------------------------------------------------------
   Stagger Animation Groups
   -------------------------------------------------------------------------- */
.stagger-group > * {
    opacity: 0;
    transform: translateY(30px);
}

.stagger-group.is-visible > * {
    opacity: 1;
    transform: translateY(0);
}

/* --------------------------------------------------------------------------
   Image Reveal Animations
   -------------------------------------------------------------------------- */
.reveal-image {
    position: relative;
    overflow: hidden;
}

.reveal-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-primary);
    z-index: 2;
    transform-origin: left;
}

.reveal-image img {
    transform: scale(1.3);
    transition: transform 1.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-image.revealed::before {
    animation: revealSlide 1s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

.reveal-image.revealed img {
    transform: scale(1);
}

@keyframes revealSlide {
    0% {
        transform: scaleX(1);
        transform-origin: left;
    }
    50% {
        transform: scaleX(1);
        transform-origin: right;
    }
    100% {
        transform: scaleX(0);
        transform-origin: right;
    }
}

/* Reveal from different directions */
.reveal-image.reveal-left::before {
    transform-origin: right;
}

.reveal-image.reveal-right::before {
    transform-origin: left;
}

.reveal-image.reveal-top::before {
    transform-origin: bottom;
}

.reveal-image.reveal-bottom::before {
    transform-origin: top;
}

/* --------------------------------------------------------------------------
   Line Draw Animations
   -------------------------------------------------------------------------- */
.line-draw {
    position: relative;
}

.line-draw::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--color-primary);
    transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.line-draw.is-visible::after,
.line-draw:hover::after {
    width: 100%;
}

/* --------------------------------------------------------------------------
   Counter Animations
   -------------------------------------------------------------------------- */
.counter-animate {
    font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Floating Animations
   -------------------------------------------------------------------------- */
.float {
    animation: float 3s ease-in-out infinite;
}

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

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

/* --------------------------------------------------------------------------
   Pulse Animations
   -------------------------------------------------------------------------- */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

/* Pulse ring effect */
.pulse-ring {
    position: relative;
}

.pulse-ring::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: 2px solid var(--color-primary);
    border-radius: inherit;
    transform: translate(-50%, -50%);
    animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* --------------------------------------------------------------------------
   Shake Animation
   -------------------------------------------------------------------------- */
.shake {
    animation: shake 0.5s ease-in-out;
}

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

/* --------------------------------------------------------------------------
   Bounce Animation
   -------------------------------------------------------------------------- */
.bounce {
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-15px);
    }
    60% {
        transform: translateY(-7px);
    }
}

/* --------------------------------------------------------------------------
   Slide Animations
   -------------------------------------------------------------------------- */
.slide-in-left {
    animation: slideInLeft 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-in-right {
    animation: slideInRight 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-in-up {
    animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.slide-in-down {
    animation: slideInDown 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

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

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

/* --------------------------------------------------------------------------
   Flip Animations
   -------------------------------------------------------------------------- */
.flip-in-x {
    animation: flipInX 0.6s ease forwards;
    backface-visibility: visible;
}

.flip-in-y {
    animation: flipInY 0.6s ease forwards;
    backface-visibility: visible;
}

@keyframes flipInX {
    from {
        opacity: 0;
        transform: perspective(400px) rotateX(90deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateX(0);
    }
}

@keyframes flipInY {
    from {
        opacity: 0;
        transform: perspective(400px) rotateY(90deg);
    }
    to {
        opacity: 1;
        transform: perspective(400px) rotateY(0);
    }
}

/* --------------------------------------------------------------------------
   Zoom Animations
   -------------------------------------------------------------------------- */
.zoom-in {
    animation: zoomIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.zoom-out {
    animation: zoomOut 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes zoomOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.5);
    }
}

/* --------------------------------------------------------------------------
   Rotate Animations
   -------------------------------------------------------------------------- */
.rotate-continuous {
    animation: rotateContinuous 20s linear infinite;
}

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

/* --------------------------------------------------------------------------
   Gradient Text Animation
   -------------------------------------------------------------------------- */
.gradient-text-animate {
    background: linear-gradient(
        90deg,
        var(--color-primary) 0%,
        var(--color-secondary) 50%,
        var(--color-primary) 100%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 3s ease infinite;
}

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

/* --------------------------------------------------------------------------
   Border Animation
   -------------------------------------------------------------------------- */
.border-animate {
    position: relative;
}

.border-animate::before,
.border-animate::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border: 2px solid transparent;
    box-sizing: border-box;
}

.border-animate::before {
    top: 0;
    left: 0;
    border-top-color: var(--color-primary);
    border-right-color: var(--color-primary);
}

.border-animate::after {
    bottom: 0;
    right: 0;
    border-bottom-color: var(--color-primary);
    border-left-color: var(--color-primary);
}

.border-animate:hover::before,
.border-animate:hover::after {
    width: 100%;
    height: 100%;
    transition: width 0.3s ease, height 0.3s ease 0.3s;
}

/* --------------------------------------------------------------------------
   Magnetic Button Effect
   -------------------------------------------------------------------------- */
.magnetic-btn {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   Tilt Effect
   -------------------------------------------------------------------------- */
.tilt {
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* --------------------------------------------------------------------------
   Glitch Effect
   -------------------------------------------------------------------------- */
.glitch {
    position: relative;
}

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--color-secondary);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-1 5s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: -2px 0 var(--color-primary);
    clip: rect(44px, 450px, 56px, 0);
    animation: glitch-2 5s infinite linear alternate-reverse;
}

@keyframes glitch-1 {
    0% { clip: rect(31px, 9999px, 94px, 0); }
    5% { clip: rect(70px, 9999px, 71px, 0); }
    10% { clip: rect(29px, 9999px, 24px, 0); }
    15% { clip: rect(68px, 9999px, 34px, 0); }
    20% { clip: rect(52px, 9999px, 72px, 0); }
    25% { clip: rect(42px, 9999px, 38px, 0); }
    30% { clip: rect(19px, 9999px, 85px, 0); }
    35% { clip: rect(99px, 9999px, 36px, 0); }
    40% { clip: rect(22px, 9999px, 77px, 0); }
    45% { clip: rect(59px, 9999px, 98px, 0); }
    50% { clip: rect(39px, 9999px, 59px, 0); }
    55% { clip: rect(43px, 9999px, 82px, 0); }
    60% { clip: rect(10px, 9999px, 54px, 0); }
    65% { clip: rect(50px, 9999px, 26px, 0); }
    70% { clip: rect(85px, 9999px, 47px, 0); }
    75% { clip: rect(65px, 9999px, 88px, 0); }
    80% { clip: rect(32px, 9999px, 61px, 0); }
    85% { clip: rect(48px, 9999px, 45px, 0); }
    90% { clip: rect(91px, 9999px, 29px, 0); }
    95% { clip: rect(14px, 9999px, 75px, 0); }
    100% { clip: rect(77px, 9999px, 40px, 0); }
}

@keyframes glitch-2 {
    0% { clip: rect(65px, 9999px, 100px, 0); }
    5% { clip: rect(52px, 9999px, 74px, 0); }
    10% { clip: rect(79px, 9999px, 85px, 0); }
    15% { clip: rect(75px, 9999px, 5px, 0); }
    20% { clip: rect(67px, 9999px, 61px, 0); }
    25% { clip: rect(14px, 9999px, 79px, 0); }
    30% { clip: rect(1px, 9999px, 66px, 0); }
    35% { clip: rect(86px, 9999px, 30px, 0); }
    40% { clip: rect(23px, 9999px, 98px, 0); }
    45% { clip: rect(85px, 9999px, 72px, 0); }
    50% { clip: rect(71px, 9999px, 75px, 0); }
    55% { clip: rect(2px, 9999px, 48px, 0); }
    60% { clip: rect(30px, 9999px, 16px, 0); }
    65% { clip: rect(59px, 9999px, 50px, 0); }
    70% { clip: rect(41px, 9999px, 62px, 0); }
    75% { clip: rect(2px, 9999px, 82px, 0); }
    80% { clip: rect(47px, 9999px, 73px, 0); }
    85% { clip: rect(3px, 9999px, 27px, 0); }
    90% { clip: rect(26px, 9999px, 55px, 0); }
    95% { clip: rect(42px, 9999px, 97px, 0); }
    100% { clip: rect(38px, 9999px, 49px, 0); }
}

/* --------------------------------------------------------------------------
   Typewriter Effect
   -------------------------------------------------------------------------- */
.typewriter {
    overflow: hidden;
    border-right: 2px solid var(--color-primary);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--color-primary); }
}

/* --------------------------------------------------------------------------
   Loading Skeleton
   -------------------------------------------------------------------------- */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-200) 25%,
        var(--color-gray-100) 50%,
        var(--color-gray-200) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

/* --------------------------------------------------------------------------
   Morphing Shape
   -------------------------------------------------------------------------- */
.morph-shape {
    animation: morph 8s ease-in-out infinite;
}

@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%;
    }
}

/* --------------------------------------------------------------------------
   Parallax Layers
   -------------------------------------------------------------------------- */
.parallax-container {
    perspective: 1px;
    height: 100vh;
    overflow-x: hidden;
    overflow-y: auto;
}

.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.parallax-layer--back {
    transform: translateZ(-1px) scale(2);
}

.parallax-layer--base {
    transform: translateZ(0);
}

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

/* --------------------------------------------------------------------------
   Page Transition Overlay
   -------------------------------------------------------------------------- */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-primary);
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.6s cubic-bezier(0.77, 0, 0.175, 1);
}

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

.page-transition.exit {
    transform: translateY(-100%);
}

/* --------------------------------------------------------------------------
   Text Highlight Animation
   -------------------------------------------------------------------------- */
.text-highlight {
    background: linear-gradient(
        to right,
        var(--color-secondary) 0%,
        var(--color-secondary) 100%
    );
    background-size: 0% 40%;
    background-repeat: no-repeat;
    background-position: 0 90%;
    transition: background-size 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.text-highlight:hover,
.text-highlight.is-visible {
    background-size: 100% 40%;
}

/* --------------------------------------------------------------------------
   Hover Underline Animation
   -------------------------------------------------------------------------- */
.hover-underline {
    position: relative;
    display: inline-block;
}

.hover-underline::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    bottom: 0;
    left: 0;
    background: var(--color-primary);
    transform: scaleX(0);
    transform-origin: bottom right;
    transition: transform 0.3s ease;
}

.hover-underline:hover::after {
    transform: scaleX(1);
    transform-origin: bottom left;
}

/* --------------------------------------------------------------------------
   Card Hover Effects
   -------------------------------------------------------------------------- */
.card-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card-lift:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-2xl);
}

/* --------------------------------------------------------------------------
   Button Ripple Effect
   -------------------------------------------------------------------------- */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    opacity: 0;
    border-radius: 100%;
    transform: scale(1, 1) translate(-50%);
    transform-origin: 50% 50%;
}

.btn-ripple:focus:not(:active)::after {
    animation: ripple 0.6s ease-out;
}

@keyframes ripple {
    0% {
        transform: scale(0, 0);
        opacity: 0.5;
    }
    100% {
        transform: scale(100, 100);
        opacity: 0;
    }
}

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

    .fade-in,
    .fade-up,
    .fade-down,
    .fade-left,
    .fade-right,
    .scale-in,
    .rotate-in,
    .split-char,
    .split-word,
    .split-line,
    .stagger-group > * {
        opacity: 1;
        transform: none;
    }

    .reveal-image::before {
        display: none;
    }

    .reveal-image img {
        transform: none;
    }
}
