/* PROJECT PAGES: title, overview gallery, text panel, video */

/* TYPOGRAPHY */

.thumbnail-title {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    margin: var(--gutter) auto 0;
    /* the buttons' top spacing, no manual 3px */
    padding: 2px 6px;
    /* the same box as the buttons... */
    border: 1px solid transparent;
    /* ...including an invisible border */

    font-size: var(--font-size);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing);
    line-height: var(--line-height);

    width: 60vw;
    height: fit-content;
    text-align: center;
}

.title-track {
    display: inline-flex;
    gap: 3rem;

    animation: title-loop 8s ease-in-out 2s 1 forwards;
}

.title-track-hidden {
    display: none;
}

.text-btn {
    position: fixed;
    bottom: calc(var(--margin) * 1.5 + 16px);
    /* the same line as the timestamp and the copyright */
    left: auto;
    right: calc(var(--margin) * 2 + var(--gutter));
    /* mirrors the home button's 5rem edge */
    margin: 0;
    transform: translateY(50%);
    /* centres the text on that line */

    font-size: var(--font-size);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing);
    line-height: var(--line-height);
}

/* THUMBNAIL */

.thumbnail-box::-webkit-scrollbar {
    display: none;
}

.thumbnail-box {
    width: 100%;
    height: var(--gallery-h, 100%); 
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
}

.thumbnail-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.overview.is-moving .thumbnail-box {
    scroll-snap-type: none;
    /* no re-snapping while the gallery resizes */
}

.thumbnail-slide {
    height: 100%;
    /* one full screen of the gallery, like an image */
    box-sizing: border-box;
    padding: var(--margin);
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
    /* the same snapping as the images */
    scroll-snap-stop: always;

    text-align: center;
    text-transform: initial;
    /* normal capitals, like the caption */
    letter-spacing: 0;
    font-size: calc(var(--font-size));
}

.thumbnail-slide p {
    max-width: 60ch;
    margin: 0;
}

/* THUMBNAIL + TEXT: caption above, gallery in the middle, details below */

.overview {
    width: calc(100% - (var(--margin) * 10));
    height: 70%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    /* one full-width column */
    --details-h: 0px;
    --count-full: calc(var(--margin) * 3);              /* the counter's normal gap (was --count-h) */
    --count-h: var(--count-full);
    --lift: 0;                                           /* 0 = normal, 1 = caption fully risen; set by JS */
    --btn-h: calc(var(--margin) * 2.5); 
    --count-closed: calc(var(--margin) * 4); 
    --caption-gap: calc(var(--margin) * 2);   
    grid-template-rows: 0px 1fr 0fr 0px; 
    transition: grid-template-rows 0.4s ease 0.2s;
    margin-top: var(--count-closed); 
}

.overview.is-open {
    grid-template-rows: var(--details-h) 6fr 1.6fr var(--btn-h);
}

.thumbnail-gallery {
    grid-row: 2;
    grid-column: 1;
    min-height: 0;
    overflow: hidden;
    box-shadow: 0 -1px 0 transparent;
    /* closed: invisible */
    transition: box-shadow 0.2s ease;
    /* closing: fades out straight away */

    font-size: var(--font-size);
    text-transform: uppercase;
    letter-spacing: var(--letter-spacing);
    line-height: var(--line-height);
}

.overview.is-open .thumbnail-gallery {
    box-shadow: 0 -1px 0 var(--text);
    /* open: the line */
    transition-delay: 0.4s;
    /* fades in with the text */
}

/* the two wrappers disappear, so caption and details become grid items */
.text-gallery,
.text-gallery-content {
    display: contents;
}

.text-gallery-caption,
.text-gallery-details {
    grid-column: 1;
    width: 100%;
    max-width: 60ch;
    min-height: 0;
    margin: 0 auto;
    /* centred; no top or bottom margin */
    padding: 0;
    overflow-y: auto;
    /* each scrolls on its own */
    scrollbar-width: none;
    text-align: center;
    text-transform: initial;
    letter-spacing: 0;
    font-size: var(--font-size);
    line-height: var(--line-height);

    opacity: 0;
    transition: opacity 0.2s ease;
}

