/* gallery.css - the Gallery page (js/gallery.js).
 *
 * v7 "Mission Control" (Oct 2026): the gallery is one console unit. The
 * picture sits in a rounded viewscreen (a FIXED 16:9 frame, so an odd-shaped
 * picture never makes the page jump; the whole picture is shown over a
 * blurred copy of itself). Under it a control strip: the picture count on a
 * small amber CRT, then the pill switches (Go to, Play, Full screen, Open
 * picture). Under that the thumbnails run in a recessed tray.
 * Colours are the v7 tokens only (css/root.css). The frame itself stays dark
 * in every theme: it is a screen.
 */

.gallery-wrapper {
    box-sizing: border-box;
    width: 100%;
    max-width: var(--page-w);
    margin: 0 auto;
    padding: 0.5rem var(--gutter) clamp(2.5rem, 5vw, 4rem);
}

.gal-viewer {
    /* As wide as the page allows, but never so tall that the frame and its
       controls don't fit on the screen together. */
    box-sizing: border-box;
    width: min(100%, calc((100vh - 15rem) * 16 / 9 + 2.6rem));
    min-width: min(100%, 320px);
    margin: 0 auto;
    padding: clamp(0.7rem, 1.6vw, 1.1rem);
    background: var(--sheet);
    border: 1px solid var(--rule);
    border-radius: calc(var(--r-panel) + 8px);
    box-shadow: 0 0 0 transparent;
}

@supports (height: 100svh) {
    .gal-viewer {
        width: min(100%, calc((100svh - 15rem) * 16 / 9 + 2.6rem));
    }
}

/* ------------------------------------------------------ Viewscreen */

.gal-frame {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: var(--crt);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.5);
}

/* Faint scan lines over the picture. */
.gal-frame::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(transparent, transparent);
    pointer-events: none;
}

.gal-frame img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.gal-frame .gal-blur {
    object-fit: cover;
    filter: blur(24px) brightness(0.45);
    transform: scale(1.12);
}

.gal-frame .gal-img {
    object-fit: contain;
    transition: opacity 0.25s ease;
}

.gal-frame.is-loading .gal-img {
    opacity: 0.35;
}

.gal-frame.is-empty img {
    display: none;
}

.gal-none {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    color: var(--phosphor);
    font-family: var(--font-crt);
    font-size: 1.8rem;
}

.gal-none[hidden] {
    display: none;
}

/* Previous / next: round pill buttons on the picture's sides. They stay
   light on the dark screen in every theme. */
.gal-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    transform: translateY(-50%);
    background: #F2F4F7;
    border: 2px solid #07090C;
    border-radius: 0;
    box-shadow: 0 3px 0 #07090C;
    color: #07090C;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.gal-nav:hover:not(:disabled),
.gal-nav:focus-visible {
    background: var(--s1);
    color: #07090C;
}

.gal-nav:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 2px;
}

.gal-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.gal-nav.prev {
    left: 14px;
}

.gal-nav.next {
    right: 14px;
}

.theme-contrast .gal-nav {
    background: #000;
    color: #fff;
    border-color: #fff;
    box-shadow: none;
}

/* ---------------------------------------------------- Control strip */

.gal-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem 1rem;
    margin-top: 0.8rem;
}

/* The count on a small CRT. */
.gal-counter {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: var(--control-h);
    min-width: 7.5rem;
    padding: 0 0.9rem;
    box-sizing: border-box;
    background: linear-gradient(var(--crt), var(--crt));
    border-radius: 0;
    box-shadow: inset 0 0 0 2px #000, inset 0 0 18px rgba(0, 0, 0, 0.8);
    color: var(--phosphor);
    font-family: var(--font-crt);
    font-size: 1.7rem;
    line-height: 1;
    letter-spacing: 0.04em;
    text-shadow: none;
    font-variant-numeric: tabular-nums;
}

.theme-contrast .gal-counter {
    background: #000;
    box-shadow: inset 0 0 0 2px #fff;
    color: #FFE000;
}

.gal-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
}

.gal-jump {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    color: var(--ink-2);
    font-weight: 500;
}

.gal-jump input {
    width: 5.2rem;
    height: var(--control-h);
    padding: 0 0.7rem;
    box-sizing: border-box;
    background: var(--sheet);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 0;
    font: 600 0.95rem var(--font-body);
    letter-spacing: 0;
}

