/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

:root {
    --primary-color: #64b5f6;
    --secondary-color: #e91e63;
    --accent-color: #ff9800;
    --bg-gradient: linear-gradient(135deg, #0a0a23 0%, #1a1a2e 50%, #533483 100%);
    --text-gradient: linear-gradient(45deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    --animation-duration: 0.5s;
    --slow-animation: 1.5s;
}

body {
    font-family: 'Segoe UI', 'Arial', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    overflow-x: hidden;
    color: white;
    line-height: 1.6;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

/* Cosmic Typography */
@font-face {
    font-family: 'Cosmic';
    src: local('Arial');
    font-weight: normal;
}

/* Loading Screen with Enhanced M Animation */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at center, #0f0f23 0%, #000 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.8s cubic-bezier(0.19, 1, 0.22, 1), visibility 0.8s;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Advanced M Letter Animation */
.logo-animation {
    font-size: 15rem;
    font-weight: 900;
    font-family: 'Cosmic', sans-serif;
    color: transparent;
    position: relative;
    animation: mEntrance 2.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards,
               mGlow 4s ease-in-out infinite 2.5s,
               mFloat 6s ease-in-out infinite 3s;
    text-shadow: none;
    perspective: 1000px;
    transform-style: preserve-3d;
    will-change: transform, opacity, text-shadow;
}

.logo-animation::before,
.logo-animation::after {
    content: 'M';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

.logo-animation::before {
    color: var(--secondary-color);
    z-index: -1;
    animation: mBefore 3s ease-in-out infinite alternate;
}

.logo-animation::after {
    color: var(--accent-color);
    z-index: -2;
    animation: mAfter 3.5s ease-in-out infinite alternate;
}

@keyframes mEntrance {
    0% { 
        transform: scale(0.2) rotateX(-90deg) rotateY(-45deg);
        opacity: 0;
        filter: blur(15px);
    }
    30% {
        transform: scale(1.2) rotateX(0) rotateY(20deg);
        opacity: 0.9;
        filter: blur(3px);
    }
    50% {
        transform: scale(0.95) rotateX(0) rotateY(-10deg);
    }
    70% {
        transform: scale(1.05) rotateX(0) rotateY(5deg);
    }
    100% { 
        transform: scale(1) rotateX(0) rotateY(0);
        opacity: 1;
        filter: blur(0);
    }
}

@keyframes mGlow {
    0%, 100% { 
        text-shadow: 0 0 20px rgba(100, 181, 246, 0.7),
                     0 0 40px rgba(100, 181, 246, 0.4),
                     0 0 60px rgba(100, 181, 246, 0.2);
    }
    33% { 
        text-shadow: 0 0 25px rgba(233, 30, 99, 0.8),
                     0 0 50px rgba(233, 30, 99, 0.5),
                     0 0 75px rgba(233, 30, 99, 0.3);
    }
    66% { 
        text-shadow: 0 0 30px rgba(255, 152, 0, 0.9),
                     0 0 60px rgba(255, 152, 0, 0.6),
                     0 0 90px rgba(255, 152, 0, 0.3);
    }
}

@keyframes mFloat {
    0%, 100% { transform: translateY(0) rotateY(0); }
    25% { transform: translateY(-15px) rotateY(5deg); }
    50% { transform: translateY(0) rotateY(0); }
    75% { transform: translateY(-10px) rotateY(-5deg); }
}

@keyframes mBefore {
    0%, 100% { transform: translate(-5px, -5px); }
    50% { transform: translate(5px, 5px); }
}

@keyframes mAfter {
    0%, 100% { transform: translate(5px, 5px); }
    50% { transform: translate(-5px, -5px); }
}

/* Main Content Transition */
.main-content {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 1.2s ease-out, transform 1s ease-out;
    will-change: opacity, transform;
}

.main-content.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Cosmic Background with Performance Optimization */
.cosmic-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    overflow: hidden;
    pointer-events: none;
}

/* Optimized Starfield Animation */
.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle var(--star-duration) infinite ease-in-out;
    will-change: opacity;
    opacity: 0;
}

.star.small { 
    width: 1px; 
    height: 1px; 
    animation-duration: 3s;
}
.star.medium { 
    width: 2px; 
    height: 2px; 
    animation-duration: 5s;
}
.star.large { 
    width: 3px; 
    height: 3px; 
    box-shadow: 0 0 5px rgba(255,255,255,0.7);
    animation-duration: 7s;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.8; }
}

/* Enhanced Planet Animations */
.planets {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.planet {
    position: absolute;
    border-radius: 50%;
    will-change: transform;
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.3));
}

