/* ============================================
   MOEBA PROTOCOL - Professional Landing Page
   Sanzo Wada Inspired Color Palette
   ============================================ */

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Custom scrollbar - Wada inspired */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #24333C; /* Iron Blue */
}

::-webkit-scrollbar-thumb {
    background: #3D5260; /* moeba-border */
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4A6273;
}

/* Selection color - Moeba Green */
::selection {
    background: rgba(181, 232, 51, 0.3);
    color: #F5F0E6;
}

/* ============================================
   LOADER ANIMATION (Original Moeba Loader)
   ============================================ */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #24333C; /* Iron Blue */
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s;
}

.loader-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.fusion-container {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: moebaFusionSequence 3s cubic-bezier(0.5, 0, 0.2, 1) forwards;
    will-change: transform, opacity;
}

.moeba-half {
    position: absolute;
    width: 45px;
    height: 55px;
    will-change: transform, border-radius, opacity;
}

.moeba-pink {
    background-color: #E83D81;
    animation: pinkAlive 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.moeba-green {
    background-color: #B5E833;
    animation: greenAlive 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.moeba-final {
    position: absolute;
    width: 90px;
    height: 90px;
    opacity: 0;
    animation: finalBirth 3s ease-in-out forwards;
    will-change: transform, opacity, filter;
}

/* Loader Keyframes */
@keyframes moebaFusionSequence {
    0%   { transform: scale(1) rotate(0deg); opacity: 1; }
    40%  { transform: scale(1.1) rotate(180deg); opacity: 1; }
    70%  { transform: scale(1) rotate(540deg); opacity: 1; }
    75%  { transform: scale(1.1) rotate(600deg); opacity: 1; }
    85%  { transform: scale(0.9) rotate(630deg); opacity: 1; }
    100% { transform: scale(25) rotate(720deg); opacity: 0; }
}

@keyframes pinkAlive {
    0% {
        transform: translateX(-150px) scale(0.5);
        border-radius: 50% 50% 50% 70% / 50% 50% 70% 50%;
    }
    30% {
        transform: translateX(-40px) scale(0.8);
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    55% {
        transform: translateX(-25px) scale(0.9);
        border-radius: 40% 60% 70% 30% / 40% 50% 60% 50%;
    }
    70% {
        transform: translateX(-16px) scale(1) scaleX(1.1);
        border-radius: 60% 30% 30% 60% / 50% 20% 20% 50%;
    }
    75% {
        transform: translateX(-10px) scale(1) scaleX(0.7) scaleY(1.3);
        border-radius: 60% 5% 5% 60% / 50% 2% 2% 50%;
        opacity: 1;
    }
    76% { opacity: 0; }
    100% { transform: translateX(-10px); opacity: 0; }
}

@keyframes greenAlive {
    0% {
        transform: translateX(150px) scale(0.5);
        border-radius: 50% 50% 70% 50% / 50% 70% 50% 50%;
    }
    30% {
        transform: translateX(40px) scale(0.8);
        border-radius: 30% 70% 60% 40% / 50% 60% 40% 70%;
    }
    55% {
        transform: translateX(25px) scale(0.9);
        border-radius: 70% 30% 40% 60% / 60% 40% 50% 40%;
    }
    70% {
        transform: translateX(16px) scale(1) scaleX(1.1);
        border-radius: 30% 60% 60% 30% / 20% 50% 50% 20%;
    }
    75% {
        transform: translateX(10px) scale(1) scaleX(0.7) scaleY(1.3);
        border-radius: 5% 60% 60% 5% / 2% 50% 50% 2%;
        opacity: 1;
    }
    76% { opacity: 0; }
    100% { transform: translateX(10px); opacity: 0; }
}

@keyframes finalBirth {
    0%, 74% { opacity: 0; transform: scale(0.5); filter: brightness(2); }
    75% {
        opacity: 1;
        transform: scale(1.05);
        filter: drop-shadow(0 0 30px rgba(232, 61, 129, 0.8)) drop-shadow(0 0 30px rgba(181, 232, 51, 0.8)) brightness(1.2);
    }
    85% {
        transform: scale(0.95);
        filter: drop-shadow(0 0 10px rgba(181, 232, 51, 0.3)) brightness(1);
    }
    100% { opacity: 1; transform: scale(1); }
}

/* ============================================
   LIGHT THEME - Version Claire (Blanc Clinique)
   ============================================ */

body.light-theme {
    /* Variables basées sur la palette "Blanc clinique pur & pro" */
    --bg-dark: #F4F7F8;        /* Blanc glacé très subtil (Hint of Iron Blue) - Fond principal */
    --bg-darker: #EAF0F2;      /* Navigation légèrement teintée pour délimiter */
    --bg-card: #FFFFFF;        /* Cartes en blanc pur */
    --border-color: rgba(0, 0, 0, 0.05); /* Bordure très fine et discrète */
    --text-light: #0f172a;     /* Texte principal foncé (Slate) */
    --text-muted: #475569;     /* Texte atténué */
}

/* Application des styles */
body.light-theme {
    background-color: #F4F7F8;
    color: #0f172a;
}

body.light-theme .bg-moeba-dark {
    background-color: #F4F7F8;
}

body.light-theme .bg-moeba-darker {
    background-color: #EAF0F2;
}

body.light-theme .bg-moeba-card {
    background-color: #FFFFFF;
}

body.light-theme .border-moeba-border {
    border-color: rgba(0, 0, 0, 0.05);
}

body.light-theme .text-moeba-light,
body.light-theme .text-moeba-cream {
    color: #0f172a;
}

body.light-theme .text-moeba-muted {
    color: #475569;
}

/* Fond transparent (Navbar) - Conversion de #F4F7F8 en RGBA */
body.light-theme .bg-moeba-dark\/80 {
    background-color: rgba(244, 247, 248, 0.8);
}

body.light-theme .loader-overlay {
    background-color: #F4F7F8;
}

/* Barre de défilement (Scrollbar) pour le thème clair */
body.light-theme ::-webkit-scrollbar-track {
    background: #F4F7F8;
}

body.light-theme ::-webkit-scrollbar-thumb {
    background: #CBD5E1; /* Gris bleuté clair pour le contraste */
}

/* ============================================
   ANIMATIONS
   ============================================ */

/* Fade in on scroll */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Subtle float animation for background elements */
@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-20px);
    }
}

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

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */
@media (max-width: 640px) {
    .loader-overlay {
        background-color: #0f1419;
    }

    body.light-theme .loader-overlay {
        background-color: #FAF8F3;
    }
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ============================================
   CUSTOM UTILITIES
   ============================================ */

/* Text balance for better typography */
.text-balance {
    text-wrap: balance;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, #B5E833, #C2FC2D);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Glass effect */
.glass {
    background: rgba(17, 24, 32, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Card hover glow */
.card-glow:hover {
    box-shadow: 0 0 40px rgba(181, 232, 51, 0.1);
}

/* Focus styles for accessibility */
a:focus-visible,
button:focus-visible {
    outline: 2px solid #B5E833;
    outline-offset: 2px;
}

/* Hide scrollbar but keep functionality */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ============================================
   LOGO PIXEL ANIMATION
   ============================================ */
#logoAnimationContainer {
    position: relative;
    width: 100%;
    height: 100%;
}

#logoPixelCanvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: default;
}

/* Subtle glow effect around animation container */
#logoAnimationContainer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(181, 232, 51, 0.1) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

#logoAnimationContainer::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(232, 61, 129, 0.08) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
    animation: pulseGlow 4s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        opacity: 0.5;
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
}

/* Light theme adjustments for animation */
body.light-theme #logoAnimationContainer::before {
    background: radial-gradient(circle, rgba(181, 232, 51, 0.15) 0%, transparent 70%);
}

