/**
 * @file
 * Cards Servicios de Apoyo (c-csa)
 * Ubicacion: css/servicios-apoyo.css
 * Registrar dentro del grupo "component" existente en svf_theme.libraries.yml
 */

/* --------------------------------------------------------------------------
   Contenedor full-bleed
   -------------------------------------------------------------------------- */
.c-csa {
  position: relative;
  width: 100vw;
  left: 50%;
  margin-left: -50vw;
  padding: 60px 0;
  overflow: hidden;
}

.c-csa__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   Grilla
   -------------------------------------------------------------------------- */
.c-csa__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* --------------------------------------------------------------------------
   Card
   -------------------------------------------------------------------------- */
.c-csa__card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  aspect-ratio: 1 / 0.85;
  padding: 30px 45px;
  border-radius: 30px;
  overflow: hidden;
  box-sizing: border-box;
}

/* Neutraliza las reglas globales de <a> del tema dentro de la card. */
.c-csa__card * {
  color: inherit !important;
}

/* Imagen de fondo: absoluta dentro de contenedor relativo.
   Los !important matan los width/height inline que inyecta Drupal. */
.c-csa__media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.c-csa__media .field,
.c-csa__media .field__item,
.c-csa__media picture {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
}

.c-csa__media img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

/* Scrim para que el texto claro se lea sobre la foto. */
.c-csa__card--imagen::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg,
    rgba(0, 0, 0, 0.10) 0%,
    rgba(0, 0, 0, 0.32) 45%,
    rgba(0, 0, 0, 0.62) 100%);
  pointer-events: none;
}

.c-csa__body {
  position: relative;
  z-index: 2;
  width: 100%;
}

.c-csa__titulo {
  margin: 0 0 18px;
  font-size: 28px;
  line-height: 1.25;
  font-weight: 700;
}

/* Card "intro": sin imagen y sin boton -> titulo centrado y mas grande. */
.c-csa__card--intro {
  justify-content: end;
}

.c-csa__card--intro .c-csa__titulo {
  margin: 0;
  font-size: 35px;
  line-height: 1.25;
}

/* --------------------------------------------------------------------------
   Boton
   -------------------------------------------------------------------------- */
.c-csa__boton .field,
.c-csa__boton .field__item {
  margin: 0;
}

.c-csa__boton a {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 13px 18px;
  border-radius: 999px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none !important;
  background-color: var(--csa-btn-bg, #ffffff);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* Mas especifico que ".c-csa__card *" para poder pintar el texto del boton. */
.c-csa__card .c-csa__boton a {
  color: var(--csa-btn-color, #383d38) !important;
}

.c-csa__boton a:hover,
.c-csa__boton a:focus {
  opacity: 0.88;
}

/* --------------------------------------------------------------------------
   Controles del carrusel (solo movil)
   -------------------------------------------------------------------------- */
.c-csa__controles {
  display: none;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.c-csa__flecha {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background-color: var(--svf-primario, #004729);
  color: #ffffff;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.c-csa__flecha svg {
  display: block;
  width: 16px;
  height: 16px;
}

.c-csa__flecha[disabled] {
  background-color: #9c9c9c;
  cursor: default;
}

.c-csa__flecha:focus {
  outline: none;
}

.c-csa__flecha:focus-visible {
  outline: 2px solid var(--svf-acento, #85aa1a);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
  .c-csa__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }

  .c-csa__card {
    padding: 24px;
  }
}

@media (max-width: 767px) {
  .c-csa {
    padding: 40px 0;
  }

  .c-csa__viewport {
    overflow-x: auto;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .c-csa__viewport::-webkit-scrollbar {
    display: none;
  }

  .c-csa__grid {
    display: flex;
    gap: 16px;
  }

  .c-csa__card {
    flex: 0 0 100%;
    scroll-snap-align: start;
    aspect-ratio: 1 / 1;
    border-radius: 28px;
    padding: 26px;
  }

  .c-csa__titulo {
    font-size: 24px;
  }

  .c-csa__card--intro .c-csa__titulo {
    font-size: 30px;
  }

  .c-csa__controles {
    display: flex;
  }
}