/* === TNG Media Gallery Pro v1.3.0 === */

/* Grille standard */
.tng-media-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    justify-items: center;
    align-items: start;
    margin-top: 20px;
}

/* Masonry */
.tng-media-gallery-masonry {
    column-count: 3;
    column-gap: 20px;
}

.tng-media-gallery-masonry .tng-media-item {
    break-inside: avoid;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .tng-media-gallery-masonry { column-count: 2; }
}

@media (max-width: 560px) {
    .tng-media-gallery-masonry { column-count: 1; }
}

/* Galerie élégante (auto-fit) */
.tng-media-gallery-elegant {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--tng-min-width, 260px), 1fr));
    gap: 25px;
    margin-top: 20px;
}

/* Bloc */
.tng-media-item {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px;
    text-align: center;
    min-height: 260px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all .25s ease;
}

.tng-media-item:hover {
    filter: brightness(1.08);
    transform: translateY(-3px);
}

/* Image */
.tng-media-item img {
    display: block;
    margin: 0 auto 8px auto;
    border-radius: 4px;
    object-fit: contain;
}

/* Texte */
.tng-media-meta {
    font-size: 13px;
    color: #333;
}

.tng-media-title {
    font-weight: 600;
    margin-bottom: 4px;
}

.tng-media-person {
    font-style: italic;
    color: #666;
}

.tng-media-notice {
    padding: 10px 14px;
    border-left: 4px solid #d63638;
    background: #fcf0f1;
}

/* ==========================================================
   Cartes modernes
   ========================================================== */

.tng-media-gallery-modern {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.tng-media-gallery-modern .tng-media-item.tng-card {
    position: relative;
    aspect-ratio: 4 / 5;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 18px;
    overflow: hidden;
    background: #e5e7eb;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
    filter: none;
    transition: transform .35s cubic-bezier(.2, .7, .2, 1), box-shadow .35s ease;
    animation: tng-card-in .55s cubic-bezier(.2, .7, .2, 1) both;
    animation-delay: calc(var(--i, 0) * 45ms);
}

.tng-media-gallery-modern .tng-media-item.tng-card:hover,
.tng-media-gallery-modern .tng-media-item.tng-card:focus-within {
    transform: translateY(-6px);
    box-shadow: 0 16px 32px rgba(0, 0, 0, .22);
    filter: none;
}

.tng-media-gallery-modern .tng-card > a {
    display: block;
    width: 100%;
    height: 100%;
    color: #fff;
    text-decoration: none;
    outline-offset: -3px;
}

.tng-media-gallery-modern .tng-card img {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    object-fit: cover;
    transition: transform .6s cubic-bezier(.2, .7, .2, 1);
}

.tng-media-gallery-modern .tng-card:hover img,
.tng-media-gallery-modern .tng-card:focus-within img {
    transform: scale(1.07);
}

/* Légende en dégradé */
.tng-card-caption {
    position: absolute;
    inset: auto 0 0 0;
    display: block;
    padding: 56px 16px 14px;
    background: linear-gradient(to top, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .35) 55%, rgba(0, 0, 0, 0) 100%);
    text-align: left;
    pointer-events: none;
}

.tng-card-person {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .45);
}

/* Le titre se déplie au survol / au focus clavier */
.tng-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    font-size: 13px;
    line-height: 1.35;
    color: rgba(255, 255, 255, .88);
    transition: max-height .4s ease, opacity .3s ease, margin .3s ease;
}

.tng-card:hover .tng-card-title,
.tng-card:focus-within .tng-card-title {
    max-height: 4.5em;
    margin-top: 5px;
    opacity: 1;
}

/* Écrans tactiles : pas de survol, la légende est toujours complète */
@media (hover: none) {
    .tng-card-title {
        max-height: 4.5em;
        margin-top: 5px;
        opacity: 1;
    }
}

@keyframes tng-card-in {
    from { opacity: 0; transform: translateY(18px) scale(.97); }
    to   { opacity: 1; transform: none; }
}

@media (max-width: 560px) {
    .tng-media-gallery-modern {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .tng-card-caption { padding: 40px 10px 10px; }
    .tng-card-person  { font-size: 13px; }
    .tng-card-title   { font-size: 12px; }
}

/* Accessibilité : réduit les animations si demandé par l'utilisateur */
@media (prefers-reduced-motion: reduce) {
    .tng-media-gallery-modern .tng-media-item.tng-card,
    .tng-media-gallery-modern .tng-card img,
    .tng-card-title {
        animation: none;
        transition: none;
    }
    .tng-media-gallery-modern .tng-card:hover img,
    .tng-media-gallery-modern .tng-card:focus-within img {
        transform: none;
    }
}
