/* Lavori — galleria fotografica */
.works-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 24px;
  margin-bottom: 28px;
}

.works-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.works-count {
  margin: 0;
  font-size: 14px;
  color: var(--text-3);
}

.works {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.work {
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease);
}

.work.is-hidden {
  display: none;
}

.work-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
  color: inherit;
  overflow: hidden;
  cursor: pointer;
}

.work-open:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.work-media {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: linear-gradient(160deg, var(--bg-dark-2), var(--bg-dark));
}

.work-media img,
.work-media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s var(--ease-out);
}

.work-media video {
  pointer-events: none; /* il clic va al bottone della scheda, che apre il video a schermo intero */
}

.work-play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.work-play svg {
  width: 56px;
  height: 56px;
  padding: 14px;
  border-radius: 50%;
  background: rgba(6, 25, 43, 0.72);
  fill: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: transform var(--t) var(--ease);
}

.work-badge-video {
  left: auto;
  right: 12px;
}

.work-media svg {
  width: 62%;
  height: auto;
  opacity: 0.95;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.35));
}

.work-soon {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
}

.work-info {
  display: block;
  padding: 14px 16px 18px;
}

.work-tag {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sea);
}

.work-title {
  display: block;
  margin-top: 4px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
}

.work-meta {
  display: block;
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-3);
}

/* Nota tecnica: dentro la scheda, sotto titolo e luogo (fuori dal bottone: leggibile da tutti, compatta in griglia) */
.work-note {
  margin: 0;
  padding: 0 16px 18px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.work-place {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.flag-place {
  width: 16px;
  height: 11px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(14, 40, 68, 0.12);
  flex: none;
}

.lb-meta .flag-place {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
  vertical-align: -1px;
}

.works-empty {
  max-width: 520px;
  margin: 24px auto 0;
  padding: 40px 24px;
  border-radius: var(--radius-lg);
  background: var(--bg-alt);
  text-align: center;
}

.works-empty.hidden {
  display: none;
}

/* ---------- Visualizzazione a schermo intero ---------- */
.lightbox {
  width: 100vw;
  max-width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(6, 25, 43, 0.96);
  color: var(--text-inv);
}

.lightbox::backdrop {
  background: rgba(6, 25, 43, 0.9);
}

.lb-figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100%;
  margin: 0;
}

/* Riquadro della foto: occupa lo spazio libero sopra la didascalia (margini per chiudi e frecce) */
.lb-stage {
  position: relative;
  min-height: 0;
  margin: clamp(56px, 8vh, 72px) clamp(56px, 8vw, 96px) 12px;
}

/* foto e video centrati e ridotti per stare interi nel riquadro, qualunque sia lo schermo;
   la didascalia resta sotto, mai sopra la foto */
.lb-stage img,
.lb-stage video {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: #000;
}

.lb-stage .lb-art {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: min(100%, 560px);
  max-height: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, var(--bg-dark-2), rgba(6, 25, 43, 0));
  transform: translate(-50%, -50%);
}

.lb-stage .lb-art svg {
  width: 60%;
  height: auto;
}

.lb-caption {
  max-height: 40vh;
  max-height: 40dvh;
  overflow-y: auto; /* nota lunga su schermi bassi: scorre la didascalia, la foto resta intera */
  text-align: center;
  padding: 8px clamp(56px, 10vw, 120px) clamp(20px, 4vh, 36px);
}

.lb-tag {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sea-light);
}

.lb-title {
  display: block;
  margin-top: 4px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lb-meta {
  display: block;
  margin-top: 4px;
  font-size: 14px;
  color: #fff;
}

.lb-note {
  max-width: 640px;
  margin: 10px auto 0;
  font-size: 15px;
  color: #fff;
}

.lb-note:empty {
  display: none;
}

.lb-count {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.04em;
}

.lb-btn {
  position: fixed;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  transition: background var(--t) var(--ease), transform var(--t) var(--ease);
}

.lb-btn .icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.lb-close {
  top: 16px;
  right: 16px;
}

.lb-prev,
.lb-next {
  top: 50%;
  transform: translateY(-50%);
}

.lb-prev {
  left: 16px;
}

.lb-next {
  right: 16px;
}

.lightbox.is-single .lb-prev,
.lightbox.is-single .lb-next {
  display: none;
}

@media (max-width: 900px) {
  .works {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .works {
    grid-template-columns: 1fr;
  }

  .works-toolbar {
    justify-content: center;
    text-align: center;
  }

  .works-filters {
    justify-content: center;
  }

  .lb-stage {
    margin: 64px 12px 10px;
  }

  /* le frecce stanno in basso: la didascalia lascia loro la fascia sotto il testo */
  .lb-caption {
    padding: 4px 16px 76px;
  }

  .lb-prev,
  .lb-next {
    top: auto;
    bottom: 16px;
    transform: none;
  }
}

@media (hover: hover) and (pointer: fine) {
  .work:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
  }

  .work:hover .work-media img,
  .work:hover .work-media video {
    transform: scale(1.04);
  }

  .work:hover .work-play svg {
    transform: scale(1.08);
  }

  .lb-btn:hover {
    background: rgba(255, 255, 255, 0.24);
  }
}

@media (prefers-reduced-motion: reduce) {
  .work,
  .work-media img {
    transition: none;
  }
}
