/* Responsive Layout Overrides & Spacing */
html, body {
    width: 100%;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body:not(.is-article-visible) {
    height: 100vh;
    height: 100dvh;
    overflow: hidden !important;
}

/* Outer layout wrapper - Generous padding top & bottom to let elements breathe */
#wrapper {
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    width: 100%;
    max-width: 100vw;
    padding: clamp(2rem, 5vh, 4.5rem) clamp(1rem, 4vw, 3rem) !important;
    display: flex;
    flex-direction: column;
    justify-content: space-between !important;
    align-items: center;
    box-sizing: border-box;
    overflow: hidden !important;
}

#wrapper:before,
#wrapper:after {
    display: none !important;
    content: none !important;
    height: 0 !important;
}

/* Hide #main completely when no article is active */
body:not(.is-article-visible) #main {
    display: none !important;
}

/* Hide header & footer when article modal is open */
body.is-article-visible #footer,
body.is-article-visible #header {
    display: none !important;
}

body.is-article-visible #main {
    display: flex !important;
    margin: 0 !important;
}

body.is-article-visible #wrapper {
    justify-content: center !important;
    padding: 1.5rem 1rem !important;
}

/* Header centered layout & spaced vertical distribution */
#header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 34rem;
    margin: auto 0 !important;
    flex: 1 1 auto;
    box-sizing: border-box;
    padding: 0;
}

#header > *:before,
#header > nav:before,
#header nav.use-middle:after {
    display: none !important;
    content: none !important;
}

/* Logo with ample distance below */
#header .logo {
    width: clamp(8.5rem, 18vh, 11rem) !important;
    height: clamp(8.5rem, 18vh, 11rem) !important;
    line-height: clamp(8.5rem, 18vh, 11rem) !important;
    flex-shrink: 0;
    margin: 0 auto clamp(1.5rem, 4vh, 3rem) auto !important;
}

/* Text Content with ample distance below */
#header .content {
    flex-shrink: 0;
    width: 100%;
    max-width: clamp(30rem, 90vw, 54rem) !important;
    margin-top: 0 !important;
    margin-bottom: clamp(1.75rem, 4.5vh, 3.25rem) !important;
    box-sizing: border-box;
    padding: 0 !important;
}

#header .content .inner {
    padding: 0 !important;
}

#header .content .inner h1 {
    font-size: clamp(1.85rem, 4.2vh, 2.4rem) !important;
    margin-bottom: clamp(0.5rem, 1.5vh, 0.85rem) !important;
}

#header .content p {
    font-size: clamp(0.85rem, 1.9vh, 0.98rem) !important;
    line-height: 1.6 !important;
}

/* Navigation bar - ALWAYS single horizontal row with gap and NO BORDERS */
#header nav {
    flex-shrink: 0;
    margin-top: 0 !important;
    margin-bottom: clamp(1.5rem, 4vh, 2.75rem) !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
    max-width: clamp(34rem, 94vw, 54rem) !important;
    box-sizing: border-box;
}

#header nav ul {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0 !important;
    margin: 0 !important;
    padding: 0.3rem 0.6rem !important;
    list-style: none !important;
    border: none !important;
    border-radius: 10px !important;
    background: rgba(255, 255, 255, 0.06) !important;
    box-shadow: none !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

#header nav ul li {
    flex: 1 1 0px !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    text-align: center !important;
}

#header nav ul li a {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: clamp(2.8rem, 5.2vh, 3.2rem) !important;
    line-height: clamp(2.8rem, 5.2vh, 3.2rem) !important;
    padding: 0 clamp(0.4rem, 1.2vw, 0.9rem) !important;
    font-size: clamp(0.8rem, 1.7vh, 0.92rem) !important;
    letter-spacing: 0.08em !important;
    color: rgba(255, 255, 255, 0.85) !important;
    box-sizing: border-box;
    border-radius: 0 !important;
    background: transparent !important;
    border: none !important;
    white-space: nowrap !important;
    text-transform: uppercase !important;
    box-shadow: none !important;
}

#header nav ul li a:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    border: none !important;
}

/* AR Button Wrapper */
.header-qr-wrapper {
    flex-shrink: 0;
    margin-top: 0 !important;
    margin-bottom: clamp(0.5rem, 2vh, 1.25rem) !important;
    width: 100%;
    display: flex !important;
    justify-content: center !important;
}

.header-qr-btn {
    border: none !important;
}

/* Footer Element */
#footer {
    margin-top: clamp(1.5rem, 4vh, 3rem) !important;
    margin-bottom: 0 !important;
    text-align: center;
    flex-shrink: 0;
}

#footer .copyright {
    font-size: clamp(0.68rem, 1.2vh, 0.75rem) !important;
}

/* Article scaling & Modal guarantees */
#main {
    width: 100%;
    max-width: 38rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    margin: 0 auto;
}

#main article {
    max-height: calc(100vh - 2.5rem);
    max-height: calc(100dvh - 2.5rem);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 38rem;
    box-sizing: border-box;
    padding: 2.25rem 1.75rem 1.75rem 1.75rem;
    background-color: rgba(14, 18, 22, 0.96) !important;
    border-radius: 12px;
}

