/* ============================================================
   FLOWBRAIN — animations.css
   Keyframes | Scroll reveals | Hover effects | Transitions
   ============================================================ */

/* ========================================================
   KEYFRAME DEFINITIONS
   ======================================================== */

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(0.75);
    }
}

@keyframes underline-reveal {
    from {
        transform: scaleX(0);
    }

    to {
        transform: scaleX(1);
    }
}

@keyframes float-a {

    0%,
    100% {
        transform: translateY(0px) rotate(-1deg);
    }

    50% {
        transform: translateY(-10px) rotate(1deg);
    }
}

@keyframes float-b {

    0%,
    100% {
        transform: translateY(0px) rotate(1deg);
    }

    50% {
        transform: translateY(10px) rotate(-1deg);
    }
}

@keyframes wap-pulse {

    0%,
    100% {
        box-shadow: 0 6px 28px rgba(37, 211, 102, 0.45), 0 0 0 0 rgba(37, 211, 102, 0.35);
    }

    50% {
        box-shadow: 0 6px 28px rgba(37, 211, 102, 0.45), 0 0 0 12px rgba(37, 211, 102, 0);
    }
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(28px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fade-left {
    from {
        opacity: 0;
        transform: translateX(-28px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fade-right {
    from {
        opacity: 0;
        transform: translateX(28px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scale-in {
    from {
        opacity: 0;
        transform: scale(0.88);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes count-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes circuit-draw {
    0% {
        stroke-dashoffset: 600;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    100% {
        stroke-dashoffset: 0;
        opacity: 0.6;
    }
}

@keyframes circuit-pulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 0.8;
    }
}

@keyframes bar-grow {
    from {
        height: 0;
    }

    to {
        height: 100%;
    }
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

@keyframes slide-up-nav {
    from {
        opacity: 0;
        transform: translateY(-100%);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes glow-rotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* ========================================================
   SCROLL-REVEAL SYSTEM
   Elements get these classes initially, JS removes them
   ======================================================== */

/* Base hidden state */
.reveal {
    opacity: 0;
    transform: translateY(28px);
    transition: opacity 0.65s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.from-left {
    transform: translateX(-28px);
}

.reveal.from-right {
    transform: translateX(28px);
}

.reveal.scale {
    transform: scale(0.92) translateY(14px);
}

.reveal.fade-only {
    transform: none;
}

/* Visible state — toggled by JS IntersectionObserver */
.reveal.visible {
    opacity: 1;
    transform: none;
}

/* Stagger delays for child elements */
.stagger>* {
    opacity: 0;
    transform: translateY(22px);
    transition: opacity 0.55s cubic-bezier(0.4, 0, 0.2, 1), transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger.visible>*:nth-child(1) {
    opacity: 1;
    transform: none;
    transition-delay: 0s;
}

.stagger.visible>*:nth-child(2) {
    opacity: 1;
    transform: none;
    transition-delay: 0.1s;
}

.stagger.visible>*:nth-child(3) {
    opacity: 1;
    transform: none;
    transition-delay: 0.2s;
}

.stagger.visible>*:nth-child(4) {
    opacity: 1;
    transform: none;
    transition-delay: 0.3s;
}

.stagger.visible>*:nth-child(5) {
    opacity: 1;
    transform: none;
    transition-delay: 0.38s;
}

.stagger.visible>*:nth-child(6) {
    opacity: 1;
    transform: none;
    transition-delay: 0.46s;
}

/* Delay helpers */
.delay-1 {
    transition-delay: 0.1s !important;
}

.delay-2 {
    transition-delay: 0.2s !important;
}

.delay-3 {
    transition-delay: 0.3s !important;
}

.delay-4 {
    transition-delay: 0.4s !important;
}

.delay-5 {
    transition-delay: 0.5s !important;
}

/* ========================================================
   HERO ENTRANCE ANIMATIONS
   ======================================================== */

.hero-animate .hero-badge {
    animation: fade-up 0.6s cubic-bezier(0.4, 0, 0.2, 1) 0.2s both;
}

.hero-animate .hero-title {
    animation: fade-up 0.7s cubic-bezier(0.4, 0, 0.2, 1) 0.35s both;
}

.hero-animate .hero-desc {
    animation: fade-up 0.7s cubic-bezier(0.4, 0, 0.2, 1) 0.5s both;
}

.hero-animate .hero-actions {
    animation: fade-up 0.7s cubic-bezier(0.4, 0, 0.2, 1) 0.62s both;
}

.hero-animate .hero-stats {
    animation: fade-up 0.7s cubic-bezier(0.4, 0, 0.2, 1) 0.75s both;
}

.hero-animate .hero-visual {
    animation: scale-in 0.9s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
}

/* ========================================================
   CIRCUIT SVG ANIMATIONS (Hero background)
   ======================================================== */

.circuit-line {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    animation: circuit-draw 4s ease-out forwards;
}

.circuit-line:nth-child(1) {
    animation-delay: 0.5s;
}

.circuit-line:nth-child(2) {
    animation-delay: 1.0s;
}

.circuit-line:nth-child(3) {
    animation-delay: 1.5s;
}

.circuit-line:nth-child(4) {
    animation-delay: 2.0s;
}

.circuit-line:nth-child(5) {
    animation-delay: 2.5s;
}

.circuit-line:nth-child(6) {
    animation-delay: 3.0s;
}

.circuit-dot {
    animation: circuit-pulse 3s ease-in-out infinite;
}

.circuit-dot:nth-child(odd) {
    animation-delay: 0s;
}

.circuit-dot:nth-child(even) {
    animation-delay: 1.5s;
}

/* ========================================================
   DASHBOARD BAR ANIMATIONS (Hero visual)
   ======================================================== */

.hero-card-main .card-bar .fill {
    height: 0;
    animation: bar-grow 1.2s cubic-bezier(0.4, 0, 0.2, 1) 1.2s forwards;
}

.hero-card-main .card-bar:nth-child(1) .fill {
    height: 0;
    animation-delay: 1.2s;
    --target-h: 45%;
}

.hero-card-main .card-bar:nth-child(2) .fill {
    animation-delay: 1.35s;
    --target-h: 72%;
}

.hero-card-main .card-bar:nth-child(3) .fill {
    animation-delay: 1.5s;
    --target-h: 55%;
}

.hero-card-main .card-bar:nth-child(4) .fill {
    animation-delay: 1.65s;
    --target-h: 88%;
}

.hero-card-main .card-bar:nth-child(5) .fill {
    animation-delay: 1.8s;
    --target-h: 65%;
}

.hero-card-main .card-bar:nth-child(6) .fill {
    animation-delay: 1.95s;
    --target-h: 78%;
}

.hero-card-main .card-bar:nth-child(7) .fill {
    animation-delay: 2.1s;
    --target-h: 92%;
}

/* ========================================================
   HOVER MICRO-INTERACTIONS
   ======================================================== */

/* Service cards — icon bounce */
.service-card:hover .service-icon {
    animation: icon-bounce 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes icon-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-5px);
    }

    70% {
        transform: translateY(-2px);
    }
}

/* CTA button shine */
.btn-accent::before,
.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(120deg, transparent, rgba(255, 255, 255, 0.18), transparent);
    transition: left 0.5s ease;
    pointer-events: none;
}

.btn-accent:hover::before,
.btn-primary:hover::before {
    left: 150%;
}

/* Nav link underline slide */
.nav-link {
    position: relative;
}

/* Portfolio card overlay animation */
.portfolio-overlay .btn {
    transform: translateY(10px);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.05s,
        opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1) 0.05s;
    opacity: 0;
}

.portfolio-card:hover .portfolio-overlay .btn {
    transform: translateY(0);
    opacity: 1;
}

/* ========================================================
   PAGE TRANSITION (soft fade)
   ======================================================== */

.page-transition {
    animation: fade-in 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ========================================================
   LOADING SPINNER (for form submit)
   ======================================================== */

.btn-loading {
    pointer-events: none;
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spinner 0.65s linear infinite;
}

.btn-accent.btn-loading::after {
    border-color: rgba(10, 10, 15, 0.3);
    border-top-color: var(--primary);
}

/* ========================================================
   SECTION ACCENT LINE (animated border top)
   ======================================================== */

.accent-line {
    display: block;
    width: 48px;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 2px;
    margin-top: 0.6rem;
    transition: width 0.4s ease;
}

.section-header:hover .accent-line {
    width: 72px;
}

/* ========================================================
   SCROLL PROGRESS BAR (top of page)
   ======================================================== */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    z-index: 9999;
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 0 2px 2px 0;
}

/* ========================================================
   NUMBERS COUNT-UP  (added via JS)
   ======================================================== */

.count-up {
    animation: count-up 0.5s ease both;
}

/* ========================================================
   NOTIFICATION TOAST
   ======================================================== */

.toast {
    position: fixed;
    bottom: 5.5rem;
    right: 2rem;
    z-index: 9500;
    background: var(--primary);
    color: var(--white);
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.38s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 320px;
    pointer-events: none;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.toast-success {
    background: #065f46;
    border-left: 3px solid var(--accent);
}

.toast.toast-error {
    background: #7f1d1d;
    border-left: 3px solid #ef4444;
}

.toast-icon {
    font-size: 1.1rem;
}

/* ========================================================
   PRELOADER
   ======================================================== */

.preloader {
    position: fixed;
    inset: 0;
    background: var(--bg-dark);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.preloader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.preloader-logo {
    font-family: 'Syne', sans-serif;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--white);
    animation: pulse-dot 1s ease-in-out infinite;
}

.preloader-logo span {
    color: var(--accent);
}

.preloader-bar {
    width: 160px;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.preloader-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: 2px;
    animation: preloader-fill 1.2s ease forwards;
}

@keyframes preloader-fill {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}

/* ========================================================
   MOBILE: reduce motion
   ======================================================== */

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal {
        opacity: 1 !important;
        transform: none !important;
    }

    .stagger>* {
        opacity: 1 !important;
        transform: none !important;
    }
}