/* The site's one photo and video viewer, see shared/photo-viewer.js.

   The stacking scale it joins: header 1000, filter dialog 1100, guide reader
   2000, request tray 9999, this 11500, vibe reader 11600. */
.gq-pv { position: fixed; inset: 0; z-index: 11500; }

.gq-pv-bg {
    position: absolute;
    inset: 0;
    background: rgba(8, 20, 34, .95);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

/* The request tray is a basket and has no business floating over a photo. */
body.gq-pv-open .gqv2-tray { display: none; }

.gq-pv-box {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px clamp(16px, 4vw, 56px) 20px;
    font-family: 'Poppins', system-ui, sans-serif;
    animation: gqPvIn .18s ease-out both;
}

@keyframes gqPvIn {
    from { opacity: 0; transform: scale(.985); }
    to   { opacity: 1; transform: none; }
}

.gq-pv-bar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #fff;
}

.gq-pv-bar h3 {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gq-pv-count {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    color: rgba(255, 255, 255, .6);
}

.gq-pv-x,
.gq-pv-nav {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    transition: background .15s ease;
}

.gq-pv-x { width: 38px; height: 38px; background: rgba(255, 255, 255, .12); font-size: 16px; }
.gq-pv-nav { width: 46px; height: 46px; background: rgba(255, 255, 255, .14); font-size: 18px; }
.gq-pv-x:hover { background: rgba(255, 255, 255, .26); }
.gq-pv-nav:hover { background: rgba(255, 255, 255, .3); }
.gq-pv-nav[hidden] { display: none; }

/* min-height:0 keeps a tall photo from pushing the strip off the screen. */
.gq-pv-row {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    gap: clamp(8px, 2vw, 20px);
}

.gq-pv-stage {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    position: relative;
    align-self: stretch;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
    container-type: size;
}

/* Fitted to an absolute box because a percentage max-height does not resolve
   against a height that comes from flex. */
.gq-pv-stage img,
.gq-pv-stage iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.gq-pv-stage iframe { border-radius: 12px; }
.gq-pv-stage img { object-fit: contain; transition: opacity .35s ease; }

/* Sized to the picture rather than the frame, so the corners land on the photo.
   --r is its width over height, set by the script once the shape is known. */
.gq-pv-stage img.is-fit {
    width: min(100cqw, calc(100cqh * var(--r)));
    height: auto;
    aspect-ratio: var(--r);
    margin: auto;
    border-radius: 12px;
}

.gq-pv-stage img.is-soft { filter: blur(12px); pointer-events: none; }
.gq-pv-stage img.is-loading { opacity: 0; }

/* The fade waits a moment so a quick load never flashes it. */
.gq-pv-spin {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    margin: -22px 0 0 -22px;
    border: 4px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 6px rgba(9, 22, 37, .35);
    pointer-events: none;
    animation: gqPvSpin .8s linear infinite, gqPvFade .2s ease .2s both;
}

@keyframes gqPvSpin { to { transform: rotate(360deg); } }
@keyframes gqPvFade { from { opacity: 0; } to { opacity: 1; } }

/* Centred with auto margins: justify-content:center cuts off the first
   thumbnails once the row is wider than the screen. Padding leaves room for
   the selected thumbnail's ring. */
.gq-pv-strip {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 5px;
    scrollbar-width: thin;
}

.gq-pv-strip button {
    position: relative;
    flex: 0 0 auto;
    width: 74px;
    height: 50px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    overflow: hidden;
    background: none;
    cursor: pointer;
    opacity: .45;
    outline: 2px solid transparent;
    outline-offset: 2px;
    transition: opacity .15s ease, outline-color .15s ease;
}

.gq-pv-strip button:first-child { margin-left: auto; }
.gq-pv-strip button:last-child { margin-right: auto; }
.gq-pv-strip button:hover { opacity: .8; }
.gq-pv-strip button.is-on { opacity: 1; outline-color: var(--gq-orange); }
.gq-pv-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }

.gq-pv-play {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    font-size: 13px;
    color: #fff;
    background: rgba(0, 0, 0, .35);
}

@media (max-width: 760px) {
    .gq-pv-box { padding: 12px 10px 14px; gap: 10px; }
    .gq-pv-bar h3 { font-size: 14px; }

    /* Swiping does their job, and the photo gets the width. */
    .gq-pv-nav { display: none; }
}
