/**
 * SOLVA - Modern Animations
 * Smooth, subtle animations
 */

/* =====================================================
   Keyframes
   ===================================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.04);
    }
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-12px);
    }
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

/* =====================================================
   Animation Classes
   ===================================================== */
.animate-fadeIn {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-fadeInUp {
    animation: fadeInUp 0.6s ease-out forwards;
}

.animate-fadeInDown {
    animation: fadeInDown 0.5s ease-out forwards;
}

.animate-scaleIn {
    animation: scaleIn 0.5s ease-out forwards;
}

.animate-pulse {
    animation: pulse 2s ease-in-out infinite;
}

.animate-float {
    animation: float 4s ease-in-out infinite;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* =====================================================
   Reveal on Scroll
   ===================================================== */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-right.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-left.active {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-scale.active {
    opacity: 1;
    transform: scale(1);
}

/* Stagger Children */
.stagger-children>* {
    opacity: 0;
    transform: translateY(25px);
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.stagger-children.active>*:nth-child(1) {
    transition-delay: 0.08s;
}

.stagger-children.active>*:nth-child(2) {
    transition-delay: 0.16s;
}

.stagger-children.active>*:nth-child(3) {
    transition-delay: 0.24s;
}

.stagger-children.active>*:nth-child(4) {
    transition-delay: 0.32s;
}

.stagger-children.active>*:nth-child(5) {
    transition-delay: 0.40s;
}

.stagger-children.active>*:nth-child(6) {
    transition-delay: 0.48s;
}

.stagger-children.active>* {
    opacity: 1;
    transform: translateY(0);
}

/* =====================================================
   Splash Screen - Cinematic Solar (REFINED CLASSIC)
   ===================================================== */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0d0d1a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s ease-out, visibility 0.8s;
    overflow: hidden;
    perspective: 1000px;
}

.splash-screen.hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Cinematic Background */
.splash-bg-overlay {
    position: absolute;
    width: 200%;
    height: 200%;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.3) 50%, transparent 100%),
        radial-gradient(1px 1px at 40% 70%, rgba(255, 255, 255, 0.3) 50%, transparent 100%),
        radial-gradient(1px 1px at 80% 80%, rgba(255, 255, 255, 0.2) 50%, transparent 100%);
    background-size: 100px 100px;
    opacity: 0.4;
    animation: cosmicDrift 20s linear infinite;
    z-index: 1;
}

.splash-content {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Solar Animation Layout */
.solar-animation-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
    position: relative;
    height: 400px;
    justify-content: center;
    transform-style: preserve-3d;
    transition: opacity 0.5s, transform 0.5s;
}

/* 3D Solar Panel */
.solar-panel-container {
    position: relative;
    width: 160px;
    height: auto;
    animation: panelUnfold 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.solar-panel-svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 20px var(--accent));
}

.panel-base {
    fill: #1d1d35;
    stroke: var(--accent);
    stroke-width: 1.5;
}

.panel-grid {
    fill: none;
    stroke: #fff;
    stroke-width: 0.5;
    opacity: 0.3;
}

.sun-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 60%);
    animation: sunPulseIntensity 2s infinite ease-in-out;
}

/* Electric Energy Rays */
.energy-rays {
    position: relative;
    height: 60px;
}

.ray {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: white;
    box-shadow: 0 0 10px var(--accent);
    animation: electricSurge 0.4s infinite linear;
}

/* Cinematic Battery */
.battery-container {
    position: relative;
    width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.5s cubic-bezier(0.6, -0.28, 0.735, 0.045);
}

.battery-head {
    width: 24px;
    height: 8px;
    background: var(--accent);
    border-radius: 4px 4px 0 0;
}

.battery-body {
    width: 80px;
    height: 120px;
    border: 4px solid var(--accent);
    border-radius: 12px;
    position: relative;
    background: rgba(13, 13, 26, 0.8);
    overflow: hidden;
}

