/* --- Mobile Navigation & Responsiveness --- */

/* Mobile Toggle - Hidden by default */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    z-index: 1001;
    padding: 10px;
}

.hamburger-line {
    width: 25px;
    height: 3px;
    background-color: var(--text-primary);
    border-radius: var(--radius-sm);
    transition: all 0.3s ease;
}

/* Animate Hamburger to X */
.mobile-menu-btn.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 6px);
}

.mobile-menu-btn.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -6px);
}

/* Mobile Screens (< 1100px) - Increased breakpoint to avoid header overflow */
@media (max-width: 1100px) {
    .header-extras {
        display: none;
    }

    .container {
        padding: 0 var(--spacing-md);
    }

    /* Header */
    .header-content {
        position: relative;
        width: 100%;
        padding: 0.5rem 1rem;
        justify-content: space-between;
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
    }

    .dev-name {
        font-size: 1.1rem;
    }

    .main-nav {
        border-left: none;
        padding-left: 0;
    }

    /* Show Toggle */
    .mobile-menu-btn {
        display: flex;
    }

    /* Hide Desktop Nav and convert to Mobile Dropdown */
    .main-nav .nav-links {
        display: flex;
        visibility: hidden;
        pointer-events: none;
        position: absolute;
        top: 100%;
        width: 15rem;
        background: var(--container-bg);
        flex-direction: column;
        align-items: center;
        padding: var(--spacing-lg) 0;
        gap: var(--spacing-md);
        border-radius: var(--radius-md);
        box-shadow: none;
        margin-top: 10px;
        right: 0;
        transform: translateY(-20px);
        opacity: 0;
        transition: all 0.3s ease;
    }

    .main-nav .nav-links.active {
        visibility: visible;
        pointer-events: auto;
        transform: translateY(0);
        opacity: 1;
    }

    /* Hero */
    .hero-section {
        padding-top: 0;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.2rem;
    }

    /* Bento Grid - 2 columns on tablet */
    #projects-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Reset all card sizes to uniform 1-col on tablet */
    #projects-grid .card-link,
    .size-lg,
    .size-md,
    .size-sm {
        grid-column: span 1 !important;
    }

    /* Tablet image heights */
    .size-lg .project-image,
    .size-md .project-image,
    .size-sm .project-image {
        height: 180px;
    }

    .content-grid {
        gap: var(--spacing-md);
    }

    /* Section titles */
    .section-title {
        font-size: 2rem;
    }
}

/* Mobile Screens (< 768px) - Separate from 1100px query */
@media (max-width: 768px) {

    /* Landing page mobile - reduced top padding to show more content by default */
    .landing-section {
        padding-top: 2vh;
    }

    .landing-card {
        padding: var(--spacing-lg) var(--spacing-md);
        max-width: 100%;
    }

    .landing-name {
        font-size: 1.5rem;
    }

    .landing-subtitle {
        font-size: 0.95rem;
    }

    .landing-games {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .landing-game-card {
        width: 130px;
        height: 130px;
        min-width: 130px;
    }

    .landing-game-info {
        align-items: center;
    }

    /* Prevent horizontal scroll on mobile - must be on html AND body */
    html {
        overflow-x: hidden !important;
        scroll-padding-top: 70px !important;
        /* Ensure scroll targets aren't hidden by fixed header - reduced for better visibility */
    }

    body {
        overflow-x: hidden !important;
        position: relative;
        padding-top: 65px !important;
        /* Compensate for fixed header - reduced to show more content by default */
    }

    /* Main content wrapper to contain overflow */
    #main-content {
        overflow-x: visible !important;
    }

    /* Ensure noise canvas stays fixed on mobile (iOS Safari fix) */
    #noise-canvas {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 100vh !important;
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        will-change: transform;
    }

    /* Fixed Header on Mobile */
    .main-header {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        z-index: 1000 !important;
        padding-top: var(--spacing-sm);
    }

    .header-content {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: var(--container-bg) !important;
        /* Solid color to match cards/footer */
    }

    /* Single Line Footer on Mobile */
    .main-footer {
        padding: var(--spacing-md) 0;
        width: 100%;
    }

    .main-footer p {
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: clip !important;
        width: fit-content !important;
        max-width: 95vw !important;
        margin: 0 auto !important;

        /* Dynamic scaling: ensure it fits on one line */
        font-size: clamp(0.6rem, 2.8vw, 0.8rem) !important;
        padding: 0.4rem 0.8rem !important;
        letter-spacing: -0.02em !important;
    }

    /* Hide dot navigation on mobile */
    .dot-nav {
        display: none !important;
    }

    /* Hide experience carousel arrows on mobile (touch drag handles it) */
    .exp-nav-btn {
        display: none !important;
    }

    /* Hide filters on mobile for cleaner carousel experience */
    .filters-container {
        display: none !important;
    }

    /* Mobile: Make contact text clickable for mailto/tel */
    .contact-info-text[data-href] {
        color: var(--accent-color);
        text-decoration: underline;
        cursor: pointer;
    }

    /* Carousel - Removed side fade mask as requested */
    #experience-grid,
    #projects-grid,
    .carousel-track-container {
        -webkit-mask-image: none !important;
        mask-image: none !important;
    }

    /* Center sections vertically on mobile viewport */
    #experience,
    #projects {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        min-height: auto;
        padding-top: var(--spacing-lg);
        padding-bottom: var(--spacing-lg);
        margin: 0;
    }

    /* Ensure container inside sections is full width */
    #experience>.container,
    #projects>.container {
        width: 100%;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    /* Experience cards in carousel */
    #experience-grid .experience-card {
        flex: 0 0 260px !important;
        min-width: 260px !important;
        max-width: 260px !important;
        scroll-snap-align: center;
        height: auto;
    }

    /* On mobile: stretch the grid to full viewport width */
    #experience-grid {
        width: 100vw !important;
        max-width: 100vw !important;
        margin-left: calc(50% - 50vw) !important;
        margin-right: calc(50% - 50vw) !important;
        padding: 20px calc(50vw - 130px) !important;
    }

    /* Convert Projects Grid to Horizontal Carousel */
    #projects-grid {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        gap: var(--spacing-md) !important;
        /* Center first and last items by calculating side padding based on card width (280px) */
        padding: var(--spacing-sm) calc(50vw - 140px) !important;
        /* Force full viewport width regardless of parent container */
        width: 100vw !important;
        margin-left: calc(50% - 50vw) !important;
        margin-right: calc(50% - 50vw) !important;
        max-width: 100vw !important;
        justify-content: flex-start !important;
        align-items: stretch !important;
        box-sizing: border-box;
        scrollbar-width: none;
        -ms-overflow-style: none;
        scroll-snap-type: none !important;
        /* Disable native snap as we use JS physics */
    }

    #projects-grid::-webkit-scrollbar {
        display: none;
    }

    /* Project card links in carousel */
    #projects-grid .card-link {
        flex: 0 0 280px !important;
        min-width: 280px !important;
        max-width: 280px !important;
        scroll-snap-align: center;
    }

    /* Project cards sizing */
    #projects-grid .project-card {
        width: 100%;
        height: 100%;
    }

    /* Project image height adjustment for mobile cards */
    #projects-grid .project-image {
        height: 140px;
    }

    /* Adjust project content padding for mobile - consistent small spacing */
    #projects-grid .project-content {
        padding: var(--spacing-sm);
    }

    /* Smaller text in mobile cards */
    #projects-grid .project-content h3,
    #experience-grid .experience-card h3 {
        font-size: 1rem;
    }

    #projects-grid .project-content p,
    #experience-grid .experience-card p {
        font-size: 0.85rem;
        line-height: 1.4;
    }

    /* Capsules - smaller on mobile */
    #projects-grid .capsule,
    #experience-grid .capsule {
        font-size: 0.65rem;
        padding: 2px 6px;
    }
}

