/* ==========================================================================
   OPERE FILTRI
   Lavora con le classi generate da opere-filtri.js e la struttura HTML del blocco.
   Usa le variabili CSS di WordPress (theme.json).
   ========================================================================== */

/* ── ROOT ─────────────────────────────────────────────────────────────────── */

.opere-filtri {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-block-start: 4rem !important;
  /* Spazio sopra il blocco, sovrascrive il margin del tema */

  /* ── BARRA SELEZIONE (riga con i dropdown trigger) ───────────────────── */
}

.opere-filtri .opere-filtri__selection {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
  }

@media (min-width: 1024px) {

.opere-filtri .opere-filtri__selection {
      flex-direction: row;
      justify-content: stretch;
  }
    }

/* ── GRUPPO (singolo dropdown) ────────────────────────────────────────── */

.opere-filtri .opere-filtri__gruppo {
    position: relative;

    /* Stato: gruppo aperto — evidenzia il trigger */

  }

.is-open:is(.opere-filtri .opere-filtri__gruppo) .opere-filtri__trigger {
        color: var(--wp--preset--color--base);
      }

:is(.is-open:is(.opere-filtri .opere-filtri__gruppo) .opere-filtri__trigger) .opere-filtri__arrow path {
          stroke: var(--wp--preset--color--base);
        }

/* ── TRIGGER (label trasformata in button dal JS) ─────────────────────── */

.opere-filtri .opere-filtri__trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: none;
    border-radius: 0;
    font-family: var(--wp--preset--font-family--body);
    font-size: var(--wp--preset--font-size--small);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--wp--preset--color--contrast);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.15s ease;
    line-height: 1;
  }

:is(.opere-filtri .opere-filtri__trigger):hover {
      color: var(--wp--preset--color--base);
    }

[aria-expanded="true"]:is(.opere-filtri .opere-filtri__trigger) .opere-filtri__arrow {
        transform: rotate(180deg);
      }

/* Freccia SVG dentro il trigger */

.opere-filtri .opere-filtri__arrow {
    flex-shrink: 0;
    transition: transform 0.2s ease;
  }

/* ── PANEL (lista bottoni filtro, aperto dal JS) ──────────────────────── */

.opere-filtri .opere-filtri__panel {
    visibility: hidden;
    position: relative;
    height: 0;
    width: 100%;
    top: 0;
    left: 0;
    z-index: 100;

    transition:
      visibility 0.2s ease,
      opacity 0.2s ease,
      height 0.3s ease;
    opacity: 0;
  }

.is-open:is(.opere-filtri .opere-filtri__panel) {
      visibility: visible;
      height: auto;
      opacity: 1;
      display: flex;
      gap: 0.3rem;
      padding: 1rem 0 0.5rem;
      flex-direction: column;
    }

#panel-artista.is-open:is(.opere-filtri .opere-filtri__panel) {
        flex-direction: column;
        gap: 1rem;
      }

:is(.opere-filtri .opere-filtri__panel) .opere-filtri__letter {
      font-size: var(--wp--preset--font-size--x-large);
      font-weight: 700;
    }

.is-open:is(.opere-filtri .opere-filtri__panel) .opere-filtri__btn {
        padding: 0.5rem 1rem 0 0.75rem;
        visibility: visible;
      }

/* ── BOTTONI FILTRO (dentro il panel) ─────────────────────────────────── */

.opere-filtri .opere-filtri__btn {
    display: inline-flex;
    position: relative;
    width: -moz-max-content;
    width: max-content;
    visibility: hidden;
    background: transparent;
    border: none;
    border-radius: 0;
    font-family: var(--wp--preset--font-family--body);
    font-size: var(--wp--preset--font-size--medium);
    font-weight: 500;
    color: var(--wp--preset--color--contrast);
    text-align: left;
    cursor: pointer;
    transition: background-color 0.1s ease;
    white-space: nowrap;
  }

:is(.opere-filtri .opere-filtri__btn)::after {
      content: "•";
      position: absolute;
      display: block;
      width: 0;
      height: 1.5px;
      left: 0;
      background-color: var(--wp--preset--color--base);
      transition: width 0.3s ease;
    }

:is(.opere-filtri .opere-filtri__btn):hover {
      color: var(--wp--preset--color--base);
    }

/* Stato: termine non disponibile per i filtri attivi */

.is-unavailable:is(.opere-filtri .opere-filtri__btn) {
      opacity: 0.3;
      pointer-events: none;
      cursor: default;
    }

/* Stato attivo — selezionato */

[aria-pressed="true"]:is(.opere-filtri .opere-filtri__btn) {
      color: var(--wp--preset--color--base);
    }

[aria-pressed="true"]:is(.opere-filtri .opere-filtri__btn)::after {
        content: "x";
      }

.is-unavailable:is(.opere-filtri .opere-filtri__alphabet-group) {
      opacity: 0.3;
      pointer-events: none;
      cursor: default;
    }

/* ── ACTIVE TAGS ──────────────────────────────────────────────────────── */

.opere-filtri .opere-filtri__active-tags {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 0;
  }

[hidden]:is(.opere-filtri .opere-filtri__active-tags) {
      display: none;
    }

/* Singolo tag */

