:root {
    --line: 2px solid #000;
    --bg: #e0e0e0;
}

body,
html {
    margin: 0;
    padding: 0;
    background: #000;
    font-family: 'Zalando Sans', sans-serif;
    font-size: 1.2rem;
}

.bento-grid {
    display: grid;
    height: 100vh;
    grid-template-columns: repeat(12, 1fr);
    /* Use fr units so gap is calculated correctly without overflowing 100vh */
    grid-template-rows: 15fr 75fr 10fr;
    gap: 2px;
    background: #000;
}

.nav-overlay {
    position: fixed;
    top: calc((100vh - 4px) * 15 / 100 + 2px);
    left: calc((100vw - 22px) * 2 / 12 + 4px);
    width: calc((100vw - 22px) * 8 / 12 + 14px);
    height: calc((100vh - 4px) * 75 / 100);
    background-color: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* Align to left instead of center */
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.overlay-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    text-align: left;
    width: 100%;
    padding-left: 10vw; /* Push it in from the left edge */
}

.overlay-content a {
    color: #fff;
    font-size: 3rem;
    text-decoration: none;
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
    font-weight: bold;
    transition: color 0.2s;
    position: relative;
    display: inline-block;
    width: fit-content;
}

.overlay-content a:hover,
.overlay-content a:active {
    color: #ccc;
}

/* Underline the active page */
.overlay-content a.active::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -5px;
    width: 100%;
    height: 4px;
    background-color: #fff;
}

.close-menu {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
}