body.is-light-theme #main article {
    background-color: rgba(255, 255, 255, 0.98) !important;
}

#main article.active {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

#header nav ul li a,
.header-qr-btn,
#main article .close {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 201, 167, 0.2);
    touch-action: manipulation;
}

#main article .close {
    z-index: 10;
}

/* /* Allow page scrolling on mobile when screen height is shorter than content */
@media screen and (max-width: 736px) {
    body:not(.is-article-visible) {
        height: auto !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    #wrapper {
        height: auto !important;
        min-height: 100vh !important;
        min-height: 100dvh !important;
        max-height: none !important;
        overflow-y: visible !important;
    }
}

/* Mobile viewport adjustments: compact & perfectly fitted to 1 screen */
@media screen and (max-width: 480px) {
    /* Natural vertical flow inside wrapper */
    #wrapper {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: clamp(0.5rem, 1.5vh, 1.25rem) 0.75rem !important;
        box-sizing: border-box !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        overflow: hidden !important;
    }

    /* Reset header margins and stretch */
    #header {
        margin: 0 !important;
        flex: 0 1 auto !important;
        justify-content: center !important;
        width: 100% !important;
    }

    /* Compact logo (max 6.0rem) so everything fits on 1 screen */
    #header .logo {
        width: clamp(4.5rem, 10.5vh, 6.0rem) !important;
        height: clamp(4.5rem, 10.5vh, 6.0rem) !important;
        line-height: clamp(4.5rem, 10.5vh, 6.0rem) !important;
        margin-bottom: clamp(0.2rem, 0.8vh, 0.45rem) !important;
    }

    #header .content {
        margin: 0.1rem 0 clamp(0.35rem, 1.2vh, 0.65rem) 0 !important;
        padding: 0 !important;
        border: none !important;
    }

    #header .content .inner {
        padding: 0.1rem 0 !important;
    }

    #header .content .inner h1 {
        font-size: 2.1rem !important;
        font-weight: 800 !important;
        margin-bottom: 0.2rem !important;
        letter-spacing: -0.015em !important;
    }

    #header .content .inner .header-subtitle {
        font-size: 1.15rem !important;
        font-weight: 800 !important;
        color: #00ffd5 !important;
        letter-spacing: 0.05em !important;
        margin-bottom: 0.5rem !important;
    }

    #header .content .inner .header-intro-text {
        gap: 0.3rem !important;
        padding: 0 !important;
        max-width: 100% !important;
    }

    #header .content .inner .header-intro-text p {
        font-size: 0.92rem !important;
        line-height: 1.45 !important;
        font-weight: 400 !important;
        letter-spacing: 0.005em !important;
        text-wrap: balance !important;
        color: #ffffff !important;
        margin: 0 !important;
    }

    #header .content p {
        font-size: 0.92rem !important;
        line-height: 1.45 !important;
        font-weight: 400 !important;
        letter-spacing: 0.005em !important;
        text-wrap: balance !important;
        color: #ffffff !important;
        margin-top: 0.4rem !important;
    }

    #header nav {
        width: 100% !important;
        max-width: 14.8rem !important;
        padding: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        margin-bottom: clamp(0.35rem, 1.2vh, 0.65rem) !important;
        box-sizing: border-box !important;
    }

    #header nav ul {
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
        align-items: stretch !important;
        gap: clamp(0.25rem, 0.8vh, 0.4rem) !important;
        background: transparent !important;
        border-radius: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    body.is-light-theme #header nav ul {
        background: transparent !important;
    }

    #header nav ul li {
        flex: 1 1 auto !important;
        width: 100% !important;
        border: none !important;
        margin: 0 !important;
    }

    #header nav ul li a {
        font-size: clamp(0.68rem, 1.6vh, 0.76rem) !important;
        font-weight: 600 !important;
        letter-spacing: 0.05em !important;
        padding: 0 0.85rem !important;
        height: clamp(1.9rem, 3.4vh, 2.25rem) !important;
        line-height: clamp(1.9rem, 3.4vh, 2.25rem) !important;
        border: none !important;
        background: rgba(255, 255, 255, 0.06) !important;
        border-radius: 8px !important;
    }

    body.is-light-theme #header nav ul li a {
        background: rgba(0, 0, 0, 0.05) !important;
    }

    #header nav ul li a:hover,
    #header nav ul li a:active {
        background: rgba(255, 255, 255, 0.16) !important;
    }

    body.is-light-theme #header nav ul li a:hover,
    body.is-light-theme #header nav ul li a:active {
        background: rgba(0, 0, 0, 0.1) !important;
    }

    .header-qr-wrapper {
        margin-bottom: clamp(0.25rem, 0.8vh, 0.5rem) !important;
    }

    .header-qr-btn {
        padding: clamp(0.35rem, 0.9vh, 0.5rem) clamp(1.0rem, 2.5vw, 1.3rem) !important;
        font-size: clamp(0.68rem, 1.6vh, 0.76rem) !important;
    }

    #footer {
        margin-top: clamp(0.25rem, 0.8vh, 0.5rem) !important;
        margin-bottom: 0.15rem !important;
        flex-shrink: 0 !important;
    }

    #footer .copyright {
        font-size: 0.62rem !important;
        letter-spacing: 0.04rem !important;
    }

    /* Enable line breaks in header description on mobile */
    #header .content p br {
        display: inline !important;
    }

    /* Stack QR scanner controls and action buttons vertically on mobile */
    .qr-result-actions,
    .qr-controls {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 15rem !important;
        margin: 0.65rem auto 0 auto !important;
        gap: 0.45rem !important;
    }

    .qr-action-btn,
    .qr-main-btn,
    .qr-sub-btn {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Light Theme adjustments for QR scanner buttons */
    body.is-light-theme .qr-action-btn,
    body.is-light-theme .qr-main-btn {
        background: rgba(0, 0, 0, 0.05) !important;
        color: rgba(0, 0, 0, 0.8) !important;
    }

    body.is-light-theme .qr-action-btn:hover,
    body.is-light-theme .qr-main-btn:hover {
        background: rgba(0, 0, 0, 0.1) !important;
        color: #000000 !important;
    }

    body.is-light-theme .qr-sub-btn {
        border-color: rgba(0, 0, 0, 0.15) !important;
        color: rgba(0, 0, 0, 0.6) !important;
    }

    body.is-light-theme .qr-sub-btn:hover {
        background: rgba(0, 0, 0, 0.04) !important;
        border-color: rgba(0, 0, 0, 0.3) !important;
        color: #000000 !important;
    }

    /* Intro grid adjustments for mobile view */
    .intro-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 0.75rem !important;
        width: 100% !important;
    }

    .intro-text {
        width: 100% !important;
        text-align: center !important;
    }

    .intro-text p {
        text-align: center !important;
        margin-bottom: 0.5rem !important;
    }

    .intro-image {
        width: 100% !important;
        max-width: 220px !important;
        margin: 0.5rem auto 0 auto !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .intro-image img {
        width: 100% !important;
        max-height: 20rem !important;
    }

    /* Stack CTA buttons vertically on mobile inside the same menu width */
    .intro-actions {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
        max-width: 17rem !important;
        margin: 0.75rem auto 0 auto !important;
        gap: 0.5rem !important;
    }

    .intro-btn {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #intro h2.major,
    #studio h2.major,
    #main article h2.major {
        font-size: 2.15rem !important;
        margin-bottom: 1.5rem !important;
    }

    #main article .studio-subtitle,
    #main article .solutions-subtitle {
        font-size: 1.2rem !important;
        margin-bottom: 1.85rem !important;
    }

    #main article h3,
    #intro .studio-block h3,
    #studio .studio-block h3,
    #solutions .studio-block h3 {
        font-size: 1.5rem !important;
        margin-top: 1.5rem !important;
        margin-bottom: 1.0rem !important;
    }

    #main article h4,
    #intro .capability-item h4,
    #studio .capability-item h4,
    #solutions .capability-item h4,
    .project-title {
        font-size: 1.32rem !important;
        margin-bottom: 0.6rem !important;
    }

    #main article p,
    #main article ul li,
    #intro .studio-block .studio-tagline,
    #studio .studio-block .studio-tagline,
    #solutions .studio-block .studio-tagline,
    .project-desc,
    .contact-quote,
    .contact-subquote {
        font-size: 1.12rem !important;
        line-height: 1.7 !important;
        color: #ffffff !important;
    }

    /* Contact logo adjustments for mobile view */
    .contact-logo-wrapper {
        margin-bottom: 1rem !important;
    }
    .contact-logo-wrapper img {
        max-height: 12rem !important;
    }
}

