/* Work listing page only. Loaded after site.css.
   Two layouts share one set of markup: a two-up card grid and a dense index of
   rows. The layout button swaps `.is-index` on .wl-items — nothing is rebuilt,
   so a filtered-down set keeps its state across the switch. */

/* Label a control carries for screen readers but not on screen */
.u-visually-hide {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------------------------------------------------------------- Page head */

/* Matches the about page's heading block: same 2em padding, same height, so
   the two pages start their content on the same line */
.wl-head {
    grid-column: 1 / span 12;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1em;
    padding: 2em 0;
    height: 8.5em;
}

/* Scoped with .site so the size outranks the `.site h1` reset in site.css —
   the same reason .contact-heading is scoped. Matched to that heading, so the
   two pages open at the same scale. It still fits inside .wl-head's fixed
   8.5em: 3em of type at 1.1 leaves room under the 2em padding, which is what
   keeps the control bar below on the same line as the about page's. */
.site .wl-heading {
    margin: 0;
    font-size: clamp(1.5em, 3.4vw, 3em);
    font-weight: 700;
    line-height: 1.1;
}

.wl-count {
    margin: 0;
    color: var(--color-faint);
    font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------- Control bar */

.wl-bar {
    grid-column: 1 / span 12;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    padding: 0.9em 0;
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 3em;
}

.wl-control {
    margin: 0;
    color: var(--color-faint);
    display: flex;
    align-items: center;
    gap: 0.5em;
}

/* The controls are the one place on the page where a button carries live
   state, so they sit at full strength against the dimmed label beside them */
.wl-control button {
    font: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    color: var(--color-primary);
    background: none;
    border: 0;
    padding: 0;
    cursor: none;
    display: flex;
    align-items: center;
    gap: 0.5em;
    transition: opacity 0.3s ease;
}

.wl-control button:hover {
    opacity: 0.55;
}

/* Two stacked bars for the index layout, four cells for the grid — drawn
   rather than shipped as an asset so it inherits the theme colour */
.wl-layout-icon {
    width: 0.85em;
    height: 0.85em;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 2px;
    background:
        linear-gradient(currentColor, currentColor) 0 0 / 100% calc(50% - 1px) no-repeat,
        linear-gradient(currentColor, currentColor) 0 100% / 100% calc(50% - 1px) no-repeat;
}

/* Grid mode: the same box splits into four cells */
.wl-layout-icon.is-grid {
    background:
        linear-gradient(currentColor, currentColor) 0 0 / calc(50% - 1px) calc(50% - 1px) no-repeat,
        linear-gradient(currentColor, currentColor) 100% 0 / calc(50% - 1px) calc(50% - 1px) no-repeat,
        linear-gradient(currentColor, currentColor) 0 100% / calc(50% - 1px) calc(50% - 1px) no-repeat,
        linear-gradient(currentColor, currentColor) 100% 100% / calc(50% - 1px) calc(50% - 1px) no-repeat;
}

/* -------------------------------------------------------------------- Items */

.wl-items {
    grid-column: 1 / span 12;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 1em;
    row-gap: 4em;
}

/* Filtered-out items leave the flow entirely, so the alternating offsets below
   re-pair without any help from JS */
.wl-item[hidden] {
    display: none;
}

.wl-item-link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: none;
}

.wl-item-media {
    position: relative;
    aspect-ratio: 1350 / 625;
    overflow: hidden;
    background: rgba(255, 255, 227, 0.06);
}

:root[data-theme="light"] .wl-item-media {
    background: rgba(35, 36, 26, 0.06);
}

.wl-item-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    -webkit-user-drag: none;
    user-select: none;
    transform: scale(1.001);
    transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.wl-item-link:hover .wl-item-media img {
    transform: scale(1.05);
}

/* Liquid distortion under the cursor — distort.js builds the warped copy on
   first hover and drops it into the media box. `.wl-item-media img` above
   already sizes it to the box; these three undo what styles.css sets for the
   carousel thumbnails it was written against, where the copy was a centred
   600px-max image rather than a cover fill, and lift it in step with the
   original rather than on the carousel's faster curve. */
.wl-item-media .distort-layer img {
    max-width: none;
    max-height: none;
    transition: transform 0.9s cubic-bezier(0.16, 1, 0.3, 1);
}

.wl-item-link.is-distorting .distort-layer {
    opacity: 1;
}

.wl-item-link:hover .distort-layer img {
    transform: scale(1.05);
}

.wl-item-content {
    display: flex;
    align-items: baseline;
    gap: 0.75em;
    padding: 0.9em 0 0;
}

.wl-item-title,
.wl-item-subtitle {
    margin: 0;
}

/* The title carries the same type as the page's h1 — same size, same 400
   weight — rather than the 700 that `.site h2, .site h3` gives every heading.
   The `.site` prefix is here to out-specify that rule, not to scope: without
   it this loses on specificity and never applies, which is exactly what was
   happening to the subtitle's own `font-weight: 400` before. The two are set
   together because a 400 title beside a 700 subtitle inverts the hierarchy —
   here the subtitle is set apart by colour, as it already was. */
.site .wl-item-title,
.site .wl-item-subtitle {
    font-weight: 400;
}

.wl-item-subtitle {
    color: var(--color-faint);
    transition: color 0.35s ease;
}

.wl-item-year {
    margin-left: auto;
    color: var(--color-faint);
    font-variant-numeric: tabular-nums;
    transition: color 0.35s ease;
}

.wl-item-link:hover .wl-item-subtitle,
.wl-item-link:hover .wl-item-year {
    color: var(--color-dim);
}

/* --------------------------------------------------------------- Index mode */

/* One row per project: thumbnail, title, discipline, year. The media keeps its
   ratio at a fraction of the width, so nothing reloads on the swap. */
.wl-items.is-index {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 0;
    /* Closing rule on the container rather than the last row: `:last-child` is
       structural and would sit under a row the filter has hidden */
    border-bottom: 1px solid var(--hairline);
}

.wl-items.is-index .wl-item-link {
    display: grid;
    grid-template-columns: 10em minmax(0, 1fr) minmax(0, 1fr) 6em;
    align-items: center;
    gap: 1em;
    padding: 1em 0;
    border-top: 1px solid var(--hairline);
}

/* The row is already a grid, so the content wrapper hands its three children
   straight to it rather than laying them out again */
.wl-items.is-index .wl-item-content {
    display: contents;
}

.wl-items.is-index .wl-item-year {
    margin-left: 0;
    text-align: right;
}

/* ------------------------------------------------------------- Empty filter */

.wl-empty {
    grid-column: 1 / span 12;
    margin: 3em 0 0;
    color: var(--color-faint);
}

/* --------------------------------------------------------------- Responsive */

@media only screen and (max-width: 1024px) {
    .wl-head,
    .wl-bar,
    .wl-items,
    .wl-empty {
        grid-column: 1 / span 4;
    }

    .wl-head {
        height: auto;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4em;
    }

    .wl-items {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 3em;
    }

    /* Index rows drop the thumbnail and the discipline: at this width they
       squeeze the title down to a couple of words per line */
    .wl-items.is-index .wl-item-link {
        grid-template-columns: minmax(0, 1fr) 5em;
    }

    .wl-items.is-index .wl-item-media,
    .wl-items.is-index .wl-item-subtitle {
        display: none;
    }
}
