/* Base & Reset */
html {
    height: auto;
    scroll-behavior: smooth;
}

body {
    background-color: #F5F5F5;
    color: #111111;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 640px) {
    body {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

::selection {
    background-color: #EB3A14;
    color: white;
}

/* Custom Cursor */
@media (pointer: fine) {
    body {
        cursor: none;
    }

    /* Should appear after loader */
    .cursor-dot,
    .cursor-circle {
        pointer-events: none;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 10000;
        mix-blend-mode: difference;
    }

    .cursor-dot {
        width: 6px;
        height: 6px;
        background: white;
        border-radius: 50%;
    }

    .cursor-circle {
        width: 32px;
        height: 32px;
        border: 1px solid white;
        border-radius: 50%;
        transition: width 0.2s, height 0.2s, background-color 0.2s;
    }

    body:hover .cursor-circle {
        opacity: 1;
    }

    .hover-active .cursor-circle {
        width: 64px;
        height: 64px;
        background-color: rgba(255, 255, 255, 0.1);
        border-color: transparent;
    }
}

@media (pointer: coarse) {

    .cursor-dot,
    .cursor-circle {
        display: none !important;
    }

    body {
        cursor: auto;
    }
}

/* Typography & Utils */
.text-balance {
    text-wrap: balance;
}

.loader {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: #111111;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #F5F5F5;
}

.magnetic-btn {
    display: inline-block;
    will-change: transform;
}

/* Reveal Animations */
.hero-char {
    display: inline-block;
    opacity: 0;
    filter: blur(12px);
    transform: translateY(20px);
    will-change: transform, opacity, filter;
}

/* 3D Code Background Container */
.code-3d-container {
    position: fixed;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(135deg, #F5F5F5 0%, #E8E8E8 50%, #F5F5F5 100%);
    background-size: 200% 200%;
    animation: gradientShift 15s ease infinite;
    pointer-events: none;
    perspective: 1000px;
    overflow: hidden;
}

/* Floating 3D Code Blocks */
.code-block-3d {
    position: absolute;
    width: 120px;
    height: 120px;
    background: rgba(235, 58, 20, 0.03);
    border: 1px solid rgba(235, 58, 20, 0.08);
    transform-style: preserve-3d;
    animation: float3d 20s infinite ease-in-out;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    line-height: 1.4;
    backdrop-filter: blur(2px);
}

.code-block-3d:nth-child(1) {
    top: 10%;
    left: 5%;
    animation-delay: 0s;
    animation-duration: 25s;
}

.code-block-3d:nth-child(2) {
    top: 60%;
    left: 80%;
    animation-delay: -5s;
    animation-duration: 30s;
}

.code-block-3d:nth-child(3) {
    top: 30%;
    right: 10%;
    animation-delay: -10s;
    animation-duration: 28s;
}

.code-block-3d:nth-child(4) {
    bottom: 20%;
    left: 15%;
    animation-delay: -15s;
    animation-duration: 32s;
}

.code-block-3d:nth-child(5) {
    top: 70%;
    left: 50%;
    animation-delay: -8s;
    animation-duration: 26s;
}

@keyframes float3d {

    0%,
    100% {
        transform: translate3d(0, 0, 0) rotateX(0deg) rotateY(0deg) rotateZ(0deg);
    }

    25% {
        transform: translate3d(30px, -40px, 50px) rotateX(10deg) rotateY(45deg) rotateZ(5deg);
    }

    50% {
        transform: translate3d(-20px, 20px, -30px) rotateX(-5deg) rotateY(90deg) rotateZ(-10deg);
    }

    75% {
        transform: translate3d(40px, 30px, 40px) rotateX(15deg) rotateY(135deg) rotateZ(8deg);
    }
}

/* Project Modal Styles */
.project-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    overflow-y: auto;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.project-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: -1;
}

.modal-content {
    background: white;
    max-width: 900px;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.4s ease;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 30px 40px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(235, 58, 20, 0.1);
    transform: rotate(90deg);
}

.modal-body {
    padding: 30px 40px;
}

.modal-section {
    margin-bottom: 30px;
}

.modal-section h4 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    color: #EB3A14;
}

.modal-tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.modal-tech-badge {
    padding: 8px 12px;
    background: #F5F5F5;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
}

.modal-features-list {
    list-style: none;
    padding: 0;
}

.modal-features-list li {
    padding: 12px 0;
    padding-left: 24px;
    position: relative;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.modal-features-list li:last-child {
    border-bottom: none;
}

.modal-features-list li:before {
    content: '✓';
    position: absolute;
    left: 0;
    color: #EB3A14;
    font-weight: bold;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Dark mode modal styles */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: #1a1a1a;
        color: #e5e5e5;
    }

    .modal-header {
        border-bottom-color: rgba(255, 255, 255, 0.1);
    }

    .modal-close {
        background: rgba(255, 255, 255, 0.05);
    }

    .modal-close:hover {
        background: rgba(235, 58, 20, 0.2);
    }

    .modal-tech-badge {
        background: rgba(255, 255, 255, 0.05);
        border-color: rgba(255, 255, 255, 0.1);
    }

    .modal-features-list li {
        border-bottom-color: rgba(255, 255, 255, 0.05);
    }
}

/* Marquee */
.marquee-track {
    display: flex;
    white-space: nowrap;
    width: max-content;
    will-change: transform;
    animation: marquee 40s linear infinite;
}

@keyframes marquee {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-50%);
    }
}

/* Project Cards 3D Effect */
.project-card {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.project-card-inner {
    transition: transform 0.1s;
    will-change: transform;
}

.project-card:hover .project-img {
    transform: scale(1.05);
}

.project-img {
    transition: transform 0.7s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Mobile Fixes */
.mobile-stack {
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .mobile-stack {
        flex-direction: row;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #0a0a0a;
        color: #e5e5e5;
    }

    /* Update background colors */
    #work,
    #contact {
        background-color: #0a0a0a !important;
    }

    #about {
        background-color: #111111 !important;
    }

    /* Update text colors */
    .text-primary {
        color: #e5e5e5 !important;
    }

    .text-secondary {
        color: #a0a0a0 !important;
    }

    /* Update borders */
    .border-black\/10,
    .border-black\/5 {
        border-color: rgba(255, 255, 255, 0.1) !important;
    }

    /* Update cards and surfaces */
    .bg-white {
        background-color: #1a1a1a !important;
    }

    .bg-background {
        background-color: #111111 !important;
    }

    .bg-gray-200 {
        background-color: #222222 !important;
    }

    /* Update navigation */
    nav a {
        color: #e5e5e5 !important;
    }

    .bg-white\/90 {
        background-color: rgba(26, 26, 26, 0.9) !important;
    }

    /* Dark mode 3D background */
    .code-3d-container {
        background: linear-gradient(135deg, #0a0a0a 0%, #1a1a1a 50%, #0a0a0a 100%) !important;
    }

    .code-block-3d {
        background: rgba(235, 58, 20, 0.05) !important;
        border-color: rgba(235, 58, 20, 0.15) !important;
        color: rgba(255, 255, 255, 0.12) !important;
    }

    /* Gradient overlay for dark mode */
    .bg-gradient-to-b {
        background: linear-gradient(to bottom, transparent, rgba(10, 10, 10, 0.1), #0a0a0a) !important;
    }
}
