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

.media-grid {
    columns: 180px;
    column-gap: var(--space-md);
    margin: 0.5rem 0;
}

.media-tile {
    position: relative;
    break-inside: avoid;
    width: 100%;
    margin-bottom: var(--space-md);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    background: var(--bg-card-hover);
}

.media-tile .gallery-thumb {
    width: 100%;
    height: auto;
    display: block;
}

.media-tile .gallery-video {
    width: 100%;
    height: auto;
    display: block;
    background: #000;
    object-fit: contain;
}

.media-tile .gallery-audio {
    width: 100%;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

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

.media-tile .non-image .icon {
    font-size: 2rem;
    margin-bottom: 0.25rem;
}

.media-tile .non-image .name {
    font-size: 0.6875rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-tile .non-image .size {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.media-tile-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: var(--space-sm);
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent 45%, transparent 70%, rgba(0, 0, 0, 0.55));
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}

.media-tile:hover .media-tile-overlay,
.media-tile:focus-within .media-tile-overlay {
    opacity: 1;
}

.media-tile-overlay > * {
    pointer-events: auto;
}

.media-source-link {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--white);
    background: rgba(0, 0, 0, 0.5);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    text-decoration: none;
}

.media-source-link:hover {
    background: var(--accent);
}

.media-delete-btn,
.media-report-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: var(--white);
    font-size: 0.9375rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-delete-btn:hover,
.media-report-btn:hover {
    background: var(--danger);
}

.media-report-btn .label {
    display: none;
}

.media-tile.media-removing {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.media-tile-meta {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm);
    font-size: 0.6875rem;
    background: rgba(0, 0, 0, 0.55);
    color: var(--white);
}

.media-uploader {
    color: var(--white);
    font-weight: 600;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-uploader:hover {
    color: var(--accent);
}

.media-deleted-at {
    color: var(--text-secondary);
    flex-shrink: 0;
}

.media-tile-actions {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: rgba(0, 0, 0, 0.55);
}

.media-tile-actions .admin-inline-form {
    flex: 1;
}

.media-tile-actions .admin-btn {
    width: 100%;
    justify-content: center;
}

@media (hover: none) and (pointer: coarse) {
    .media-tile-overlay {
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .media-tile-overlay,
    .media-tile.media-removing {
        transition: none;
    }
}
