/* ==========================================================================
   Mosaic Gallery — Frontend
   ========================================================================== */

.mosgal-wrapper {
    --mosgal-columns: 4;
    --mosgal-gap: 10px;
    --mosgal-radius: 14px;
    --mosgal-ink: #1a1714;
    --mosgal-paper: #faf8f4;
    --mosgal-line: #e6e1d8;
    --mosgal-accent: #0f5075;
    --mosgal-muted: #8b8478;

    max-width: 1200px;
    margin: 6rem auto 2.5rem !important;
    padding: 0 16px;
    box-sizing: border-box;
    font-family: -apple-system, "Helvetica Neue", "Segoe UI", sans-serif;
    color: var(--mosgal-ink);
}

.mosgal-wrapper *,
.mosgal-wrapper *::before,
.mosgal-wrapper *::after {
    box-sizing: border-box;
}

/* --- Categoria / accordion ----------------------------------------------- */

.mosgal-category {
    border: 1px solid var(--mosgal-line);
    border-radius: var(--mosgal-radius);
    background: var(--mosgal-paper);
    margin-bottom: 14px;
    overflow: hidden;
    transition: box-shadow .25s ease;
}

.mosgal-category.is-open {
    box-shadow: 0 14px 40px -22px rgba(26, 23, 20, .45);
}

.mosgal-category__header {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 20px 24px;
    background: var(--mosgal-accent) !important;
    border: 0;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: #ffffff !important;
    transition: filter .2s ease;
}

.mosgal-category__header:hover {
    filter: brightness(1.07);
}

.mosgal-category__header:focus-visible {
    outline: 2px solid var(--mosgal-ink);
    outline-offset: -2px;
}

.mosgal-category__title {
    flex: 1 1 auto;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: -.01em;
    text-transform: uppercase;
}

.mosgal-category__count {
    flex: 0 0 auto;
    min-width: 28px;
    height: 28px;
    padding: 0 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    color: var(--mosgal-accent);
    background: #ffffff;
    border-radius: 999px;
}

.mosgal-category__chevron {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
    border-right: 2.5px solid #ffffff;
    border-bottom: 2.5px solid #ffffff;
    transform: rotate(45deg);
    transition: transform .3s ease;
}

.mosgal-category.is-open .mosgal-category__chevron {
    transform: rotate(-135deg);
}

.mosgal-category__panel {
    padding: 0 20px 20px;
}

.mosgal-category__desc {
    margin: 0 4px 16px;
    color: var(--mosgal-muted);
    font-size: .95rem;
    line-height: 1.55;
}

/* --- Griglia uniforme ----------------------------------------------------- */

.mosgal-mosaic {
    display: grid;
    grid-template-columns: repeat(var(--mosgal-columns), 1fr);
    gap: var(--mosgal-gap);
}

.mosgal-tile {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 8px;
    background: var(--mosgal-line);
    cursor: pointer;
    transform: translateZ(0);
}

.mosgal-tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .5s cubic-bezier(.2, .8, .2, 1);
}

.mosgal-tile__overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 55%, rgba(26, 23, 20, .35) 100%);
    opacity: 0;
    transition: opacity .3s ease;
}

.mosgal-tile:hover img {
    transform: scale(1.07);
}

.mosgal-tile:hover .mosgal-tile__overlay {
    opacity: 1;
}

.mosgal-tile:focus-visible {
    outline: 3px solid var(--mosgal-accent);
    outline-offset: 2px;
}

/* --- Stato vuoto ---------------------------------------------------------- */

.mosgal-empty {
    text-align: center;
    color: #8b8478;
    font-style: italic;
    padding: 2rem 0;
}

/* --- Lightbox ------------------------------------------------------------- */

.mosgal-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4vmin;
    background: rgba(15, 13, 11, .92);
    opacity: 0;
    visibility: hidden;
    transition: opacity .28s ease, visibility .28s ease;
}

.mosgal-lightbox.is-active {
    opacity: 1;
    visibility: visible;
}

.mosgal-lightbox__img {
    max-width: 100%;
    max-height: 82vh;
    border-radius: 6px;
    box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8);
    transform: scale(.94);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}

.mosgal-lightbox.is-active .mosgal-lightbox__img {
    transform: scale(1);
}

.mosgal-lightbox__caption {
    position: absolute;
    bottom: 3vmin;
    left: 50%;
    transform: translateX(-50%);
    max-width: 80%;
    text-align: center;
    color: #f3efe8;
    font-size: .9rem;
    letter-spacing: .02em;
}

.mosgal-lightbox__btn {
    position: absolute;
    background: rgba(255, 255, 255, .1);
    border: 0;
    color: #fff;
    cursor: pointer;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease;
}

.mosgal-lightbox__btn:hover {
    background: rgba(255, 255, 255, .25);
}

.mosgal-lightbox__close {
    top: 3vmin;
    right: 3vmin;
}

.mosgal-lightbox__prev {
    left: 3vmin;
    top: 50%;
    transform: translateY(-50%);
}

.mosgal-lightbox__next {
    right: 3vmin;
    top: 50%;
    transform: translateY(-50%);
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 900px) {
    .mosgal-mosaic {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 600px) {
    .mosgal-mosaic {
        grid-template-columns: repeat(2, 1fr);
        --mosgal-gap: 7px;
    }

    .mosgal-category__header {
        padding: 16px 18px;
    }

    .mosgal-category__title {
        font-size: 1rem;
    }

    .mosgal-lightbox__prev {
        left: 1vmin;
    }

    .mosgal-lightbox__next {
        right: 1vmin;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mosgal-wrapper *,
    .mosgal-lightbox * {
        transition: none !important;
    }
}