.opere-filtri .opere-filtri__tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background-color: var(--wp--preset--color--base);
    border: 1px solid var(--wp--preset--color--base);
    border-radius: 999px;
    font-family: var(--wp--preset--font-family--body);
    font-size: var(--wp--preset--font-size--x-small);
    font-weight: 500;
    color: var(--wp--preset--color--contrast);
    cursor: pointer;
    transition:
      background-color 0.15s ease,
      color 0.15s ease;
    line-height: 1;
  }

:is(.opere-filtri .opere-filtri__tag):hover {
      background-color: var(--wp--preset--color--contrast);
      color: var(--wp--preset--color--base);
    }

:is(.opere-filtri .opere-filtri__tag):hover svg path {
        fill: var(--wp--preset--color--base);
        stroke: var(--wp--preset--color--base);
      }

/* ── RESET ────────────────────────────────────────────────────────────── */

.opere-filtri .opere-filtri__reset {
    align-self: flex-end;
    padding: 0;
    background: transparent;
    border: none;
    font-family: var(--wp--preset--font-family--body);
    font-size: var(--wp--preset--font-size--x-small);
    font-weight: 500;
    color: var(--wp--preset--color--contrast);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
    transition: color 0.15s ease;
  }

:is(.opere-filtri .opere-filtri__reset):hover {
      color: var(--wp--preset--color--contrast-2);
    }

[hidden]:is(.opere-filtri .opere-filtri__reset) {
      display: none;
    }

/* ── GRIGLIA CARD ─────────────────────────────────────────────────────── */

.opere-filtri .opere-filtri__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(343px, 1fr));
    gap: 2rem 1rem;
    padding-top: 32px;

    /* @media (max-width: 1024px) {
            grid-template-columns: repeat(2, 1fr);
            gap: 24px 16px;
        }

        @media (max-width: 768px) {
            grid-template-columns: 1fr;
            gap: 24px;
        } */
  }

/* ── FOOTER (load more + empty) ───────────────────────────────────────── */

.opere-filtri .opere-filtri__footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-top: 48px;
  }

/* Messaggio vuoto */

.opere-filtri .opere-filtri__empty {
    font-size: var(--wp--preset--font-size--medium);
    font-weight: 500;
    color: var(--wp--preset--color--contrast-2);
    margin: 0;
    text-align: center;
  }

[hidden]:is(.opere-filtri .opere-filtri__empty) {
      display: none;
    }

/* ── CARD ─────────────────────────────────────────────────────────────────── */
.opera-card__link:hover .opera-card__image {
      transform: scale(0.9);
    }
.opera-card__link:hover .opera-card__title,.opera-card__link:hover .opera-card__meta {
      opacity: 0.75;
    }
.opera-card__link .opera-card {
    display: flex;
    flex-direction: column;
  }
:is(.opera-card__link .opera-card) .figure-card {
      background-color: var(--wp--preset--color--base);
    }
:is(.opera-card__link .opera-card) .opera-card__image {
      display: block;
      width: 100%;
      height: auto;
      aspect-ratio: 1 / 1;
      -o-object-fit: cover;
         object-fit: cover;
      transition: transform 0.5s ease-in-out;
    }
:is(.opera-card__link .opera-card) .opera-card__body {
      padding-top: 0.75rem;
      display: flex;
      flex-direction: column;
      gap: 0.5rem;
    }
:is(.opera-card__link .opera-card) .opera-card__title {
      font-size: var(--wp--preset--font-size--x-large) !important;
      transition: opacity 0.3s ease;
    }
:is(.opera-card__link .opera-card) .opera-card__meta {
      font-size: var(--wp--preset--font-size--large) !important;
      font-weight: 700;
      text-transform: uppercase;
      color: var(--wp--preset--color--base);
      transition: opacity 0.3s ease;
      line-height: 105%;
    }

/* ── LOAD MORE ────────────────────────────────────────────────────────────── */

.opere-load-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 32px;
  background-color: transparent;
  border: 1.5px solid var(--wp--preset--color--contrast);
  border-radius: 0;
  font-family: var(--wp--preset--font-family--body);
  font-size: var(--wp--preset--font-size--small);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--wp--preset--color--contrast);
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.opere-load-more:hover {
    background-color: var(--wp--preset--color--contrast);
    color: var(--wp--preset--color--base);
  }

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

/* Stato loading */

.opere-load-more.is-loading {
    opacity: 0.5;
    pointer-events: none;
    cursor: default;
  }

.opere-load-more.is-loading::after {
      content: "";
      display: inline-block;
      width: 12px;
      height: 12px;
      border: 1.5px solid currentColor;
      border-top-color: transparent;
      border-radius: 50%;
      animation: opere-spin 0.6s linear infinite;
    }

@keyframes opere-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── RESPONSIVE: barra filtri su mobile ───────────────────────────────────── */

@media (max-width: 600px) {
  .opere-filtri__selection {
    flex-wrap: wrap;
  }

  .opere-filtri__trigger {
    padding: 10px 12px;
    font-size: var(--wp--preset--font-size--x-small);
  }

  .opere-filtri__panel {
    min-width: 180px;
  }

    .opere-filtri__panel.is-open {
      flex-direction: column;
    }
}
