/* ==========================================================================
   ALIANI + SILEO ARCHITETTI — COMPONENTI INTERATTIVI
   ========================================================================== */

/* 1. SLIDER PRIMA / DOPO (DAL RENDER ALLA REALTÀ) */
.ba-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 160px 24px 0;
}

.ba-slider {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #EAE6DF;
  overflow: hidden;
  user-select: none;
  touch-action: pan-y;
}

@media (max-width: 768px) {
  .ba-slider {
    aspect-ratio: 4 / 3;
  }
}

.ba-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ba-overlay {
  position: absolute;
  inset: 0;
  width: 50%;
  overflow: hidden;
  will-change: width;
}

.ba-overlay .ba-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Assicura che l'immagine nell'overlay mantenga la larghezza del contenitore padre */
  min-width: 100cqw;
}

/* Gestione larghezza dell'immagine interna con container queries */
.ba-slider {
  container-type: inline-size;
}

.ba-overlay img {
  width: 100cqw;
  max-width: none;
  height: 100%;
  object-fit: cover;
}

.ba-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #FFFFFF;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(0,0,0,0.35);
  transform: translateX(-50%);
  will-change: left;
}

.ba-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FFFFFF;
  color: #2B2D31;
  border: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  letter-spacing: -0.1em;
  font-weight: 400;
  pointer-events: none;
}

.ba-badge {
  position: absolute;
  bottom: 16px;
  padding: 6px 14px;
  font-size: 10px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-weight: 500;
  pointer-events: none;
  z-index: 2;
}

.ba-badge-render {
  left: 16px;
  background: rgba(255, 255, 255, 0.94);
  color: #2B2D31;
}

.ba-badge-reale {
  right: 16px;
  background: rgba(43, 45, 49, 0.94);
  color: #FFFFFF;
}

.ba-range {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  margin: 0;
  cursor: ew-resize;
  opacity: 0;
  z-index: 3;
}

.ba-range:focus-visible {
  opacity: 1;
  outline: 2px solid var(--accent);
}

/* 2. STATS & CONTATORI */
.stats-section {
  max-width: var(--max-width);
  margin: 120px auto 0;
  padding: 0 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 40px clamp(16px, 2vw, 32px);
  border-top: 1px solid var(--border-light);
  padding-top: 48px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-value-wrap {
  font-weight: 200;
  font-size: clamp(32px, 3.2vw, 54px);
  line-height: 1.1;
  color: var(--text-main);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  display: flex;
  align-items: baseline;
  overflow: visible;
}

.stat-suffix {
  font-size: 0.6em;
  color: var(--accent);
  margin-left: 2px;
}

.stat-label {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 36px 24px;
  }
}

@media (max-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 32px 16px;
  }
  .stat-value-wrap {
    font-size: clamp(26px, 7vw, 38px);
  }
}

/* 3. MAPPA E TERRITORIO */
.territorio-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 56px;
  align-items: center;
}

.places-list {
  margin-top: 36px;
  border-top: 1px solid var(--border-dark);
}

.place-btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  width: 100%;
  min-height: 48px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  color: var(--text-main);
  transition: color 0.3s ease;
}

.place-btn:hover, .place-btn.active {
  color: var(--accent);
}

.place-btn .place-name {
  font-size: 16px;
  font-weight: 400;
}

.place-btn .place-desc {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.map-container {
  position: relative;
  aspect-ratio: 720 / 562;
  background: #F6F7F7;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

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

.map-region-label {
  position: absolute;
  font-size: 11px;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  pointer-events: none;
}

.map-inset {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 92px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--border-light);
  backdrop-filter: blur(4px);
}

.map-pin {
  position: absolute;
  width: 0;
  height: 0;
  transition: opacity 0.8s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1.4);
}

.map-pin-core {
  position: absolute;
  left: -6px;
  top: -6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-main);
  border: 2px solid #FFFFFF;
  box-sizing: border-box;
  transition: background 0.4s ease, transform 0.4s ease;
  cursor: pointer;
}

.map-pin.big .map-pin-core {
  left: -9px;
  top: -9px;
  width: 18px;
  height: 18px;
}

.map-pin.active .map-pin-core {
  background: var(--accent);
  transform: scale(1.15);
}

.map-pin-pulse {
  position: absolute;
  left: -22px;
  top: -22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(156, 119, 72, 0.28);
  transform: scale(0);
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1.4);
  pointer-events: none;
}

.map-pin.active .map-pin-pulse {
  transform: scale(1);
}

