/* archive page: a grid of image slideshows (one image visible per project at a time) */

.archive-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
}

/* small category heading above a grid */
.archive-heading {
    margin: 0 0 14px;
    font-family: "JetBrainsMono-Regular", sans-serif;
    font-size: 11pt;
    font-weight: normal;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

/* a heading that starts a new category sits well below the previous grid */
.archive-grid + .archive-heading {
    margin-top: 56px;
}

/* consecutive grids (categories) get some room between them */
.archive-grid + .archive-grid {
    margin-top: 56px;
}

.slideshow-card {
    position: relative;
    margin: 0;
}

.slideshow {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 5px;
    background-color: var(--bg);
}

.slide {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 35%; /* crop toward the upper-middle so heads and tops are less likely to be cut off */
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

/* wide "grid" videos are shown whole (letterboxed) instead of cropped to a square */
.slide.slide-contain {
    object-fit: contain;
}

.slide.active {
    opacity: 1;
}

/* the drawings were made for a white page (many are transparent PNGs), so they get a light backing */
/* stickers: white-background artwork, shown whole (not cropped) on a white square */
.slideshow-sticker .slideshow {
    background-color: #fff;
}

.slideshow-sticker .slide {
    object-fit: contain;
}

.slideshow-light .slideshow {
    background-color: #f4f4f4;
}

/* the figcaption (title + counter) is kept for screen readers and touch screens; with a mouse the tooltip shows it instead */
.slide-title {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

a.slide-btn,
button.slide-btn {
    all: unset;
    opacity: 0;
    transition: opacity 0.2s ease-out;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    box-sizing: border-box;
    border: none;
    background-color: rgba(0, 0, 0, 0.6);
    color: #ececec;
    font-family: "JetBrainsMono-Regular", sans-serif;
    z-index: 1;
}

/* "all: unset" above also wipes the hidden attribute, so single-image tiles need this to lose their arrows */
button.slide-btn[hidden] {
    display: none;
}

.slideshow-card:hover button.slide-btn,
.slideshow-card:focus-within button.slide-btn {
    opacity: 1;
}

.slideshow .slide-prev {
    left: 0;
}

.slideshow .slide-next {
    right: 0;
    left: auto;
}

button.slide-btn:hover {
    color: var(--accent);
}

button.slide-btn:focus-visible {
    outline: 1px solid var(--accent);
}

.slide-count {
    flex: none;
    font-size: 9pt;
}

/* 5 tiles per row by default, stepping down on narrower windows */
@media (max-width: 1100px) {
    .archive-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 900px) {
    .archive-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    .archive-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .archive-grid + .archive-heading,
    .archive-heading {
        margin-top: 36px;
    }
}

/* touch screens have no hover (so no tooltip): show the title as an overlay and keep the arrows visible */
@media (hover: none) {
    .slide-title {
        left: 0;
        right: 0;
        bottom: 0;
        width: auto;
        height: auto;
        margin: 0;
        clip: auto;
        overflow: visible;
        z-index: 2;
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
        gap: 6px;
        padding: 22px 8px 6px;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0));
        font-size: 10pt;
        line-height: 1.25;
        border-radius: 0 0 5px 5px;
        pointer-events: none;
        white-space: normal;
    }
    .slide-title .slide-name {
        min-width: 0;
        overflow-wrap: anywhere;
    }
    button.slide-btn {
        opacity: 1;
        width: 36px;
        height: 36px;
        line-height: 36px;
    }
}

/* full-screen image viewer (scripts/lightbox.js) */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000; /* fully black: nothing from the page behind shows through */
    opacity: 0;
    transition: opacity 0.2s ease-out;
}

.lightbox[hidden] {
    display: none;
}

.lightbox.open {
    opacity: 1;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 86vh;
    width: auto;
    height: auto;
    border-radius: 5px;
}

/* the drawings are made for a white page, so give them a light backing here too */
.lightbox-light .lightbox-img {
    background-color: #f4f4f4;
}

button.lightbox-btn {
    all: unset;
    position: absolute;
    width: 44px;
    height: 44px;
    line-height: 44px;
    text-align: center;
    font-size: 20pt;
    color: #ececec;
    font-family: "JetBrainsMono-Regular", sans-serif;
}

button.lightbox-btn[hidden] {
    display: none;
}

button.lightbox-btn:hover {
    color: var(--accent);
}

button.lightbox-btn:focus-visible {
    outline: 1px solid var(--accent);
}

button.lightbox-close {
    top: 18px;
    right: 22px;
    font-size: 26pt;
}

button.lightbox-prev {
    left: 22px;
    top: 50%;
    margin-top: -22px;
}

button.lightbox-next {
    right: 22px;
    top: 50%;
    margin-top: -22px;
}

.lightbox-caption {
    position: absolute;
    left: 24px;
    bottom: 20px;
    display: flex;
    gap: 14px;
    align-items: baseline;
    color: #ececec;
    pointer-events: none;
}

.lightbox-title {
    font-size: 12pt;
}

.lightbox-count {
    font-size: 9pt;
}

/* phones: lightbox controls get a backing so they stay visible over the picture, and the picture can use the width */
@media (max-width: 767px) {
    button.lightbox-btn {
        background-color: rgba(0, 0, 0, 0.55);
        border-radius: 50%;
    }
    button.lightbox-prev {
        left: 10px;
    }
    button.lightbox-next {
        right: 10px;
    }
    button.lightbox-close {
        top: 12px;
        right: 12px;
    }
    .lightbox-img {
        max-width: 96vw;
        max-height: 80vh;
    }
    .lightbox-caption {
        left: 14px;
        bottom: 14px;
        right: 14px;
        flex-wrap: wrap;
    }
}
