* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #00ff88;
    --secondary-color: #0066ff;
    --dark-bg: #0a0a0a;
    --text-color: #ffffff;
    --text-secondary: #b0b0b0;
    --card-bg: rgba(20, 20, 20, 0.8);
}

html {
    scroll-behavior: auto;
    /* Changed from smooth for better snap responsiveness */
    scroll-padding-top: 80px;
    /* account for fixed navbar when snapping */
}

/* Enable vertical scroll snapping across sections */
html,
body {
    height: 100%;
    scroll-snap-type: y mandatory;
    /* keep sections from hiding under fixed navbar */
    scroll-padding-top: 80px;
    -ms-overflow-style: none;
    /* IE/Edge legacy */
    scrollbar-width: none;
    /* Firefox */
    overflow-y: scroll;
}

/* Temporarily disable snapping during programmatic smooth scroll */
html.no-snap,
body.no-snap {
    scroll-snap-type: none !important;
}

/* Hide scrollbars in WebKit-based browsers */
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 0;
    height: 0;
}

#coverBlack {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    opacity: 1.0;
    background: #000000;
}

body {
    font-family: 'Vend Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-color);
    overflow-x: hidden;
    line-height: 1.6;
}

/* Intro Animation Overlay */
#intro-canvas {
    position: fixed;
    top: 0;
    left: 0;
    /* Fallback to classic viewport, then dynamic, then large (fills under URL bar) */
    width: 100vw;
    width: 100dvw;
    width: 100lvw;
    height: 100vh;
    height: 100dvh;
    height: 100lvh;
    z-index: 10000;
    background: transparent;
    /* let the page show during camera zoom */
    transition: opacity 0.3s ease-out;
}

#intro-canvas.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Hide main content initially */
.main-content {
    opacity: 0;
    transition: opacity 0.6s ease-in;
}

.main-content.visible {
    opacity: 1;
}

@keyframes fadeInDelayed {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

/* Three.js Background Canvas */
#bg-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    width: 100dvw;
    width: 100lvw;
    height: 100vh;
    height: 100dvh;
    height: 100lvh;
    z-index: -1;
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    /* justify-content: space-between; Removed to allow margin-auto on logo to push items right */
    align-items: center;
    gap: 2rem; /* Add gap between menu and controls */
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -1px;
    text-decoration: none;
    margin-right: auto; /* Pushes nav items to the right */
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lang-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-color);
    padding: 0.5rem 0.8rem;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

.lang-text {
    font-weight: 700;
    letter-spacing: 1px;
}

/* Hamburger toggle (hidden on desktop) */
.nav-toggle {
    display: none;
    background: transparent;
    border: 0;
    padding: 0.25rem;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 26px;
    height: 2px;
    background: var(--text-color);
    margin: 6px 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle.open span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.nav-toggle.open span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.open span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-menu a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-menu a::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-menu a:hover::after {
    width: 100%;
}

.nav-menu a:hover {
    color: var(--primary-color);
}

/* Hero Section */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
}

.hero-content {
    max-width: 800px;
}

.glitch {
    font-size: clamp(3rem, 10vw, 8rem);
    font-weight: 900;
    margin-bottom: 1rem;
    color: var(--primary-color);
    position: relative;
    animation: glitch-anim 3s infinite;
}

@keyframes glitch-anim {

    0%,
    90%,
    100% {
        text-shadow: none;
    }

    91%,
    93%,
    95%,
    97%,
    99% {
        text-shadow:
            2px 2px 0 var(--secondary-color),
            -2px -2px 0 #ff0066;
    }
}

.subtitle {
    font-size: clamp(1.2rem, 3vw, 2rem);
    margin-bottom: 1rem;
    font-weight: 300;
    color: var(--text-color);
}

.tagline {
    font-size: clamp(1rem, 2vw, 1.2rem);
    margin-bottom: 2rem;
    color: var(--text-secondary);
}

.cta-button {
    display: inline-block;
    padding: 1rem 3rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--dark-bg);
    text-decoration: none;
    font-weight: 700;
    border-radius: 50px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3);
}

.cta-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0, 255, 136, 0.5);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Section Titles */
.section-title {
    font-size: clamp(2.5rem, 5vw, 4rem);
    text-align: center;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Services Section */
.services {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.services-grid {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 2rem;
    overflow-x: visible;
    /* Disable horizontal scroll on desktop to prevent interference with page scroll */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
}

/* Hide horizontal scrollbar for services row in WebKit */
.services-grid::-webkit-scrollbar {
    display: none;
}

.service-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    flex: 0 0 320px;
    /* horizontal card width */
}

.service-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 30px rgba(0, 255, 136, 0.2);
}

.service-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.service-icon-3d {
    width: 100%;
    height: 150px;
    margin-bottom: 1rem;
    position: relative;
}