.battery-fill {
    position: absolute;
    bottom: 6px;
    left: 6px;
    right: 6px;
    height: 0%;
    background: linear-gradient(180deg, #fff 0%, var(--accent) 30%, var(--accent-dark) 100%);
    border-radius: 6px;
    transition: height 0.1s linear;
}

.battery-percentage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    z-index: 20;
}

/* Finale Reveal Wrapper */
.final-reveal-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    opacity: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    z-index: 100;
}

.final-logo-icon {
    width: 130px;
    filter: drop-shadow(0 0 20px rgba(164, 172, 186, 0.4));
}

.final-logo-icon img {
    width: 100%;
    height: auto;
    display: block;
}

.splash-text {
    opacity: 0;
    transform: translateY(20px);
    text-align: center;
}

.fade-in-text {
    font-size: clamp(2.5rem, 8vw, 4rem);
    font-weight: 900;
    color: white;
    letter-spacing: 0.18em;
    margin: 0;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    font-family: 'Tajawal', sans-serif;
}

.splash-screen .tagline {
    font-size: clamp(0.9rem, 2.5vw, 1.15rem);
    color: var(--accent);
    margin-top: 1.2rem;
    font-weight: 400;
    letter-spacing: 0.05em;
    opacity: 0.9;
    max-width: 700px;
    line-height: 1.8;
    margin-left: auto;
    margin-right: auto;
    font-family: 'IBM Plex Sans Arabic', sans-serif;
}

/* Transition Classes (Activated by JS) */
.battery-container.hide {
    opacity: 0;
    transform: scale(3);
    filter: blur(20px);
}

.solar-animation-wrapper.fade {
    opacity: 0;
    transform: scale(0.9);
    pointer-events: none;
}

.final-reveal-wrapper.shockwave-reveal {
    animation: shockwaveSlam 0.8s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.splash-text.text-reveal-active {
    animation: cinematicTextRise 1s cubic-bezier(0, 0.55, 0.45, 1) forwards;
}

/* Loader bar */
.splash-loader {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 100px;
    margin: 1.5rem auto 0;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out 0.4s forwards;
    opacity: 0;
}

.splash-loader .loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #5b7bb3, #7a98cc, #5b7bb3);
    background-size: 200% 100%;
    border-radius: 100px;
    animation: loadProgress 1.8s ease-out 0.5s forwards, shimmerEffect 1.5s linear infinite;
}

/* Splash Keyframe Animations */
@keyframes panelUnfold {
    0% {
        opacity: 0;
        transform: rotateX(90deg) scale(0.5);
    }

    100% {
        opacity: 1;
        transform: rotateX(0deg) scale(1);
    }
}

@keyframes shockwaveSlam {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(3);
        filter: blur(20px);
    }

    40% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(0.95);
        filter: blur(0);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes cinematicTextRise {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes electricSurge {
    0% {
        transform: scaleY(0);
        opacity: 0;
    }

    50% {
        opacity: 1;
    }

    100% {
        transform: scaleY(1.5);
        opacity: 0;
    }
}

@keyframes sunPulseIntensity {

    0%,
    100% {
        opacity: 0.3;
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        opacity: 0.6;
        transform: translate(-50%, -50%) scale(1.3);
    }
}

@keyframes cosmicDrift {
    0% {
        background-position: 0 0;
    }

    100% {
        background-position: 100px 100px;
    }
}

@keyframes loadProgress {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

@keyframes shimmerEffect {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* =====================================================
   Loading Spinner
   ===================================================== */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(42, 59, 92, 0.15);
    border-top-color: #2a3b5c;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-lg {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* Button Loading */
.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin: -10px 0 0 -10px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* =====================================================
   Hover Effects
   ===================================================== */
.hover-lift {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.12);
}

.hover-scale {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* =====================================================
   Reduced Motion
   ===================================================== */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .reveal,
    .reveal-right,
    .reveal-left,
    .reveal-scale,
    .stagger-children>* {
        opacity: 1;
        transform: none;
    }
}