.planet1 {
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, #ff6b6b, #d63031);
    top: 15%;
    left: -150px;
    animation: floatRight 25s linear infinite,
               planetPulse 8s ease-in-out infinite;
}

.planet2 {
    width: 40px;
    height: 40px;
    background: radial-gradient(circle at 30% 30%, #74b9ff, #0984e3);
    top: 65%;
    left: -120px;
    animation: floatRight 35s linear infinite 5s,
               planetPulse 10s ease-in-out infinite 2s;
}

.planet3 {
    width: 30px;
    height: 30px;
    background: radial-gradient(circle at 30% 30%, #55efc4, #00b894);
    top: 35%;
    left: -100px;
    animation: floatRight 30s linear infinite 10s,
               planetPulse 12s ease-in-out infinite 4s;
}

@keyframes floatRight {
    from { transform: translateX(0); }
    to { transform: translateX(calc(100vw + 200px)); }
}

@keyframes planetPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Nebula Effects */
.nebula {
    position: absolute;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.15;
    will-change: transform;
}

.nebula:nth-child(1) {
    background: radial-gradient(circle, var(--primary-color), transparent 70%);
    top: 20%;
    left: 10%;
    animation: nebulaFloat 30s ease-in-out infinite alternate;
}

.nebula:nth-child(2) {
    background: radial-gradient(circle, var(--secondary-color), transparent 70%);
    bottom: 15%;
    right: 10%;
    animation: nebulaFloat 40s ease-in-out infinite alternate-reverse;
}

@keyframes nebulaFloat {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(50px, -30px); }
    50% { transform: translate(-40px, 20px); }
    75% { transform: translate(30px, 40px); }
}

/* Header Styles with Enhanced Effects */
.header {
    display: flex;
    align-items: center;
    padding: 30px 0;
    position: relative;
    z-index: 100;
    animation: fadeInDown 1s ease-out both;
}

.mini-logo {
    font-size: 2.5rem;
    font-weight: 900;
    font-family: 'Cosmic', sans-serif;
    color: transparent;
    background: var(--text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    margin-right: 25px;
    position: relative;
    animation: logoFloat 4s ease-in-out infinite;
    text-shadow: 0 0 15px rgba(255,255,255,0.2);
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-5px) rotate(2deg); }
    50% { transform: translateY(0) rotate(0); }
    75% { transform: translateY(-3px) rotate(-2deg); }
}

.name-title {
    flex-grow: 1;
}