.service-card h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.service-card p {
    color: var(--text-secondary);
    line-height: 1.8;
}

/* About Section */
.about {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.about-content {
    text-align: center;
}

.about-text {
    font-size: 1.3rem;
    max-width: 800px;
    margin: 0 auto 2rem;
    color: var(--text-secondary);
    line-height: 1.8;
}

.stats {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 3rem;
    margin-top: 1rem;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 1rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* Projects Section */
.projects {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow: hidden;
    /* Prevent scrollbar from affecting layout */
}

.projects-wrapper {
    width: 100%;
    position: relative;
}

.project-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(20, 20, 20, 0.6);
    color: var(--primary-color);
    border: 1px solid rgba(0, 255, 136, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    padding-bottom: 4px; /* Optical center adjustment */
    line-height: 1;
    opacity: 0; /* Controlled by JS */
    pointer-events: none;
}

.project-nav.visible {
    opacity: 1;
    pointer-events: all;
}

.project-nav:hover {
    background: var(--primary-color);
    color: var(--dark-bg);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

.project-nav.prev {
    left: -1rem; /* Outside initially on desktop */
}

.project-nav.next {
    right: -1rem; /* Outside initially on desktop */
}

/* Adjust desktop wrapper to allow buttons outside if needed, or put them inside */
@media (min-width: 769px) {
    .projects-wrapper {
        padding: 0 2rem; /* Make room for buttons */
    }
    .project-nav.prev {
        left: 0;
    }
    .project-nav.next {
        right: 0;
    }
}

.projects-grid {
    display: flex;
    gap: 2rem;
    overflow-x: auto;
    padding: 2rem 1rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Firefox */
}

.projects-grid::-webkit-scrollbar {
    display: none;
    /* Chrome/Safari */
}

.project-card {
    flex: 0 0 350px;
    height: 450px;
    background: var(--card-bg);
    border-radius: 20px;
    overflow: hidden;
    position: relative;
    scroll-snap-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.4s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.project-card:hover {
    transform: translateY(-10px) scale(1.02);
    border-color: var(--primary-color);
    box-shadow: 0 15px 40px rgba(0, 255, 136, 0.2);
    z-index: 10;
}

.project-image {
    width: 100%;
    height: 55%;
    /* Reduced from 60% to give more room for text */
    object-fit: cover;
    transition: transform 0.5s ease;
}

.project-card:hover .project-image {
    transform: scale(1.1);
}

.project-info {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(to top, rgba(10, 10, 10, 1), rgba(20, 20, 20, 0.9));
    z-index: 2;
}

.project-title {
    font-size: 1.5rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.project-short-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 255, 136, 0.1);
    color: var(--primary-color);
    border-radius: 50px;
    border: 1px solid rgba(0, 255, 136, 0.2);
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 2rem;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #151515;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 25px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow-y: auto;
    transform: translateY(50px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    font-family: sans-serif;
}

.modal-close:hover {
    background: var(--primary-color);
    color: black;
    transform: rotate(90deg);
}

.modal-body {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 0;
}

.modal-image-container {
    height: 100%;
    min-height: 400px;
    background: #000;
}

.modal-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-details {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.modal-details h3 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    line-height: 1.1;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.modal-details p {
    color: var(--text-secondary);
    line-height: 1.8;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.cta-button.small {
    padding: 0.8rem 2rem;
    font-size: 0.9rem;
    align-self: flex-start;
}

/* Mobile adjustments for Projects and Modal */
@media (max-width: 768px) {
    .projects {
        padding: 1rem 0;
        display: block;
        /* Reset flex display to ensure proper flow */
    }

    .projects .container {
        padding: 0;
        /* Remove container padding to let grid touch edges */
        width: 100%;
        max-width: 100%;
    }

    .projects-grid {
        padding: 2rem calc((100vw - min(85vw, 350px)) / 2);
        /* Add padding to grid instead */
        gap: 1rem;
        scroll-padding-left: 0;
        margin: 0;
        /* Reset margins */
        width: 100%;
        /* Full width */
        justify-content: flex-start;
        /* Ensure items start from left */
    }

    .project-card {
        flex: 0 0 85vw;
        /* Slightly wider card */
        max-width: 350px;
        height: 55vh;
        min-height: 350px;
        margin-right: 0;
        /* Reset any margins */
        opacity: 0.5;
        /* Dim non-active cards */
        transform: scale(0.9);
        /* Scale down non-active cards */
        transition: all 0.3s ease;
    }

    .project-card .project-image {
        height: 50%;
        /* Reduce image height on mobile to give more text space */
    }

    .project-card .project-info {
        padding: 1.2rem;
        /* Slightly reduce padding */
    }

    .project-card .project-title {
        font-size: 1.3rem;
        /* Slightly smaller title */
    }

    .project-card.active {
        opacity: 1;
        transform: scale(1);
    }

    .project-nav {
        width: 35px;
        height: 35px;
        font-size: 1.5rem;
        background: rgba(10, 10, 10, 0.8);
        border-color: rgba(0, 255, 136, 0.4);
    }

    .project-nav.prev {
        left: 10px;
    }

    .project-nav.next {
        right: 10px;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
        /* Sheet-like on mobile or full screen */
    }

    .modal-content {
        max-height: 90vh;
        /* Leave some space at top */
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        transform: translateY(100%);
        transition: transform 0.4s ease-out;
        /* Remove bounce effect on mobile */
    }

    .modal-overlay.active .modal-content {
        transform: translateY(0);
    }

    .modal-body {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
    }

    .modal-image-container {
        height: 200px;
        min-height: auto;
        flex-shrink: 0;
    }

    .modal-details {
        padding: 1.5rem;
        overflow-y: auto;
        /* Allow scrolling within details if needed */
    }

    .modal-details h3 {
        font-size: 1.5rem;
    }

    .modal-close {
        top: 1rem;
        right: 1rem;
        background: rgba(0, 0, 0, 0.6);
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }
}

/* Contact Section */
.contact {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

/* Scroll snap targets: ensure each section fills the viewport and snaps */
.hero,
.about,
.services,
.projects,
.contact {
    scroll-snap-align: start;
    scroll-snap-stop: always;
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile */
    box-sizing: border-box;
}

.contact-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 4rem;
    margin-top: 2rem;
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 1rem;
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--text-color);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.2);
}

.submit-button {
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--dark-bg);
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
}

.submit-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 25px rgba(0, 255, 136, 0.5);
}

.contact-info h3 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.contact-info p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    line-height: 1.8;
    text-align: center;
}

.info-item {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.info-item span:first-child {
    font-size: 1.5rem;
}

.info-item a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

.info-item a:hover {
    color: var(--primary-color);
}

/* Match info-item h4 color with other headings */
.info-item h4 {
    color: var(--primary-color);
}

/* Footer */
.footer {
    padding: 2rem 0;
    text-align: center;
    background: rgba(10, 10, 10, 0.9);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer p {
    color: var(--text-secondary);
}

/* Mobile device detection class */
.mobile-device {
    /* This class will be added by JavaScript for mobile devices */
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-controls {
        gap: 0.5rem;
    }
    
    .nav-toggle {
        display: block;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        margin: 0;
        padding: 0.75rem 2rem 1rem;
        background: rgba(10, 10, 10, 0.98);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        transform: translateY(-8px);
        transition: max-height 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
    }

    .nav-menu.open {
        max-height: 300px;
        opacity: 1;
        transform: translateY(0);
    }

    .nav-menu li a {
        padding: 0.5rem 0;
        display: block;
    }

    .nav-menu {
        gap: 1rem;
    }

    .nav-menu a {
        font-size: 0.9rem;
    }

    .services-grid {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 1rem;
        overflow-x: visible;
        padding: 0;
    }

    .service-card {
        flex: 0 1 auto;
        width: min(100%, 400px); /* Increased width for side-by-side layout */
        max-width: 100%;
        padding: 1.5rem;
        margin: 0 auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        text-align: left;
        gap: 1.5rem;
    }

    .service-icon-3d {
        width: 80px;
        height: 80px;
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .service-info {
        flex: 1;
    }

    .service-card h3 {
        font-size: 1.3rem;
        margin-bottom: 0.5rem;
    }

    .service-card p {
        font-size: 0.95rem;
        line-height: 1.5;
    }

    .service-card .service-icon {
        font-size: 2rem;
        margin-bottom: 0.75rem;
    }

    .service-card h3 {
        font-size: 1.2rem;
        margin-bottom: 0.75rem;
    }

    .service-card p {
        font-size: 0.9rem;
        line-height: 1.6;
    }

    .stats {
        display: flex;
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 0.5rem;
        margin-top: 2rem;
        width: 100%;
    }

    .stat {
        flex: 1;
        min-width: 0;
        padding: 0 0.25rem;
    }

    .stat-number {
        font-size: 1.8rem;
        margin-bottom: 0.25rem;
    }

    .stat-label {
        font-size: 0.7rem;
        letter-spacing: 0.5px;
        line-height: 1.2;
        /* Force wrapping for each word to keep columns narrow */
        width: min-content; 
        margin: 0 auto;
    }

    .contact-content {
        grid-template-columns: 1fr;
    }

    /* Ensure all sections have consistent padding and centering on mobile */
    .hero,
    .about,
    .services,
    .contact {
        padding: 2rem 1rem;
        justify-content: center;
        height: auto;
        min-height: 100dvh;
    }
}