/* Project case studies, set like an MIT Media Lab article: a full-width cover,
   then the page grid from styles.css (section links on the left) with the
   story as one column of plain text — headings, a bold italic lead, paragraphs,
   lists, quotes — and figures whose captions sit in the right margin. Neutral
   palette only; colour comes from the project imagery.

   Markup vocabulary (pages/projects/*.vue):
     header.project-header   .project-kicker, h1, p.lead, p.project-award,
                             p.project-links > a.btn
     dl.project-facts        div > dt + dd, one per fact
     section                 h2, p.lead, p, h3, ul/ol, blockquote,
                             p.statement, figure
     figure                  img / video / iframe (or div.figure-grid of them)
                             + figcaption, shown in the right margin */

.hero-image {
    display: block;
    width: 100%;
    height: auto;
}

.project-page {
    /* The text measure, and the caption column beside figures. Text is never
       wider than the space left of the captions, so both stay aligned. */
    --measure: 760px;
    --caption-width: 200px;
    --caption-gap: 48px;
    --text-width: min(var(--measure), calc(100% - var(--caption-width) - var(--caption-gap)));
}

.project-page .content {
    display: block;
    min-width: 0;
}

/* Sections span the column (their figures reach into the caption margin);
   everything else keeps to the text measure. */
.project-page .content > :not(section),
.project-page section > * {
    max-width: var(--text-width);
}

.project-page section {
    margin-top: 96px;
    scroll-margin-top: calc(var(--header-height) + 32px);
}

/* ---------- Header ---------- */

.project-kicker {
    margin: 0 0 12px;
    font-weight: 700;
    color: var(--color-gray);
}

.project-header h1 {
    margin: 0 0 20px;
}

.project-header .lead {
    font-size: 20px;
    line-height: 1.5;
}

.project-award {
    margin-top: 12px;
    font-weight: 700;
}

.project-links {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 28px;
}

/* Timeline / team / role / skills. */
.project-facts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px 32px;
    margin: 48px 0 0;
    padding: 20px 0;
    border-top: 2px solid var(--color-foreground);
    border-bottom: 1px solid var(--color-line);
}

.project-facts dt {
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-gray);
}

.project-facts dd {
    margin: 0;
    font-size: 16px;
    line-height: 1.5;
}

/* ---------- Text ---------- */

.project-page section h2 {
    margin: 0 0 24px;
    font-size: 45px;
    line-height: 1.05;
}

.project-page section h3 {
    margin: 40px 0 12px;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.35;
}

.project-page section h2 + h3 {
    margin-top: 0;
}

.project-page .content p,
.project-page .content li {
    font-size: 18px;
    line-height: 1.67;
}

.project-page section p {
    margin: 0 0 20px;
}

/* The lead: the section's first sentence, bold italic. */
.project-page .lead {
    font-style: italic;
    font-weight: 700;
}

.project-page .content ul,
.project-page .content ol {
    margin: 0 0 20px;
    padding-left: 22px;
}

.project-page .content li {
    margin-bottom: 8px;
}

.project-page .content a:not(.btn):not(.project-card) {
    text-decoration: underline;
    text-decoration-color: var(--color-primary);
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}

.project-page .content a:not(.btn):not(.project-card):hover {
    color: var(--color-accent);
}

/* A guiding question or goal, set large on a black rule. */
.project-page .content .statement {
    margin: 32px 0;
    padding-left: 24px;
    border-left: 4px solid var(--color-foreground);
    font-size: 24px;
    font-weight: 700;
    line-height: 1.4;
}

/* What people said: interview quotes and user feedback. */
.project-page blockquote {
    margin: 28px 0;
    padding-left: 24px;
    border-left: 2px solid var(--color-foreground);
}

.project-page .content blockquote p {
    margin: 0 0 6px;
    font-size: 20px;
    font-style: italic;
}

.project-page blockquote cite {
    font-size: 14px;
    font-style: normal;
    color: var(--color-gray);
}

/* ---------- Figures: media in the text column, caption in the margin ---------- */

.project-page figure {
    display: grid;
    grid-template-columns: var(--text-width) minmax(0, 1fr);
    column-gap: var(--caption-gap);
    align-items: start;
    max-width: none;
    margin: 40px 0;
}

.project-page figure > :not(figcaption) {
    grid-column: 1;
    display: block;
    width: 100%;
    height: auto;
}

.project-page figure > :not(figcaption) + :not(figcaption) {
    margin-top: 16px;
}

.project-page figcaption {
    grid-column: 2;
    grid-row: 1 / span 20;
    /* Stays beside a tall figure (a stack of slides) while it scrolls by. */
    position: sticky;
    top: calc(var(--header-height) + 32px);
    padding-top: 14px;
    font-size: 14px;
    font-style: italic;
    line-height: 1.5;
    color: var(--color-gray);
}

/* A short hairline over the caption, as on the Media Lab site. */
.project-page figcaption::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 1px;
    background-color: var(--color-gray-light);
}

.project-page figure iframe {
    aspect-ratio: 16 / 9;
    border: 0;
}

/* An interactive Figma prototype needs room to be used. */
.project-page figure iframe.figma-embed {
    aspect-ratio: auto;
    height: 75vh;
    border: 1px solid var(--color-line);
}

