/* ══════════════════════════════════════════════
  04c - Galeria do estúdio
══════════════════════════════════════════════ */

html.gal-lock {
  overflow: hidden;
}

.gal {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: clamp(1rem, 3vw, 2.5rem);
  border: 0;
  background: transparent;
  color: var(--text-dark);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.gal[open] {
  display: grid;
  place-items: center;
}

.gal::backdrop {
  background: transparent;
}

.gal::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 10% 15%, rgba(var(--verde-claro-rgb), 0.38), transparent 42%),
    radial-gradient(circle at 92% 88%, rgba(var(--rosa-vivo-rgb), 0.2), transparent 45%),
    radial-gradient(circle at 70% 8%, rgba(var(--sol-rgb), 0.18), transparent 38%),
    rgba(var(--bege-claro-rgb), 0.88);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  opacity: 0;
  transition: opacity 0.5s var(--easing-expo);
}

.gal.is-open::before {
  opacity: 1;
}

.gal-shell {
  position: relative;
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 4.5rem);
}

.gal-close {
  position: fixed;
  z-index: 5;
  top: clamp(1rem, 2.5vw, 1.75rem);
  right: clamp(1rem, 2.5vw, 1.75rem);
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--white);
  color: var(--verde-profundo);
  box-shadow: 0 12px 30px -12px rgba(var(--verde-profundo-rgb), 0.45);
  cursor: pointer;
  opacity: 0;
  scale: 0.6;
  transition:
    opacity 0.4s var(--easing-expo) 0.2s,
    scale 0.5s var(--easing-back) 0.2s,
    rotate 0.4s var(--easing-expo),
    background-color 0.25s ease,
    color 0.25s ease;
}

.gal.is-open .gal-close {
  opacity: 1;
  scale: 1;
}

.gal-close:hover {
  rotate: 90deg;
  background: var(--terracota-medio);
  color: var(--white);
}

.gal-close [data-lucide],
.gal-close svg {
  width: 22px;
  height: 22px;
}

.gal-media {
  position: relative;
  justify-self: end;
  width: min(100%, calc(min(80dvh, 760px) * 0.75));
  opacity: 0;
  translate: 0 32px;
  scale: 0.96;
  transition:
    opacity 0.7s var(--easing-expo),
    translate 0.9s var(--easing-expo),
    scale 0.9s var(--easing-expo);
}

.gal-media::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 28px;
  background: linear-gradient(140deg, var(--verde-vivo) 0%, var(--sol) 100%);
  translate: 0 0;
  rotate: 0deg;
  transition:
    translate 1s var(--easing-expo) 0.25s,
    rotate 1s var(--easing-expo) 0.25s;
}

.gal.is-open .gal-media {
  opacity: 1;
  translate: 0 0;
  scale: 1;
}

.gal.is-open .gal-media::before {
  translate: 18px 18px;
  rotate: 2.5deg;
}

.gal-stage {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 24px;
  overflow: hidden;
  background: var(--menta);
  box-shadow: 0 40px 80px -40px rgba(var(--verde-profundo-rgb), 0.6);
  touch-action: pan-y;
}

.gal-slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  visibility: hidden;
}

.gal-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  -webkit-user-drag: none;
}

.gal-slide.is-active {
  z-index: 2;
  opacity: 1;
  visibility: visible;
}

.gal-slide.is-leaving {
  z-index: 1;
  opacity: 1;
  visibility: visible;
}

.gal-slide.is-active.from-next {
  animation: gal-wipe-next 0.95s var(--easing-expo) both;
}

.gal-slide.is-active.from-prev {
  animation: gal-wipe-prev 0.95s var(--easing-expo) both;
}

.gal-slide.is-active.from-next img,
.gal-slide.is-active.from-prev img {
  animation: gal-settle 1.2s var(--easing-expo) both;
}

.gal-slide.is-leaving img {
  animation: gal-recede 0.95s var(--easing-expo) both;
}

@keyframes gal-wipe-next {
  from { clip-path: inset(0 0 0 100%); }
  to   { clip-path: inset(0 0 0 0); }
}

@keyframes gal-wipe-prev {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 0 0 0); }
}

@keyframes gal-settle {
  from { scale: 1.14; }
  to   { scale: 1; }
}

@keyframes gal-recede {
  from { scale: 1; filter: brightness(1); }
  to   { scale: 0.94; filter: brightness(0.85); }
}

.gal-nav {
  position: absolute;
  z-index: 3;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  gap: 0.5rem;
}

