/* Galeria — mosaico bento + lightbox imersivo */

.gallery-stage {
  margin-top: var(--space-lg);
}

.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.gallery-hint {
  margin: 0;
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
}

.gallery-link-all {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-brand-purple);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.gallery-link-all:hover {
  border-bottom-color: currentColor;
}

[data-theme="dark"] .gallery-link-all {
  color: var(--color-brand-green);
}

/* Prévia na capa — 3 fotos + CTA (compacto) */
.gallery-mosaic--preview {
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr) minmax(0, 0.8fr);
  grid-template-rows: 1fr 1fr;
  grid-auto-flow: unset;
  grid-auto-rows: unset;
  gap: var(--space-md);
  height: clamp(240px, 30vw, 360px);
  max-height: 360px;
}

.gallery-mosaic--preview .gallery-tile--preview-main {
  grid-column: 1;
  grid-row: 1 / 3;
}

.gallery-mosaic--preview .gallery-tile--preview-top {
  grid-column: 2 / 4;
  grid-row: 1;
}

.gallery-mosaic--preview .gallery-tile--preview-mid {
  grid-column: 2;
  grid-row: 2;
}

.gallery-more-tile {
  grid-column: 3;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: var(--space-md);
  min-height: 100%;
  border-radius: var(--radius-xl);
  text-align: center;
  text-decoration: none;
  color: var(--color-brand-purple);
  background: linear-gradient(145deg, rgba(74, 41, 179, 0.08), rgba(50, 185, 71, 0.1));
  border: 2px dashed rgba(74, 41, 179, 0.35);
  transition:
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease,
    border-color 0.3s ease,
    background 0.3s ease;
}

.gallery-more-tile:hover,
.gallery-more-tile:focus-visible {
  outline: none;
  transform: translateY(-3px);
  border-color: var(--color-brand-purple);
  background: linear-gradient(145deg, rgba(74, 41, 179, 0.12), rgba(50, 185, 71, 0.14));
  box-shadow: var(--shadow-card-hover);
}

[data-theme="dark"] .gallery-more-tile {
  color: var(--color-brand-green);
  border-color: rgba(50, 185, 71, 0.4);
  background: linear-gradient(145deg, rgba(74, 41, 179, 0.15), rgba(50, 185, 71, 0.08));
}

.gallery-more-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: var(--radius-full);
  background: rgba(74, 41, 179, 0.12);
  color: var(--color-brand-purple);
}

[data-theme="dark"] .gallery-more-icon {
  background: rgba(50, 185, 71, 0.15);
  color: var(--color-brand-green);
}

.gallery-more-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  line-height: 1.2;
}

.gallery-more-desc {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  line-height: 1.35;
  max-width: 9rem;
}

.section-gallery--preview {
  padding-block: var(--space-2xl);
}

.section-gallery--preview .section-header {
  margin-bottom: var(--space-lg);
}

@media (max-width: 767px) {
  .gallery-mosaic--preview {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto auto;
    height: auto;
    max-height: none;
  }

  .gallery-mosaic--preview .gallery-tile--preview-main {
    grid-column: 1 / 3;
    grid-row: 1;
    min-height: 220px;
  }

  .gallery-mosaic--preview .gallery-tile--preview-top {
    grid-column: 1 / 3;
    grid-row: 2;
    min-height: 160px;
  }

  .gallery-mosaic--preview .gallery-tile--preview-mid {
    grid-column: 1;
    grid-row: 3;
    min-height: 140px;
  }

  .gallery-more-tile {
    grid-column: 2;
    grid-row: 3;
    min-height: 140px;
  }
}

/* Mosaico responsivo (inspirado em grids editoriais / bento) */
.gallery-mosaic {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(200px, 28vw);
  grid-auto-flow: dense;
  gap: var(--space-md);
}

.gallery-tile {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--radius-xl);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  background: var(--color-bg-soft);
  isolation: isolate;
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-tile:focus-visible {
  outline: 3px solid var(--color-brand-purple);
  outline-offset: 3px;
}

.gallery-tile-img {
  position: absolute;
  inset: 0;
  display: block;
}

.gallery-tile-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-tile-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(10, 12, 18, 0) 35%,
    rgba(10, 12, 18, 0.55) 100%
  );
  opacity: 0.85;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

.gallery-tile-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-md) var(--space-md);
  pointer-events: none;
}

.gallery-tile-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.gallery-tile-action {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius-full);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.3s ease,
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-tile:hover .gallery-tile-img img,
.gallery-tile:focus-visible .gallery-tile-img img {
  transform: scale(1.06);
}

.gallery-tile:hover .gallery-tile-shade,
.gallery-tile:focus-visible .gallery-tile-shade {
  opacity: 1;
}

.gallery-tile:hover .gallery-tile-action,
.gallery-tile:focus-visible .gallery-tile-action {
  opacity: 1;
  transform: translateY(0);
}

.gallery-count {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.85rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-brand-purple);
  background: rgba(74, 41, 179, 0.08);
  border-radius: var(--radius-full);
}

