/* --- LAYOUT.CSS — Page Structure & Responsive Layout --- */


/* --- 1. CONFIGURATION --- */

:root {
    --section-exit-duration: 0.10s;
    --section-enter-duration: 0.16s;
}


/* --- 2. GLOBAL BACKGROUND LAYER --- */

body {
    /* Mobile default: no top padding (header is transparent blur), bottom space for mobile nav */
    padding-top: 0;
    padding-bottom: 80px;
    position: relative;
    background-image: none;
}

/* Desktop: constant body padding to clear the expanded header.
   The header shrinks visually on scroll but body padding stays put —
   no double-speed scrolling artifact. */
@media (min-width: 651px) {
    body {
        padding-top: 160px;
        padding-bottom: 0;
    }
}


/* --- 3. HEADER — Mobile-First --- */

.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;

    /* Mobile: opaque solid bar, natural height only */
    background: var(--color-header-bg);
    border-bottom: 1px dashed var(--color-border);
    box-shadow: none;
    transition: transform 0.3s ease,
                background var(--transition-theme),
                border-color var(--transition-theme);
}

/* Mobile smart collapse: JS toggles .nav-hidden — bar slides away when
   scrolling down, returns on any scroll up */
@media (max-width: 650px) {
    .main-header.nav-hidden {
        transform: translateY(-100%);
    }
}

/* --- Solid overlay layer (desktop scroll collapse) --- */
.main-header::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: light-dark(#faf6f3, #1c1a18);
    opacity: 0;
    z-index: -1;
    pointer-events: none;
    transition: opacity 0.4s ease, background-color var(--transition-theme);
}


/* --- Desktop: Progressive header collapse driven by --header-progress ---
   0 = fully expanded (at scroll top)
   1 = fully collapsed (scrolled past COLLAPSE_DISTANCE)
   
   JS sets --header-progress on .main-header via scroll handler.
   All visual properties interpolate based on this single value.        */

@media (min-width: 651px) {
    .main-header {
        z-index: 1000;
        background-color: transparent;
        border-bottom: 1px dashed transparent;
        transition: border-color var(--transition-theme), box-shadow 0.3s ease;
    }

    /* Solid background layer — fades in progressively with scroll. */
    .main-header::after {
        z-index: -1;
        height: 100%;
        opacity: var(--header-progress, 0);
        transition: background-color var(--transition-theme), box-shadow var(--transition-theme);
    }

    /* Fully collapsed: border snaps in */
    .main-header.shrunk {
        border-bottom-color: var(--color-border);
    }
}


/* --- 4. SITE TITLE / LOGO --- */

#site-title-wrapper {
    padding: var(--space-xs) 0;
    max-height: 80px;
    overflow: hidden;
    /* No CSS transition — driven by --header-progress on desktop */
    transition: none;
}

#site-title-img {
    height: 40px;
    margin: 0;
    cursor: pointer;
    opacity: 1;
    display: block;
    position: relative;
    left: 1px;
    transition: none;
}

/* Mobile: logo ALWAYS stays visible */

/* Desktop: logo shrinks/fades with scroll progress */
@media (min-width: 651px) {
    #site-title-wrapper {
        padding: 0;
        /* max-height interpolates from 80px → 0 */
        max-height: calc(80px * (1 - var(--header-progress, 0)));
        /* Soft dissolve at the bottom edge instead of a hard clip.
           The mask fades the last 20px to transparent. */
        -webkit-mask-image: linear-gradient(
            to bottom,
            black 0%,
            black calc(100% - 20px),
            transparent 100%
        );
        mask-image: linear-gradient(
            to bottom,
            black 0%,
            black calc(100% - 20px),
            transparent 100%
        );
    }
    #site-title-img {
        height: 55px;
        margin: var(--space-lg) 0 0 0;
        /* Fade and slide up with progress */
        opacity: calc(1 - var(--header-progress, 0));
        margin-top: calc(var(--space-lg) - 20px * var(--header-progress, 0));
        pointer-events: auto;
    }
    /* When fully collapsed, disable pointer events on the hidden logo */
    .main-header.shrunk #site-title-img {
        pointer-events: none;
    }
}


/* --- 5. NAVIGATION --- */

/* --- Desktop nav (hidden on mobile) --- */
.main-header > nav {
    display: none;
}

@media (min-width: 651px) {
    .main-header > nav {
        display: flex;
        margin: var(--space-xs) 0 var(--space-2xs) 0;
        gap: var(--space-xl);
        justify-content: center;
        align-items: center;
        position: relative;
    }
}

/* --- Nav Buttons (desktop only — scoped so .mobile-nav, also a <nav>,
   doesn't inherit the pill styling it would just have to undo) --- */
.main-header nav button {
    font-size: var(--text-base);
    font-weight: 500;
    border: 1px solid transparent;
    padding: 0.4rem 1.2rem;
    border-radius: var(--radius-full);
    position: relative;
}

