/* Gallery-specific layout and native dialog styles. */
.gallery-toolbar {
    width: min(100%, 1400px);
    margin: 1.5rem auto 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.gallery-toolbar__note,
.gallery-status {
    margin: 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.95rem;
}

.gallery-status {
    flex: 1 1 100%;
    min-height: 1.4em;
}

.gallery-refresh {
    flex: 0 1 auto;
    min-height: 2.75rem;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 999px;
    padding: 0.55rem 1rem;
    color: #fff;
    background: rgba(0, 0, 0, 0.28);
    font: inherit;
    cursor: pointer;
}

/* Keep the gallery in place while the optional refresh control initializes. */
.gallery-refresh[hidden] {
    display: inline-block !important;
    visibility: hidden;
}

.gallery-refresh:hover:not(:disabled),
.gallery-refresh:focus-visible {
    background: rgba(255, 255, 255, 0.15);
}

.gallery-refresh:disabled {
    cursor: wait;
    opacity: 0.65;
}

.gallery-grid {
    width: min(100%, 1400px);
    min-width: 0;
    margin: 2.5rem auto;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
    gap: clamp(0.85rem, 2vw, 1.5rem);
}

.gallery-card {
    min-width: 0;
    margin: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 0.7rem;
    background: rgba(0, 0, 0, 0.24);
    box-shadow: 0 0.4rem 1.2rem rgba(0, 0, 0, 0.2);
}

.gallery-card__link {
    display: flex;
    min-width: 0;
    height: auto;
    flex-direction: column;
    color: inherit;
    text-decoration: none;
}

.gallery-card__link:hover .gallery-card__media,
.gallery-card__link:focus-visible .gallery-card__media {
    transform: scale(1.025);
}

.gallery-card__media {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 2;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.06);
    transition: transform 180ms ease;
}

.gallery-grid--digital-art .gallery-card__media {
    aspect-ratio: 1;
}

.gallery-card__caption {
    display: block;
    min-height: 3.5rem;
    padding: 0.8rem 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.95rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.gallery-dialog {
    width: min(94vw, 1050px);
    max-width: 1050px;
    max-height: min(92dvh, 900px);
    margin: auto;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 0.8rem;
    color: #fff;
    background: #121212;
    overflow: hidden;
}

.gallery-dialog::backdrop {
    background: rgba(0, 0, 0, 0.84);
}

.gallery-dialog__shell {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    max-height: min(92dvh, 900px);
    overflow: auto;
}

.gallery-dialog__image {
    display: block;
    width: 100%;
    height: min(72dvh, 650px);
    max-height: 72dvh;
    object-fit: contain;
    background: #080808;
}

.gallery-dialog__content {
    display: grid;
    gap: 0.55rem;
    padding: 1rem 1.25rem 1.25rem;
}

.gallery-dialog__title,
.gallery-dialog__post {
    margin: 0;
    overflow-wrap: anywhere;
}

.gallery-dialog__title {
    font-size: 1.15rem;
    line-height: 1.3;
}

.gallery-dialog__post {
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.95rem;
    line-height: 1.45;
    white-space: pre-wrap;
}

.gallery-dialog__close,
.gallery-dialog__nav {
    position: absolute;
    z-index: 1;
    display: inline-grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 50%;
    color: #fff;
    background: rgba(0, 0, 0, 0.68);
    font: inherit;
    cursor: pointer;
}

.gallery-dialog__close:hover,
.gallery-dialog__close:focus-visible,
.gallery-dialog__nav:hover:not(:disabled),
.gallery-dialog__nav:focus-visible {
    background: rgba(255, 255, 255, 0.2);
}

.gallery-dialog__close {
    top: 0.75rem;
    right: 0.75rem;
}

.gallery-dialog__nav {
    top: min(36dvh, 360px);
    transform: translateY(-50%);
}

.gallery-dialog__nav--previous {
    left: 0.75rem;
}

.gallery-dialog__nav--next {
    right: 0.75rem;
}

.gallery-dialog__nav:disabled {
    cursor: default;
    opacity: 0.35;
}

.gallery-dialog__open {
    justify-self: start;
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.gallery-dialog__open:hover,
.gallery-dialog__open:focus-visible {
    color: #cce8ff;
}

@media (max-width: 600px) {
    .gallery-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .gallery-refresh {
        width: 100%;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr));
    }

    .gallery-dialog {
        width: 100vw;
        max-width: none;
        max-height: 100dvh;
        border: 0;
        border-radius: 0;
    }

    .gallery-dialog__shell {
        max-height: 100dvh;
    }

    .gallery-dialog__image {
        height: 64dvh;
        max-height: 64dvh;
    }

    .gallery-dialog__nav {
        top: min(32dvh, 300px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .gallery-card__media {
        transition: none;
    }
}
