/* ============================================
   Dra. Ana Matumoto — Antes & Depois
   Editorial luxe · dark cinematic carousel
   Inherits tokens from hero.css (:root)
   ============================================ */

.gallery {
  position: relative;
  padding: clamp(110px, 14vh, 180px) clamp(20px, 4vw, 64px) clamp(96px, 12vh, 160px);
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  isolation: isolate;
}

.gallery::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 80% 0%,
      rgba(203, 163, 107, 0.07) 0%,
      transparent 60%),
    radial-gradient(ellipse 50% 35% at 10% 100%,
      rgba(203, 163, 107, 0.05) 0%,
      transparent 55%);
  pointer-events: none;
  z-index: -1;
}

.gallery-inner {
  max-width: 1280px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
.gallery-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 760px;
  margin: 0 auto clamp(56px, 7vh, 88px);
}

.eyebrow--gallery {
  margin-bottom: clamp(24px, 3.5vh, 36px);
}

.gallery-title {
  font-family: var(--f-display);
  font-weight: 350;
  font-size: clamp(38px, 5.4vw, 84px);
  line-height: 1;
  letter-spacing: -0.022em;
  color: var(--ink);
  font-variation-settings: "opsz" 144, "SOFT" 40;
}

.gallery-title em {
  font-style: italic;
  color: var(--accent-2);
  font-variation-settings: "opsz" 144, "SOFT" 100;
}

.gallery-title-line {
  display: block;
  margin-top: 0.08em;
  font-style: italic;
  color: var(--ink-soft);
  font-size: 0.62em;
  letter-spacing: -0.01em;
  font-variation-settings: "opsz" 72, "SOFT" 80;
}

.gallery-title .period {
  color: var(--accent);
  margin-left: -0.04em;
}

.gallery-lede {
  margin-top: clamp(22px, 3vh, 32px);
  max-width: 580px;
  font-size: clamp(15px, 1.05vw, 17.5px);
  line-height: 1.6;
  font-weight: 300;
  color: var(--ink-soft);
}

.gallery-lede strong {
  color: var(--ink);
  font-weight: 500;
}

.gallery-lede em {
  font-family: var(--f-display);
  font-style: italic;
  color: var(--accent-2);
  font-weight: 400;
}

/* ---------- Stage (arrows + viewport) ---------- */
.gallery-stage {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(16px, 3vw, 40px);
  max-width: 980px;
  margin: 0 auto;
}

.gallery-nav {
  position: relative;
  width: clamp(48px, 4.5vw, 58px);
  height: clamp(48px, 4.5vw, 58px);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: rgba(10, 8, 7, 0.4);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.4s var(--ease), color 0.4s var(--ease), transform 0.4s var(--ease), background 0.4s var(--ease);
  z-index: 3;
}

.gallery-nav svg {
  width: 16px;
  height: 12px;
  transition: transform 0.4s var(--ease);
}

.gallery-nav:hover {
  border-color: var(--accent);
  color: var(--accent-2);
  background: rgba(203, 163, 107, 0.08);
}

.gallery-nav--prev:hover svg { transform: translateX(-3px); }
.gallery-nav--next:hover svg { transform: translateX(3px); }

.gallery-nav:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---------- Viewport / track ---------- */
.gallery-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 6%, #000 94%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, #000 6%, #000 94%, transparent 100%);
}

.gallery-track {
  display: flex;
  align-items: stretch;
  transition: transform 0.85s cubic-bezier(0.22, 0.61, 0.36, 1);
  touch-action: pan-y;
  cursor: grab;
  will-change: transform;
}

.gallery-track.is-dragging {
  transition: none;
  cursor: grabbing;
}

.gallery-slide {
  flex: 0 0 100%;
  width: 100%;
  padding: 0 clamp(8px, 1.5vw, 18px);
  display: flex;
  justify-content: center;
  opacity: 0.36;
  transform: scale(0.94);
  transition: opacity 0.85s var(--ease-out), transform 0.85s var(--ease-out), filter 0.85s var(--ease-out);
  filter: saturate(0.7);
}

.gallery-slide.is-active {
  opacity: 1;
  transform: scale(1);
  filter: saturate(1);
}

.gallery-frame {
  position: relative;
  width: 100%;
  max-width: 720px;
  aspect-ratio: 4 / 5;
  background: var(--bg-2);
  border-radius: 2px;
  overflow: hidden;
  box-shadow:
    0 1px 0 rgba(244, 238, 227, 0.06) inset,
    0 30px 80px -30px rgba(0, 0, 0, 0.8),
    0 12px 32px -12px rgba(0, 0, 0, 0.6);
}

.gallery-frame::before,
.gallery-frame::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 1px solid var(--accent);
  z-index: 3;
  opacity: 0;
  transition: opacity 0.6s var(--ease-out) 0.2s, transform 0.6s var(--ease-out) 0.2s;
}

.gallery-frame::before {
  top: 10px;
  left: 10px;
  border-right: none;
  border-bottom: none;
  transform: translate(-4px, -4px);
}

.gallery-frame::after {
  bottom: 10px;
  right: 10px;
  border-left: none;
  border-top: none;
  transform: translate(4px, 4px);
}