body.light-theme #logoAnimationContainer::after {
    background: radial-gradient(circle, rgba(232, 61, 129, 0.12) 0%, transparent 70%);
}

/* ============================================
   PARALLAX & DEEP DIVE SECTION
   ============================================ */
.parallax-container {
    perspective: 1000px;
    transform-style: preserve-3d;
}

.parallax-layer {
    transition: transform 0.1s ease-out;
    will-change: transform;
}

.parallax-back {
    z-index: 1;
}

.parallax-mid {
    z-index: 2;
}

/* Tech Cards 3D Effect */
.tech-card {
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out, border-color 0.3s ease-out;
    transform-style: preserve-3d;
    will-change: transform;
}

.tech-card:hover {
    z-index: 10;
}

/* Code Preview Styling */
pre code {
    font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* Floating dots animation for deep dive */
@keyframes floatDot {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.4;
    }
    50% {
        transform: translateY(-20px) scale(1.2);
        opacity: 0.8;
    }
}

.parallax-mid > div:nth-child(1) {
    animation: floatDot 4s ease-in-out infinite;
}

.parallax-mid > div:nth-child(2) {
    animation: floatDot 5s ease-in-out infinite 1s;
}

.parallax-mid > div:nth-child(3) {
    animation: floatDot 6s ease-in-out infinite 2s;
}

/* Light theme for deep dive */
body.light-theme .tech-card {
    background: rgba(255, 255, 255, 0.9);
}

/* ============================================
   WATERFALL VISUALIZATION
   ============================================ */
.waterfall-step {
    opacity: 0;
    animation: waterfallFadeIn 0.6s ease-out forwards;
}

.waterfall-step:nth-child(1) { animation-delay: 0.1s; }
.waterfall-step:nth-child(3) { animation-delay: 0.2s; }
.waterfall-step:nth-child(5) { animation-delay: 0.3s; }
.waterfall-step:nth-child(7) { animation-delay: 0.4s; }

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

/* Waterfall connection lines */
.waterfall-step > div {
    position: relative;
}

.waterfall-step > div::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -20px;
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0.3;
}

.waterfall-step:first-child > div::before {
    display: none;
}

/* Responsive adjustments for parallax */
@media (max-width: 1024px) {
    .parallax-container {
        display: none;
    }

    .tech-card {
        transform: none !important;
    }
}