.main-header nav button:hover {
    color: var(--color-accent);
    background-color: transparent;
    transform: translateY(-2px);
    text-decoration: none;
}

.main-header nav button.active {
    background-color: transparent;
    color: var(--color-text-primary);
    font-weight: 500;
    text-decoration: none;
    box-shadow: none;
    transform: translateY(0);
}

/* Prompt motif on active nav — dossier through-line. */
.main-header nav button::before {
    content: '>';
    position: absolute;
    left: 0.4rem;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-accent);
    font-size: 0.85em;
    opacity: 0;
    transform: translateX(-5px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.main-header nav button.active::before {
    opacity: 1;
    transform: translateX(0);
}



/* --- Mobile Bottom Nav --- */
.mobile-nav {
    display: flex;
    position: fixed;
    bottom: -1px;
    left: 0;
    width: 100%;
    background: var(--color-header-bg);
    z-index: 1100;
    padding: 5px 0;
    transition: background var(--transition-theme), box-shadow var(--transition-theme);
}



.mobile-nav button {
    flex-grow: 1;
    padding: 8px 5px;
    border-radius: 0;
    margin: 0;
    position: relative;
    z-index: 1;
    transition: transform 0.1s ease-out;
}

.mobile-nav button.active {
    color: var(--color-text-primary);
    text-decoration: none;
}

/* Mobile click squish effect removed */

.mobile-nav .mobile-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.mobile-nav .mobile-content .svg-icon { font-size: 1.4rem; }
.mobile-nav .mobile-content .caption {
    font-size: 0.7rem;
    font-family: var(--font-primary);
    font-weight: 700;
}

/* Desktop: hide mobile nav */
@media (min-width: 651px) {
    .mobile-nav { display: none; }
}


/* --- 6. SECTIONS — data-state Transition System --- */

.section {
    opacity: 0;
    transform: scale(0.98);
    filter: blur(4px);
    transition: opacity var(--section-enter-duration) cubic-bezier(0, 0, 0.2, 1),
                transform var(--section-enter-duration) cubic-bezier(0, 0, 0.2, 1),
                filter var(--section-enter-duration) cubic-bezier(0, 0, 0.2, 1);
}

/* Inactive: removed from layout */
.section[data-state="inactive"] {
    display: none;
}

/* Entering: in layout but transparent (waiting for next rAF to go active) */
.section[data-state="entering"] {
    display: block;
    opacity: 0;
    transform: scale(0.98);
    filter: blur(4px);
}

/* Active: fully visible */
.section[data-state="active"] {
    display: block;
    opacity: 1;
    transform: scale(1);
    filter: blur(0);
}

/* Exiting: sharp cut-out — faster than entrance, hard ease-in */
.section[data-state="exiting"] {
    display: block;
    opacity: 0;
    transform: scale(0.98);
    filter: blur(4px);
    transition: opacity var(--section-exit-duration) cubic-bezier(0.4, 0, 1, 1),
                transform var(--section-exit-duration) cubic-bezier(0.4, 0, 1, 1),
                filter var(--section-exit-duration) cubic-bezier(0.4, 0, 1, 1);
}

.section-content {
    padding: 90px var(--space-md) var(--space-xl);
}

@media (min-width: 651px) {
    .section-content {
        padding: 80px var(--space-xl) var(--space-xl);
    }
}

/* --- Staggered entrance animations (unified for ALL sections) ---
   Snappy, terminal-style: content pops in fast with tight stagger,
   like lines being printed to a console.                            

   Uses snapUp (8px) instead of fadeInUp (20px) — less float, more snap. */

@keyframes snapUp {
    from { opacity: 0; transform: translateY(8px); filter: blur(4px); }
    to   { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.section[data-state="active"] .anim-group,
.section[data-state="active"] .project-detail-layout,
.section[data-state="active"] .about-container {
    opacity: 0;
    animation: snapUp 0.35s cubic-bezier(0, 0, 0.2, 1) forwards;
}
.section[data-state="active"] .anim-group:nth-of-type(2) { animation-delay: 0.06s; }
.section[data-state="active"] .anim-group:nth-of-type(3) { animation-delay: 0.12s; }
.section[data-state="active"] .anim-group:nth-of-type(4) { animation-delay: 0.18s; }
.section[data-state="active"] .anim-group:nth-of-type(5) { animation-delay: 0.24s; }

/* --- About blocks: same snap-in, slightly offset within the container --- */
.section[data-state="active"] .about-block {
    opacity: 0;
    animation: snapUp 0.3s cubic-bezier(0, 0, 0.2, 1) forwards;
}
.section[data-state="active"] .about-block:nth-of-type(1) { animation-delay: 0.08s; }
.section[data-state="active"] .about-block:nth-of-type(2) { animation-delay: 0.14s; }
.section[data-state="active"] .about-block:nth-of-type(3) { animation-delay: 0.20s; }
.section[data-state="active"] .about-block:nth-of-type(4) { animation-delay: 0.26s; }


/* --- 7. FOOTER --- */

.footer {
    max-width: 500px;
    margin: var(--space-3xl) auto;
    padding: var(--space-xl) var(--space-md);
    display: flex;
    justify-content: center;
    align-items: center;
}

.footer-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    width: 100%;
}

#signature {
    justify-self: end;
    margin-right: 20px;
    cursor: pointer;
    max-width: 110px;
    transition: var(--transition-tech);
}

.footer-divider {
    color: light-dark(#8A8176, #E6E1D5);
    font-size: 0.8rem;
    display: inline-block;
}

.footer-social-links {
    justify-self: start;
    margin-left: 20px;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.footer-icon {
    height: 30px;
    width: auto;
    display: block;
    transition: var(--transition-tech);
}

/* Desktop: wider footer */
@media (min-width: 651px) {
    .footer { padding: var(--space-xl); }
    #signature { max-width: 130px; margin-right: 19px; }
    .footer-social-links { margin-left: 30px; gap: var(--space-xs); }
}

/* Tiny screens: tighter footer */
@media (max-width: 480px) {
    #signature { max-width: 100px; margin-right: 15px; }
    .footer-social-links { margin-left: 15px; gap: 0.6rem; }
    .footer-icon { height: 28px; }
}


/* --- 8. LIGHTBOX --- */

/* --- Keyframes --- */
@keyframes fadeOutForward  { from { opacity: 1; transform: translateX(0); }   to { opacity: 0; transform: translateX(-15px); } }
@keyframes fadeInForward   { from { opacity: 0; transform: translateX(15px); } to { opacity: 1; transform: translateX(0); } }
@keyframes fadeOutBackward { from { opacity: 1; transform: translateX(0); }   to { opacity: 0; transform: translateX(15px); } }
@keyframes fadeInBackward  { from { opacity: 0; transform: translateX(-15px); } to { opacity: 1; transform: translateX(0); } }

/* --- Lightbox Container --- */
.lightbox {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.no-scroll { overflow: hidden; }

/* --- Expanded Image --- */
.lightbox__image {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    box-shadow: 0 10px 30px -5px var(--color-shadow);
    opacity: 0;
    transform: scale(0.95);
    transition:
        opacity 0.35s cubic-bezier(0, 0, 0.2, 1),
        transform 0.35s cubic-bezier(0, 0, 0.2, 1);
}
.lightbox__image.active {
    opacity: 1;
    transform: scale(1);
}

/* --- Directional animations (shared by image + title) --- */
.lightbox__image.fade-out-forward,
.lightbox__title.fade-out-forward  { animation: fadeOutForward  0.25s cubic-bezier(0.5, 0, 0.75, 0) forwards; }
.lightbox__image.fade-in-forward,
.lightbox__title.fade-in-forward   { animation: fadeInForward   0.35s cubic-bezier(0, 0, 0.2, 1) forwards; }
.lightbox__image.fade-out-backward,
.lightbox__title.fade-out-backward { animation: fadeOutBackward 0.25s cubic-bezier(0.5, 0, 0.75, 0) forwards; }
.lightbox__image.fade-in-backward,
.lightbox__title.fade-in-backward  { animation: fadeInBackward  0.35s cubic-bezier(0, 0, 0.2, 1) forwards; }


/* --- Lightbox Title --- */
.lightbox__title {
    max-width: 90%;
    margin-top: 1.2rem;

    font-family: var(--font-secondary);
    font-weight: 400;
    font-size: var(--text-base);
    letter-spacing: 0.05em;

    /* Always light text on dark backdrop — raw value, not theme variable */
    color: rgba(230, 224, 212, 0.7);

    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease 0.1s;
}
.lightbox.active .lightbox__title {
    opacity: 1;
}


/* --- Lightbox Controls --- */
.lightbox__arrow,
.lightbox__close {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-circle);
    font-size: 1.5rem;
    color: var(--dark-text-primary);
    opacity: 0.8;
}
.lightbox__arrow:hover,
.lightbox__close:hover {
    color: var(--dark-accent);
    transform: scale(1.1);
}
.lightbox__arrow:active,
.lightbox__close:active {
    transform: scale(0.98);
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
}
.lightbox__arrow img,
.lightbox__close img {
    width: 32px;
    height: 32px;
}

.lightbox__arrow {
    position: absolute;
    top: 50%;
    margin-top: -28px;
    z-index: 2001;

    /* Mobile: hide arrows (swipe instead) */
    display: none;
}
.lightbox__arrow.left  { left: 20px; }
.lightbox__arrow.right { right: 20px; }

.lightbox__close {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 2002;
}

/* Desktop: show arrows, adjust close position */
@media (min-width: 651px) {
    .lightbox__arrow { display: flex; }
    .lightbox__close { top: 20px; right: 20px; }
}


/* --- 9. TABLET BREAKPOINT --- */

@media (max-width: 900px) {
    .project-detail-layout { flex-direction: column; }
    .project-media-container iframe { height: 400px; }
}