[data-theme="dark"] .gallery-count {
  color: var(--color-brand-green);
  background: rgba(50, 185, 71, 0.12);
}

.section-gallery-page {
  padding-top: calc(var(--header-height, 72px) + var(--space-xl));
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.breadcrumb a {
  color: var(--color-brand-purple);
  text-decoration: none;
  font-weight: 600;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.gallery-back {
  margin-top: var(--space-2xl);
  text-align: center;
}

/* Destaques no mosaico completo — desktop */
@media (min-width: 768px) {
  .gallery-mosaic:not(.gallery-mosaic--preview) {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-auto-rows: minmax(160px, 14vw);
    gap: var(--space-lg);
  }

  .gallery-tile--feature {
    grid-column: span 3;
    grid-row: span 2;
  }

  .gallery-tile--tall {
    grid-column: span 2;
    grid-row: span 2;
  }

  .gallery-tile--wide {
    grid-column: span 3;
    grid-row: span 1;
  }

  .gallery-tile--feature .gallery-tile-title,
  .gallery-tile--tall .gallery-tile-title {
    font-size: var(--font-size-lg);
  }
}

@media (min-width: 1100px) {
  .gallery-mosaic:not(.gallery-mosaic--preview) {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-rows: minmax(148px, 11.5vw);
  }

  .gallery-tile--feature {
    grid-column: span 7;
    grid-row: span 3;
  }

  .gallery-tile--tall {
    grid-column: span 5;
    grid-row: span 2;
  }

  .gallery-tile--wide {
    grid-column: span 4;
    grid-row: span 1;
  }

  .gallery-tile--normal {
    grid-column: span 4;
    grid-row: span 1;
  }
}

@media (max-width: 767px) {
  .gallery-mosaic:not(.gallery-mosaic--preview) {
    grid-auto-rows: minmax(220px, 42vw);
  }

  .gallery-mosaic:not(.gallery-mosaic--preview) .gallery-tile--feature,
  .gallery-mosaic:not(.gallery-mosaic--preview) .gallery-tile--tall {
    grid-column: span 2;
    grid-row: span 1;
  }

  .gallery-tile-action {
    opacity: 1;
    transform: none;
  }
}

/* ========== Lightbox ========== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.lightbox.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  border: none;
  padding: 0;
  background: rgba(8, 10, 16, 0.92);
  backdrop-filter: blur(12px);
  cursor: pointer;
}

.lightbox-shell {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: min(100%, 1200px);
  max-height: 96vh;
  gap: var(--space-md);
}

.lightbox-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding-inline: 0.25rem;
}

.lightbox-meta {
  min-width: 0;
}

.lightbox-caption {
  margin: 0;
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}

.lightbox-counter {
  margin: 0.25rem 0 0;
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.7);
}

.lightbox-close {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.lightbox-stage {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-sm);
  min-height: 0;
}

.lightbox-figure {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: min(72vh, 640px);
}

.lightbox-img {
  display: block;
  max-width: min(92vw, 1080px);
  max-height: min(72vh, 720px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.lightbox-img.is-fading {
  opacity: 0;
  transform: scale(0.985);
}

.lightbox-nav {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}

.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.lightbox-nav:active {
  transform: scale(0.95);
}

.lightbox-thumbs {
  display: flex;
  gap: 0.5rem;
  padding: 0.35rem 0.15rem 0.15rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
}

.lightbox-thumbs::-webkit-scrollbar {
  height: 6px;
}

.lightbox-thumbs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.35);
  border-radius: 99px;
}

.lightbox-thumb {
  flex: 0 0 auto;
  width: 4.5rem;
  height: 3.25rem;
  padding: 0;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.55;
  scroll-snap-align: start;
  transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.lightbox-thumb:hover {
  opacity: 0.85;
}

.lightbox-thumb.is-active {
  opacity: 1;
  border-color: var(--color-brand-green);
  transform: scale(1.04);
}

body.lightbox-open {
  overflow: hidden;
}

@media (max-width: 720px) {
  .lightbox {
    padding: var(--space-sm);
  }

  .lightbox-stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    gap: 0.5rem;
  }

  .lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 2.75rem;
    height: 2.75rem;
    background: rgba(0, 0, 0, 0.45);
  }

  .lightbox-prev {
    left: 0.25rem;
  }

  .lightbox-next {
    right: 0.25rem;
  }

  .lightbox-figure {
    min-height: min(58vh, 480px);
    grid-row: 1;
    grid-column: 1;
  }

  .lightbox-img {
    max-height: 58vh;
    max-width: 100%;
  }

  .lightbox-caption {
    font-size: var(--font-size-base);
  }

  .lightbox-thumb {
    width: 3.75rem;
    height: 2.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-tile-img img,
  .gallery-tile-action,
  .gallery-tile-shade,
  .lightbox-img {
    transition: none;
  }

  .gallery-tile:hover .gallery-tile-img img {
    transform: none;
  }
}
