/* ==========================================================================
   LAYOUT.CSS — Page Structure, Container, Navigation, Slideshow
   ========================================================================== */

/* Utilities
   ========================================================================== */

[x-cloak] {
    display: none !important;
}

.no-scroll {
    overflow: hidden;
}

/* Visually hidden — accessible to screen readers, not visible */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Page Structure
   ========================================================================== */

.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--container-pad);
}

/* Main content area */
#content {
    margin-top: 100px;
}

/* Narrow column variant — list pages, text detail, contact */
#content.content--narrow {
    max-width: var(--content-max);
}

/* Layout: content alongside a sidebar (CV page) */
.layout-with-aside {
    display: flex;
    gap: var(--padding-xl);
    align-items: flex-start;
}

.layout-with-aside #content {
    flex: 1 1 60%;
    min-width: 0;
    margin-top: 100px;
}

.layout-with-aside #aside {
    flex: 0 1 35%;
    min-width: 0;
    margin-top: 100px;
    padding-top: 40px;
}

#aside p {
    color: #888;
}

/* Layout: works detail — image left, text right */
#content.layout-works-detail {
    display: flex;
    gap: var(--padding-xl);
    align-items: flex-start;
    max-width: none;
}

#content.layout-works-detail .stills {
    flex: 0 0 55%;
    min-width: 0;
}

#content.layout-works-detail .work-info {
    flex: 1;
    min-width: 0;
}

/* Mobile layout adjustments */
@media (max-width: 768px) {
    /* Content starts below the fixed menu bar */
    #content {
        margin-top: calc(var(--menu-bar-height) + var(--menu-bar-height));
    }

    #content.content--narrow {
        max-width: none;
    }

    .layout-with-aside {
        flex-direction: column;
    }

    .layout-with-aside #content,
    .layout-with-aside #aside {
        flex: none;
        width: 100%;
        margin-top: 0;
    }

    .layout-with-aside #content {
        margin-top: calc(var(--menu-bar-height) + var(--padding-xl));
    }

    .layout-with-aside #aside {
        padding-top: var(--padding-lg);
    }

    #content.layout-works-detail {
        flex-direction: column;
    }

    /* Without this, align-items: flex-start causes .stills to shrink-wrap
       to its text content width in column direction, making the video embed tiny */
    #content.layout-works-detail .stills {
        width: 100%;
    }
}

/* Footer & Desktop Navigation
   ========================================================================== */

#footer {
    margin: 50px 0 100px;
    position: relative;
}

/* Desktop: sticky nav + scrollable content
   ========================================================================== */

@media (min-width: 769px) {
    /* Cap content height, enable inner scroll, fade bottom edge */
    #content {
        overflow-y: auto;
        max-height: 600px;
        mask-image: linear-gradient(to bottom, black calc(100% - 60px), transparent 100%);
    }

    /* Remove fade on pages where content doesn't overflow (e.g. homepage slideshow) */
    #content.no-fade {
        mask-image: none;
    }

    /* Works-detail is a flex row with images — let it scroll naturally instead */
    #content.layout-works-detail {
        overflow-y: visible;
        max-height: none;
    }

    /* Sticky nav bar — stays at viewport bottom when page is tall enough to scroll */
    #footer {
        position: sticky;
        bottom: 0;
        background: var(--ground);
        margin: 30px 0 0;
        padding-bottom: 20px;
        z-index: 10;
    }
}

#footer nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#nav {
    display: flex;
    flex-wrap: wrap;
    font-size: var(--fs-large);
    margin-left: -0.6rem; /* compensate for li padding so first item aligns left */
}

#nav li a {
    color: var(--accent);
    display: inline-block;
    padding: 0.6em;
    text-decoration: none;
}

#nav li a:hover,
#nav li.current a {
    color: var(--figure);
    text-decoration: none;
}

.site-name {
    font-size: var(--fs-large);
    font-weight: var(--fw-normal);
}

/* Mobile Navigation
   ========================================================================== */

/* Hide desktop footer nav on mobile */
@media (max-width: 768px) {
    #footer {
        display: none;
    }
}

/* Mobile menu toggle button */
.menu-toggle {
    display: none; /* hidden on desktop */
}

@media (max-width: 768px) {
    /* Full-width bar fixed at the top of the viewport */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: var(--menu-bar-height);
        background: var(--ground);
        border-bottom: 1px dashed var(--accent);
        padding: 0 var(--container-pad);
        z-index: 60;
        cursor: pointer;
        /* reset button styles */
        border-left: none;
        border-right: none;
        border-top: none;
        /* typography */
        color: var(--accent);
        font-family: inherit;
        font-size: 1.4rem;
        font-style: italic;
        font-weight: var(--fw-bold);
        text-transform: lowercase;
    }

    .menu-toggle:hover {
        color: var(--figure);
    }
}

/* Mobile nav overlay — full viewport */
.nav-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: var(--ground);
    display: flex;
    flex-direction: column;
    padding: var(--padding-xl);
    padding-top: 4rem;
    overflow-y: auto;
}

.nav-overlay__close {
    position: fixed;
    top: 20px;
    right: var(--container-pad);
    background: none;
    border: none;
    color: var(--accent);
    font-family: inherit;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.nav-overlay__close:hover {
    color: var(--figure);
}

.nav-overlay__list {
    display: flex;
    flex-direction: column;
    gap: var(--padding-lg);
}

.nav-overlay__list li a {
    font-size: var(--fs-large);
    color: var(--accent);
    font-style: italic;
    text-decoration: none;
}

.nav-overlay__list li a:hover,
.nav-overlay__list li.current a {
    color: var(--figure);
}

.nav-overlay__name {
    margin-top: var(--padding-xl);
    font-size: 1rem;
}

/* Slideshow
   ========================================================================== */

/* CSS Grid stacks all slides in the same cell — enables crossfade at all
   breakpoints without needing a fixed container height on mobile. */

#slideshow {
    display: grid;
}

/* All slides occupy the same grid cell, stacked on top of each other */
.slide {
    grid-area: 1 / 1;
    display: flex;
    gap: var(--padding-lg);
    background: var(--ground);
    opacity: 0;
    transition: opacity 0.5s ease;
}

.slide.active {
    opacity: 1;
    z-index: 2;
}

/* Outgoing slide stays visible during the crossfade transition */
.slide.slide-prev {
    opacity: 1;
    z-index: 1;
}

.slide img {
    flex: 0 0 70%;
    width: 70%;
    object-fit: cover;
}

.slide .caption {
    flex: 1;
    font-size: 1rem;
    min-width: 0;
}

/* Caption vertical-alignment variants */
.caption.topright {
    align-self: flex-start;
    text-align: right;
}

.caption.midright {
    align-self: center;
    text-align: right;
}

.caption.botright {
    align-self: flex-end;
    text-align: right;
}

.caption.topleft {
    align-self: flex-start;
    text-align: left;
}

.caption.midleft {
    align-self: center;
    text-align: left;
}

.caption.botleft {
    align-self: flex-end;
    text-align: left;
}

/* Desktop: constrain image/slideshow height */
@media (min-width: 769px) {
    .slide img {
        max-height: 380px;
    }
}

/* Mobile: stack image and caption vertically */
@media (max-width: 768px) {
    .slide {
        flex-direction: column;
    }

    .slide img {
        flex: none;
        width: 100%;
    }

    .slide .caption {
        text-align: left !important;
        align-self: auto !important;
    }
}