.name {
    font-size: 3.5rem;
    font-weight: 800;
    background: var(--text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    line-height: 1.1;
    text-shadow: 0 0 20px rgba(255,255,255,0.1);
    animation: textGlow 6s ease-in-out infinite;
}

@keyframes textGlow {
    0%, 100% { 
        text-shadow: 0 0 10px rgba(100, 181, 246, 0.3),
                     0 0 20px rgba(100, 181, 246, 0.2);
    }
    50% { 
        text-shadow: 0 0 20px rgba(100, 181, 246, 0.5),
                     0 0 40px rgba(100, 181, 246, 0.3);
    }
}

.subtitle {
    font-size: 1.3rem;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 8px;
    font-weight: 300;
    letter-spacing: 1px;
    animation: fadeIn 1.5s ease-out 0.3s both;
}

/* Container Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 30px;
    position: relative;
    z-index: 1;
}

/* Section Animations */
.section {
    margin: 70px 0;
    padding: 50px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: translateY(40px);
    opacity: 0;
    transition: all 0.8s cubic-bezier(0.215, 0.61, 0.355, 1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4),
                inset 0 1px 0 rgba(255,255,255,0.05);
    will-change: transform, opacity;
}

.section.visible {
    transform: translateY(0);
    opacity: 1;
}

.section:nth-child(even).visible {
    transition-delay: 0.1s;
}

.section-title {
    font-size: 2.8rem;
    margin-bottom: 40px;
    text-align: center;
    background: var(--text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
    padding-bottom: 15px;
    font-weight: 700;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 3px;
    background: var(--text-gradient);
    border-radius: 3px;
}

/* About Section */
.about-content p {
    font-size: 1.25rem;
    line-height: 1.8;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    max-width: 800px;
    margin: 0 auto;
    animation: fadeInUp 1s ease-out 0.2s both;
}

/* Social Media Grid with Hover Effects */
.social-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 40px;
}

.social-link {
    display: flex;
    align-items: center;
    padding: 25px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    text-decoration: none;
    color: white;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
}

.social-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, 
                rgba(100, 181, 246, 0.1), 
                rgba(233, 30, 99, 0.1), 
                rgba(255, 152, 0, 0.1));
    opacity: 0;
    transition: opacity 0.4s ease;
}

.social-link:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(100, 181, 246, 0.3);
    background: rgba(255, 255, 255, 0.12);
}

.social-link:hover::before {
    opacity: 1;
}

.social-icon {
    font-size: 3rem;
    margin-right: 20px;
    min-width: 60px;
    text-align: center;
    transition: transform 0.4s ease;
}

.social-link:hover .social-icon {
    transform: scale(1.1) rotate(5deg);
}

.social-info h3 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.social-link:hover .social-info h3 {
    color: white;
}

.social-info p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
    transition: color 0.3s ease;
}

.social-link:hover .social-info p {
    color: rgba(255, 255, 255, 0.9);
}

/* Portfolio Grid with Creative Effects */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 40px;
}

.portfolio-item, 
.portfolio-item-not-full, 
.ai-portfolo-prt-soon {
    padding: 30px;
    background: rgba(100, 181, 246, 0.08);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow;
}

.portfolio-item::before,
.portfolio-item-not-full::before,
.ai-portfolo-prt-soon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, 
                rgba(100, 181, 246, 0.1), 
                transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.portfolio-item:hover,
.portfolio-item-not-full:hover,
.ai-portfolo-prt-soon:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(100, 181, 246, 0.2);
    background: rgba(100, 181, 246, 0.12);
}

.portfolio-item:hover::before,
.portfolio-item-not-full:hover::before,
.ai-portfolo-prt-soon:hover::before {
    opacity: 1;
}

.portfolio-item h3,
.portfolio-item-not-full h3,
.ai-portfolo-prt-soon h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--primary-color);
    position: relative;
    transition: color 0.3s ease;
}

.portfolio-item:hover h3,
.portfolio-item-not-full:hover h3,
.ai-portfolo-prt-soon:hover h3 {
    color: white;
}

.portfolio-item p,
.portfolio-item-not-full p,
.ai-portfolo-prt-soon p {
    color: rgba(255, 255, 255, 0.7);
    transition: color 0.3s ease;
}

.portfolio-item:hover p,
.portfolio-item-not-full:hover p,
.ai-portfolo-prt-soon:hover p {
    color: rgba(255, 255, 255, 0.9);
}

.portfolio-link {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 25px;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    color: white;
    text-decoration: none;
    border-radius: 25px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    z-index: 1;
    font-weight: 500;
    box-shadow: 0 5px 15px rgba(100, 181, 246, 0.4);
}

