/* The slideshow. Everything is sized by CSS rather than by JavaScript reading naturalWidth,
   which is what made the old viewer misbehave when clicks arrived faster than downloads. */

* { box-sizing: border-box; }

body {
    margin: 0;
    background: #000;
    color: #fff;
    font-family: Tahoma, Verdana, Geneva, sans-serif;
    overflow: hidden;
}

.stage {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.stage img,
.stage video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.stage img[hidden],
.stage video[hidden] { display: none; }

/* A quiet pulse while a picture is on its way, rather than a blank screen. */
.stage.loading::after {
    content: "";
    position: absolute;
    width: 2.5rem;
    height: 2.5rem;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

.nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.6rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
}

.nav:hover:not(:disabled) { background: rgba(255, 79, 163, 0.75); }
.nav:disabled { opacity: 0.2; cursor: default; }

.prev { left: 0.75rem; }
.next { right: 0.75rem; }

.close {
    position: fixed;
    top: 0.75rem;
    right: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    text-decoration: none;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    z-index: 10;
}

.close:hover { background: rgba(255, 79, 163, 0.75); }

.bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem 1rem;
    padding: 0.6rem 4.5rem;
    background: rgba(0, 0, 0, 0.6);
    font-size: 0.85rem;
    z-index: 10;
}

.caption { overflow-wrap: anywhere; }
.counter { color: #bbb; }
.download { color: #ff9ccb; }

@media (max-width: 640px) {
    .nav { width: 2.75rem; height: 2.75rem; font-size: 1.2rem; }
    .bar { padding: 0.6rem 0.75rem; }
}
