/* ==========================================================================
   Portfolio cards (additions to the .portfolio-* styles in custom.css)
   ========================================================================== */
.portfolio-media.pf-card {
    display: block;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
}

.portfolio-media.pf-card:focus-visible {
    outline: 2px solid var(--ink, #f4f2ec);
    outline-offset: 3px;
}

.portfolio-item:hover .portfolio-media.pf-card video {
    transform: scale(1.04);
}

.pf-card-play {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 54px;
    height: 54px;
    margin: -27px 0 0 -27px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(13, 13, 13, 0.45);
    border: 1px solid rgba(244, 242, 236, 0.35);
    color: var(--ink, #f4f2ec);
    font-size: 16px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.3s var(--ease, ease), transform 0.3s var(--ease, ease);
    pointer-events: none;
}

.pf-card-play i.fa-play {
    margin-left: 3px;
}

.pf-card-play--link {
    font-size: 15px;
}

.portfolio-item:hover .pf-card-play,
.pf-card:focus-visible .pf-card-play {
    opacity: 1;
    transform: scale(1);
}

/* Touch screens have no hover: keep a subtle play hint visible. */
@media (hover: none) {
    .pf-card-play {
        opacity: 0.85;
        transform: scale(0.8);
    }
}

.pf-card-count {
    position: absolute;
    right: 12px;
    top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(13, 13, 13, 0.55);
    color: var(--ink, #f4f2ec);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    pointer-events: none;
}

/* ==========================================================================
   Viewer
   ========================================================================== */
html.pf-lock,
html.pf-lock body {
    overflow: hidden !important;
}

.pf-viewer {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) 72px;
    grid-template-rows: 72px minmax(0, 1fr) auto;
    grid-template-areas:
        ". . close"
        "prev stage next"
        ". bar .";
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.pf-viewer.is-open {
    opacity: 1;
    visibility: visible;
}

.pf-viewer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 8, 10, 0.94);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.pf-viewer-close,
.pf-viewer-nav {
    position: relative;
    z-index: 2;
    align-self: center;
    justify-self: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid rgba(244, 242, 236, 0.25);
    background: rgba(244, 242, 236, 0.06);
    color: var(--ink, #f4f2ec);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.pf-viewer-close:hover,
.pf-viewer-nav:hover {
    background: rgba(244, 242, 236, 0.14);
    border-color: rgba(244, 242, 236, 0.5);
}

.pf-viewer-close:focus-visible,
.pf-viewer-nav:focus-visible,
.pf-viewer-link:focus-visible {
    outline: 2px solid var(--ink, #f4f2ec);
    outline-offset: 3px;
}

.pf-viewer-close { grid-area: close; }
.pf-viewer-nav--prev { grid-area: prev; }
.pf-viewer-nav--next { grid-area: next; }
.pf-viewer-nav[hidden] { display: none; }

.pf-viewer-stage {
    grid-area: stage;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    transform: translateY(12px) scale(0.985);
    transition: transform 0.35s var(--ease, ease);
}

.pf-viewer.is-open .pf-viewer-stage {
    transform: none;
}

.pf-viewer-stage.is-loading::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border-radius: 50%;
    border: 2px solid rgba(244, 242, 236, 0.2);
    border-top-color: var(--ink, #f4f2ec);
    animation: pf-spin 0.8s linear infinite;
    pointer-events: none;
}

@keyframes pf-spin {
    to { transform: rotate(360deg); }
}

.pf-viewer-video,
.pf-viewer-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    border-radius: 16px;
    background: #000;
}

.pf-viewer-video {
    width: 100%;
    height: auto;
    max-height: calc(100vh - 190px);
    max-height: calc(100dvh - 190px);
}

.pf-viewer-img {
    width: auto;
    height: auto;
    max-height: calc(100vh - 190px);
    max-height: calc(100dvh - 190px);
    object-fit: contain;
    background: transparent;
}

.pf-viewer-img-link {
    display: contents;
}

.pf-viewer-embed {
    position: relative;
    width: min(100%, calc((100vh - 190px) * 16 / 9));
    width: min(100%, calc((100dvh - 190px) * 16 / 9));
    aspect-ratio: 16 / 9;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
}

.pf-viewer-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.pf-viewer-bar {
    grid-area: bar;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 20px 0 28px;
}

.pf-viewer-meta {
    display: flex;
    align-items: baseline;
    gap: 14px;
    min-width: 0;
}

.pf-viewer-title {
    color: var(--ink, #f4f2ec);
    font-size: 16px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pf-viewer-counter {
    flex: none;
    color: var(--ink-dim, rgba(244, 242, 236, 0.6));
    font-size: 13px;
}

.pf-viewer-link {
    flex: none;
    text-decoration: none;
}

.pf-viewer-link[hidden] {
    display: none;
}

@media (max-width: 760px) {
    .pf-viewer {
        grid-template-columns: 16px minmax(0, 1fr) 16px;
        grid-template-rows: 64px minmax(0, 1fr) auto;
    }
    .pf-viewer-close {
        grid-column: 2 / 4;
        justify-self: end;
        margin-right: 16px;
    }
    /* Arrows sit over the media edges on phones (swipe also works). */
    .pf-viewer-nav {
        grid-area: stage;
        width: 40px;
        height: 40px;
        font-size: 15px;
        background: rgba(13, 13, 13, 0.55);
    }
    .pf-viewer-nav--prev { justify-self: start; margin-left: 6px; }
    .pf-viewer-nav--next { justify-self: end; margin-right: 6px; }
    .pf-viewer-video,
    .pf-viewer-img,
    .pf-viewer-embed {
        border-radius: 12px;
    }
    .pf-viewer-video,
    .pf-viewer-img {
        max-height: calc(100vh - 220px);
        max-height: calc(100dvh - 220px);
    }
    .pf-viewer-embed {
        width: 100%;
    }
    .pf-viewer-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        padding: 16px 0 24px;
    }
    .pf-viewer-meta {
        width: 100%;
    }
    .pf-viewer-title {
        white-space: normal;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pf-viewer,
    .pf-viewer-stage,
    .pf-card-play {
        transition: none !important;
    }
}
