/* ==========================================
   ELEMENT 5: GALLERY SECTION
   Mariátegui Project - Custom Styles
   ========================================== */

#galeria.g6-gallery-section {
  position: relative;
  overflow: hidden;
  background: var(--g6-surface-warm) !important;
  padding-top: var(--mariategui-section-pt, 60px) !important;
  padding-bottom: 30px !important;
}

#galeria.g6-gallery-section .container-fluid {
  padding: 0 !important;
}

#galeria.g6-gallery-section .title {
  margin-bottom: clamp(2rem, 5vw, 4rem);
}

#galeria.g6-gallery-section .g6-gallery-slider-wrapper {
  position: relative;
  overflow: hidden;
  padding: 0 60px; /* Homologado a 60px exactos en escritorio */
  max-width: 1600px;
  margin: 0 auto;
}

/* Fix hover state conflict for editorial cards in gallery */
#galeria.g6-gallery-section .project-card-s3 .image img {
  opacity: 1 !important;
  filter: none !important;
  transform: none !important;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#galeria.g6-gallery-section .project-card-s3:hover .image img,
#galeria.g6-gallery-section .project-card-s3:focus-within .image img {
  opacity: 1 !important;
  filter: none !important;
  transform: scale(1.035) !important;
}

#galeria.g6-gallery-section .g6-lightbox-trigger:hover .g6-lightbox-icon-overlay,
#galeria.g6-gallery-section .g6-lightbox-trigger:focus .g6-lightbox-icon-overlay {
  opacity: 1 !important;
}

/* Override text colors for gallery cards to match dark background */
#galeria .g6-editorial-project-card .g6-card-zone,
#galeria .g6-editorial-project-card .g6-card-desc {
  color: var(--g6-cream-veil) !important;
}

/* ==========================================
   Gallery Card Content (Brochure Specs)
   Custom variant for Mariátegui gallery cards
   ========================================== */

body.g6-brand #galeria .g6-editorial-project-card {
  display: flex !important;
  flex-direction: column !important;
  background: var(--g6-card-header, #736d64) !important;
  overflow: hidden !important;
  height: auto !important;
}

/* Restore the original white frame border but only for the image to avoid cutting */
body.g6-brand #galeria .g6-editorial-project-card .image::after {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: 12px;
  right: 12px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  pointer-events: none;
  z-index: 3;
}

body.g6-brand #galeria .g6-editorial-project-card .image {
  flex: 0 0 auto !important;
  width: 100% !important;
  aspect-ratio: 3 / 2 !important; /* Proporción más equilibrada para fotos mixtas */
  max-height: 60vh !important;
  min-height: 400px !important;
  overflow: hidden;
  position: relative;
  background: var(--g6-card-header, #736d64);
}

body.g6-brand #galeria .g6-editorial-project-card .image img {
  object-fit: cover !important; /* Volvemos a cover para que todas se vean homologadas y llenen el espacio */
  object-position: center center;
  width: 100% !important;
  height: 100% !important;
  display: block !important;
}

@media (max-width: 1366px), (max-height: 800px) {
  #galeria.g6-gallery-section {
    padding-top: var(--mariategui-section-pt, 60px) !important;
    padding-bottom: 30px !important;
  }
  
  body.g6-brand #galeria .g6-editorial-project-card .image {
    max-height: 55vh !important;
    aspect-ratio: 16 / 9 !important; /* En notebooks usamos un formato un poco más bajo para que quepa todo */
  }
  
  .g6-gallery-swiper-thumbs {
    height: 140px;
  }
}

@media (max-width: 991px) {
  body.g6-brand #galeria .g6-editorial-project-card .image img {
    object-fit: cover !important; /* En móviles volvemos a cover para llenar mejor el espacio */
  }
}

@media (max-width: 768px) {
  #galeria.g6-gallery-section .g6-gallery-slider-wrapper {
    padding: 0 15px;
  }
  
  body.g6-brand #galeria .g6-editorial-project-card .image {
    aspect-ratio: 4 / 3 !important;
    max-height: 45vh !important;
    min-height: 300px !important;
  }
  
  .g6-gallery-swiper-thumbs {
    height: 100px;
  }
  
  body.g6-brand #galeria .g6-editorial-project-card .g6-card-content {
    padding: 15px 15px 25px !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    gap: 0 !important;
  }

  body.g6-brand #galeria .g6-brochure-spec {
    min-width: 0 !important;
    padding: 0 10px !important;
    flex: 1 1 50% !important;
  }

  body.g6-brand #galeria .g6-brochure-spec:first-child {
    padding-right: 15px !important;
  }

  body.g6-brand #galeria .g6-brochure-spec:last-child {
    padding-left: 15px !important;
  }

  body.g6-brand #galeria .g6-brochure-spec p {
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    hyphens: auto !important;
  }
}

