/* Media section below the calendar (design/ribbon-and-media.md): the dark background carries on, the
   band's photos and videos sit in a masonry collage, and photos open in a full-screen viewer. */

.media {
    --pad-top: clamp(40px, 8vw, 72px);
    padding: var(--pad-top) var(--gutter) calc(64px + env(safe-area-inset-bottom, 0px));
    /* Reached from the ribbon, the heading lands just under it rather than a padding's height below. */
    scroll-margin-top: calc(16px - var(--pad-top));
    background: #08080a;
}

.media-inner {
    max-width: var(--content-max);
    margin: 0 auto;
}

/* The heading row is a .section-head (landing.css), with the Photos / Videos switch styled like the
   calendar's List / Month (calendar.css). */

.media-status {
    margin: 0 0 16px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
}

.media-status:empty { display: none; }

/* ---- Collage ------------------------------------------------------------------------------- */

/* media.js deals the tiles into these columns, each to the shortest one, so the newest stay on top. */
.media-grid {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.media-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Each tile keeps its picture's shape (media.js sets aspect-ratio from gallery.json), so nothing
   jumps as the pictures load. */
.media-tile {
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
}

.media-tile img,
.media-tile video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-tile video {
    object-fit: contain;
    background: #000;
}

button.media-tile {
    appearance: none;
    font: inherit;
    color: inherit;
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
}

button.media-tile img { transition: transform 0.3s ease; }

button.media-tile:hover img { transform: scale(1.03); }

/* A video's still frame with a round ▶ in the middle; the whole tile is the button. */
.media-play {
    appearance: none;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 0;
    padding: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.35) 100%);
    border: 0;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.media-play span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    padding-left: 5px;  /* the triangle's weight sits left of its box */
    font: 400 1.6rem/1 var(--font);
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    transition: transform 0.2s, background-color 0.2s;
}

.media-play:hover span {
    background: rgba(0, 0, 0, 0.6);
    transform: scale(1.06);
}

button.media-tile:focus-visible,
.media-play:focus-visible,
.media-tile video:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -3px;
}

/* ---- Photo viewer -------------------------------------------------------------------------- */

.viewer {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.94);
    outline: none;
    touch-action: pan-y pinch-zoom;  /* sideways swipes are media.js's, to move between photos */
}

.viewer[hidden] { display: none; }

.viewer-photo {
    display: block;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    border-radius: var(--radius);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
    -webkit-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

.viewer-btn {
    appearance: none;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0;
    padding: 0 0 4px;
    font: 400 2.2rem/1 var(--font);
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.viewer-btn:hover { background: rgba(255, 255, 255, 0.24); }

.viewer-btn:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* At the first or last photo there's nowhere to go that way. */
.viewer-btn:disabled { visibility: hidden; }

.viewer-prev {
    left: max(16px, env(safe-area-inset-left, 0px));
    top: 50%;
    margin-top: -24px;
}

.viewer-next {
    right: max(16px, env(safe-area-inset-right, 0px));
    top: 50%;
    margin-top: -24px;
}

.viewer-close {
    top: calc(env(safe-area-inset-top, 0px) + 16px);
    right: max(16px, env(safe-area-inset-right, 0px));
}

/* While the viewer is open the page behind doesn't scroll. */
body.viewer-open { overflow: hidden; }

/* Wide screens: room for the arrows beside the photo instead of over it. */
@media (min-width: 700px) {
    .viewer-photo { max-width: calc(100vw - 160px); }
}

@media (prefers-reduced-motion: reduce) {
    button.media-tile img,
    .media-play span { transition: none; }
}
