/* =========================================================
   AGRITENUTA SAN FRANCESCO — Pagina Gallery
   File: wwwroot/css/gallery.css
   Dipende da: site.css
   ========================================================= */

/* ─────────────────────────────────────────────
   PAGE HERO — minimal, lascia spazio alle foto
───────────────────────────────────────────── */
.page-hero {
    position: relative;
    height: 44vh;
    min-height: 320px;
    margin-top: calc(var(--nav-h, 80px) * -1);
    padding-top: var(--nav-h, 80px);
    overflow: hidden;
    background: var(--dark);
    display: flex;
    align-items: flex-end;
}

.page-hero__bg {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(to bottom, rgba(0,0,0,.15) 0%, rgba(0,0,0,.78) 100%),
        url('/images/gallery/hero-gallery.jpg');
    background-size: cover;
    background-position: center 40%;
    transform: scale(1.03);
    animation: subtleZoom 22s ease-in-out infinite alternate;
}

@keyframes subtleZoom {
    from { transform: scale(1.03); }
    to   { transform: scale(1.07); }
}

.page-hero__grain {
    position: absolute;
    inset: 0;
    opacity: .04;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 180px;
}

.page-hero__content {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem 3.5rem;
    animation: fadeUp .9s .1s ease both;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

.page-hero__eyebrow {
    display: flex;
    align-items: center;
    gap: .9rem;
    font-size: .67rem;
    letter-spacing: .32em;
    text-transform: uppercase;
    color: var(--gold);
    margin-bottom: 1rem;
}
.page-hero__eyebrow::before {
    content: '';
    display: inline-block;
    width: 32px;
    height: 1px;
    background: var(--gold-40);
}

.page-hero__title {
    font-family: var(--font-display);
    font-size: clamp(3rem, 6vw, 5.5rem);
    font-weight: 300;
    color: var(--cream);
    line-height: .97;
    letter-spacing: -.02em;
}
.page-hero__title em { font-style: italic; color: #d6e59a; }

/* ─────────────────────────────────────────────
   CONTAINER
───────────────────────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* ─────────────────────────────────────────────
   FILTER TABS — sticky sotto hero
───────────────────────────────────────────── */
.gallery-filters {
    position: sticky;
    top: calc(var(--nav-h, 80px) - 12px);
    z-index: 50;
    background: rgba(20, 22, 16, .92);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--white-05);
}

.gallery-filters__inner {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.gallery-filters__inner::-webkit-scrollbar { display: none; }

.filter-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: .68rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--cream-45);
    padding: 1.1rem .9rem;
    border-bottom: 2px solid transparent;
    transition: color .2s ease, border-color .2s ease;
    white-space: nowrap;
}
.filter-btn:hover { color: var(--cream); }
.filter-btn.is-active {
    color: var(--cream);
    border-bottom-color: var(--gold);
}

.filter-count {
    display: inline-block;
    font-size: .58rem;
    background: rgba(201,162,39,.2);
    color: var(--gold);
    border-radius: 999px;
    padding: .1rem .45rem;
    margin-left: .3rem;
    vertical-align: middle;
}

/* ─────────────────────────────────────────────
   MASONRY GALLERY
───────────────────────────────────────────── */
.gallery-section {
    padding: 3rem 0 6rem;
}

/* Grid masonry CSS puro — 3 colonne */
.masonry-grid {
    columns: 3;
    column-gap: 3px;
    padding: 0;
}

.gallery-item {
    break-inside: avoid;
    margin-bottom: 3px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    display: block;
    background: #1a1c16;

    /* Animazione entrata */
    animation: itemFadeIn .5s ease both;
}

@keyframes itemFadeIn {
    from { opacity: 0; transform: scale(.97); }
    to   { opacity: 1; transform: scale(1); }
}

/* Nasconde gli elementi filtrati */
.gallery-item.is-hidden {
    display: none;
}

.gallery-item__img {
    width: 100%;
    display: block;
    aspect-ratio: var(--ratio, 4/3);
    background-size: cover;
    background-position: center;
    transition: transform .65s cubic-bezier(.25,1,.5,1);
}

/* Proporzioni variate per naturalezza visiva */
.gallery-item[data-ratio="tall"]   .gallery-item__img { aspect-ratio: 3/4; }
.gallery-item[data-ratio="wide"]   .gallery-item__img { aspect-ratio: 16/9; }
.gallery-item[data-ratio="square"] .gallery-item__img { aspect-ratio: 1/1; }
.gallery-item[data-ratio="std"]    .gallery-item__img { aspect-ratio: 4/3; }

/* Overlay hover */
.gallery-item__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.4rem;
    transition: background .35s ease;
}

.gallery-item:hover .gallery-item__img { transform: scale(1.05); }
.gallery-item:hover .gallery-item__overlay { background: rgba(0,0,0,.45); }

.gallery-item__meta {
    transform: translateY(8px);
    opacity: 0;
    transition: transform .3s ease, opacity .3s ease;
}
.gallery-item:hover .gallery-item__meta {
    transform: translateY(0);
    opacity: 1;
}

.gallery-item__caption {
    font-size: .80rem;
    color: var(--cream);
    letter-spacing: .05em;
    line-height: 1.4;
}

