/* ========================================
   MOBILE IMPROVEMENTS - CLEAN REDESIGN
   ======================================== */

/* ========================================
   NAVBAR - HAMBURGER MENU
   ======================================== */

/* Hide hamburger on desktop */
.mobile-menu-btn {
    display: none;
}

@media (max-width: 768px) {

    /* Show hamburger button */
    .mobile-menu-btn {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 40px;
        height: 40px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 8px;
        z-index: 1001;
        order: 3;
        /* After logo, before nav */
    }

    .mobile-menu-btn span {
        width: 100%;
        height: 3px;
        background: var(--primary-color, #00ff66);
        border-radius: 10px;
        transition: all 0.3s ease;
    }

    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(8px, 8px);
    }

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

    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -7px);
    }

    /* Hide nav by default on mobile */
    .navbar-nav {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100%;
        height: calc(100vh - 70px);
        background: rgba(255, 255, 255, 0.95);
        /* Light background instead of dark */
        backdrop-filter: blur(20px);
        flex-direction: column;
        align-items: center;
        justify-content: flex-start;
        padding: 2rem 0;
        gap: 1.5rem;
        transition: left 0.3s ease;
        z-index: 1000;
    }

    .navbar-nav.active {
        left: 0;
    }

    .navbar-actions {
        order: 2;
        /* Before hamburger */
    }
}

/* ========================================
   HERO SECTION - CTA BUTTONS
   ======================================== */

@media (max-width: 768px) {
    .hero-cta {
        flex-direction: row !important;
        gap: 0.75rem !important;
    }

    .hero-cta .cta-btn {
        flex: 1;
        min-width: 0;
        padding: 0.75rem 1rem !important;
        font-size: 0.85rem !important;
    }
}

/* ========================================
   KEYBOARD - REMOVE BORDER ON MOBILE
   ======================================== */

@media (max-width: 768px) {
    .keyboard::before {
        display: none !important;
    }

    .keyboard {
        border: none !important;
        box-shadow: none !important;
    }
}

/* ========================================
   LABS - FIX CARD ALIGNMENT
   ======================================== */

@media (max-width: 768px) {
    .lab-overlay {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        padding: 1rem;
    }

    .lab-icon {
        margin-bottom: 0.5rem;
    }
}

/* ========================================
   SERVICES SECTION - MOBILE IMPROVEMENTS
   ======================================== */

/* Desktop - details always visible, buttons hidden */
.service-toggle-btn {
    display: none !important;
    /* Must be !important to override mobile styles when in desktop view */
}

.service-features {
    display: block;
}

/* ========================================
   SERVICES MOBILE - FINAL VERSION
   ======================================== */

