/*
|--------------------------------------------------------------------------
| Ivrea Observatory · SkyCam gallery
|--------------------------------------------------------------------------
| Full-screen, accessible gallery for the recent SkyCam timeline.
*/

body.io-gallery-open {
    overflow: hidden !important;
}

.archive-item[data-skycam-gallery-item] {
    position: relative;
    cursor: zoom-in;
}

.archive-item[data-skycam-gallery-item]::after {
    content: "⤢";
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    color: #f8fafc;
    background: rgba(2, 6, 23, .66);
    border: 1px solid rgba(255,255,255,.16);
    box-shadow: 0 8px 24px rgba(0,0,0,.22);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.archive-item[data-skycam-gallery-item]:hover::after,
.archive-item[data-skycam-gallery-item]:focus-visible::after {
    opacity: 1;
    transform: translateY(0);
}

.io-skycam-gallery[hidden] {
    display: none !important;
}

.io-skycam-gallery {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: grid;
    place-items: center;
    padding: clamp(10px, 2.2vw, 28px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}

.io-skycam-gallery.is-open {
    opacity: 1;
    visibility: visible;
}

.io-gallery-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 10%, rgba(56,189,248,.12), transparent 36%),
        rgba(2, 6, 23, .88);
    backdrop-filter: blur(18px) saturate(.8);
    -webkit-backdrop-filter: blur(18px) saturate(.8);
}

.io-gallery-dialog {
    position: relative;
    width: min(1440px, 100%);
    height: min(920px, calc(100vh - clamp(20px, 4.4vw, 56px)));
    height: min(920px, calc(100dvh - clamp(20px, 4.4vw, 56px)));
    min-height: 420px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    border-radius: clamp(20px, 3vw, 34px);
    background:
        radial-gradient(circle at top right, rgba(56,189,248,.11), transparent 34%),
        linear-gradient(160deg, rgba(15,23,42,.98), rgba(3,9,20,.98));
    border: 1px solid rgba(255,255,255,.16);
    box-shadow: 0 38px 120px rgba(0,0,0,.58), inset 0 1px 0 rgba(255,255,255,.08);
    transform: translateY(12px) scale(.985);
    transition: transform .22s ease;
}

.io-skycam-gallery.is-open .io-gallery-dialog {
    transform: translateY(0) scale(1);
}

.io-gallery-header,
.io-gallery-footer {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px clamp(16px, 2.4vw, 28px);
}

.io-gallery-header {
    border-bottom: 1px solid rgba(255,255,255,.10);
}

.io-gallery-footer {
    border-top: 1px solid rgba(255,255,255,.10);
    color: #94a3b8;
    font-size: 12px;
    font-weight: 750;
}

.io-gallery-title-wrap {
    min-width: 0;
}

.io-gallery-kicker {
    display: block;
    margin-bottom: 4px;
    color: #7dd3fc;
    font-size: 10px;
    font-weight: 950;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.io-gallery-caption {
    display: block;
    overflow: hidden;
    color: #f8fafc;
    font-size: clamp(15px, 1.8vw, 20px);
    font-weight: 920;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.io-gallery-close,
.io-gallery-nav {
    appearance: none;
    border: 1px solid rgba(255,255,255,.15);
    color: #f8fafc;
    background: rgba(255,255,255,.075);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 12px 30px rgba(0,0,0,.18);
    cursor: pointer;
}

.io-gallery-close {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    font-size: 27px;
    line-height: 1;
}

.io-gallery-close:hover,
.io-gallery-nav:hover,
.io-gallery-close:focus-visible,
.io-gallery-nav:focus-visible {
    background: rgba(255,255,255,.14);
    border-color: rgba(186,230,253,.32);
    outline: none;
}

.io-gallery-stage {
    position: relative;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: stretch;
    overflow: hidden;
    padding: clamp(12px, 2vw, 24px) clamp(52px, 6vw, 86px);
    background:
        linear-gradient(45deg, rgba(255,255,255,.018) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.018) 75%),
        linear-gradient(45deg, rgba(255,255,255,.018) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.018) 75%);
    background-position: 0 0, 12px 12px;
    background-size: 24px 24px;
}

.io-gallery-media {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.io-gallery-image {
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    object-fit: contain;
    object-position: center center;
    filter: drop-shadow(0 26px 42px rgba(0,0,0,.42));
    opacity: 1;
    transform: scale(1);
    transition: opacity .16s ease, transform .16s ease;
    user-select: none;
    -webkit-user-drag: none;
}

.io-skycam-gallery.is-loading .io-gallery-image {
    opacity: .35;
    transform: scale(.992);
}

.io-gallery-nav {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 48px;
    height: 62px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    transform: translateY(-50%);
    font-size: 30px;
    line-height: 1;
}

.io-gallery-prev { left: 14px; }
.io-gallery-next { right: 14px; }

.io-gallery-counter {
    color: #e2e8f0;
    font-variant-numeric: tabular-nums;
    font-weight: 900;
}

.io-gallery-help {
    text-align: right;
}

@media (max-width: 720px) {
    .archive-item[data-skycam-gallery-item]::after {
        opacity: 1;
        transform: none;
    }

    .io-skycam-gallery {
        padding: 0;
    }

    .io-gallery-dialog {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        min-height: 100%;
        border-radius: 0;
        border: 0;
    }

    .io-gallery-header,
    .io-gallery-footer {
        padding: 13px 14px;
    }

    .io-gallery-stage {
        padding: 10px 46px;
    }


    .io-gallery-nav {
        width: 40px;
        height: 54px;
        border-radius: 15px;
        font-size: 26px;
    }

    .io-gallery-prev { left: 4px; }
    .io-gallery-next { right: 4px; }

    .io-gallery-help {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .io-skycam-gallery,
    .io-gallery-dialog,
    .io-gallery-image,
    .archive-item[data-skycam-gallery-item]::after {
        transition: none !important;
    }
}