.gallery-item__tag {
    display: inline-block;
    margin-top: .4rem;
    font-size: .58rem;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--gold);
    border: 1px solid var(--gold-40);
    padding: .2rem .6rem;
    border-radius: 999px;
}

/* Icona zoom centrata */
.gallery-item__zoom {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(.7);
    opacity: 0;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    transition: opacity .3s ease, transform .3s ease;
    pointer-events: none;
}
.gallery-item:hover .gallery-item__zoom {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ─────────────────────────────────────────────
   LIGHTBOX
───────────────────────────────────────────── */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(10, 11, 8, .97);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity .35s ease, visibility 0s .35s;
}

.lightbox.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity .35s ease;
}

.lightbox__img-wrap {
    position: relative;
    max-width: 90vw;
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox__img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 40px 100px rgba(0,0,0,.6);
    transition: opacity .25s ease;
}

/* Fallback: se non c'è <img> reale, usa background */
.lightbox__bg-img {
    width: min(90vw, 1100px);
    height: min(82vh, 720px);
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 4px;
}

.lightbox__caption {
    position: absolute;
    bottom: -2.8rem;
    left: 0; right: 0;
    text-align: center;
    font-size: .78rem;
    letter-spacing: .12em;
    color: var(--cream-45);
}

/* Controlli */
.lightbox__close {
    position: fixed;
    top: 1.5rem;
    right: 1.8rem;
    background: none;
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cream-60);
    font-size: 1.1rem;
    cursor: pointer;
    transition: color .2s ease, border-color .2s ease;
    z-index: 10;
}
.lightbox__close:hover { color: var(--cream); border-color: rgba(255,255,255,.4); }

.lightbox__prev,
.lightbox__next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 50%;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--cream-60);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color .2s ease, border-color .2s ease, background .2s ease;
    z-index: 10;
}
.lightbox__prev { left: 1.5rem; }
.lightbox__next { right: 1.5rem; }
.lightbox__prev:hover,
.lightbox__next:hover {
    color: var(--cream);
    border-color: rgba(255,255,255,.35);
    background: rgba(255,255,255,.05);
}

/* Counter */
.lightbox__counter {
    position: fixed;
    bottom: 1.8rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: .70rem;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--cream-35);
    z-index: 10;
}

/* Thumbnail strip */
.lightbox__thumbstrip {
    position: fixed;
    bottom: 3.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 4px;
    z-index: 10;
    max-width: 90vw;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 8px;
}
.lightbox__thumbstrip::-webkit-scrollbar { display: none; }

.lightbox__thumb {
    flex-shrink: 0;
    width: 44px;
    height: 32px;
    border-radius: 3px;
    background-size: cover;
    background-position: center;
    opacity: .35;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: opacity .2s ease, border-color .2s ease;
}
.lightbox__thumb.is-active,
.lightbox__thumb:hover {
    opacity: 1;
    border-color: var(--gold);
}

/* ─────────────────────────────────────────────
   LOAD MORE
───────────────────────────────────────────── */
.gallery-loadmore {
    display: flex;
    justify-content: center;
    padding: 2rem 0 4rem;
}

.btn-loadmore {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    padding: .9rem 2.4rem;
    border-radius: 999px;
    border: 1px solid var(--gold-40);
    color: var(--gold);
    font-size: .74rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    background: none;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: background .25s ease, border-color .25s ease;
}
.btn-loadmore:hover { background: rgba(201,162,39,.1); border-color: var(--gold); }
.btn-loadmore.is-loading { opacity: .5; pointer-events: none; }

/* ─────────────────────────────────────────────
   CTA INSTAGRAM
───────────────────────────────────────────── */
.section-instagram {
    padding: 5rem 0 7rem;
    border-top: 1px solid var(--white-05);
    text-align: center;
}

.section-instagram h2 {
    font-family: var(--font-display);
    font-size: clamp(2rem, 3.5vw, 3rem);
    font-weight: 300;
    color: var(--cream);
    margin-bottom: .8rem;
}
.section-instagram h2 em { font-style: italic; color: #d6e59a; }

.section-instagram p {
    font-size: .95rem;
    color: var(--cream-60);
    margin-bottom: 2rem;
}

.btn-instagram {
    display: inline-flex;
    align-items: center;
    gap: .7rem;
    padding: .95rem 2.2rem;
    border-radius: 999px;
    background: rgba(201,162,39,.95);
    color: var(--dark);
    font-size: .76rem;
    letter-spacing: .18em;
    text-transform: uppercase;
    font-weight: 500;
    transition: transform .3s ease, background .25s ease;
    white-space: nowrap;
}
.btn-instagram:hover { transform: translateY(-2px); background: #d9b33d; }

/* ─────────────────────────────────────────────
   RESPONSIVE
───────────────────────────────────────────── */
@media (max-width: 1100px) {
    .masonry-grid { columns: 2; }
}

@media (max-width: 700px) {
    .masonry-grid { columns: 2; column-gap: 2px; }
    .gallery-item { margin-bottom: 2px; }
    .lightbox__prev { left: .5rem; }
    .lightbox__next { right: .5rem; }
    .lightbox__thumbstrip { display: none; }
}

@media (max-width: 480px) {
    .masonry-grid { columns: 1; }
    .container { padding: 0 1rem; }
}