/* A language switch inside a caption, set as plain text. */
.slide-language {
    display: block;
    margin-top: 8px;
    font-style: normal;
}

.slide-language button {
    padding: 0;
    border: none;
    background: none;
    color: var(--color-gray);
    font-size: 14px;
    font-weight: 400;
}

.slide-language button:hover,
.slide-language button[aria-pressed="true"] {
    background: none;
    color: var(--color-foreground);
    font-weight: 700;
}

/* Several pieces of media in one figure: a plain grid, no frames. (Scoped
   to the figure so it outranks the block display given to figure media.) */
.project-page figure > .figure-grid,
.figure-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.project-page figure > .figure-grid--3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.project-page figure > .figure-grid--4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.figure-grid img,
.figure-grid video {
    display: block;
    width: 100%;
    height: auto;
}

/* A landscape piece beside a portrait one: columns in proportion to their
   shapes, so the two come out the same height. */
.project-page figure > .figure-grid--wide-tall {
    grid-template-columns: 7fr 3fr;
}

/* Portrait media is never shown full width on its own. Without a partner it
   floats beside the text it belongs to, under half the column wide, with its
   caption beneath. The figure goes before that text in the markup. */
.project-page figure.figure-float {
    display: block;
    float: right;
    width: calc(var(--text-width) * 0.42);
    margin: 6px calc(100% - var(--text-width)) 24px 40px;
}

.project-page figure.figure-float figcaption {
    position: static;
    margin-top: 12px;
}

/* New subsections, statements, and full figures start below a float. */
.project-page section h3,
.project-page .content .statement,
.project-page blockquote,
.project-page figure:not(.figure-float) {
    clear: both;
}

.project-page section::after {
    content: '';
    display: block;
    clear: both;
}

/* Transparent artwork and screenshots get a neutral backdrop. */
.on-surface {
    background-color: var(--color-surface);
}

/* ---------- More projects ---------- */

.project-page .next-project-section {
    padding-top: 48px;
    border-top: 1px solid var(--color-line);
}

.project-page .next-project-section > * {
    max-width: none;
}

.project-page .next-project-section h2 {
    font-size: 32px;
}

/* ---------- Narrower screens: captions drop under their media ---------- */

@media (max-width: 1180px) {
    .project-page {
        --text-width: min(var(--measure), 100%);
    }

    .project-page figure {
        display: block;
    }

    .project-page figcaption {
        position: relative;
        top: auto;
        margin-top: 12px;
        max-width: var(--measure);
    }
}

@media (max-width: 640px) {
    /* Too narrow to wrap text beside it: the float sits alone, but small. */
    .project-page figure.figure-float {
        float: none;
        width: 100%;
        max-width: 320px;
        margin: 32px 0;
    }
}

@media (max-width: 768px) {
    /* The wide covers crop to 4:3 rather than become a letterbox sliver. */
    .hero-image {
        aspect-ratio: 4 / 3;
        object-fit: cover;
    }

    .project-facts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .project-page section {
        margin-top: 72px;
    }

    .project-page section h2 {
        font-size: 34px;
    }

    .project-page .content p,
    .project-page .content li {
        font-size: 17px;
    }

    .project-page .content .statement {
        font-size: 20px;
    }

    .project-page figure > .figure-grid--3,
    .project-page figure > .figure-grid--4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* Expandable project media */
.content img.media-expandable,
.content video.media-expandable {
    cursor: zoom-in;
}

html.media-lightbox-open,
html.media-lightbox-open body {
    overflow: hidden;
}

.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: rgba(12, 12, 12, 0.88);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.media-lightbox.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.media-lightbox-stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-width: min(1200px, 100%);
    max-height: 100%;
}

.media-lightbox.is-portrait .media-lightbox-stage {
    max-width: min(480px, 100%);
}

.media-lightbox-media {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: calc(100vh - 48px);
    object-fit: contain;
    transform-origin: center center;
    border-radius: 0;
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
    background: #000;
    transform: translateY(10px) scale(0.98);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
}

.media-lightbox.is-open .media-lightbox-media {
    transform: translateY(0) scale(1);
    opacity: 1;
}

/* Artwork with a transparent background gets the backdrop it has in the page
   (set inline from JS) plus a little padding, so the fill reads as a deliberate
   frame instead of the scrim showing through the image. */
.media-lightbox-media.has-backdrop {
    box-sizing: border-box;
    padding: 24px;
    background-color: #fff;
}

/* Pinch/wheel zoom is driven from JS, so the browser must not claim the touch
   gestures on the image itself. Videos keep default touch handling for controls. */
.media-lightbox-image {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

.media-lightbox-video {
    width: 100%;
    background: #000;
}

.media-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 1;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s ease, transform 0.18s ease;
}

.media-lightbox-close:hover,
.media-lightbox-close:focus-visible {
    background: rgba(255, 255, 255, 0.22);
    outline: none;
    transform: scale(1.04);
}

@media (max-width: 768px) {
    .media-lightbox {
        padding: 12px;
    }

    .media-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }

    .media-lightbox-media {
        max-height: calc(100vh - 24px);
        border-radius: 0;
    }

    .media-lightbox-media.has-backdrop {
        padding: 12px;
    }