body.g6-brand #galeria .g6-editorial-project-card .g6-card-content {
  flex: 0 0 auto !important;
  display: flex !important;
  justify-content: center;
  align-items: flex-start;
  gap: 0;
  padding: 20px 35px 30px !important;
  text-align: center !important;
  margin: 0 !important;
  width: 100%;
  background: var(--g6-card-header, #736d64) !important;
  position: relative;
  z-index: 5;
}

/* Re-add the orange bar at the very bottom of the info area */
body.g6-brand #galeria .g6-editorial-project-card .g6-card-content::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(38%, 12rem);
  height: 8px;
  background: var(--g6-orange, #fe3b1f);
  z-index: 6;
  pointer-events: none;
  border-radius: 1px;
}

body.g6-brand #galeria .g6-brochure-spec {
  max-width: 50%;
  flex: 0 1 auto;
  min-width: 260px;
}

body.g6-brand #galeria .g6-brochure-spec:first-child {
  padding-right: 40px;
  text-align: right !important; /* First column to the RIGHT */
}

body.g6-brand #galeria .g6-brochure-spec:last-child {
  padding-left: 40px;
  text-align: left !important; /* Second column to the LEFT */
  border-left: 2px solid #d1cdbf;
}

body.g6-brand #galeria .g6-brochure-spec p:first-child {
  font-family: "Montserrat", sans-serif !important;
  font-size: clamp(0.7rem, 0.9vw, 0.88rem) !important; /* Homologado con .g6-card-kicker */
  font-weight: 700 !important;
  letter-spacing: 1.2px !important;
  text-transform: uppercase;
  color: #fff !important;
  margin-bottom: 8px !important;
  line-height: 1.2 !important;
}

body.g6-brand #galeria .g6-brochure-spec p:last-child {
  font-family: "Montserrat", sans-serif !important;
  font-size: clamp(0.8rem, 1.1vw, 1.2rem) !important; /* Ajustado para mejor legibilidad */
  color: var(--g6-cream-veil) !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
}

/* Remove redundant card-level frame and bar in gallery to keep image clean */
body.g6-brand #galeria .g6-editorial-project-card::after,
body.g6-brand #galeria .g6-editorial-project-card::before {
  display: none !important;
}

/* Keep frame only inside the image container */
body.g6-brand #galeria .g6-editorial-project-card .image::after {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  pointer-events: none;
  z-index: 3;
}

/* Thumbnail Slider - Full Width & Larger */
.g6-gallery-swiper-thumbs {
  max-width: 100% !important;
  width: 100% !important;
  margin: 0; /* Espacio eliminado para pegar las miniaturas al slider principal */
  position: relative;
  z-index: 10;
  height: 180px;
  padding: 0 !important;
}

.g6-gallery-swiper-thumbs .swiper-wrapper {
  justify-content: flex-start;
}

.g6-gallery-swiper-thumbs .swiper-slide {
  opacity: 0.4;
  cursor: pointer;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
  position: relative;
  overflow: hidden;
  border: none;
  border-radius: 0;
}

.g6-gallery-swiper-thumbs .swiper-slide:hover,
.g6-gallery-swiper-thumbs .swiper-slide-thumb-active {
  opacity: 1;
  box-shadow: inset 0 0 0 4px var(--g6-orange, #fe3b1f);
}

.g6-gallery-swiper-thumbs .swiper-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  filter: grayscale(20%);
}

.g6-gallery-swiper-thumbs .swiper-slide:hover img,
.g6-gallery-swiper-thumbs .swiper-slide-thumb-active img {
  transform: scale(1.05);
  filter: grayscale(0%);
}

/* Rediseño de títulos en miniaturas para que sean más elegantes */
.g6-gallery-swiper-thumbs .swiper-slide::after {
  content: attr(data-title);
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 8px 4px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.9) 0%, transparent 100%);
  color: #fff;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.g6-gallery-swiper-thumbs .swiper-slide:hover::after,
.g6-gallery-swiper-thumbs .swiper-slide-thumb-active::after {
  opacity: 1;
  transform: translateY(0);
}

/* Main Slider Active State */
.mySwiper2 .swiper-slide-active img {
  transform: scale(1.02);
  transition: transform 1.2s ease-out;
}

.mySwiper2 .swiper-slide img {
  transition: transform 1.2s ease-out;
}

/* Force white navigation arrows (legacy SVG override via filter) */
.swiper-button-next,
.swiper-button-prev {
  filter: brightness(0) invert(1) !important;
  opacity: 0.8;
  transition: opacity 0.3s;
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
  opacity: 1;
}

.g6-gallery-swiper-main .swiper-button-next {
  right: 20px !important;
}

.g6-gallery-swiper-main .swiper-button-prev {
  left: 20px !important;
}
