/* ======================================================
   VIEWER — immagini a schermo intero in stile HUD (viewer.js)
   ====================================================== */
.viewer {
    position: fixed;
    inset: 0;
    z-index: 8000;  /* sopra navbar e HUD, sotto warp e cursore */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: 'IBM Plex Mono', monospace;
}

.viewer[hidden] {
    display: none;
}

.viewer__backdrop {
    position: absolute;
    inset: 0;
    background:
        repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.25) 0 1px, transparent 1px 3px),
        rgba(3, 3, 3, 0.94);
}

/* ---------- Barra superiore ---------- */
.viewer__bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 22px var(--side-safe, 5rem);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.viewer__tag {
    display: flex;
    align-items: center;
    gap: 0.7em;
    color: #FF4D32;
}

.viewer__blink {
    width: 7px;
    height: 7px;
    background: currentColor;
    animation: viewer-blink 1.2s steps(1) infinite;
}

@keyframes viewer-blink {
    50% { opacity: 0; }
}

.viewer__counter {
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, 0.6);
}

.viewer__close,
.viewer__nav {
    padding: 6px 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

.viewer__close:hover,
.viewer__nav:hover {
    color: #FF4D32;
}

.viewer__close:focus-visible,
.viewer__nav:focus-visible {
    outline: 1px solid currentColor;
    outline-offset: 4px;
}

/* ---------- Immagine ---------- */
.viewer__stage {
    position: relative;
    z-index: 1;
    margin: 0;
    line-height: 0;
}

.viewer__img {
    display: block;
    width: auto;
    height: auto;
    max-width: 82vw;
    max-height: 74vh;  /* mai ingrandita oltre la sua misura reale */
}

.viewer__img[hidden] {
    display: none;
}

.viewer__stage.is-glitching .viewer__img {
    filter:
        drop-shadow(5px 0 0 rgba(255, 77, 50, 0.85))
        drop-shadow(-5px 0 0 rgba(0, 200, 255, 0.6));
}

/* angoli del mirino attorno all'immagine */
.viewer__corners i {
    position: absolute;
    width: 16px;
    height: 16px;
    border: 0 solid #FF4D32;
}

.viewer__corners i:nth-child(1) { top: -10px;    left: -10px;  border-top-width: 1px;    border-left-width: 1px; }
.viewer__corners i:nth-child(2) { top: -10px;    right: -10px; border-top-width: 1px;    border-right-width: 1px; }
.viewer__corners i:nth-child(3) { bottom: -10px; right: -10px; border-bottom-width: 1px; border-right-width: 1px; }
.viewer__corners i:nth-child(4) { bottom: -10px; left: -10px;  border-bottom-width: 1px; border-left-width: 1px; }

/* fascio di scansione a ogni cambio immagine */
.viewer__scan {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: #FF4D32;
    box-shadow: 0 0 12px 2px rgba(255, 77, 50, 0.7);
    opacity: 0;
    pointer-events: none;
}

.viewer__stage.is-scanning .viewer__scan {
    animation: viewer-scan 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes viewer-scan {
    0%   { top: 0;    opacity: 1; }
    85%  { opacity: 1; }
    100% { top: 100%; opacity: 0; }
}

/* ---------- Didascalia e frecce ---------- */
.viewer__caption {
    position: absolute;
    left: 50%;
    bottom: 26px;
    max-width: 70vw;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    transform: translateX(-50%);
}

.viewer__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    font-size: 0.75rem;
    transform: translateY(-50%);
}

.viewer__nav--prev { left: var(--side-safe, 5rem); }
.viewer__nav--next { right: var(--side-safe, 5rem); }

@media (max-width: 768px) {
    .viewer__img {
        max-width: 92vw;
        max-height: 66vh;
    }

    .viewer__nav {
        top: auto;
        bottom: 60px;
        transform: none;
    }

    .viewer__nav--prev { left: 1.25rem; }
    .viewer__nav--next { right: 1.25rem; }
}

@media (prefers-reduced-motion: reduce) {
    .viewer__blink {
        animation: none;
    }
}