/* Short Viewports (Landscape Mobile) */
@media screen and (max-height: 560px) {
    #wrapper {
        padding: 0.75rem !important;
    }

    #header .logo {
        width: 5.5rem !important;
        height: 5.5rem !important;
        line-height: 5.5rem !important;
        margin-bottom: 0.75rem !important;
    }

    #header .content {
        margin-bottom: 0.75rem !important;
    }

    #header .content .inner h1 {
        font-size: 1.5rem !important;
        margin-bottom: 0.2rem !important;
    }

    #header .content p {
        font-size: 0.78rem !important;
        line-height: 1.35 !important;
    }

    #header nav {
        margin-bottom: 0.75rem !important;
    }

    #header nav ul li a {
        height: 2.2rem !important;
        line-height: 2.2rem !important;
        font-size: 0.68rem !important;
    }

    .header-qr-wrapper {
        margin-bottom: 0.5rem !important;
    }

    #footer {
        margin-top: 0.5rem !important;
    }
}

/* Optimize article padding on mobile to maximize gallery width */
@media screen and (max-width: 736px) {
    #main article#work, 
    #main article#about {
        padding-left: 0.85rem !important;
        padding-right: 0.85rem !important;
    }
}

@media screen and (max-width: 480px) {
    #main article#work, 
    #main article#about {
        padding-left: 0.65rem !important;
        padding-right: 0.65rem !important;
    }
    
    .projects-grid {
        gap: 1.5rem !important;
    }
}
