/* ESC – My Favorite Works: ogni regola è limitata al componente. */
.escfw-gallery {
  width: calc(100% - 32px);
  max-width: none;
  margin: 30px 16px;
  position: relative;
}
.escfw-gallery .escfw-grid {
  display: block;
  column-count: 3;
  column-gap: 16px;
}
.escfw-gallery .escfw-card {
  display: block;
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
  position: relative;
}
.escfw-gallery .escfw-open {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  text-decoration: none;
  line-height: 0;
  cursor: zoom-in;
}
.escfw-gallery .escfw-open:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}
.escfw-gallery .escfw-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border: 0;
  object-fit: contain;
  box-shadow: none;
  transform: none;
  opacity: 1;
}
.escfw-gallery .escfw-section-title {
  text-align: center;
  margin: 0 0 24px;
  color: inherit;
}
@media (max-width: 992px) {
  .escfw-gallery .escfw-grid { column-count: 2; }
}
@media (max-width: 576px) {
  .escfw-gallery .escfw-grid { column-count: 1; }
}
/* Griglia di fallback per la variante compatta: quattro colonne anche senza JS. */
.escfw-gallery .escfw-grid[data-escfw-compact="1"] { column-count: 4; }
@media (max-width: 992px) {
  .escfw-gallery .escfw-grid[data-escfw-compact="1"] { column-count: 2; }
}
@media (max-width: 576px) {
  .escfw-gallery .escfw-grid[data-escfw-compact="1"] { column-count: 1; }
}
/* JS progressivo: il layout classico rimane il fallback se lo script non parte.
   Le posizioni vengono applicate in un'unica passata senza cambiare i file immagine. */
.escfw-gallery .escfw-grid.escfw-grid-packed {
  column-count: auto;
  position: relative;
}
.escfw-gallery .escfw-grid.escfw-grid-packed .escfw-card {
  position: absolute;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  break-inside: auto;
  -webkit-column-break-inside: auto;
}
/* Anteprima con query privata: mai nascondere la griglia sul sito pubblico. */
body.escfw-private-preview .fotogenic_masonry_images { visibility: hidden !important; }
.escfw-gallery .escfw-lightbox {
  border: none;
  padding: 0;
  margin: auto;
  max-width: 100vw;
  max-height: 100dvh;
  width: 100vw;
  height: 100dvh;
  background: #101213;
  color: #fff;
  overflow: hidden;
}
.escfw-gallery .escfw-lightbox::backdrop { background: rgba(0,0,0,.91); }
.escfw-gallery .escfw-lightbox-inner {
  width: 100%; height: 100%; display: flex; align-items: center;
  justify-content: center; position: relative; padding: 32px 56px 46px;
  box-sizing: border-box;
}
.escfw-gallery .escfw-lightbox-media {
  min-width: 0; min-height: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; height: 100%; width: 100%;
}
.escfw-gallery .escfw-lightbox-image {
  display: block; width: auto; height: auto; max-width: 100%;
  max-height: calc(100dvh - 105px); object-fit: contain; box-shadow: none;
}
.escfw-gallery .escfw-lightbox-caption {
  font-size: 13px; line-height: 1.4; font-family: inherit; margin-top: 12px; color: #e1e1e1;
  text-align: center; min-height: 18px;
}
.escfw-gallery .escfw-close, .escfw-gallery .escfw-prev, .escfw-gallery .escfw-next {
  position: absolute; z-index: 1; border: 0; background: rgba(0,0,0,.15);
  color: #fff; cursor: pointer; font: 300 36px/1 Arial, sans-serif;
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 50px; padding: 0;
}
.escfw-gallery .escfw-close { right: 12px; top: 10px; font-size: 30px; }
.escfw-gallery .escfw-prev { left: 6px; top: 50%; transform: translateY(-50%); }
.escfw-gallery .escfw-next { right: 6px; top: 50%; transform: translateY(-50%); }
.escfw-gallery .escfw-lightbox button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
@media (max-width: 576px) {
  .escfw-gallery .escfw-lightbox-inner { padding: 52px 34px 40px; }
  .escfw-gallery .escfw-lightbox-image { max-height: calc(100dvh - 115px); }
  .escfw-gallery .escfw-prev, .escfw-gallery .escfw-next { width: 32px; }
}

/* Solo immagini ESC: riduce drag e menu da pressione prolungata su mobile.
   Non impedisce download tramite rete, screenshot o cache del browser. */
.escfw-gallery .escfw-image,
.escfw-gallery .escfw-lightbox-image {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}


/* v0.3.3 — Hover con tempi Gallery (0.5s ease): oscuramento invariato.
   v0.3.2 — Hover cinematografico sulle SOLE miniature ESC.
   Nessun effetto su dimensioni delle card, Masonry o immagini nella lightbox. */
.escfw-gallery .escfw-card .escfw-open {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.escfw-gallery .escfw-card .escfw-image {
  transform: scale(1);
  transform-origin: center center;
  transition: transform 500ms ease;
}
.escfw-gallery .escfw-card .escfw-open::after {
  content: '';
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, .16);
  opacity: 0;
  transition: opacity 500ms ease;
}
/* Mouse/trackpad: zoom morbido + lieve oscuramento senza tagliare foto originali. */
@media (hover: hover) and (pointer: fine) {
  .escfw-gallery .escfw-card .escfw-open:hover .escfw-image {
    transform: scale(1.045);
  }
  .escfw-gallery .escfw-card .escfw-open:hover::after {
    opacity: 1;
  }
}
/* Tastiera: stesso feedback quando il link della foto ha il focus. */
.escfw-gallery .escfw-card .escfw-open:focus-visible .escfw-image {
  transform: scale(1.045);
}
.escfw-gallery .escfw-card .escfw-open:focus-visible::after {
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .escfw-gallery .escfw-card .escfw-image,
  .escfw-gallery .escfw-card .escfw-open::after {
    transition: none;
  }
}
