:root {
    --accent-light: #8A66F4;
    --accent: #6E48E0;
    --accent-dark: #5330D2;
    --secondary-light: #FF7AC6;
    --secondary: #FF56B1;
    --secondary-dark: #F034A0;
    --dark-light: #2D3748;
    --dark: #1A202C;
    --dark-dark: #0D1117;
    --light-dark: #E2E8F0;
    --light: #F7FAFC;
    --light-light: #FFFFFF;
}

body {
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    font-family: 'Space Grotesk', sans-serif;
    background-color: var(--light-light);
    color: #1a202c;
    transition: background-color 0.3s, color 0.3s;
}

.dark body {
    background-color: var(--dark-dark);
    color: #f7fafc;
}

.loader {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    background-color: #0A0F1E;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s;
}

/* Hide scrollbar for Chrome, Safari and Opera */
::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
body {
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}

/* Core Styles */
.font-syne {
    font-family: 'Syne', sans-serif;
}

/* Cursor Styles (desktop only) */
@media (min-width: 1024px) {
    body {
        cursor: none;
    }

    .cursor,
    .cursor-follower {
        position: fixed;
        left: 0;
        top: 0;
        pointer-events: none;
        border-radius: 50%;
        z-index: 9999;
        mix-blend-mode: difference;
        will-change: transform;
        transform: translateZ(0);
    }

    .cursor {
        width: 8px;
        height: 8px;
        background-color: #fff;
        transform: translate(-50%, -50%);
        transition: width 0.3s, height 0.3s;
    }

    .cursor-follower {
        width: 40px;
        height: 40px;
        border: 1px solid #fff;
        background-color: rgba(255, 255, 255, 0.1);
        transform: translate(-50%, -50%);
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), width 0.3s, height 0.3s;
    }

    a:hover~.cursor,
    button:hover~.cursor {
        width: 0;
        height: 0;
    }

    a:hover~.cursor-follower,
    button:hover~.cursor-follower {
        width: 60px;
        height: 60px;
        background-color: rgba(255, 255, 255, 0.2);
    }
}

/* Hide cursor on mobile */
@media (max-width: 1023px) {

    .cursor,
    .cursor-follower {
        display: none;
    }
}

/* Gradient Text */
.gradient-text {
    background: linear-gradient(135deg, #8A66F4 0%, #FF56B1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Gradient Background */
.gradient-bg {
    background: linear-gradient(135deg, #8A66F4 0%, #FF56B1 100%);
}

/* Glass Effect - optimize for performance */
.glass {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (min-width: 768px) {
    .glass {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

.dark .glass {
    background: rgba(10, 15, 30, 0.6);
}

/* 3D Cards (desktop only) */
@media (min-width: 768px) {
    .card-3d {
        transition: transform 0.3s ease;
        transform-style: preserve-3d;
        perspective: 1000px;
        will-change: transform;
    }

    .card-3d:hover {
        transform: translateY(-10px);
    }
}

/* Disable 3D effect on mobile */
@media (max-width: 767px) {
    .card-3d {
        transition: transform 0.3s ease;
    }

    .card-3d:hover {
        transform: translateY(-5px);
    }
}

/* Reveal Animation Classes */
.reveal-bottom {
    opacity: 0;
    transform: translateY(50px);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-50px);
}

.reveal-right {
    opacity: 0;
    transform: translateX(50px);
}

/* Optimize Image hover effect */
.img-hover {
    overflow: hidden;
}

.img-hover img {
    transition: transform 0.5s ease-out;
}

.img-hover:hover img {
    transform: scale(1.05);
}

/* Simplified Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: #8A66F4;
    border-radius: 3px;
}

/* Optimized Marquee Animation */
.marquee {
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    display: flex;
}

.marquee-content {
    display: flex;
    animation: marquee 30s linear infinite;
    will-change: transform;
}

.marquee-item {
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* Optimized Loader Animation */
.loader-content {
    width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.loader-bar {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    margin-top: 20px;
    position: relative;
    overflow: hidden;
    border-radius: 3px;
}

.loader-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #8A66F4, #FF56B1);
    animation: loading 2s ease forwards;
}

@keyframes loading {
    0% {
        width: 0;
    }

    100% {
        width: 100%;
    }
}

/* Efficient Magnetic Button implementation */
.magnetic-wrap {
    display: inline-block;
    position: relative;
}

.magnetic-area {
    position: relative;
    display: inline-block;
    transform-style: preserve-3d;
    will-change: transform;
}

/* Optimized Portfolio Item Animation */
.portfolio-mask {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.portfolio-item:hover .portfolio-mask {
    opacity: 1;
}

.portfolio-item img {
    transition: transform 0.5s ease-out;
    will-change: transform;
}

.portfolio-item:hover img {
    transform: scale(1.05);
}

/* Simplified divider */
.divider {
    height: 1px;
    width: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
}

/* Optimized language switching */
.lang-vi {
    display: none;
}

html.vi .lang-en {
    display: none;
}

html.vi .lang-vi {
    display: block;
}

/* Optimized noise effect */
.noise {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    opacity: 0.02;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-size: 150px 150px;
}

/* Optimized Mobile Navigation */
.mobile-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    height: 100vh;
    background: rgba(10, 15, 30, 0.95);
    z-index: 999;
    transition: right 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-nav.active {
    right: 0;
}

.nav-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.nav-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Optimized Rotating Border Animation */
.rotating-border {
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
}

.rotating-border::before {
    content: '';
    position: absolute;
    inset: 0;
    background: conic-gradient(from var(--angle), #8A66F4, #FF56B1, #8A66F4);
    --angle: 0deg;
    animation: rotate 6s linear infinite;
    z-index: -1;
}

.rotating-border::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: inherit;
    border-radius: calc(1rem - 2px);
    z-index: -1;
}

@property --angle {
    syntax: '<angle>';
    initial-value: 0deg;
    inherits: false;
}

@keyframes rotate {
    to {
        --angle: 360deg;
    }
}

/* Optimized Pulsing Dot */
.pulsing-dot {
    position: relative;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #FF56B1;
    margin-right: 12px;
}

.pulsing-dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgba(255, 86, 177, 0.3);
    transform: translate(-50%, -50%);
    animation: pulse 2s infinite;
    will-change: transform, opacity;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }

    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}