.gal-jump input:focus-visible {
    outline: 1px solid var(--accent);
    outline-offset: 1px;
}

/* Pill switches, like .os-btn. */
.gal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    height: var(--control-h);
    min-width: 4rem;
    padding: 0 1.05rem;
    box-sizing: border-box;
    background: var(--sheet);
    color: var(--ink);
    border: 1px solid var(--rule);
    border-radius: 0;
    box-shadow: var(--shadow);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    letter-spacing: 0;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.15s ease;
    font-weight: 500;
}

.gal-btn:hover:not(:disabled),
.gal-btn:focus-visible {
    background: var(--sheet-2);
    color: var(--ink);
}

.gal-btn:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: none;
}

.gal-btn[aria-pressed="true"] {
    background: var(--solid);
    color: var(--on-solid);
}

.gal-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.gal-btn[hidden] {
    display: none;
}

#playBtn {
    min-width: 6.4rem;
}

.gal-hint {
    margin: 0.7rem 0.2rem 0;
    color: var(--ink-3);
    font-size: 0.85rem;
    text-align: left;
}

/* -------------------------------------------- The thumbnail tray */

.gal-strip {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.8rem;
    padding: 0.5rem;
    background: var(--sheet-3);
    border: 1px solid var(--rule);
    border-radius: 0;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-3) transparent;
}

.gal-strip:empty {
    display: none;
}

.gal-thumb {
    flex: 0 0 auto;
    width: 112px;
    aspect-ratio: 16 / 9;
    padding: 0;
    overflow: hidden;
    background: var(--crt);
    border: 2px solid transparent;
    border-radius: 0;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.gal-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gal-thumb:hover,
.gal-thumb:focus-visible {
    opacity: 1;
    outline: none;
    border-color: var(--ink-2);
}

.gal-thumb[aria-current="true"] {
    opacity: 1;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--rule);
}

/* --------------------------------------------------- Full screen
   The browser's own full screen where it has one, or the frame filling
   the window (iPhones). Escape or the X closes it. */
.gal-exit {
    display: none;
}

.gal-frame:fullscreen,
.gal-frame.is-full {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #000;
}

.gal-frame.is-full {
    position: fixed;
    inset: 0;
    z-index: 3000;
    height: 100dvh;
}

.gal-frame:fullscreen .gal-exit,
.gal-frame.is-full .gal-exit {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    background: #F2F4F7;
    border: 2px solid #07090C;
    border-radius: 0;
    box-shadow: 0 3px 0 #07090C;
    color: #07090C;
    font-size: 1.5rem;
    cursor: pointer;
}

body.gal-full-open {
    overflow: hidden;
}

/* --------------------------------------------------------- Admins */

.gal-admin {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1.2rem;
    margin: 1.4rem 0 0;
    padding: 1rem 1.2rem;
    background: var(--sheet-2);
    border: 1px dashed var(--rule);
    border-radius: 0;
}

.gal-admin p {
    flex: 1 1 20rem;
    margin: 0;
    text-align: left;
    color: var(--ink-2);
}

.gal-admin p strong {
    color: var(--ink);
}

/* ------------------------------------------------- Narrow screens */

@media (max-width: 640px) {
    .gal-viewer {
        padding: 0.55rem;
        border-radius: 0;
    }

    .gal-frame {
        border-radius: 0;
    }

    .gal-bar {
        justify-content: center;
    }

    .gal-counter {
        width: 100%;
        justify-content: center;
    }

    .gal-controls {
        display: grid;
        grid-template-columns: auto auto;
        justify-content: center;
    }

    .gal-jump input {
        width: 4.5rem;
    }

    .gal-nav {
        width: 40px;
        height: 40px;
    }

    .gal-nav.prev {
        left: 8px;
    }

    .gal-nav.next {
        right: 8px;
    }

    .gal-thumb {
        width: 88px;
    }
}

/* Picture band on a phone: root.css sets the title at 3rem, which is too
   wide in Michroma for a long word ("OFFICERS", "SPECIAL THANKS") at 390px.
   Scoped here until the shared rule is changed. */
@media (max-width: 560px) {
    main .bg-container:not(.bg-home) .bg-container-text h1 {
        font-size: clamp(1.6rem, 8vw, 2.4rem);
        overflow-wrap: anywhere;
    }

    main .bg-container:not(.bg-home) .bg-container-text p {
        font-size: 0.68rem;
    }
}