.is-active .gallery-frame::before,
.is-active .gallery-frame::after {
  opacity: 0.7;
  transform: translate(0, 0);
}

.gallery-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: contrast(1.03) saturate(0.96);
}

/* Center vertical divider — emphasizes the antes/depois split */
.gallery-frame .gallery-divider {
  position: absolute;
  top: 8%;
  bottom: 8%;
  left: 50%;
  width: 1px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(244, 238, 227, 0.42) 18%,
    rgba(244, 238, 227, 0.42) 82%,
    transparent 100%);
  transform: translateX(-50%);
  z-index: 2;
  pointer-events: none;
}

/* Labels — antes / depois chips */
.gallery-label {
  position: absolute;
  top: clamp(14px, 2.2vw, 22px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--f-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  padding: 7px 13px 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(10, 8, 7, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ink-soft);
  z-index: 3;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.7s var(--ease-out) 0.35s, transform 0.7s var(--ease-out) 0.35s;
}

.is-active .gallery-label {
  opacity: 1;
  transform: translateY(0);
}

.gallery-label::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-mute);
}

.gallery-label--before {
  left: clamp(14px, 2.2vw, 22px);
}

.gallery-label--after {
  right: clamp(14px, 2.2vw, 22px);
  color: var(--accent-2);
  border-color: rgba(203, 163, 107, 0.28);
}

.gallery-label--after::before {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Foot (counter, dots, progress) ---------- */
.gallery-foot {
  max-width: 980px;
  margin: clamp(40px, 5vh, 64px) auto 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: clamp(20px, 4vw, 56px);
}

.gallery-counter {
  display: inline-flex;
  align-items: baseline;
  gap: 14px;
  font-family: var(--f-display);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-soft);
  font-variation-settings: "opsz" 72, "SOFT" 100;
  justify-self: start;
}

.counter-current {
  font-size: clamp(38px, 4.5vw, 56px);
  line-height: 1;
  color: var(--ink);
}

.counter-divider {
  width: 32px;
  height: 1px;
  background: var(--line-strong);
  align-self: center;
  margin: 0 2px;
}

.counter-total {
  font-size: 17px;
  color: var(--ink-mute);
  letter-spacing: 0.04em;
}

.gallery-dots {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: center;
}

.gallery-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: none;
  background: rgba(244, 238, 227, 0.22);
  padding: 0;
  cursor: pointer;
  transition: background 0.4s var(--ease), transform 0.4s var(--ease);
}

.gallery-dot::after {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
}

.gallery-dot:hover {
  background: var(--ink-soft);
}

.gallery-dot.is-active {
  background: var(--accent);
  transform: scale(1.25);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.gallery-progress {
  position: relative;
  width: 100%;
  height: 1px;
  background: var(--line);
  overflow: hidden;
  justify-self: end;
  max-width: 220px;
}

.gallery-progress-bar {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-2) 100%);
  transform-origin: left center;
  transform: scaleX(0);
}

.gallery-progress-bar.is-running {
  animation: galleryProgress 6s linear forwards;
}

@keyframes galleryProgress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* ---------- Entrance reveal ---------- */
.gallery-head > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1s var(--ease-out), transform 1s var(--ease-out);
}

.gallery.is-revealed .gallery-head > *:nth-child(1) { opacity: 1; transform: translateY(0); transition-delay: 0.05s; }
.gallery.is-revealed .gallery-head > *:nth-child(2) { opacity: 1; transform: translateY(0); transition-delay: 0.18s; }
.gallery.is-revealed .gallery-head > *:nth-child(3) { opacity: 1; transform: translateY(0); transition-delay: 0.3s; }

.gallery-stage,
.gallery-foot {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.1s var(--ease-out) 0.4s, transform 1.1s var(--ease-out) 0.4s;
}

.gallery.is-revealed .gallery-stage,
.gallery.is-revealed .gallery-foot {
  opacity: 1;
  transform: translateY(0);
}

.gallery.is-revealed .gallery-foot {
  transition-delay: 0.55s;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .gallery-stage {
    grid-template-columns: 1fr;
  }

  .gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
  }

  .gallery-nav--prev { left: 4px; }
  .gallery-nav--next { right: 4px; }

  .gallery-viewport {
    -webkit-mask-image: none;
    mask-image: none;
  }

  .gallery-slide {
    padding: 0 8px;
  }

  .gallery-frame {
    aspect-ratio: 3 / 4;
    max-width: 520px;
  }

  .gallery-foot {
    grid-template-columns: auto auto;
    gap: 20px;
  }

  .gallery-progress {
    display: none;
  }

  .gallery-dots {
    justify-self: end;
  }
}

@media (max-width: 560px) {
  .gallery {
    padding: 80px 18px 64px;
  }

  .gallery-nav {
    width: 42px;
    height: 42px;
    background: rgba(10, 8, 7, 0.7);
  }

  .gallery-label {
    font-size: 9px;
    padding: 6px 11px 6px 9px;
    letter-spacing: 0.2em;
  }

  .counter-current { font-size: 34px; }
  .counter-divider { width: 22px; }
  .counter-total { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-track,
  .gallery-slide,
  .gallery-frame::before,
  .gallery-frame::after,
  .gallery-label,
  .gallery-progress-bar {
    transition: none !important;
    animation: none !important;
  }
}
