/* Pages */

html:not([data-acknowledged]):has(section.acknowledgement) {
    overflow: hidden;

    :is(header, main > section:not(.acknowledgement)) {
        visibility: hidden;
    }

    /* Stays a thin strip even when a refresh's restored scroll position has set .is-revealed (header_reveal_controller.js) */
    section.colour-bar {
        transform: translateY(calc(0.5rem - 100%));
    }
}

/* Typology grid: the index, and related stories on the show page */
section.story-grid {
    flex: 1;
    display: grid;
    grid-template-columns: var(--grid-columns);
    position: relative;

    &.is-arranging {
        visibility: hidden;
    }

    .typology-links {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;

        path {
            fill: none;
            stroke: var(--typology-link-colour, var(--white));
            stroke-width: 3px;
            stroke-linecap: round;
            stroke-linejoin: round;
            vector-effect: non-scaling-stroke;
            stroke-dasharray: 0 8;
        }
    }

    .story {
        aspect-ratio: 1/1;
        width: 100%;
        height: 100%;
        line-height: 0;
        overflow: hidden;
        position: relative;
        cursor: pointer;
        color: inherit;
        text-decoration: none;
        opacity: 0;
        transition: opacity 1s ease;

        &:has([data-halftone-drawn]),
        &:not(:has([data-halftone-target])),
        .halftone--fallback & {
            opacity: 1;
        }

        &:nth-of-type(4n) {
            border-radius: 40rem;
        }

        .story-information {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            width: 100%;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 1rem;
            align-items: center;
            text-align: center;
            color: var(--white);
            line-height: 1.2;
            opacity: 0;
            transition: opacity 0.2s ease-in-out;

            .icons {
                display: flex;
                gap: 0.25rem;
            }

            .icon {
                width: 1rem;
                height: 1rem;
                object-fit: contain;
            }
        }

        /* Only with a real pointer: on touch, iOS spends the first tap showing a hover change and needs a second to open */
        @media (hover: hover) {
            &:hover .story-information {
                opacity: 1;
            }
        }

        img, video {
            width: 100%;
            height: 100%;
            object-fit: cover;
            aspect-ratio: 1/4;
        }
    }
}


main.stories {
    display: flex;
    flex-direction: column;

    section.introduction {
        color: var(--white);
        display: grid;
        grid-template-columns: var(--grid-columns);
        position: relative;
        row-gap: 2.5rem;
        padding: 2rem 0 4rem 0;

        /* Columns may shrink below their buttons' full labels, which then end in … (application.css) */
        > * {
            min-width: 0;
        }

        .button {
            width: 100%;

            &:hover {
                gap: 1rem;
            }
        }

        img {
            max-width: 15rem;
        }

        .span-2 {
            grid-column: span 2;
            padding-right: 4rem;
        }

        @media (width < 77rem) {
            .section:nth-of-type(2) {
                grid-column: 3/5;
            }

            nav {
                grid-column: 1/3;
            }

            .section:nth-of-type(3) {
                grid-column: 3;
            }
        }

        @media (width < 50rem) {
            grid-template-columns: 1fr 1fr;
            padding-bottom: 4rem;

            .section:nth-of-type(3) {
                grid-column: inherit;
            }

            .section:nth-of-type(2) {
                grid-column: span 2 ;
            }

            > :nth-child(-n + 3) {
                grid-column: 1 / -1;
            }

            .span-2 {
                padding-right: 0;
            }
        }
    }

    /* Once per visit (acknowledgement_controller.js): seen, it's gone; unseen, the rest waits behind it */
    html[data-acknowledged] & section.acknowledgement {
        display: none;
    }

    /* Fixed, so it covers the screen wherever a refresh restores the scroll position to */
    section.acknowledgement {
        position: fixed;
        inset: 0;
        cursor: pointer; /* clicking anywhere enters (acknowledgement_controller.js) */

        /* Hidden until line_reveal_controller.js has split the text, so it doesn't show and then pop in */
        @media (scripting: enabled) {
            &:not([data-line-reveal-ready]) :is(p, .button) {
                opacity: 0;
            }
        }

        display: grid;
        place-items: center;
        color: var(--white);
        padding: 0 1rem;

        .acknowledgement-content {
            max-width: var(--width-wide);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4rem;
        }
    }
}

main.story {
    padding: 6rem 0 0 0;
    display: flex;
    gap: 2rem;
    min-height: calc(100svh - 4rem);
    flex-direction: column;

    &.exhibit {
        padding: 0;
        height: 100vh;
        align-items: center;
        justify-content: center;
    }

    .story-background {
        position: fixed;
        inset: 0 0 auto;
        height: 100lvh;

        video, img {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
    }

    section.story-text {
        @media (scripting: enabled) {
            &:not([data-line-reveal-ready]) :is(.h4, .lexxy-content > *, .tag, .button) {
                visibility: hidden;
            }
        }

        position: relative;
        padding: 4rem 0;
        width: 100%;
        zoom: var(--zoom, 1);
        max-width: calc(1400px / var(--zoom, 1));
        margin: auto;
        display: flex;
        flex-direction: column;
        gap: 6rem;
        align-items: center;
        justify-content: center;

        @media (width < 50rem) {
            gap: 4rem;
        }

        .icon {
            display: inline-block;
            width: 0.8rem;
            height: 0.8rem;
            background-color: var(--white);
            mask: var(--icon) center / contain no-repeat;
        }

        p {
            color: var(--white);
            /*color: oklch(from var(--story-colour, var(--white)) clamp(0, (0.65 - l) * infinity, 1) 0 0);*/
        }

        .h4 {
            color: var(--white);
            /*color: oklch(from var(--story-colour, var(--white)) clamp(0, (0.65 - l) * infinity, 1) 0 0);*/
            text-align: center;
        }

        .button {
            background-color: var(--black);

            &:hover {
                background-color: var(--white);
            }
        }
    }

    .tags {
        justify-content: center;
    }

}

main.page {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding: 12rem 0;
    align-items: center;
    color: var(--white);

    &.center {
        min-height: calc(100svh - 4rem);
        justify-content: center;
    }

    @media (width < 50rem) {
        padding: 6rem 0;
    }

    section.content {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6rem;
        width: 100%;

        @media (width < 50rem) {
            gap: 4rem;
        }

        .large {
            max-width: var(--width-wide);
            margin-bottom: 4rem;

            p {
                font-size: clamp(1.6rem, 3.5vw, 3.1rem);
            }
        }

        .body {
            max-width: var(--width-text);

            p + p {
                text-indent: var(--indent);
            }

            .lexxy-content {
                color: inherit;
            }

            blockquote {
                padding-left: var(--indent);

                p + p {
                    text-indent: 0;
                }
            }

            a {
                color: var(--orange);
            }
        }

        .image {
            width: calc(66vw - var(--gutter));
            max-width: var(--width-wide);
            display: flex;
            flex-direction: column;
            gap: 0.75rem;

            &.small {
                max-width: var(--width-text);

                img {
                    max-width: 300px;
                    aspect-ratio: 1/1;
                    object-fit: cover;
                    filter: grayscale(1);
                }
            }

            @media (width < 77rem) {
                width: 100%;
            }

            img {
                width: 100%;
            }

            figcaption {
                opacity: 0.5;
            }
        }
    }

}