.gal-arrow {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: rgba(var(--white-rgb), 0.9);
  color: var(--verde-profundo);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px -12px rgba(var(--verde-profundo-rgb), 0.5);
  cursor: pointer;
  transition:
    background-color 0.25s ease,
    color 0.25s ease,
    scale 0.3s var(--easing-back);
}

.gal-arrow:hover {
  background: var(--terracota-medio);
  color: var(--white);
  scale: 1.08;
}

.gal-arrow:active {
  scale: 0.94;
}

.gal-arrow svg {
  width: 20px;
  height: 20px;
}

.gal-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 26rem;
}

.gal-info > * {
  opacity: 0;
  translate: 0 18px;
  transition:
    opacity 0.7s var(--easing-expo),
    translate 0.8s var(--easing-expo);
}

.gal-info > .gal-cta {
  transition:
    opacity 0.7s var(--easing-expo),
    translate 0.8s var(--easing-expo),
    border-radius 0.5s cubic-bezier(0.23, 1, 0.32, 1),
    box-shadow 0.3s ease,
    transform 0.3s ease;
}

.gal.is-open .gal-info > * {
  opacity: 1;
  translate: 0 0;
}

.gal.is-open .gal-info > :nth-child(1) { transition-delay: 0.18s; }
.gal.is-open .gal-info > :nth-child(2) { transition-delay: 0.24s; }
.gal.is-open .gal-info > :nth-child(3) { transition-delay: 0.3s; }
.gal.is-open .gal-info > :nth-child(4) { transition-delay: 0.36s; }
.gal.is-open .gal-info > :nth-child(5) { transition-delay: 0.42s; }
.gal.is-open .gal-info > :nth-child(6) { transition-delay: 0.48s; }

.gal.is-closing *,
.gal.is-closing::before,
.gal.is-closing .gal-media::before {
  transition-delay: 0s !important;
  transition-duration: 0.3s !important;
}

.gal-eyebrow {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--verde-medio);
}

.gal-title {
  margin-top: 0.85rem;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3.6vw, 3rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--verde-profundo);
}

.gal-title em {
  font-style: normal;
  color: var(--terracota-escuro);
}

.gal-text {
  margin-top: 1.1rem;
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 1.1vw, 1.05rem);
  line-height: 1.7;
  color: var(--text-muted);
}

.gal-caption {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  width: 100%;
  margin-top: 2rem;
  padding-top: 1.1rem;
  border-top: 1px solid rgba(var(--verde-profundo-rgb), 0.14);
}

.gal-count {
  flex-shrink: 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 3.6em;
  color: var(--terracota-medio);
}

.gal-caption-text {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.45;
  flex: 1;
  min-height: calc(1.45em * 2);
  color: var(--text-dark);
  text-align: left;
}

.gal-thumbs {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.gal-thumb {
  width: 64px;
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--menta);
  cursor: pointer;
  opacity: 0.5;
  transition:
    opacity 0.3s ease,
    box-shadow 0.3s ease,
    translate 0.3s var(--easing-expo);
}

.gal-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gal-thumb:hover {
  opacity: 0.85;
  translate: 0 -3px;
}

.gal-thumb.is-current {
  opacity: 1;
  box-shadow:
    0 0 0 2px var(--bege-claro),
    0 0 0 4px var(--terracota-medio);
}

.gal-cta {
  margin-top: 2rem;
}

.gal button:focus-visible,
.gal a:focus-visible {
  outline: 3px solid var(--sol);
  outline-offset: 3px;
}

@media (max-width: 860px) {
  .gal {
    padding: 4.75rem 1.25rem 2rem;
  }

  .gal[open] {
    place-items: start center;
  }

  .gal-shell {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .gal-media {
    justify-self: center;
    width: min(100%, calc(50dvh * 0.75));
  }

  .gal.is-open .gal-media::before {
    translate: 10px 10px;
    rotate: 2deg;
  }

  .gal-info {
    align-items: center;
    width: 100%;
    max-width: 30rem;
    margin-inline: auto;
    text-align: center;
  }

  .gal-text {
    display: none;
  }

  .gal-title {
    font-size: clamp(1.7rem, 7vw, 2.2rem);
  }

  .gal-title {
    margin-top: 0.5rem;
  }

  .gal-caption {
    justify-content: center;
    margin-top: 1rem;
    padding-top: 0.9rem;
  }

  .gal-thumbs {
    display: none;
  }

  .gal-cta {
    width: 100%;
    justify-content: center;
    margin-top: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gal *,
  .gal::before,
  .gal-media::before {
    transition: none !important;
    animation: none !important;
  }
}