@media (max-width: 768px) {

    /* Section container */
    .services-section {
        padding: 3rem 1rem !important;
        overflow-x: hidden !important;
    }

    /* Subtitle spacing */
    .services-section .section-subtitle,
    .services-section>p {
        margin-top: 1.5rem !important;
    }

    .services-grid {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* CRITICAL: Force single-column grid layout */
    .services-grid .service-card {
        display: grid !important;
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto auto !important;
        gap: 0.5rem !important;
        /* Reduced from 1rem to 0.5rem for tighter spacing */
        width: 100% !important;
        padding: 1.25rem !important;
        margin-bottom: 1.5rem !important;
        box-sizing: border-box !important;
        overflow: visible !important;
    }

    /* Service header takes full width in mobile */
    .services-grid .service-card .service-header {
        grid-column: 1 / -1 !important;
        grid-row: 1 / 2 !important;
        width: 100% !important;
        /* Full width to match buttons below */
        display: flex !important;
        align-items: center !important;
        gap: 1rem !important;
    }

    /* Icon stays visible */
    .services-grid .service-card .service-icon {
        width: 56px !important;
        height: 56px !important;
        flex-shrink: 0 !important;
    }

    /* Title takes remaining space */
    .services-grid .service-card .service-title {
        flex: 1 !important;
        margin: 0 !important;
        font-size: 1.1rem !important;
    }

    /* Service features list */
    .services-grid .service-card .service-features {
        grid-column: 1 / -1 !important;
        grid-row: 2 / 3 !important;
        max-height: 0 !important;
        overflow: hidden !important;
        margin: 0 !important;
        padding: 0 !important;
        transition: max-height 0.4s ease !important;
    }

    .services-grid .service-card.expanded .service-features {
        max-height: 500px !important;
        margin-top: 1rem !important;
    }

    .services-grid .service-card .service-features ul {
        padding-left: 1.25rem !important;
        margin: 0.5rem 0 !important;
    }

    .services-grid .service-card .service-features li {
        margin-bottom: 0.5rem !important;
    }

    /* ROW 3: Buttons equal width side by side */
    .services-grid .service-card .service-cta {
        grid-column: 1 / 3 !important;
        /* Span full width */
        grid-row: 3 / 4 !important;
        width: calc(50% - 0.5rem) !important;
        /* Take 50% minus gap */
        margin: 1rem 1rem 0 0 !important;
        padding: 0.75rem 0.5rem !important;
        font-size: 0.8rem !important;
        box-sizing: border-box !important;
        text-align: center !important;
    }

    .services-grid .service-card .service-toggle-btn {
        grid-column: 1 / 3 !important;
        /* Span full width */
        grid-row: 3 / 4 !important;
        width: calc(50% - 0.5rem) !important;
        /* Take 50% minus gap */
        margin: 1rem 0 0 auto !important;
        /* Push to right */
        padding: 0.75rem 0.5rem !important;
        font-size: 0.8rem !important;
        box-sizing: border-box !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        background: var(--color-white) !important;
        /* WHITE BACKGROUND */
        border: 2px solid var(--color-lime) !important;
        /* LIME GREEN BORDER */
        border-radius: 10px !important;
        color: var(--color-dark) !important;
        /* BLACK TEXT */
        cursor: pointer !important;
        font-weight: 600 !important;
    }

    .services-grid .service-card .service-toggle-btn:hover {
        background: var(--color-lime) !important;
        /* LIME GREEN BACKGROUND ON HOVER */
        color: var(--color-white) !important;
        /* WHITE TEXT ON HOVER */
    }

    .services-grid .service-card .toggle-arrow {
        transition: transform 0.3s ease !important;
        flex-shrink: 0 !important;
    }

    .services-grid .service-card.expanded .toggle-arrow {
        transform: rotate(180deg) !important;
    }

    .services-grid .service-card .hide-text {
        display: none !important;
    }

    .services-grid .service-card.expanded .show-text {
        display: none !important;
    }

    .services-grid .service-card.expanded .hide-text {
        display: inline !important;
    }
}


/* Additional Services Toggle */
.additional-services-toggle {
    display: none;
}

.sticky-hide-btn {
    display: none;
}

.additional-services-wrapper {
    display: block;
}

@media (max-width: 768px) {
    .additional-services-toggle {
        display: block;
        width: 100%;
        padding: 1.25rem 2rem;
        margin: 2rem 0;
        background: linear-gradient(135deg, var(--color-lime), #00cc6a);
        border: none;
        border-radius: 12px;
        color: var(--color-dark);
        font-weight: 700;
        font-size: 1rem;
        cursor: pointer;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 8px 24px rgba(0, 255, 136, 0.25);
        position: relative;
        overflow: hidden;
    }

    .additional-services-toggle::before {
        content: '';
        position: absolute;
        inset: 0;
        background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.2));
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .additional-services-toggle:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 32px rgba(0, 255, 136, 0.4);
    }

    .additional-services-toggle:hover::before {
        transform: translateX(100%);
    }

    .additional-services-toggle .hide-text {
        display: none;
    }

    .additional-services-wrapper.visible~.additional-services-toggle .show-text {
        display: none;
    }

    .additional-services-wrapper.visible~.additional-services-toggle .hide-text {
        display: inline;
    }

    /* Additional services hidden by default on mobile */
    .additional-services-wrapper {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.5s ease;
    }

    .additional-services-wrapper.visible {
        max-height: 10000px;
    }

    /* Sticky hide button */
    .sticky-hide-btn {
        position: fixed;
        bottom: 2rem;
        left: 50%;
        transform: translateX(-50%);
        z-index: 100;
        padding: 1rem 2rem;
        background: linear-gradient(135deg, #ff6b35, #ff3b00);
        border: none;
        border-radius: 50px;
        color: white;
        font-weight: 600;
        font-size: 0.95rem;
        cursor: pointer;
        box-shadow: 0 10px 30px rgba(255, 107, 53, 0.4);
        opacity: 0;
        pointer-events: none;
        transition: all 0.3s ease;
    }

    .additional-services-wrapper.visible~.sticky-hide-btn {
        opacity: 1;
        pointer-events: all;
    }

    .sticky-hide-btn:hover {
        transform: translateX(-50%) translateY(-2px);
        box-shadow: 0 15px 40px rgba(255, 107, 53, 0.5);
    }
}

/* ========================================
   MOBILE SKILLS SECTION - SCALED KEYBOARD LAYOUT
   ======================================== */

@media (max-width: 768px) {
    .skills-section {
        padding: 0.5rem 1rem 3rem 1rem !important;
        /* Minimal top padding */
    }

    /* Reduce top spacing for Labs and Demos sections */
    .labs-section,
    .demos-section {
        padding-top: 0.5rem !important;
    }

    /* Add spacing between title and subtitle in Labs/Demos */
    .labs-section .section-subtitle,
    .labs-section>p,
    .demos-section .section-subtitle,
    .demos-section>p {
        margin-top: 1.5rem !important;
    }

    /* Stack layout: info on top, keyboard below */
    .skills-layout {
        display: flex;
        flex-direction: column;
        gap: 2rem;
    }

    /* Info screen takes natural height */
    .keyboard-screen {
        width: 100%;
        min-height: auto;
    }

    /* Keyboard wrapper - centered container */
    .keyboard-wrapper {
        width: 100%;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: flex-start !important;
        overflow: hidden !important;
        gap: 1rem;
    }

    /* Keyboard - force desktop structure with scaling */
    .keyboard {
        width: max-content !important;
        /* max-content allows background to fit all keys */
        max-width: none !important;
        /* Remove max-width constraint */
        display: flex !important;
        flex-direction: column !important;
        transform-origin: top center !important;
        transform: scale(0.45) !important;
        margin-bottom: -275px !important;
        /* Compensate for scale empty space */
    }

    /* CRITICAL: Force rows to not wrap */
    .keyboard-row {
        flex-wrap: nowrap !important;
        display: flex !important;
        justify-content: center !important;
    }

    /* Filters wrap */
    .keyboard-filters {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.5rem;
        justify-content: center;
        width: 100%;
    }

    .filter-btn {
        flex: 0 0 auto;
        padding: 0.6rem 1rem !important;
        font-size: 0.75rem !important;
    }
}

/* Responsive scaling for different widths */
@media (max-width: 500px) {
    .keyboard {
        transform: scale(0.42) !important;
        margin-bottom: -295px !important;
    }
}

@media (max-width: 420px) {
    .keyboard {
        transform: scale(0.38) !important;
        margin-bottom: -320px !important;
    }
}

@media (max-width: 360px) {
    .keyboard {
        transform: scale(0.34) !important;
        margin-bottom: -345px !important;
    }
}


/* ========================================
   LABS SECTION - MOBILE GRID 3x4
   ======================================== */

@media (max-width: 768px) {
    .labs-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.75rem !important;
    }

    .lab-card {
        height: 110px !important;
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

    .lab-card:active {
        transform: scale(0.95);
    }

    /* Simplify card content for grid */
    .lab-desc {
        display: none !important;
    }

    .lab-title {
        font-size: 0.75rem !important;
        margin-top: 0.25rem !important;
    }

    .lab-icon {
        width: 35px !important;
        height: 35px !important;
    }

    .lab-icon svg {
        width: 25px !important;
        height: 25px !important;
    }
}