/**
 * Gallery Management System — homepage preview grid + Gallery archive
 * (hero/filter/masonry grid/load more). New file so main.css and the
 * existing assets/css/gallery.css (the embedded-gallery-component
 * styles, e.g. Experience/Room galleries) both stay untouched. Reuses
 * existing tokens/patterns (.overlay, .btn-whtapp, --radius-*) rather
 * than inventing new ones.
 *
 * Loaded after main.css via an explicit enqueue dependency (inc/enqueue.php).
 */

/* ---- Homepage Gallery preview ---- */
.tm-gallery-preview-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
}

.tm-gallery-preview-item {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: var(--radius-sm);
    aspect-ratio: 1 / 1;
}

.tm-gallery-preview-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform var(--transition-base);
}

.tm-gallery-preview-item:hover .tm-gallery-preview-image {
    transform: scale(1.08);
}

.tm-gallery-preview-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(22, 22, 22, 0);
    transition: background-color var(--transition-base);
}

.tm-gallery-preview-item:hover .tm-gallery-preview-overlay {
    background-color: rgba(22, 22, 22, 0.45);
}

.tm-gallery-preview-label {
    color: var(--pwhite);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.tm-gallery-preview-item:hover .tm-gallery-preview-label {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Gallery archive: hero (same pattern as .tm-contact-hero/.tm-about-hero) ---- */
.tm-gallery-hero {
    position: relative;
    min-height: 420px;
    display: flex;
    align-items: center;
    background-size: cover;
    background-position: center;
}

.tm-gallery-hero-content {
    position: relative;
    z-index: 1;
    width: 100%;
    padding: 60px 0;
}

.tm-gallery-hero-content h1 {
    margin: 0 0 12px;
}

/* ---- Gallery archive: category filter ---- */
.tm-gallery-filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 40px 0;
}

.tm-gallery-filter-pill {
    padding: 8px 20px;
    background-color: transparent;
    border: 1px solid var(--green);
    border-radius: var(--radius-full);
    color: var(--green);
    font-family: 'Montserrat', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
}

.tm-gallery-filter-pill:hover {
    background-color: var(--lgreen);
}

.tm-gallery-filter-pill.is-active {
    background-color: var(--green);
    border-color: var(--green);
    color: var(--pwhite);
}

/* ---- Gallery archive: masonry grid ----
   CSS columns, not a JS masonry library — items flow top-to-bottom per
   column at their own natural aspect ratio (no forced crop, unlike the
   fixed-height treatments elsewhere on the site), so there's nothing to
   reflow once an image loads: zero layout shift. */
.tm-gallery-masonry {
    column-count: 4;
    column-gap: 20px;
}

.tm-gallery-masonry-item {
    position: relative;
    display: block;
    break-inside: avoid;
    margin-bottom: 20px;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.tm-gallery-masonry-item[hidden] {
    display: none;
}

.tm-gallery-masonry-item .tm-gallery-item {
    position: relative;
    display: block;
}

.tm-gallery-masonry-thumb {
    width: 100%;
    height: auto;
    display: block;
    transition: transform var(--transition-base);
}

.tm-gallery-masonry-item:hover .tm-gallery-masonry-thumb {
    transform: scale(1.04);
}

.tm-gallery-masonry-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 24px 14px 12px;
    background: linear-gradient(to top, rgba(22, 22, 22, 0.75), rgba(22, 22, 22, 0));
    color: var(--pwhite);
    font-size: 13px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity var(--transition-base), transform var(--transition-base);
}

.tm-gallery-masonry-item:hover .tm-gallery-masonry-caption {
    opacity: 1;
    transform: translateY(0);
}

.tm-gallery-load-more[hidden] {
    display: none;
}

@media screen and (max-width: 991px) {
    .tm-gallery-preview-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .tm-gallery-masonry {
        column-count: 3;
    }
}

@media screen and (max-width: 767px) {
    .tm-gallery-hero {
        min-height: 320px;
    }

    .tm-gallery-preview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .tm-gallery-masonry {
        column-count: 2;
        column-gap: 12px;
    }

    .tm-gallery-masonry-item {
        margin-bottom: 12px;
    }
}

@media screen and (max-width: 479px) {
    .tm-gallery-masonry {
        column-count: 1;
    }
}
