/* retoor <retoor@molodetz.nl> */

.attachment-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0.75rem 0;
}

.attachment-gallery-item {
    position: relative;
    max-width: 240px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    background: var(--bg-card-hover);
}

.attachment-gallery-item:hover {
    transform: scale(1.05);
}

.attachment-gallery-item img {
    display: block;
    width: auto;
    height: auto;
    max-width: 240px;
    max-height: 200px;
}

.attachment-gallery.single .attachment-gallery-item:has(.gallery-thumb) {
    width: 100%;
    max-width: 100%;
}

.attachment-gallery.single .attachment-gallery-item:has(.gallery-thumb):hover {
    transform: none;
    border-color: var(--border-light);
}

.attachment-gallery.single .gallery-thumb {
    width: 100%;
    max-width: 100%;
    max-height: 480px;
    object-fit: contain;
}

.attachment-gallery-item:has(.non-image) {
    width: 120px;
    height: 120px;
}

.attachment-gallery-item:has(.gallery-video) {
    width: 100%;
    max-width: 480px;
    height: auto;
    aspect-ratio: 16 / 9;
    cursor: default;
    background: #000;
}

.attachment-gallery-item:has(.gallery-video):hover {
    transform: none;
}

.attachment-gallery-item .gallery-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.gallery-audio {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    display: block;
}

.attachment-gallery-item .non-image {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--text-secondary);
}

.attachment-gallery-item .non-image .icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.attachment-gallery-item .non-image .name {
    font-size: 0.6875rem;
    word-break: break-all;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-gallery-item .non-image .size {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.attachment-gallery-item .non-image:hover {
    color: var(--accent);
}

@media (max-width: 480px) {
    .attachment-gallery-item {
        max-width: 160px;
    }

    .attachment-gallery-item img {
        max-width: 160px;
        max-height: 140px;
    }

    .attachment-gallery-item:has(.non-image) {
        width: 80px;
        height: 80px;
    }
}
