/* ============================================================
   GALERIA DE TREBALLS (treballs.html)
   ============================================================ */

/* la galeria ocupa gairebé tot l'ample de la pantalla, amb un marge petit als costats */
.gallery { padding: clamp(78px, 8vw, 110px) clamp(8px, 1.4vw, 22px) clamp(40px, 5vw, 80px); }
.gallery[hidden], .work-view[hidden] { display: none; }

.gallery__cats {
  padding: 0 clamp(16px, 6.3vw, 100px);
  display: flex; flex-wrap: wrap; gap: 6px 22px; margin-bottom: clamp(14px, 1.6vw, 24px);
  font: 400 clamp(14px, 1.3vw, 19px)/1 "TheBold", sans-serif; text-transform: uppercase;
}
.gallery__cats a { color: var(--red); text-decoration: none; padding-bottom: 4px; border-bottom: 3px solid transparent; }
.gallery__cats a:hover, .gallery__cats a[aria-current] { border-color: var(--blue); }

/* mosaic: les posicions les calcula gallery-layout.js (en %) */
.g-canvas { position: relative; width: 100%; }
.g-item {
  position: absolute; padding: 0; border: 0; background: rgba(255, 214, 122, .6);
  cursor: zoom-in; overflow: hidden;
  animation: rise .7s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(min(var(--i, 0), 14) * 60ms);
}
.g-item img {
  display: block; width: 100%; height: 100%; object-fit: cover;
  transition: transform .5s cubic-bezier(.2,.8,.2,1), filter .3s ease;
  -webkit-user-drag: none; user-select: none;
}
.g-item:hover img, .g-item:focus-visible img { transform: scale(1.035); }
.g-item:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }

/* ---------- vista d'una obra (carrusel) ---------- */
.work-view {
  min-height: 100svh;
  display: grid; justify-items: center; align-content: start;
  padding: clamp(66px, 6.5vw, 96px) 0 clamp(30px, 4vw, 60px);
  overflow: hidden;
}
.work-view__back {
  justify-self: start; margin: 0 0 clamp(6px, 1vw, 14px) clamp(16px, 4vw, 60px);
  border: 0; background: none; cursor: pointer; padding: 4px 0;
  color: var(--red); font: 700 clamp(14px, 1.2vw, 17px)/1 "Redaction 50", Georgia, serif;
}
.work-view__back:hover { text-decoration: underline; }
.work-view__stage {
  --stage-h: min(68svh, 72vw);   /* alçada de l'obra: hi ha d'haver lloc per al títol i el botó */
  position: relative; width: 100%;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: clamp(20px, 6vw, 110px);
  height: var(--stage-h);
}
.wv-main { margin: 0; display: grid; place-items: center; justify-self: center; }
.wv-main img {
  display: block; height: auto; width: auto;
  max-height: var(--stage-h); max-width: 64vw; object-fit: contain;
  box-shadow: 3px 4px 6px rgba(60, 0, 0, .3);
  -webkit-user-drag: none; user-select: none;
}
.wv-main img.is-in { animation: wv-in .45s cubic-bezier(.2,.8,.2,1); }
@keyframes wv-in { from { opacity: 0; transform: scale(.97); } }
/* passar a l'anterior / següent: còpies de les imatges que llisquen d'un lloc a l'altre (treballs.js) */
@property --m { syntax: "<percentage>"; inherits: false; initial-value: 100%; }
.work-view__stage.is-sliding > :not(.wv-ghosts) { visibility: hidden; }
.wv-ghosts { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.wv-ghost {
  position: absolute; overflow: hidden;
  -webkit-mask: linear-gradient(var(--to), #000 var(--m), transparent);
  mask: linear-gradient(var(--to), #000 var(--m), transparent);
}
.wv-ghost-shadow { position: absolute; box-shadow: 3px 4px 6px rgba(60, 0, 0, .3); }   /* la mateixa que .wv-main img */
.wv-ghost img { position: absolute; display: block; max-width: none; -webkit-user-drag: none; user-select: none; }
.work-view__title.is-slide, .work-view__title.is-slide + .work-view__buy { animation: wv-title .45s ease .08s both; }
@keyframes wv-title { from { opacity: 0; transform: translateY(6px); } }

/* les veïnes, desenfocades i mig tallades pels costats */
.wv-side {
  height: calc(var(--stage-h) * .82); border: 0; padding: 0; background: none; cursor: pointer;
  display: flex; align-items: center; overflow: hidden;
  filter: blur(5px); opacity: .75;
  transition: filter .3s ease, opacity .3s ease;
}
.wv-side img { height: 100%; width: auto; max-width: none; -webkit-user-drag: none; }
.wv-side--prev { justify-content: flex-end; -webkit-mask: linear-gradient(to left, #000 55%, transparent); mask: linear-gradient(to left, #000 55%, transparent); }
.wv-side--next { justify-content: flex-start; -webkit-mask: linear-gradient(to right, #000 55%, transparent); mask: linear-gradient(to right, #000 55%, transparent); }
.wv-side:hover, .wv-side:focus-visible { filter: blur(2px); opacity: .95; }
.wv-side[hidden] { visibility: hidden; display: flex; }

.work-view__title {
  margin: clamp(12px, 1.6vw, 22px) 0 0; padding: 0 16px; text-align: center;
  font: 700 clamp(20px, 2.4vw, 36px)/1.05 "Redaction 50", Georgia, serif; text-transform: uppercase; color: var(--red);
}
.work-view__buy {
  margin-top: clamp(8px, 1vw, 14px);
  padding: .45em 1em .4em; border-radius: .45em;
  background: var(--red); color: var(--pink); text-decoration: none;
  font: 700 clamp(12px, 1.1vw, 15px)/1 "Redaction 50", Georgia, serif; text-transform: uppercase;
  transition: filter .2s ease, transform .2s ease;
}
.work-view__buy:hover { filter: brightness(1.12); transform: translateY(-1px); }
.work-view__buy[hidden] { display: none; }

@media (max-width: 700px) {
  .work-view__stage { --stage-h: min(60svh, 110vw); gap: 10px; }
  .wv-main, .wv-main img { max-width: 76vw; }
  .wv-side { filter: blur(3px); }
}
@media (prefers-reduced-motion: reduce) {
  .g-item, .wv-main img.is-in, .work-view__title.is-slide,
  .work-view__title.is-slide + .work-view__buy { animation: none; }
}
