/* =========================================================
   SCIMEC SAS — Servicios v3: foto de fondo a tarjeta completa
   + fondo de sección oscuro + encuadre inteligente sin recortes.
   Se carga DESPUÉS de servicios-corporativo.css.
   servicios-carrusel-v3.js asigna a cada foto una de estas clases:
     .fit-cover  la foto llena la tarjeta (proporción parecida)
     .fit-top    foto completa arriba, a todo el ancho (foto horizontal en tarjeta alta)
     .fit-side   foto completa a la derecha, a todo el alto (foto vertical en tarjeta ancha)
   El espacio sobrante se rellena con la misma foto desenfocada.
   ========================================================= */

/* ---------- Fondo de la sección ---------- */
.services {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 104px 0;
  color: #FFFFFF;
  background: #121A20 url("assets/img/servicios/servicios-fondo-seccion.webp") center / cover no-repeat;
  border-top: 1px solid rgba(255, 163, 82, 0.28);
}
.services::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(10, 20, 27, 0.95) 0%, rgba(10, 20, 27, 0.80) 45%, rgba(10, 20, 27, 0.95) 100%);
}
.services .section-tag { color: #FFA352; }
.services .section-title { color: #FFFFFF; }
.services .section-desc { color: rgba(255, 255, 255, 0.8); }

/* ---------- Rejilla ---------- */
.services .services-grid {
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  align-items: stretch;
}

/* ---------- Tarjeta ---------- */
.services .service-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 570px;
  height: auto;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: var(--radius, 10px);
  overflow: hidden;
  background: #15191D;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  isolation: isolate;
}
.services .service-card .service-img,
.services .service-card:nth-child(2n) .service-img {
  position: absolute;
  inset: 0;
  z-index: -2;
  min-height: 0;
  height: 100%;
  order: 0;
  overflow: hidden;
}

/* ---------- Diapositivas ---------- */
.services .service-img .slide {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  opacity: 0;
  background: #15191D;
  transition: opacity 1.1s ease;
}
.services .service-img .slide.is-active,
.services .service-img .slide:only-child { opacity: 1; }

/* Relleno desenfocado con la misma foto */
.services .service-img .slide::before {
  content: "";
  position: absolute;
  inset: -40px;
  background-image: var(--img, none);
  background-position: center;
  background-size: cover;
  filter: blur(26px) brightness(0.5) saturate(1.1);
}

/* Por defecto (y .fit-cover): la foto llena toda la tarjeta */
.services .service-img img {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: 50% 40%;
  transition: transform 0.6s ease;
}

/* Foto horizontal en tarjeta alta: completa arriba, se funde hacia abajo */
.services .service-img .slide.fit-top img {
  bottom: auto;
  height: auto;
  object-fit: contain;
  -webkit-mask-image: linear-gradient(to bottom, #000 80%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 80%, transparent 100%);
}

/* Foto vertical en tarjeta ancha: completa a la derecha, se funde hacia la izquierda */
.services .service-img .slide.fit-side img {
  left: auto;
  right: 0;
  width: auto;
  max-width: 62%;
  height: 100%;
  object-fit: contain;
  object-position: 100% 50%;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16%);
          mask-image: linear-gradient(to right, transparent 0, #000 16%);
}

/* Foto panorámica de cilindros: siempre llena, anclada a la derecha */
.services .service-img .slide[data-fit="cover"] img { object-position: 85% 50%; }

/* Oscurecido para leer el texto (abajo en tarjetas altas) */
.services .service-card::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(to top, rgba(18, 22, 26, 0.95) 0%, rgba(18, 22, 26, 0.86) 36%, rgba(18, 22, 26, 0.30) 64%, rgba(18, 22, 26, 0) 82%);
}

/* ---------- Texto ---------- */
.services .service-body {
  position: relative;
  flex: 0 0 auto;
  padding: 28px 28px 30px;
  background: transparent;
}
.services .service-icon {
  width: 46px;
  height: 46px;
  margin: 0 0 14px;
  border: 0;
  border-radius: 50%;
  background: var(--orange, #F1791F);
  color: var(--white, #FFFFFF);
  font-size: 1.15rem;
}
.services .service-body h3 {
  margin: 0 0 12px;
  color: var(--white, #FFFFFF);
  font-family: var(--font-head, 'Barlow Condensed', sans-serif);
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.1;
  text-wrap: balance;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
}
.services .service-body p {
  margin: 0;
  color: #E6E8EA;
  font-size: 0.97rem;
  line-height: 1.62;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

/* ---------- Puntos del carrusel ---------- */
.services .service-dots {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 20px;
  background: rgba(10, 20, 27, 0.5);
}
.services .service-dots button {
  width: 24px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  transition: background 0.3s, width 0.3s;
}
.services .service-dots button.is-active { width: 36px; background: var(--orange, #F1791F); }
.services .service-dots button:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 3px; }

/* ---------- Interacción ---------- */
.services .service-card:hover {
  transform: translateY(-5px);
  border-color: rgba(241, 121, 31, 0.45);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55);
}
.services .service-card:hover .service-img .is-active img { transform: scale(1.03); }

/* ---------- Tarjetas anchas: 1ª, 5ª y 9ª ---------- */
.services .service-card:nth-child(4n+1) {
  grid-column: 1 / -1;
  min-height: 430px;
  justify-content: center;
}
.services .service-card:nth-child(4n+1)::after {
  background: linear-gradient(to right, rgba(18, 22, 26, 0.94) 0%, rgba(18, 22, 26, 0.82) 36%, rgba(18, 22, 26, 0.25) 62%, rgba(18, 22, 26, 0) 80%);
}
.services .service-card:nth-child(4n+1) .service-body { max-width: 580px; padding: 44px 48px; }
.services .service-card:nth-child(4n+1) h3 { font-size: 2.2rem; }

/* ---------- Tablet: 2 columnas (4ª y 8ª también anchas) ---------- */
@media (max-width: 1024px) {
  .services .services-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .services .service-card:nth-child(4n) {
    grid-column: 1 / -1;
    min-height: 420px;
    justify-content: center;
  }
  .services .service-card:nth-child(4n)::after {
    background: linear-gradient(to right, rgba(18, 22, 26, 0.94) 0%, rgba(18, 22, 26, 0.82) 40%, rgba(18, 22, 26, 0.25) 66%, rgba(18, 22, 26, 0) 84%);
  }
  .services .service-card:nth-child(4n) .service-body,
  .services .service-card:nth-child(4n+1) .service-body { max-width: 50%; padding: 36px; }
  .services .service-card:nth-child(4n+1) h3 { font-size: 1.9rem; }
  .services .service-img .slide.fit-side img { max-width: 56%; }
}

/* ---------- Móvil: 1 columna ---------- */
@media (max-width: 720px) {
  .services { padding: 76px 0; }
  .services .services-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .services .service-card,
  .services .service-card:nth-child(4n+1),
  .services .service-card:nth-child(4n) {
    grid-column: auto;
    min-height: 540px;
    justify-content: flex-end;
  }
  .services .service-card:nth-child(4n+1)::after,
  .services .service-card:nth-child(4n)::after {
    background: linear-gradient(to top, rgba(18, 22, 26, 0.95) 0%, rgba(18, 22, 26, 0.86) 38%, rgba(18, 22, 26, 0.30) 66%, rgba(18, 22, 26, 0) 84%);
  }
  .services .service-body,
  .services .service-card:nth-child(4n+1) .service-body,
  .services .service-card:nth-child(4n) .service-body { max-width: none; padding: 22px 22px 26px; }
  .services .service-body h3,
  .services .service-card:nth-child(4n+1) h3 { font-size: 1.55rem; }
}

@media (prefers-reduced-motion: reduce) {
  .services .service-card,
  .services .service-img img,
  .services .service-img .slide { transition: none; }
  .services .service-card:hover,
  .services .service-card:hover .service-img .is-active img { transform: none; }
}
