/* XERF Gallery – Before & After Carousel (Gutenberg-safe)
   - Structure uses core/group, core/columns, core/image, core/buttons
   - No core/html; layout encoded by Columns widths; CSS is visual only
*/

:root {
  --xg-brand: #8B4A4A;
  --xg-dark: #1C1C1C;
  --xg-text: #2A2A2A;
  --xg-muted: #6F6F6F;
  --xg-bg-soft: #FAF7F2;
  --xg-bg-light: #F3E6DA;
  --xg-white: #FFFFFF;
  --xg-border: #E5E5E5;
  --xg-max: 1200px;
  --xg-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --xg-shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --xg-shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
  --xg-transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===============================================
   SECTION WRAPPER
   =============================================== */

.xg-gallery-section {
  background: linear-gradient(180deg, var(--xg-white) 0%, var(--xg-bg-soft) 100%);
  padding: clamp(50px, 6vw, 80px) clamp(20px, 5vw, 80px);
  position: relative;
  overflow: hidden;
}
.xg-gallery-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 150px;
  background: radial-gradient(ellipse at top, rgba(139, 74, 74, 0.04) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.xg-inner { max-width: var(--xg-max); margin-inline: auto; position: relative; z-index: 1; }

/* ===============================================
   HEADER
   =============================================== */

.xg-header { text-align: center; margin-bottom: clamp(30px, 4vw, 50px); }
.xg-main-title {
  font-size: clamp(28px, 4.5vw, 48px);
  font-weight: 700;
  line-height: 1.2;
  color: var(--xg-dark);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.xg-subtitle {
  font-size: clamp(15px, 1.8vw, 18px);
  color: var(--xg-muted);
  margin: 0;
  line-height: 1.6;
  font-weight: 400;
}

/* ===============================================
   CAROUSEL
   =============================================== */

.xg-carousel-wrapper { position: relative; max-width: 900px; margin: 0 auto; }
.xg-carousel-container {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  background: var(--xg-white);
  box-shadow: var(--xg-shadow-lg);
}
.xg-carousel-track {
  display: flex;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}
.xg-carousel-slide {
  min-width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

/* ===============================================
   BEFORE/AFTER COMPARISON (Columns-based)
   =============================================== */

.xg-comparison-wrapper {
  position: relative;
  background: var(--xg-bg-light);
}

/* Vertical divider */
.xg-comparison-wrapper::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 2px; height: 80%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(139, 74, 74, 0.3) 20%,
    rgba(139, 74, 74, 0.5) 50%,
    rgba(139, 74, 74, 0.3) 80%,
    transparent 100%
  );
  z-index: 2;
}

.xg-ba-side {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.xg-before { background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%); }
.xg-after  { background: linear-gradient(135deg, var(--xg-bg-light) 0%, var(--xg-bg-soft) 100%); }

/* Label */
.xg-ba-label {
  position: absolute;
  top: 20px; left: 50%;
  transform: translateX(-50%);
  margin: 0 !important;
  padding: 8px 20px;
  background: rgba(0, 0, 0, 0.75);
  color: var(--xg-white);
  font-size: clamp(11px, 1.4vw, 13px);
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: 20px;
  z-index: 3;
  backdrop-filter: blur(8px);
}
.xg-after .xg-ba-label {
  background: linear-gradient(90deg, rgba(139, 74, 74, 0.92) 0%, rgba(109, 56, 56, 0.92) 100%);
}

/* Image wrap */
.xg-ba-image { margin: 0 !important; width: 100%; display: flex; align-items: center; justify-content: center; padding: 30px 20px; }
.xg-ba-image img {
  width: 100%; height: auto; max-height: 400px; object-fit: contain; display: block; transition: var(--xg-transition);
}
.xg-before .xg-ba-image img { filter: saturate(0.9) brightness(0.98); }
.xg-after  .xg-ba-image img { filter: saturate(1.08) brightness(1.02); }

/* Caption */
.xg-caption {
  padding: 20px 24px; margin: 0 !important;
  font-size: clamp(14px, 1.6vw, 16px); line-height: 1.6;
  color: var(--xg-text); text-align: center;
  background: var(--xg-white);
  border-top: 1px solid var(--xg-border);
  font-weight: 500; min-height: 70px;
  display: flex; align-items: center; justify-content: center;
}

/* ===============================================
   NAVIGATION ARROWS (core/button wrappers)
   =============================================== */

.xg-carousel-nav {
  position: absolute;
  top: 50%; transform: translateY(-50%);
  width: 50px; height: 50px;
  border-radius: 50%;
  z-index: 10; user-select: none;
  box-shadow: var(--xg-shadow-md);
}
.xg-carousel-nav.prev  { left: -25px; }
.xg-carousel-nav.next  { right: -25px; }

.xg-carousel-nav .wp-block-button__link {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  border: 2px solid var(--xg-brand);
  border-radius: 50%;
  background: var(--xg-white);
  color: var(--xg-brand);
  font-size: 22px; font-weight: 700;
  box-shadow: none; text-decoration: none;
  transition: var(--xg-transition);
  padding: 0;
}
.xg-carousel-nav:hover .wp-block-button__link {
  background: var(--xg-brand);
  color: var(--xg-white);
  transform: scale(1.1);
  box-shadow: var(--xg-shadow-lg);
}
.xg-carousel-nav .wp-block-button__link:active { transform: scale(0.95); }

/* ===============================================
   INDICATORS (core/buttons with core/button children)
   =============================================== */

.xg-carousel-indicators {
  display: flex; gap: 10px; justify-content: center;
  padding: 20px 0 0;
}
.xg-indicator-dot { width: auto; height: auto; }
.xg-indicator-dot .wp-block-button__link {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--xg-border); border: 2px solid transparent;
  display: inline-block; text-indent: -9999px; overflow: hidden; padding: 0;
  transition: var(--xg-transition);
}
.xg-indicator-dot:hover .wp-block-button__link {
  background: var(--xg-muted); transform: scale(1.2);
}
.xg-indicator-dot.active .wp-block-button__link {
  background: var(--xg-brand);
  width: 30px; border-radius: 5px; border-color: var(--xg-brand);
}

/* ===============================================
   FOOTER
   =============================================== */

.xg-footer {
  margin-top: clamp(30px, 5vw, 50px);
  padding-top: clamp(25px, 4vw, 40px);
  border-top: 1px solid var(--xg-border);
  text-align: center;
}
.xg-disclaimer {
  font-size: clamp(12px, 1.4vw, 14px);
  color: var(--xg-muted);
  margin: 0 0 20px !important;
  font-style: italic;
  line-height: 1.6;
}
.xg-footer .wp-block-buttons { margin: 0 !important; }

/* ===============================================
   RESPONSIVE
   =============================================== */

@media (max-width: 1023px) and (min-width: 783px) {
  .xg-ba-image img { max-height: 350px; }
  .xg-carousel-nav { width: 45px; height: 45px; }
  .xg-carousel-nav.prev { left: -22px; }
  .xg-carousel-nav.next { right: -22px; }
}

@media (max-width: 782px) {
  .xg-gallery-section { padding: clamp(35px, 5vw, 50px) 16px; }
  .xg-carousel-container { border-radius: 16px; }

  /* Columns stack automatically; adjust divider to horizontal */
  .xg-comparison-wrapper::after {
    width: 80%; height: 2px; top: 50%; left: 50%; transform: translate(-50%, -50%);
  }

  .xg-ba-image { padding: 20px 16px; }
  .xg-ba-image img { max-height: 250px; }
  .xg-ba-label { top: 12px; padding: 6px 16px; font-size: 11px; }
  .xg-caption { padding: 16px 20px; font-size: 14px; min-height: 60px; }

  .xg-carousel-nav { width: 40px; height: 40px; }
  .xg-carousel-nav.prev { left: 10px; }
  .xg-carousel-nav.next { right: 10px; }

  .xg-indicator-dot .wp-block-button__link { width: 8px; height: 8px; }
  .xg-indicator-dot.active .wp-block-button__link { width: 24px; }
}

@media (max-width: 480px) {
  .xg-ba-image img { max-height: 200px; }
}

/* ===============================================
   ACCESSIBILITY & MOTION
   =============================================== */

.xg-carousel-nav .wp-block-button__link:focus-visible {
  outline: 3px solid var(--xg-brand);
  outline-offset: 4px;
}
.xg-indicator-dot .wp-block-button__link:focus-visible {
  outline: 2px solid var(--xg-brand);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  .xg-carousel-track { transition: none; }
  .xg-carousel-nav .wp-block-button__link,
  .xg-indicator-dot .wp-block-button__link,
  .xg-ba-image img { transition: none; }
}

@media (prefers-contrast: high) {
  .xg-ba-label { background: rgba(0, 0, 0, 0.95); border: 2px solid var(--xg-white); }
  .xg-carousel-nav .wp-block-button__link { border-width: 3px; }
}