/* Continue 1100px rules */
@media (max-width: 1100px) {

    /* Filters */
    .filters-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        width: 100%;
        max-width: 90%;
        margin: 0 auto 1.5rem auto;
    }

    .filter-row {
        display: flex;
        justify-content: center;
        flex-wrap: wrap;
        gap: 8px;
        width: 100%;
    }

    .filter-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
        width: auto;
        min-height: auto;
        border-radius: var(--card-radius);
        display: inline-block;
        white-space: nowrap;
    }

    .card-link {
        width: 85%;
        max-width: 340px;
    }

    .project-image {
        height: 150px;
    }

    /* Lightbox */
    .lightbox-content {
        max-width: 95vw;
        max-height: 50vh;
    }

    /* Contact Page Responsiveness */
    .contact-section {
        padding-top: var(--spacing-md);
    }
    
    /* Portfolio sections need more space from header on mobile */
    #intro, #experience, #projects {
        padding-top: var(--spacing-md);
    }

    .contact-container {
        flex-direction: column-reverse;
        gap: var(--spacing-lg);
    }

    .contact-sidebar {
        width: 100%;
        min-width: 0;
    }

    .contact-main {
        width: 100%;
    }

    .contact-info-link {
        color: var(--accent-color) !important;
        cursor: pointer !important;
    }

    .project-hero {
        padding-bottom: 0 !important;
        margin-bottom: 0.25rem !important;
    }

    .project-video-area {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    .video-container {
        margin-bottom: 0 !important;
    }

    .project-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "video"
            "sidebar"
            "text";
        gap: var(--spacing-sm);
        row-gap: var(--spacing-lg) !important;
    }

    .project-video-area {
        margin-bottom: 0;
    }

    .tech-stack-card {
        margin-bottom: 0.5rem !important;
    }

    .filter-btn,
    .hover-bouncy {
        transition-property: background, color, border-color !important;
        will-change: auto;
    }

    .filter-btn:hover,
    .filter-btn.active,
    .hover-bouncy:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    .lightbox-btn {
        padding: 15px;
        font-size: 2rem;
    }
}

/* Disable hover effects on mobile only */
@media (max-width: 768px) {
    .hover-bouncy {
        transition-property: opacity !important;
        will-change: opacity;
    }

    .hover-bouncy:hover {
        transform: none !important;
        box-shadow: none !important;
    }

    /* Web Design Contact Section Mobile Fixes */
    .webdesign-contact-btn {
        min-width: 0 !important;
        width: 100%;
        max-width: 100%;
        padding: 0.75rem 1rem !important;
    }

    .webdesign-contact-methods {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .wdc-value {
        word-break: break-all;
        font-size: 0.85rem;
        line-height: 1.3;
    }

    .webdesign-contact-title {
        font-size: 1.5rem !important;
        line-height: 1.2;
    }

    .webdesign-contact-sub {
        font-size: 0.95rem !important;
        line-height: 1.4;
    }

    /* Fix web design back link snapping */
    .webdesign-back .back-link {
        transition: none !important;
        transform: none !important;
    }
}
