/* Portfolio page — photo grid + lightbox (portafolio.html) */

.portfolio__lead {
  margin: -32px 0 56px;
  max-width: 560px;
  font-size: 19px;
  color: var(--muted);
}

/* ---------- Grid ---------- */
/* One tile per piñata; extra angles live in the lightbox. Desktop: 4 columns with a
   2x2 feature tile; the rainbow sits beside it as a square; below 1000px: 2 columns, feature spans both. */

.works {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 40px 32px;
}

.work {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.work--feature { grid-column: span 2; grid-row: span 2; }

.work__open {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--stripe);
  overflow: hidden;
  cursor: zoom-in;
  transition: border-color 0.15s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.work--feature .work__open { flex: 1 1 0; min-height: 0; aspect-ratio: auto; }
.works--cartoneria { align-items: center; }
.works--cartoneria .work--feature { grid-row: auto; align-self: start; }
.works--cartoneria .work--feature .work__open { flex: none; aspect-ratio: 5 / 6; }
.cartoneria__lead {
  grid-column: span 2;
  max-width: 420px;
  margin: 0;
  font-family: var(--serif);
  font-weight: 300;
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.3;
  color: var(--muted);
}
.cartoneria .section__title { margin-bottom: 40px; }
.work--square .work__open { aspect-ratio: 1 / 1; }

/* paper-layer lift on hover, in the accent colour */
.work__open:hover {
  border-color: var(--ink);
  transform: translate(-3px, -3px);
  box-shadow: 6px 6px 0 var(--accent);
}
.work__open:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.work__open img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.6, 0.2, 1);
}
.work__open:hover img { transform: scale(1.03); }

/* transparent cutout cover: a warm glow behind the piñata and a soft contact shadow */
.work--cutout .work__open {
  background:
    radial-gradient(circle at 50% 46%, rgba(245, 184, 46, 0.30), transparent 64%),
    var(--stripe);
}
.work--cutout .work__open img { filter: drop-shadow(0 10px 12px rgba(10, 10, 11, 0.22)); }

/* "3 fotos" tag on piñatas that have more than one angle */
.work__count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 11px 5px;
  border-radius: 999px;
  background: var(--header-bg-scrolled);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12px;
  line-height: 1.3;
  letter-spacing: 0.02em;
  backdrop-filter: blur(6px);
}
.work__count b { font-weight: 600; }

.work figcaption {
  margin-top: 14px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 20px;
  color: var(--muted);
  transition: color 0.15s ease;
}
.work:has(.work__open:hover) figcaption,
.work:has(.work__open:focus-visible) figcaption { color: var(--ink); }

/* gentle reveal while scrolling (class added by gallery.js) */
.reveal-ready .work {
  transition: opacity 0.6s ease var(--stagger, 0ms), transform 0.6s cubic-bezier(0.2, 0.6, 0.2, 1) var(--stagger, 0ms);
}
.reveal-ready .work:not(.is-visible) { opacity: 0; transform: translateY(18px); }

/* Current page marker in the nav */
.nav__link.is-current { color: var(--ink); }

@media (max-width: 999px) {
  .works { grid-template-columns: repeat(2, 1fr); gap: 32px 20px; }
  .work--feature .work__open { flex: none; aspect-ratio: 5 / 6; }
  .work--feature { grid-row: auto; }
  .cartoneria__lead { max-width: none; font-size: 20px; }
}
@media (max-width: 640px) {
  .portfolio__lead { margin: -16px 0 36px; font-size: 17px; }
  .work figcaption { font-size: 17px; margin-top: 10px; }
  .work__count { right: 6px; bottom: 6px; font-size: 11px; padding: 3px 9px 4px; }
  .work__open:hover { transform: none; box-shadow: none; }
}

/* ---------- Lightbox ---------- */

/* scrollbar-gutter keeps the page from jumping sideways when the scrollbar goes away */
html.lightbox-open { overflow: hidden; scrollbar-gutter: stable; }

.lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.lightbox:not([open]) { display: none; }
.lightbox::backdrop { background: rgba(10, 10, 11, 0.95); }

/* soft open: backdrop fades in, photo rises a few pixels */
.lightbox[open] { animation: lb-in 0.28s cubic-bezier(0.2, 0.6, 0.2, 1); }
.lightbox[open]::backdrop { animation: lb-fade 0.28s ease; }
@keyframes lb-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes lb-fade { from { opacity: 0; } }

.lightbox__figure {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 72px 72px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  touch-action: pan-y pinch-zoom;
}
.lightbox__img {
  display: block;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100% - 44px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  background: var(--bg);
  transition: filter 0.3s ease;
}
/* the small thumb shows right away, soft, until the full photo has loaded */
.lightbox__img.is-loading { filter: blur(6px); }
/* arrows slide the next photo in from the side it came from */
.lightbox__img.slide-next { animation: lb-slide-next 0.28s cubic-bezier(0.2, 0.6, 0.2, 1); }
.lightbox__img.slide-prev { animation: lb-slide-prev 0.28s cubic-bezier(0.2, 0.6, 0.2, 1); }
@keyframes lb-slide-next { from { opacity: 0; transform: translateX(28px); } }
@keyframes lb-slide-prev { from { opacity: 0; transform: translateX(-28px); } }
.lightbox__caption {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  color: #f4f1ea;
  text-align: center;
}
.lightbox__title {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 300;
  font-size: 20px;
  line-height: 1.2;
}
.lightbox__count {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: rgba(244, 241, 234, 0.6);
}

/* angles of the current piñata */
.lightbox__thumbs {
  display: flex;
  justify-content: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.lightbox__thumbs[hidden] { display: none; }
.lightbox__thumb {
  display: block;
  padding: 0;
  border: 1px solid rgba(244, 241, 234, 0.3);
  border-radius: 3px;
  background: none;
  overflow: hidden;
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.lightbox__thumb { background: rgba(244, 241, 234, 0.08); }
.lightbox__thumb img { display: block; width: 52px; height: 65px; object-fit: cover; }
.lightbox__thumb:hover { opacity: 1; }
.lightbox__thumb[aria-current="true"] { opacity: 1; border-color: #f4f1ea; }
.lightbox__thumb:focus-visible { outline: 2px solid #f4f1ea; outline-offset: 2px; }
.lightbox__figure.has-thumbs .lightbox__img { max-height: calc(100% - 132px); }

.lightbox__btn {
  position: absolute;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(244, 241, 234, 0.35);
  border-radius: 50%;
  background: rgba(10, 10, 11, 0.4);
  color: #f4f1ea;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.lightbox__btn:hover { border-color: #f4f1ea; background: rgba(10, 10, 11, 0.7); }
.lightbox__btn:focus-visible { outline: 2px solid #f4f1ea; outline-offset: 3px; }
.lightbox__close { top: 16px; right: 16px; font-size: 30px; }
.lightbox__prev  { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox__next  { right: 16px; top: 50%; transform: translateY(-50%); }

@media (max-width: 640px) {
  .lightbox__figure { padding: 64px 12px 20px; }
  .lightbox__title { font-size: 17px; }
  /* thumb-reach: arrows sit under the photo, swipe also works */
  .lightbox__prev, .lightbox__next { top: auto; bottom: 14px; transform: none; width: 44px; height: 44px; }
  .lightbox__prev { left: 14px; }
  .lightbox__next { right: 14px; }
  .lightbox__figure { padding-bottom: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  .lightbox[open], .lightbox[open]::backdrop,
  .lightbox__img.slide-next, .lightbox__img.slide-prev { animation: none; }
  .lightbox__img { transition: none; }
  .lightbox__img.is-loading { filter: none; }
  .work__open, .work__open img { transition: none; }
  .work__open:hover, .work__open:hover img { transform: none; }
}
