/* project page styles on top of team.css: section sidebar, text, and images with glass captions */

/* ── 1. background (same as .team-page-body) ── */
.project-page-body {
    background: linear-gradient(120deg, #F4F2FC, #E8F0E4, #F2EBE1, #E4EBE6);
    min-height: 100vh;
    /* clip, not hidden: a scrolling body would unstick the sidebar */
    overflow-x: clip;
    width: 100%;
}

.project-page-wrapper {
    background-color: transparent;
    border-radius: 0;
    margin: 0 auto;
    max-width: none;
    box-shadow: none;
}

/* ── 2. layout: sidebar + main, capped and centred on very wide screens ── */
.project-layout {
    display: flex;
    align-items: flex-start;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

.project-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: calc(var(--nav-h) + 2rem);
    padding: 1.2rem 0 1.2rem 2rem;
}

.project-main {
    flex: 1;
    min-width: 0;
    padding: 1.2rem 2rem 5rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 3.5rem;
}

/* ── 3. Intro block ── */
.project-intro {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding-bottom: 1.4rem;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    max-width: 760px;
    margin: 0 auto;
}

.project-intro-eyebrow {
    font-family: 'Quicksand', sans-serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0;
}

.project-intro-title {
    font-family: 'Quicksand', sans-serif;
    font-size: clamp(1.8rem, calc(4.5vw * var(--fs-scale, 1)), 3.2rem);
    font-weight: 600;
    color: #1A1A1A;
    letter-spacing: -1px;
    line-height: 1.15;
    margin: 0;
}

.project-intro-text {
    font-family: 'Quicksand', sans-serif;
    font-size: 0.98rem;
    color: var(--text-body);
    line-height: 1.8;
    margin: 0.4rem 0 0 0;
    max-width: 620px;
}

/* ── 4. sections: one section = one block ── */
.project-section {
    display: flex;
    flex-direction: column;
    gap: 1.4rem;
    scroll-margin-top: calc(var(--nav-h) + 1.5rem);
}

.project-section-head {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    max-width: 720px;
    margin: 0 auto;
}

.project-section-index {
    font-family: 'Quicksand', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.project-section-title {
    font-family: 'Quicksand', sans-serif;
    font-size: clamp(1.5rem, calc(3vw * var(--fs-scale, 1)), 2.2rem);
    font-weight: 600;
    color: #1A1A1A;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin: 0;
}

/* text content - fixed, readable width */
.project-text {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 720px;
    margin: 0 auto;
}

.project-text p {
    font-family: 'Quicksand', sans-serif;
    font-size: 0.98rem;
    line-height: 1.85;
    color: rgba(0,0,0,0.58);
    margin: 0;
}

.project-text p strong {
    color: #1A1A1A;
    font-weight: 600;
}

/* ── 5. images: <figure class="project-figure"> + <figcaption class="glass-caption">; alt describes the image, caption adds context ── */
.project-figure {
    position: relative;
    width: 100%;
    max-width: 720px; /* never wider than the text */
    margin: 0 auto; /* centred on the page */
    border-radius: 32px;
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(0,0,0,0.06);
    background-color: #e4ebe6; /* fallback while loading / if the image is missing */
    aspect-ratio: 16 / 9; /* keeps the shape even if the <img> is hidden */
    max-height: 70vh; /* on big wide screens, do not swamp the page */
}

.project-figure img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ratio modifiers; --tall and --square capped by max-width */
.project-figure--tall   { aspect-ratio: 3 / 4;  max-width: 480px; max-height: 75vh; }
.project-figure--banner { aspect-ratio: 21 / 9; max-height: 55vh; }
.project-figure--square { aspect-ratio: 1 / 1;  max-width: 560px; }

/* natural: nothing cropped (gels, plates); caption sits under the image */
.project-figure--natural { aspect-ratio: auto; max-height: none; margin-bottom: 2rem; overflow: visible; background: transparent; box-shadow: none; border-radius: 0; }
.project-figure--natural img { width: auto; max-width: 100%; height: auto; max-height: 32rem; object-fit: contain; margin-inline: auto; border-radius: 24px; box-shadow: 0 12px 35px rgba(0,0,0,0.06); }

/* the glass caption - same recipe as .glass-name-pill */
.glass-caption {
    position: absolute;
    left: 14px;
    right: 14px;
    bottom: 14px;
    box-sizing: border-box;
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 22px;
    padding: 12px 20px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
    font-family: 'Quicksand', sans-serif;
    font-size: 0.85rem;
    line-height: 1.55;
    color: rgba(0, 0, 0, 0.68);
    max-width: 90%;
    transition: background 0.4s ease, box-shadow 0.5s ease;
}

/* ── placeholder pattern + icon when an image is missing ── */
.project-figure.img-missing {
    background:
        repeating-linear-gradient(
            135deg,
            rgba(255,255,255,0.5) 0px,
            rgba(255,255,255,0.5) 1px,
            transparent 1px,
            transparent 16px
        ),
        linear-gradient(135deg, #E8F0E4 0%, #D9E2D4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-figure.img-missing::after {
    content: '';
    width: 15%;
    aspect-ratio: 1 / 1;
    max-width: 64px;
    min-width: 32px;
    background-color: rgba(49, 64, 49, 0.22);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='9' cy='9' r='1.6' fill='%23000'/%3E%3Cpath d='M21 15l-5-5-9 9'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='2'/%3E%3Ccircle cx='9' cy='9' r='1.6' fill='%23000'/%3E%3Cpath d='M21 15l-5-5-9 9'/%3E%3C/svg%3E") center / contain no-repeat;
}

.glass-caption strong { color: #1A1A1A; font-weight: 600; }

/* hover lift - same logic as .team-member-clean:hover .glass-name-pill */
.project-figure:hover .glass-caption {
    background: rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.16), 0 0 28px rgba(255, 255, 255, 0.22);
}

/* captions appear statically */

/* ── 6a) gallery (renderer's gallery block): stacked slides + prev/next that morph circle ⇄ bar ⇄ two circles ── */
.project-gallery {
    --btn-size: 44px;
    --nav-gap: 10px;
    --nav-inset: 14px;
    position: relative; width: 100%; max-width: 720px; margin: 0 auto;
}

.gallery-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 60vh;
    border-radius: 32px;
    overflow: hidden;
    background-color: #e4ebe6;
    box-shadow: 0 12px 35px rgba(0,0,0,0.06);
}

/* ── slides: is-active / is-next-1 / is-next-2 / is-hidden, crossfade in place ── */
.gallery-viewport > .project-figure {
    position: absolute;
    width: 100%;
    height: 100%;
    max-width: none;
    aspect-ratio: auto;
    max-height: none;
    margin: 0;
    border-radius: 24px;
    box-shadow: none;
    /* opacity + scale ≥ 1 only, so no edge is uncovered */
    transition: opacity 0.9s cubic-bezier(0.33, 0, 0.25, 1),
                transform 1.05s cubic-bezier(0.22, 0.61, 0.36, 1),
                filter 1.15s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.gallery-viewport > .project-figure.is-active {
    inset: 0;
    z-index: 4;
    opacity: 1;
    transform: scale(1);
    filter: brightness(1) blur(0px);
    pointer-events: auto;
}
.gallery-viewport > .project-figure.is-next-1 {
    inset: 0;
    z-index: 3;
    opacity: 0;
    transform: scale(1.015);
    filter: brightness(0.92) blur(3px);
    pointer-events: none;
}
.gallery-viewport > .project-figure.is-next-2 {
    inset: 0;
    z-index: 2;
    opacity: 0;
    transform: scale(1.015);
    filter: brightness(0.92) blur(3px);
    pointer-events: none;
}
.gallery-viewport > .project-figure.is-hidden {
    inset: 0;
    z-index: 1;
    opacity: 0;
    transform: scale(1.015);
    filter: brightness(0.92) blur(3px);
    pointer-events: none;
}

/* captions: their own quick translate + blur morph; room left for the buttons */
.gallery-viewport .glass-caption {
    right: 124px;
    transform: translateY(5px);
    filter: blur(4px);
    opacity: 0;
    transition: opacity 0.6s cubic-bezier(0.22, 0.61, 0.36, 1),
                transform 0.65s cubic-bezier(0.22, 0.61, 0.36, 1),
                filter 0.6s cubic-bezier(0.22, 0.61, 0.36, 1),
                background 0.4s ease, box-shadow 0.5s ease;
    animation: none; /* no pill-enter needed here */
}
.gallery-viewport > .project-figure.is-active .glass-caption {
    transform: translateY(0);
    filter: blur(0);
    opacity: 1;
}

/* Small "2 / 3" counter, top-right */
.gallery-counter {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 5;
    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 14px;
    padding: 5px 12px;
    font-family: 'Quicksand', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(0,0,0,0.55);
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.4s ease 0.18s, transform 0.4s ease 0.18s;
}
.project-gallery.in-view .gallery-counter { opacity: 1; transform: translateY(0); }

/* ── prev/next: continuous shape morph; border:none avoids a seam where they touch ── */
.gallery-nav {
    position: absolute;
    bottom: var(--nav-inset);
    right: var(--nav-inset);
    z-index: 5;
    width: calc(var(--btn-size) * 2 + var(--nav-gap));
    height: var(--btn-size);
}
.gallery-btn {
    position: absolute;
    top: 0;
    left: calc((100% - var(--btn-size)) / 2); /* 0%: centred, overlapping */
    width: var(--btn-size);
    height: var(--btn-size);
    border: none;
    border-radius: 22px; /* a circle when width=height */
    /* flat white 0.80, no backdrop-filter (matches the SVG track); no border */
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.68);
    cursor: pointer;
    padding: 0;
    z-index: 2;
    transition: background 0.3s ease, box-shadow 0.4s ease, transform 0.15s ease;
}
.gallery-btn > svg {
    width: 16px;
    height: 16px;
    opacity: 0;
}

/* prev widens left, next right, meeting as one bar at 45%; easeOutExpo per phase */
@keyframes nav-morph-prev {
    0%   { width: var(--btn-size); left: calc((100% - var(--btn-size)) / 2); border-radius: 22px;
           animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
    45%  { width: 50%; left: 0; border-radius: 22px 0 0 22px;
           animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
    100% { width: var(--btn-size); left: 0; border-radius: 22px; }
}
@keyframes nav-morph-next {
    0%   { width: var(--btn-size); left: calc((100% - var(--btn-size)) / 2); border-radius: 22px;
           animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
    45%  { width: 50%; left: 50%; border-radius: 0 22px 22px 0;
           animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
    100% { width: var(--btn-size); left: calc(100% - var(--btn-size)); border-radius: 22px; }
}
/* icons fade in from 10% to ~70% */
@keyframes nav-icon-fade {
    0%, 10% { opacity: 0; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); }
    70%, 100% { opacity: 1; }
}

.project-gallery.in-view .gallery-btn.gallery-prev {
    animation: nav-morph-prev 1.15s linear forwards;
}
.project-gallery.in-view .gallery-btn.gallery-next {
    animation: nav-morph-next 1.15s linear forwards;
}
.project-gallery.in-view .gallery-btn > svg {
    animation: nav-icon-fade 1.15s linear forwards;
}
.gallery-btn:hover {
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.18);
}
.gallery-btn:active { transform: scale(0.88); transition-duration: 0.15s; }

@media (min-width: 700px) {
    .gallery-viewport { aspect-ratio: 16 / 7; }
}

/* ── 6b) stack: up to 3 overlapping photos, spring-in on .in-view; hover brings one forward ── */
.project-stack {
    position: relative;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 5 / 4;
    margin: 1.5rem auto;
}

.project-stack .project-figure {
    position: absolute;
    width: 76%;
    height: 70%;
    max-width: none;
    aspect-ratio: auto;
    max-height: none;
    opacity: 0;
    transform: translateY(28px) scale(0.85);
    transition: opacity 0.5s ease,
                transform 0.6s cubic-bezier(0.34,1.56,0.64,1),
                box-shadow 0.4s ease;
}

.project-stack .project-figure:nth-child(1) { top: 0;   left: 0;   z-index: 1; }
.project-stack .project-figure:nth-child(2) { top: 14%; left: 22%; z-index: 2; }
.project-stack .project-figure:nth-child(3) { top: 28%; left: 6%;  z-index: 3; }

.project-stack.in-view .project-figure:nth-child(1) { opacity: 1; transform: rotate(-5deg); transition-delay: 0s; }
.project-stack.in-view .project-figure:nth-child(2) { opacity: 1; transform: rotate(4deg);  transition-delay: 0.12s; }
.project-stack.in-view .project-figure:nth-child(3) { opacity: 1; transform: rotate(-2deg); transition-delay: 0.24s; }

.project-stack .project-figure:hover {
    transform: rotate(0deg) scale(1.04);
    box-shadow: 0 18px 45px rgba(0,0,0,0.16);
    z-index: 10;
    transition-delay: 0s;
}

/* ── 7. Responsive ── */
@media (max-width: 900px) {
    .project-sidebar {
        width: 100%;
        position: relative;
        top: 0;
        padding: 1.5rem 1.5rem 0 1.5rem;
    }
    .sidebar-nav { padding-top: 0.5rem; }
    .project-main { padding: 2rem 1.5rem 5rem 1.5rem; gap: 2.75rem; }
    .project-layout { flex-direction: column; }
}

@media (max-width: 600px) {
    .project-intro-title { letter-spacing: -1px; }
    .project-section-head { flex-direction: column; gap: 0.25rem; }
    .project-figure { border-radius: 22px; }
    .gallery-viewport { border-radius: 22px; max-height: 46vh; }
    .project-gallery { --btn-size: 38px; --nav-gap: 8px; }
    .gallery-btn > svg { width: 14px; height: 14px; }
    .gallery-counter { font-size: 0.7rem; padding: 4px 10px; }
    .gallery-viewport .glass-caption { right: 100px; }
    .project-stack { max-width: 320px; }
    .glass-caption {
        left: 10px; right: 10px; bottom: 10px;
        padding: 10px 16px;
        font-size: 0.8rem;
        max-width: none;
    }
}
/* ── References section ──────────────────────────────────────── */
.project-references { margin-top: 1rem; }

.project-ref-list {
    list-style: none;
    max-width: 720px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0;
    counter-reset: none;
    border-top: 1px solid rgba(0,0,0,0.07);
    padding-top: 0.5rem;
}

.project-ref-item {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 0.5rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    scroll-margin-top: calc(var(--nav-h) + 2rem);
    transition: background 0.2s ease;
}
.project-ref-item:last-child { border-bottom: none; }
.project-ref-item:target {
    background: rgba(58, 75, 58, 0.06);
    border-radius: 6px;
    padding-left: 0.6rem;
    margin-left: -0.6rem;
}

.ref-num {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-top: 0.15rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.ref-body {
    font-size: 0.84rem;
    line-height: 1.65;
    color: var(--text-body);
}

.ref-authors {
    font-weight: 500;
    color: var(--ink);
}

.ref-title {
    color: var(--text-muted);
}

.ref-source {
    font-style: italic;
    color: var(--tertiary-dark);
}

.ref-doi {
    display: inline-block;
    font-size: 0.78rem;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 1px solid var(--tertiary-pale);
    word-break: break-all;
    transition: color 0.2s ease, border-color 0.2s ease;
}
.ref-doi:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* grouped lists: { group } and { subgroup } headings, links inside { text } citations */
.project-ref-group,
.project-ref-subgroup {
    width: 100%;
    max-width: 720px;
    margin: 2rem auto 0.4rem;
    text-align: left;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
}
.project-ref-subgroup {
    margin-top: 1.2rem;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.ref-body a:not(.ref-doi) {
    color: inherit;
    overflow-wrap: anywhere;
    text-decoration-color: var(--tertiary-pale);
}
.ref-body a:not(.ref-doi):hover { color: var(--primary); }

/* ── inline citation links ([1], [2], ...) ── */
.citation-link {
    font-size: 0.7em;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 0 1px;
    transition: color 0.15s ease;
}
.citation-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

@media (max-width: 600px) {
    .project-ref-item { grid-template-columns: 1.6rem 1fr; gap: 0.3rem; }
    .ref-body { font-size: 0.8rem; }
}
