/* Work + Projects views (homepage): the detail card a grid tile or list row opens into.
   The <dialog> is a full-screen, transparent scroller with the card centred in it, so
   anything too tall scrolls instead of being clipped or drawn over the media.
   --ar and --nat-w (set by workViewsCard.js from the media) size it: the media fills its
   box at its own shape and never grows past 1.5x its native width. */

.wv-card {
    --gut: 16px;
    --pad: 12px;
    --card-w: min(1100px, calc(100vw - 2 * var(--gut)));
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: var(--gut);
    box-sizing: border-box;
    border: 0;
    background: transparent;
    color: var(--text-color);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.wv-card[open] {
    display: flex;
}

.wv-card::backdrop {
    background: rgba(35, 28, 6, 0.6);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

/* margin: auto centres while it fits and falls back to the top when it doesn't. */
.wv-card-inner {
    position: relative;
    width: var(--card-w);
    margin: auto;
    box-sizing: border-box;
    padding: var(--pad);
    border-radius: 22px;
    background: var(--bg-color);
    box-shadow: 0 30px 80px rgba(30, 24, 5, 0.35);
}

.wv-card-media {
    position: relative;
    overflow: hidden;
    aspect-ratio: var(--ar, 16 / 9);
    border-radius: 14px;
    background: var(--wv-tint);
}

.wv-card-media > img,
.wv-card-media > video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---- Text + actions (shared) ---- */

.wv-card-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.wv-card-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.wv-card-sub {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.65;
}

.wv-card-sub a,
.wv-card-desc a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.wv-card-desc a {
    text-decoration-color: var(--highlight-pip);
    text-decoration-thickness: 2px;
}

.wv-card-title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--fs-prose-h4);
    line-height: 1.15;
}

.wv-card-desc {
    margin: 2px 0 0;
    font-size: 1rem;
    line-height: var(--lh-body);
    opacity: 0.85;
    text-wrap: pretty;
}

/* Phones: the site's prose tuning (taller lowercase), like the bio. */
@media (max-width: 768px) {
    .wv-card-desc {
        font-size: var(--fs-ui);
        font-variation-settings: 'YTLC' 500, 'wdth' 100;
    }
}

.wv-card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.wv-card-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

/* Phones only (see the 720px block below). */
.wv-card-nav--float {
    display: none;
}

.wv-card-step,
.wv-card-close {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(55, 44, 9, 0.07);
    color: inherit;
    cursor: pointer;
}

.wv-card-close {
    position: absolute;
    top: calc(var(--pad) + 10px);
    right: calc(var(--pad) + 10px);
    z-index: 3;
    color: var(--text-color);
    background: color-mix(in srgb, var(--bg-color) 90%, transparent);
    box-shadow: 0 2px 10px rgba(30, 24, 5, 0.18);
}

.wv-card-count {
    min-width: 56px;
    font-size: 0.9rem;
    font-variant-numeric: tabular-nums;
    text-align: center;
    opacity: 0.6;
}

.wv-card-link {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 38px;
    padding: 0 12px 0 16px;
    border-radius: 999px;
    background: var(--text-color);
    color: var(--bg-color);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    text-decoration: none;
    white-space: nowrap;
}

.wv-card-link .material-icons {
    font-size: 20px;
}

.wv-card-link[hidden] {
    display: none;
}

/* In place of the link while a case study is still being written - the same lock and
   wording as Featured's "Coming Soon!" badge, muted like the list's. */
.wv-card-soon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    opacity: 0.6;
}

.wv-card-soon .material-icons {
    font-size: 18px;
}

.wv-card-soon[hidden] {
    display: none;
}

.wv-card :focus-visible {
    outline: 3px solid var(--highlight-yellow);
    outline-offset: 2px;
}

@media (hover: hover) {
    .wv-card-step:hover,
    .wv-card-close:hover {
        background: rgba(55, 44, 9, 0.14);
    }

    .wv-card-link:hover {
        opacity: 0.88;
    }
}

/* ---- Layout: media as large as the screen allows on a dark stage; text beside it
   (wide screens) or below it (narrow). The stage itself is the card - no panel edge. ---- */

.wv-card {
    --card-w: 100%;
    padding: 24px;
}

.wv-card::backdrop {
    background: rgba(20, 16, 4, 0.92);
}

.wv-card .wv-card-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) min(380px, 34vw);
    align-items: end;
    gap: 24px;
    min-height: 100%;
    padding: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
}

.wv-card .wv-card-media {
    align-self: center;
    justify-self: center;
    width: min(100%, calc((100dvh - 48px) * var(--ar)), var(--nat-w, 9999px));
    border-radius: 10px;
}

.wv-card .wv-card-panel {
    max-height: calc(100dvh - 48px);
    padding: 16px;
    border-radius: 18px;
    background: var(--bg-color);
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    overflow-y: auto;
    box-sizing: border-box;
}

.wv-card .wv-card-close {
    top: 0;
    right: 0;
}

@media (max-width: 720px) {
    .wv-card {
        padding: 12px;
    }

    .wv-card .wv-card-inner {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 12px;
    }

    .wv-card .wv-card-media {
        width: min(100%, var(--nat-w, 9999px));
    }

    .wv-card .wv-card-panel {
        width: 100%;
        max-height: none;
        overflow: visible;
    }

    /* Swipe between items (workViewsCard.js); vertical scrolling stays native. Room at
       the bottom so the fixed nav never covers the panel's end. */
    .wv-card {
        touch-action: pan-y pinch-zoom;
        padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    }

    .wv-card .wv-card-media,
    .wv-card .wv-card-panel {
        will-change: transform;
    }

    /* The count + arrows leave the panel and sit fixed at the bottom right, outside the
       sliding card, so they stay in one place and only the count changes. */
    .wv-card .wv-card-panel .wv-card-nav {
        display: none;
    }

    .wv-card .wv-card-nav--float {
        display: flex;
        position: fixed;
        right: 12px;
        bottom: max(12px, env(safe-area-inset-bottom, 0px));
        z-index: 4;
        padding: 4px;
        border-radius: 999px;
        background: color-mix(in srgb, var(--bg-color) 92%, transparent);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
    }
}