.portfolio-link::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, var(--secondary-color), var(--accent-color));
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: -1;
}

.portfolio-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(233, 30, 99, 0.5);
}

.portfolio-link:hover::before {
    opacity: 1;
}

/* Contact Section with Interactive Elements */
.contact-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 40px;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 25px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 300px;
    position: relative;
    overflow: hidden;
}

.contact-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(45deg, 
                rgba(100, 181, 246, 0.1), 
                transparent);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.contact-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px rgba(100, 181, 246, 0.3);
    background: rgba(255, 255, 255, 0.12);
}

.contact-item:hover::before {
    opacity: 1;
}

.contact-icon {
    font-size: 2.5rem;
    margin-right: 20px;
    transition: transform 0.3s ease;
}

.contact-item:hover .contact-icon {
    transform: scale(1.1) rotate(5deg);
}

.contact-item h3 {
    font-size: 1.3rem;
    margin-bottom: 5px;
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.contact-item:hover h3 {
    color: white;
}

.contact-item p {
    color: rgba(255, 255, 255, 0.8);
    transition: color 0.3s ease;
}

.contact-item:hover p {
    color: rgba(255, 255, 255, 0.95);
}

/* Keyframe Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInDown {
    from { 
        opacity: 0;
        transform: translateY(-20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        padding: 0 25px;
    }
    
    .section {
        padding: 40px;
    }
    
    .social-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
    
    .portfolio-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .logo-animation {
        font-size: 10rem;
    }
    
    .header {
        flex-direction: column;
        text-align: center;
    }
    
    .mini-logo {
        margin: 0 0 15px 0;
        font-size: 3rem;
    }
    
    .name {
        font-size: 2.5rem;
    }
    
    .subtitle {
        font-size: 1.1rem;
    }
    
    .section {
        padding: 30px;
        margin: 50px 0;
    }
    
    .section-title {
        font-size: 2.2rem;
    }
    
    .social-grid,
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-item {
        min-width: 100%;
    }
    
    /* Reduce animation intensity on mobile */
    .planet {
        animation-duration: 60s !important;
    }
    
    .logo-animation {
        animation: mEntrance 1.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards,
                   mGlow 5s ease-in-out infinite 1.8s;
    }
    
    .logo-animation::before,
    .logo-animation::after {
        animation: none;
    }
}

@media (max-width: 480px) {
    .logo-animation {
        font-size: 7rem;
    }
    
    .container {
        padding: 0 15px;
    }
    
    .name {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .section {
        padding: 25px;
        margin: 40px 0;
    }
    
    .section-title {
        font-size: 1.8rem;
    }
    
    .social-icon {
        font-size: 2.5rem;
        margin-right: 15px;
    }
    
    .contact-icon {
        font-size: 2rem;
        margin-right: 15px;
    }
    
    /* Further reduce animations */
    .star {
        animation: none;
        opacity: 0.5;
    }
    
    .nebula {
        display: none;
    }
    
    .logo-animation {
        animation: mEntrance 1.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    }
}

/* Performance Optimizations */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
    
    .main-content {
        opacity: 1;
        transform: none;
    }
    
    .section {
        transform: none;
        opacity: 1;
    }
}

/* Fallbacks for Older Browsers */
@supports not (backdrop-filter: blur(12px)) {
    .section {
        background: rgba(10, 10, 35, 0.9);
        backdrop-filter: none;
    }
}

/* Print Styles */
@media print {
    .cosmic-bg,
    .loading-screen {
        display: none;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .section {
        background: white;
        border: 1px solid #ddd;
        box-shadow: none;
        backdrop-filter: none;
    }
    
    .name,
    .section-title {
        background: none;
        -webkit-text-fill-color: black;
        color: black;
        text-shadow: none;
    }
    
    .portfolio-link {
        background: #333;
        color: white;
        box-shadow: none;
    }
}