.overlay-logo-link {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-logo {
    height: 2rem;
    width: auto;
    filter: invert(1);
    object-fit: contain;
}

body.menu-open .bento-grid {
    filter: blur(10px);
    pointer-events: none;
}

/* Ensure logo link inherits styling */
.logo-box a {
    text-decoration: none;
    color: inherit;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px; /* Add some padding so the logo doesn't touch the edges */
    box-sizing: border-box;
}

.site-logo {
    max-width: 100%;
    max-height: 2.2rem; /* Cap height to roughly match the 2rem h2 title */
    object-fit: contain;
    display: block;
}



/* Kirby Layout Grid Styles */
.grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.column {
    grid-column: span var(--span, 12);
}

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

.blocks img,
.blocks video,
.blocks iframe,
.blocks figure {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    object-position: left top;
    height: auto;
    display: block;
}

.lazy-fade {
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
}

.lazy-fade.loaded {
    opacity: 1;
}

.blocks figure {
    margin: 0;
}

/* Archive List Styles */
.archive-list {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    width: 100%;
}

.archive-item h2 {
    margin: 0 0 1rem 0;
    font-size: 2rem;
    text-transform: uppercase;
    font-family: 'Zalando Sans', sans-serif;
}

.archive-item h2 a {
    text-decoration: none;
    color: inherit;
    transition: opacity 0.2s;
}

.archive-item h2 a:hover {
    opacity: 0.6;
}

.archive-desc {
    font-size: 1.2rem;
    line-height: 1.5;
}

.archive-desc p {
    margin: 0 0 1rem 0;
}

.blocks > * {
    margin: 0;
}

.blocks .content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.blocks .content > * {
    margin: 0;
}

.bento-item {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #000;
    font-weight: bold;
    text-transform: uppercase;
    transition: background-color 0.2s ease, filter 0.2s ease;
}

/* Apply hover/active effects to all bento items except the 3D center and project center */
.bento-item:not(.center-3d):not(.center-project):hover,
.bento-item:not(.center-3d):not(.center-project):active {
    background-color: #ccc;
}

@keyframes clickInvert {
    0% { filter: invert(0); background-color: #ccc; }
    50% { filter: invert(1); background-color: #ccc; }
    100% { filter: invert(0); background-color: #ccc; }
}

.bento-item.clicked-anim {
    animation: clickInvert 0.2s ease-in-out forwards;
}

/* For boxes with background images (like past/future boxes), use a blend mode or filter so the hover is visible */
.bento-item[style*="background-image"]:hover,
.bento-item[style*="background-image"]:active {
    background-blend-mode: multiply;
}

/* Row 1 (Header: 2-8-2 split) */
.logo-box {
    grid-column: span 2;
}

.title-box {
    grid-column: span 8;
}

.title-box h2.header {
    margin: 0;
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    transition: font-weight 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.title-box:hover h2.header {
    font-weight: 900;
}

.title-box a {
    text-decoration: none;
    color: inherit;
}

@keyframes widthPulse {
    0% { 
        font-stretch: 100%; 
        font-variation-settings: "wdth" 100; 
    }
    50% { 
        font-stretch: 200%; 
        font-variation-settings: "wdth" 200; 
    }
    100% { 
        font-stretch: 50%; 
        font-variation-settings: "wdth" 50; 
    }
}

h3.h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
    transition: font-weight 0.4s cubic-bezier(0.25, 1, 0.5, 1), letter-spacing 0.4s cubic-bezier(0.25, 1, 0.5, 1), font-variation-settings 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.bento-item:hover h3.h3,
.bento-item:active h3.h3 {
    font-weight: 400;
    letter-spacing: 0.15em;
    font-variation-settings: "wght" 400, "wdth" 150;
}

.menu-box {
    grid-column: span 2;
    border: none;
    cursor: pointer;
}

/* Hamburger Icon */
.hamburger {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 20px;
}

.hamburger span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: #000;
    border-radius: 3px;
}
.past-box {
    grid-column: span 2;
    background-size: cover;
}

.center-3d {
    grid-column: span 8;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.main-model-viewer {
    width: 100%;
    height: 100%;
    outline: none;
}

.future-box {
    grid-column: span 2;
}

/* Past & Future Pages Slideshow */
.nav-arrow {
    grid-column: span 2;
    cursor: pointer;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    transition: background-color 0.2s;
}

.nav-arrow:hover {
    background-color: #ccc;
}

.center-project {
    grid-column: span 8;
    background: var(--bg);
    position: relative;
    overflow: hidden;
    display: flex; /* override bento-item flex */
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.slideshow-container {
    flex: 1;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.slide {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 0;
    background-color: var(--bg); /* Ensure background covers elements behind it */
}

.slide.active {
    transform: translateX(0);
    z-index: 1;
}

.slide.slide-out-left {
    transform: translateX(-100%);
    z-index: 1;
}

.slide.slide-out-right {
    transform: translateX(100%);
    z-index: 1;
}

.slide.slide-in-left {
    transform: translateX(-100%);
    z-index: 0;
    transition: none; /* Snap to position before sliding in */
}

.slide.slide-in-right {
    transform: translateX(100%);
    z-index: 0;
    transition: none; /* Snap to position before sliding in */
}

.slide-image-bg {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-color: #000;
    position: absolute;
    top: 0;
    left: 0;
    filter: blur(20px) brightness(0.7);
    transform: scale(1.1); /* Prevent blurred edges from showing background */
    z-index: 0;
}

.slide-image-fg {
    width: 100%;
    height: 100%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

.project-info {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    background: transparent;
    border-top: none;
    text-align: left;
    height: auto;
    z-index: 2;
    pointer-events: none;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
    box-sizing: border-box;
}

.project-info h2 {
    margin: 0;
    font-size: 1.5rem;
}

.project-desc {
    display: none; /* Hide the layout blocks from the preview */
}

.slide-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    position: relative;
}

/* ... keep previous Row 1 and Row 2 styles ... */

/* Row 3 (Footer: 3 equal parts = 4 spans each) */
.copyright-box,
.links-social-box,
.news-box {
    grid-column: span 4;
    grid-row: 3;
}

.copyright-box {
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    font-family: 'Orbitron', sans-serif;
}

.news-box {
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.newsletter-form {
    display: flex;
    width: 100%;
    max-width: 220px;
    height: 30px;
    border: var(--line);
    border-radius: 15px;
    overflow: hidden;
    background: transparent;
    box-sizing: border-box;
}

.newsletter-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0 10px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    outline: none;
    color: #000;
    width: 100%;
    box-sizing: border-box;
}

.newsletter-input::placeholder {
    color: #000;
    opacity: 1;
}

.newsletter-submit {
    border: none;
    background: transparent;
    border-left: var(--line);
    padding: 0 10px;
    cursor: pointer;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    box-sizing: border-box;
}

.newsletter-submit:hover {
    background: #ccc;
}

/* Styling the merged box */
.links-social-box {
    gap: 20px;
    /* Space between links and social */
}

.links-social-box a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.links-social-box a:hover {
    opacity: 0.6;
}

.links-social-box .separator {
    opacity: 0.5;
    font-weight: normal;
}

/* Past/Future Child Pages Layout */
.bento-item.project-sidebar {
    grid-column: span 4;
    grid-row: 2;
    padding: 40px;
    display: block; /* override bento-item flex */
    text-align: left;
    background: var(--bg);
}

.project-header {
    position: sticky;
    top: 40px;
}

.project-header h1 {
    font-size: 2rem;
    margin-top: 0;
    margin-bottom: 1rem;
    text-transform: uppercase;
    font-family: 'Zalando Sans', sans-serif;
}

.project-header p {
    margin: 0.5rem 0;
    font-weight: bold;
    text-transform: uppercase;
}

.bento-item.project-content {
    grid-column: span 8;
    grid-row: 2;
    padding: 40px;
    display: block; /* override bento-item flex */
    background: var(--bg);
}

.bento-item.project-content.info-full-width {
    grid-column: span 12;
}

.project-content .grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.threejs-embed {
    position: relative;
    width: 100%;
    /* Tall enough for scroll-driven / full-viewport WebGL inside the iframe (avoid root-absolute /assets/ confusion). */
    min-height: clamp(360px, 75vh, 1000px);
    margin: 0 0 2rem 0;
    background: #111;
    border-radius: 4px;
    overflow: hidden;
}

.threejs-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* Future work — fullscreen 3D: Apocateca header row only, embed fills the rest; optional layout blocks scroll below */
body.future-work-fullscreen .bento-grid {
    height: auto;
    min-height: 100dvh;
    grid-template-rows: 15vh auto;
    gap: 2px;
    background: #000;
}

body.future-work-fullscreen .copyright-box,
body.future-work-fullscreen .links-social-box,
body.future-work-fullscreen .news-box {
    display: none;
}

body.future-work-fullscreen .future-fullscreen-stage {
    grid-column: 1 / -1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    background: #000;
}

body.future-work-fullscreen .future-fullscreen-embed-wrap {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    height: calc(100dvh - 15vh - 2px);
    min-height: 320px;
    background: #111;
}

body.future-work-fullscreen .future-fullscreen-iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

body.future-work-fullscreen .future-fullscreen-details {
    flex: 0 0 auto;
    width: 100%;
    box-sizing: border-box;
    padding: 2rem 2.5rem 4rem;
    background: var(--bg);
}

body.future-work-fullscreen .future-fullscreen-details .grid {
    margin-bottom: 0;
}

body.future-work-fullscreen .nav-overlay {
    top: calc(15vh + 2px);
    left: 0;
    width: 100vw;
    height: calc(100dvh - 15vh - 2px);
}

/* Past & Future Pages Grid Adjustments */
html:has(body.past), html:has(body.future), html:has(body.past-work), html:has(body.future-work), html:has(body.future-work-fullscreen), html:has(body.info),
body.past, body.future, body.past-work, body.future-work, body.future-work-fullscreen, body.info {
    overflow-y: auto;
    overflow-x: hidden;
}

body:not(.past):not(.future):not(.past-work):not(.future-work):not(.future-work-fullscreen):not(.info),
html:not(:has(body.past)):not(:has(body.future)):not(:has(body.past-work)):not(:has(body.future-work)):not(:has(body.future-work-fullscreen)):not(:has(body.info)) {
    overflow: hidden;
}

body.past .bento-grid, body.future .bento-grid {
    height: auto;
    min-height: 100vh;
    grid-template-rows: 15vh 75vh auto 10vh;
    gap: 2px;
    background: #000;
}

body.past-work .bento-grid, body.future-work .bento-grid {
    height: auto;
    min-height: 100vh;
    grid-template-rows: 15vh minmax(75vh, auto) auto 10vh;
    gap: 2px;
    background: #000;
}

body.info .bento-grid {
    height: auto;
    min-height: 100vh;
    grid-template-rows: 15vh minmax(75vh, auto) 10vh;
    gap: 2px;
    background: #000;
}

body.past .copyright-box, body.past .links-social-box, body.past .news-box,
body.future .copyright-box, body.future .links-social-box, body.future .news-box,
body.past-work .copyright-box, body.past-work .links-social-box, body.past-work .news-box,
body.future-work .copyright-box, body.future-work .links-social-box, body.future-work .news-box {
    grid-row: 4;
}

body.info .copyright-box, body.info .links-social-box, body.info .news-box {
    grid-row: 3;
}

.events-grid-container {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    padding: 4rem 2rem;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.events-grid-container.single-item-grid {
    display: none;
}

.events-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4rem 2rem;
    width: 100%;
    max-width: 1400px;
    justify-content: space-evenly;
}

.event-grid-item {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    gap: 1rem;
    transition: opacity 0.2s;
}

.event-grid-item:hover {
    opacity: 0.7;
}

.event-image {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
    object-fit: cover;
    background-size: cover;
    background-position: center;
    background-color: #000;
    display: block;
}

.event-title {
    font-size: 1.2rem; /* h3 size based on design */
    margin: 0;
    text-align: center;
    text-transform: uppercase;
    font-family: 'Zalando Sans', sans-serif;
}

/* Mobile Tweak for 3-item footer */
@media (max-width: 800px) {
    .bento-grid {
        grid-template-columns: repeat(4, 1fr);
        /* Use svh to account for mobile browser UI bars */
        grid-template-rows: 10svh 48svh 10svh 10svh 10svh 12svh;
        height: 100svh;
        width: 100svw;
        overflow: hidden;
    }

    /* Row 1: Header (Logo, Title, Menu) */
    .logo-box { 
        grid-column: span 1; 
        grid-row: 1; 
        border-right: var(--line);
    }
    .title-box { 
        grid-column: span 2; 
        grid-row: 1; 
        border-right: var(--line);
    }
    .menu-box { 
        grid-column: span 1; 
        grid-row: 1; 
    }
    
    .title-box h2.header {
        font-size: 1.1rem; /* Scale down title for mobile to fit 50% width */
    }

    .site-logo {
        max-height: 1.1rem; /* Scale down logo to match title */
    }

    .hamburger {
        width: 24px;
        height: 16px;
    }

    /* Row 2: Center 3D on top */
    .center-3d, .center-project {
        grid-column: span 4;
        grid-row: 2;
        min-height: unset;
    }

    /* Row 3: Past and Future split 50/50 */
    .past-box {
        grid-column: span 2;
        grid-row: 3;
        min-height: unset;
        border-right: var(--line);
    }
    .future-box {
        grid-column: span 2;
        grid-row: 3;
        min-height: unset;
    }
    .nav-arrow.prev-arrow {
        grid-column: span 2;
        grid-row: 3;
        min-height: unset;
        border-right: var(--line);
    }
    .nav-arrow.next-arrow {
        grid-column: span 2;
        grid-row: 3;
        min-height: unset;
    }

    h3.h3 {
        font-size: 1rem; /* Scale down past/future text */
    }

    /* Row 4: Footer links stacked vertically */
    .news-box { 
        grid-column: span 4;
        grid-row: 4; 
        padding: 5px 10px; 
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .links-social-box { 
        grid-column: span 4;
        grid-row: 5; 
        padding: 5px; 
        border-top: var(--line);
        font-size: 0.9rem;
    }
    .copyright-box { 
        grid-column: span 4;
        grid-row: 6; 
        padding: 5px; 
        border-top: var(--line);
        font-size: 0.9rem;
    }

    /* Past & Future Pages Mobile Grid Adjustments */
    body.past .bento-grid, body.future .bento-grid {
        height: auto;
        min-height: 100svh;
        grid-template-rows: 10svh 1fr 10svh 10svh 12svh;
        overflow: visible;
        gap: 2px;
    }

    body.past .center-project, body.future .center-project,
    body.past .nav-arrow, body.future .nav-arrow {
        display: none;
    }

    .nav-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height if supported */
        background-color: rgba(0, 0, 0, 0.8);
        z-index: 9999;
    }

    body.past-work .bento-grid, body.future-work .bento-grid {
        height: auto;
        min-height: 100svh;
        grid-template-rows: 10svh auto auto 1fr 10svh 10svh 12svh;
        overflow: visible;
        gap: 2px;
    }

    body.future-work-fullscreen .bento-grid {
        height: auto;
        min-height: 100svh;
        grid-template-rows: 10svh auto;
        overflow: visible;
        gap: 2px;
    }

    body.future-work-fullscreen .future-fullscreen-embed-wrap {
        height: calc(100dvh - 10svh - 2px);
        min-height: 240px;
    }

    body.future-work-fullscreen .nav-overlay {
        top: calc(10svh + 2px);
        height: calc(100dvh - 10svh - 2px);
    }

    body.future-work-fullscreen .future-fullscreen-details {
        padding: 1.25rem 1rem 3rem;
    }

    body.info .bento-grid {
        height: auto;
        min-height: 100svh;
        grid-template-rows: 10svh 1fr 10svh 10svh 12svh;
        overflow: visible;
        gap: 2px;
    }

    /* Child Pages Mobile Adjustments */
    .bento-item.project-sidebar {
        grid-column: span 4;
        grid-row: 2;
        padding: 20px;
        height: auto;
        min-height: max-content;
    }

    .bento-item.project-content {
        grid-column: span 4;
        grid-row: 3;
        padding: 20px;
        height: auto;
        min-height: max-content;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .bento-item.project-content.info-full-width {
        grid-column: span 4;
        grid-row: 2;
    }

    body.past-work .news-box, body.future-work .news-box { grid-row: 5; }
    body.past-work .links-social-box, body.future-work .links-social-box { grid-row: 6; }
    body.past-work .copyright-box, body.future-work .copyright-box { grid-row: 7; }

    body.info .news-box { grid-row: 3; }
    body.info .links-social-box { grid-row: 4; }
    body.info .copyright-box { grid-row: 5; }

    .project-content .grid {
        display: flex;
        flex-direction: column;
        justify-content: center;
        height: 100%;
        gap: 30px; /* slightly more breathing room between sections */
    }

    body.past .events-grid-container, body.future .events-grid-container {
        grid-row: 2;
        padding: 2rem 1rem;
        box-sizing: border-box;
        display: flex !important; /* Force show on mobile even if single item */
    }

    body.past-work .events-grid-container, body.future-work .events-grid-container {
        grid-row: 4;
        padding: 2rem 1rem;
        box-sizing: border-box;
    }

    body.past .events-grid, body.future .events-grid,
    body.past-work .events-grid, body.future-work .events-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    body.past .news-box, body.future .news-box {
        grid-row: 3;
    }
    body.past .links-social-box, body.future .links-social-box {
        grid-row: 4;
    }
    body.past .copyright-box, body.future .copyright-box {
        grid-row: 5;
    }

    .event-image {
        aspect-ratio: auto;
        object-fit: contain;
    }

    .newsletter-form {
        max-width: 100%;
        height: 30px;
    }
    
    .newsletter-input, .newsletter-submit {
        font-size: 0.9rem;
    }

    /* Kirby Mobile Layout Grid */
    .grid {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }
    
    .column {
        width: 100%;
    }
}