/*
 * Recent work (T-8644, shared since T-8662): the part x-corporate.story.work draws, up to three showcase case studies
 * under a head with one link to the case index. Loaded by every page that shows it (the homepage's scene 15, the
 * services index); the scene's own spacing stays with its page. The head's layout repeats home.css's .pv-head--action
 * so the part stands on a page without home.css.
 */

.pv-work > .pv-head--action {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px 48px;
    max-width: none;
}

.pv-work > .pv-head--action > div {
    display: grid;
    gap: 14px;
    max-width: 40rem;
}

.pv-work .pv-head .pv-body {
    margin-top: 6px;
}

.pv-work > .pv-head {
    margin-bottom: 40px;
}

.pv-work__more .pv-link {
    align-items: center;
    min-height: 44px;
}

/* The newest case leads on the left (six columns, its cover large); the others stand one under another on the right,
   each its text with its cover beside it. A case without a cover is its text alone: no box is drawn for it. */
.pv-cases {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    /* The lead spans all three rows; the others take the first two at their own height, the rest falls to the third. */
    grid-template-rows: auto auto 1fr;
    column-gap: var(--pv-gap);
    row-gap: 28px;
}

.pv-case {
    position: relative;
    display: grid;
    grid-column: 8 / 13;
    align-content: start;
    gap: 16px var(--pv-gap);
    min-width: 0;
    padding-top: 16px;
    border-top: 1px solid var(--pv-rule);
}

.pv-case:not(:first-child):has(> .pv-case__cover:not(.is-failed)) {
    grid-template-columns: minmax(0, 1fr) 40%;
}

.pv-case > .pv-case__cover {
    grid-column: 2;
    grid-row: 1;
}

.pv-case > .pv-case__text {
    grid-column: 1;
    grid-row: 1;
}

.pv-case:first-child {
    grid-column: 1 / 7;
    grid-row: 1 / -1;
    grid-template-columns: minmax(0, 1fr);
}

.pv-case:first-child > .pv-case__cover,
.pv-case:first-child > .pv-case__text {
    grid-column: 1;
    grid-row: auto;
}

/* One case: it leads alone, as wide as the head. */
.pv-case:only-child {
    grid-column: 1 / 9;
}

.pv-case__text {
    display: grid;
    align-content: start;
    gap: 8px;
    min-width: 0;
}

/* The cover: its own 3:2 box, cropped to fill it; one that cannot load is left out with its box, and the case's
   cover track goes with it (the two-column rules match only a cover that has not failed). */
.pv-case__cover {
    display: block;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: var(--pv-paper);
}

.pv-case__cover picture,
.pv-case__cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pv-case__cover.is-failed {
    display: none;
}

.pv-case__client {
    color: var(--pv-muted);
    font-size: var(--pv-type-label);
    font-weight: 500;
    line-height: 1.4;
}

.pv-case__title {
    font-size: clamp(19px, 0.3vw + 16px, 22px);
    line-height: 1.2;
    letter-spacing: -0.012em;
    text-wrap: balance;
    overflow-wrap: break-word;
}

.pv-case:first-child .pv-case__title {
    font-size: var(--pv-type-subhead);
    line-height: 1.15;
    letter-spacing: -0.016em;
}

/* The title is the case's one link, stretched over the whole case. */
.pv-case__link {
    text-decoration: underline;
    text-decoration-color: transparent;
    text-decoration-thickness: 1px;
}

.pv-case__link::after {
    content: '';
    position: absolute;
    inset: 0;
}

/* A case without a cover (none, or it failed) keeps a quiet underline so its title still reads as a link (T-8749). */
.pv-case:not(:has(> .pv-case__cover:not(.is-failed))) .pv-case__link {
    text-decoration-color: var(--pv-line);
}

.pv-case:hover .pv-case__link,
.pv-case:not(:has(> .pv-case__cover:not(.is-failed))):hover .pv-case__link {
    text-decoration-color: currentColor;
}

/* On touch, where nothing hovers, the title keeps a quiet underline so it reads as a link. */
@media (hover: none) {
    .pv-case__link {
        text-decoration-color: var(--pv-line);
    }
}

.pv-case__link:focus-visible {
    outline: none;
    text-decoration-color: currentColor;
}

.pv-case:has(.pv-case__link:focus-visible) {
    outline: 2px solid var(--pv-ink);
    outline-offset: 6px;
}

/* The services, muted, parted by a middle dot. */
.pv-case__services {
    display: flex;
    flex-wrap: wrap;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--pv-muted);
    font-size: var(--pv-type-small);
}

.pv-case__services li:not(:last-child)::after {
    content: '·';
    content: '·' / '';
    padding-inline: 8px;
}

/* One under another: each case its text on the left and its cover beside it, the lead too. */
@media (max-width: 1099px) {
    .pv-cases {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: none;
        row-gap: 0;
    }

    .pv-case,
    .pv-case:first-child,
    .pv-case:only-child {
        grid-column: 1;
        grid-row: auto;
        padding-block: 20px;
    }

    .pv-case:has(> .pv-case__cover:not(.is-failed)),
    .pv-case:first-child:has(> .pv-case__cover:not(.is-failed)) {
        grid-template-columns: minmax(0, 1fr) 38%;
    }

    .pv-case:first-child > .pv-case__cover {
        grid-column: 2;
        grid-row: 1;
    }

    .pv-case:first-child > .pv-case__text {
        grid-column: 1;
        grid-row: 1;
    }

    .pv-case:first-child .pv-case__title {
        font-size: clamp(19px, 0.3vw + 16px, 22px);
        line-height: 1.2;
        letter-spacing: -0.012em;
    }
}

/* A phone: a small 3:2 cover beside the text; tighter spacing throughout. */
@media (max-width: 759px) {
    .pv-work > .pv-head {
        row-gap: 8px;
        margin-bottom: 16px;
    }

    .pv-work__intro {
        display: none;
    }

    .pv-case,
    .pv-case:first-child,
    .pv-case:only-child {
        padding-block: 14px;
    }

    .pv-case:has(> .pv-case__cover:not(.is-failed)),
    .pv-case:first-child:has(> .pv-case__cover:not(.is-failed)) {
        grid-template-columns: minmax(0, 1fr) clamp(96px, 30vw, 128px);
        column-gap: 16px;
    }

    .pv-case:has(.pv-case__link:focus-visible) {
        outline-offset: 2px;
    }
}