.text-gallery-caption::-webkit-scrollbar,
.text-gallery-details::-webkit-scrollbar {
    display: none;
}

.text-gallery-caption {
    grid-row: 3;
    transition: opacity 0.2s ease, margin-top 0.4s ease 0.2s, min-height 0.4s ease 0.2s;
}

.text-gallery-details {
    grid-row: 1;
    align-self: end;
    padding-bottom: calc(var(--margin) * 1.5);
    pointer-events: none;
}

.text-gallery-caption.has-more {
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5em), transparent 100%);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 2.5em), transparent 100%);
}

/* open state: spacing and visibility only exist now, so the closed rows are truly 0 */
.overview.is-open .text-gallery-caption {
    margin-top: calc(var(--count-h) + (var(--margin) * 2));
    min-height: 4lh;                                    /* three lines of the caption's own line height */
    opacity: 1;
    transition-delay: 0.4s, 0s, 0s;                     /* opacity waits; margin and min-height don't */
}

.overview.is-open .text-gallery-details {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.4s;
}

/* IMAGE COUNT: "1/10" in the gap between the gallery and the caption */

.image-count {
    grid-row: 3;
    grid-column: 1;                               /* the same cell as the caption */
    align-self: start;
    height: var(--count-closed);                  /* closed: just the number, under the gallery */
    min-height: var(--count-closed);              /* holds the closed row open for it */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;

    font-size: var(--font-size);
    line-height: var(--line-height);
    font-variant-numeric: tabular-nums;           /* digits stay the same width as they change */
    pointer-events: none;

    box-shadow: inset 0 -1px 0 transparent;       /* the line only exists when open */
    transition: height 0.4s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.overview.is-open .image-count {
    height: var(--count-h);                       /* open: the full gap above the caption */
    box-shadow: inset 0 -1px 0 var(--text);
    transition-delay: 0s, 0.4s, 0.4s;             /* the height moves with the row; the line fades in after */
}

/* ONE SLIDE: no number, so the gap collapses to just the line */

.overview.is-single {
    --count-closed: 0px;                                /* closed: no row under the gallery, so it stays centred */
    --count-full: 1px;                                  /* open and expanded: the gap is only the 1px line */
}

/* READING: the caption and its line rise over the gallery */

.overview.is-reading {
    --count-h: calc(var(--count-full) * (1 - var(--lift)) + var(--lift) * 1px);   /* the counter's gap closes down to its 1px line */
    grid-template-rows: var(--details-h) calc(var(--gallery-h) * (1 - var(--lift))) 1fr var(--btn-h);
    transition: none;                                   /* JS animates --lift frame by frame */
}

.overview.is-reading .thumbnail-gallery {
    box-shadow: 0 -1px 0 color-mix(in srgb, var(--text) calc((1 - var(--lift)) * 100%), transparent);
}

.overview.is-reading .image-count {
    color: transparent;
    transition: color 0.15s ease;                       /* was: opacity 0.2s ease, color 0.15s ease */
}

.overview.is-reading .text-gallery-caption {
    transition: opacity 0.2s ease;
}

/* EXPAND BUTTON: a stemless chevron under the caption */

.expand-btn {
    grid-row: 4;                                        /* its own row under the caption */
    grid-column: 1;
    justify-self: center;
    width: 3rem;                                        /* a generous tap area; the drawing stays 14px */
    min-height: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* visible when open and there is more text to read, or while expanded */
.overview.is-open:has(.text-gallery-caption.has-more) .expand-btn,
.overview.is-open.is-reading .expand-btn {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.4s;
}

.expand-btn svg {
    width: 9px;                                         /* was 14px: the same width as the Menu plus */
    height: 5px;                                        /* was 8px: keeps the same proportions */
    transition: transform 0.4s ease;
}

.overview.is-expanded .expand-btn svg {
    transform: rotate(180deg);                          /* points down when expanded */
}

/* VIDEO */

.thumbnail-box iframe {
    display: block;
    /* iframes are inline by default, which leaves a gap and can break the height */
    width: 100%;
    height: 100%;
    /* the same height as the gallery box, like the images */
    border: 0;
    /* removes the grey frame the browser adds */
    scroll-snap-align: start;
    /* makes the video a snap point, so you can scroll back up to it */
    scroll-snap-stop: always;
}

/* HOME BUTTON: laptop = outlined word like Menu, phone = house icon (see responsive.css) */

.home-btn.home-icon {
    right: calc(var(--margin) * 2);
    /* mirrors the menu button: 5rem from the edge with the margin */
    transform: none;
    /* cancels the 1px nudge the old name link used */
    padding: 2px 6px;
    /* same as the menu button */
    border-color: var(--text);
    /* the outline */
    font-weight: 400;
    /* the old name link was 900 */
    letter-spacing: var(--letter-spacing);
}

.home-dot {
    display: none;
    /* the dot is for phone only (see responsive.css) */
}

/* Larger invisible tap area, like the menu button */
.home-btn.home-icon::after {
    content: "";
    position: absolute;
    inset: -10px;
}

/* PAGE SCROLL: the project plus a footer strip revealed by scrolling once more */

.project-scroll {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    scrollbar-width: none;
}

.project-scroll::-webkit-scrollbar {
    display: none;
}

.project-main {
    flex: none;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    scroll-snap-align: start;
}

.text-btn {
    transition: opacity 0.4s ease;
}

.footer-visible .text-btn {
    opacity: 0;
    pointer-events: none;
}

/* BEHIND THE SCENES: button and pop-up */

.bts-btn {
    position: fixed;
    left: 50%;
    bottom: calc(var(--margin) * 1.5 + 16px);
    /* the same line as the timestamp and Read More */
    transform: translate(-50%, 50%);
    text-transform: uppercase;
    font-size: var(--font-size);
    letter-spacing: var(--letter-spacing);
    line-height: var(--line-height);
    transition: opacity 0.4s ease;
}

.footer-visible .bts-btn {
    /* fades out with the timestamp when the copyright strip shows */
    opacity: 0;
    pointer-events: none;
}

.bts-dialog {
    width: 56vw;
    height: calc(100dvh - (var(--margin) * 4));
    max-width: none;
    max-height: none;
    padding: 0;
    border: 0;
    /* no outline */
    background: transparent;
    /* no white card: the images and the x float directly on the page */
    color: inherit;
}

.bts-dialog[open] {
    display: flex;
    flex-direction: column;
}

.bts-dialog::backdrop {
    background: rgba(255, 255, 255);
    /* a light wash so the black x stays readable */
}

.bts-close {
    flex: none;
    align-self: center;
    /* top centre */
    position: relative;
    width: 3rem;
    height: 3rem;
}

.bts-close::before,
.bts-close::after {
    /* a bare x, with no circle */
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 11px;
    height: 1px;
    background: currentColor;
    transform: translate(-50%, -50%) rotate(45deg);
}

.bts-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.bts-images {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--margin);
    padding: 0 var(--margin) var(--margin);
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    /* one image at a time */
    scrollbar-width: none;
}

.bts-images::-webkit-scrollbar {
    display: none;
}

.bts-images img {
    flex: none;
    /* never squashed to fit */
    display: block;
    width: 100%;
    height: 100%;
    /* as tall as the visible scroll area, so one image fills the card */
    object-fit: contain;
    /* the whole image is visible, never cropped */
    object-position: center;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    /* a fast scroll can't skip an image */
}


/* MOBILE: only what changes */

@media (max-width: 1000px) {

    .text-btn {
        right: var(--gutter);
    }

    .overview {
        width: calc(100% - (var(--margin) * 6.5));
    }

    .thumbnail-title {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        margin: var(--gutter) auto 0;
        /* same top spacing as the menu and home buttons */
        width: calc(100% - var(--margin) * 11);
        /* leaves room for the two circles on either side */

        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        text-align: center;
    }

    .title-track-hidden {
        display: block;
    }

    @keyframes title-loop {
        from {
            transform: translateX(0);
        }

        to {
            transform: translateX(calc(-50% - 1.5rem));
        }
    }

    .bts-dialog {
        width: calc(100vw - (var(--margin) * 2));
    }
}