.map-pin-label {
  position: absolute;
  left: 14px;
  top: -9px;
  white-space: nowrap;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--text-main);
  font-weight: 400;
  pointer-events: none;
  transition: color 0.3s ease;
}

.map-pin.active .map-pin-label {
  color: var(--accent);
  font-weight: 500;
  font-size: 12px;
}

/* 4. FILTRI E GRIGLIA PROGETTI */
.filters-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 40px 0 56px;
}

.filter-btn {
  min-height: 44px;
  padding: 0 22px;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--border-dark);
  font-weight: 400;
  background: #FFFFFF;
  color: var(--text-main);
  transition: all 0.3s ease;
}

.filter-btn:hover {
  background: var(--bg-hover);
}

.filter-btn.active {
  background: var(--border-dark);
  color: #FFFFFF;
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 56px 36px;
}

.project-card {
  display: flex;
  flex-direction: column;
}

.project-card .ph {
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--bg-warm);
}

.project-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 1.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.project-card:hover img {
  transform: scale(1.04);
}

.project-card-meta {
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.project-card-title {
  font-size: 18px;
  font-weight: 300;
  margin: 0;
}

.project-card-cat {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* 5. METODO - TIMELINE 6 FASI */
.metodo-progress-bar {
  position: relative;
  width: 100%;
  height: 2px;
  background: var(--border-light);
  margin-bottom: 24px;
}

.metodo-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: var(--accent);
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.metodo-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 48px;
}

.metodo-nav-btn {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  min-height: 44px;
  padding: 16px 20px 16px 0;
  font-size: 13px;
  letter-spacing: 0.15em;
  color: var(--text-main);
  opacity: 0.5;
  transition: opacity 0.3s ease, color 0.3s ease;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.metodo-nav-btn.active {
  opacity: 1;
  color: var(--accent);
  font-weight: 500;
}

.metodo-phase-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 56px;
  align-items: center;
}

.metodo-phase-img {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-warm);
}

.metodo-phase-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 6. LIGHTBOX PROGETTO */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20, 21, 23, 0.92);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(8px);
}

.lightbox.active {
  display: flex;
}

.lightbox-content {
  max-width: 90vw;
  max-height: 88vh;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  box-shadow: 0 12px 36px rgba(0,0,0,0.5);
}

.lightbox-caption {
  margin-top: 14px;
  color: #FFFFFF;
  font-size: 13px;
  letter-spacing: 0.05em;
  text-align: center;
}

.lightbox-close {
  position: absolute;
  top: 24px;
  right: 24px;
  color: #FFFFFF;
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  line-height: 1;
  padding: 8px;
}

/* 7. GALLERIA PROGETTO A RITMO ALTERNATO E RIGHE GIUSTIFICATE */
.project-gallery {
  display: flex;
  flex-direction: column;
  gap: 36px;
  margin-top: 28px;
  width: 100%;
}

/* Riga a piena larghezza (solo orizzontale): sempre 100% del contenitore, allineata ai bordi */
.gallery-row-full {
  width: 100%;
  max-width: 100%;
}

.gallery-row-full .gallery-item {
  margin: 0;
  width: 100%;
}

.gallery-row-full img {
  width: 100%;
  height: auto;
  display: block;
}

/* Riga multi (coppia o trio di foto con STESSA altezza e proporzioni esatte) */
.gallery-row-multi {
  display: flex;
  gap: 28px;
  width: 100%;
  max-width: 100%;
  align-items: flex-start;
  justify-content: center;
}

/* Il limite di altezza 80vh vale SOLO per le righe che contengono foto verticali */
.gallery-row-multi.has-vertical {
  max-width: min(100%, calc(80vh * var(--sum-ar, 2.5) + (var(--items-count, 2) - 1) * 28px));
  margin: 0 auto;
}

.gallery-row-multi .gallery-item {
  flex: var(--ar, 1.5) 1 0px;
  min-width: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.gallery-row-multi img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.gallery-caption {
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  line-height: 1.4;
}

/* Mobile (<= 768px e 360px): una colonna sola a tutta larghezza */
@media (max-width: 768px) {
  .project-gallery {
    gap: 24px;
  }
  .gallery-row-full {
    max-width: 100% !important;
  }
  .gallery-row-multi {
    display: flex !important;
    flex-direction: column !important;
    gap: 24px !important;
    max-width: 100% !important;
  }
  .gallery-row-multi .gallery-item {
    flex: none !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .gallery-row-full img,
  .gallery-row-multi img {
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
  }
}


