/*
 * CFE Service Card for Divi 5
 * The background image is a real child element, not the module background.
 * That allows the image to transform smoothly while text stays still.
 */

.et_pb_module.cfe_service_card {
  height: 100%;
  margin-bottom: 0;
}

.et_pb_module.cfe_service_card .et_pb_module_inner {
  height: 100%;
}

.et_pb_module.cfe_service_card .cfe-service-card {
  height: 100%;
}

.cfe-service-card {
  --cfe-card-green: #5ab279;
  --cfe-card-white: #ffffff;
  --cfe-card-bg: #1a1a1a;
  --cfe-card-text-muted: rgba(255,255,255,0.65);
  --cfe-card-overlay-bottom: rgba(0,0,0,0.88);
  --cfe-card-overlay-mid: rgba(0,0,0,0.15);

  position: relative;
  display: block;
  overflow: hidden;
  min-height: 420px;
  aspect-ratio: 3 / 4;
  background: var(--cfe-card-bg);
  color: var(--cfe-card-white);
  text-decoration: none;
  cursor: pointer;
  isolation: isolate;
}

.cfe-service-card:focus-visible {
  outline: 3px solid var(--cfe-card-green);
  outline-offset: 4px;
}

.cfe-service-card__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  transform: scale(1);
  transition: transform 0.5s ease;
  will-change: transform;
}

.cfe-service-card:hover .cfe-service-card__bg,
.cfe-service-card:focus-visible .cfe-service-card__bg {
  transform: scale(1.05);
}

.cfe-service-card__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    var(--cfe-card-overlay-bottom) 0%,
    var(--cfe-card-overlay-mid) 60%,
    transparent 100%
  );
  pointer-events: none;
}

.cfe-service-card__content {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 24px 20px;
}

.cfe-service-card__number {
  display: block;
  margin: 0 0 8px;
  color: var(--cfe-card-green);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.15em;
}

.cfe-service-card__title {
  margin: 0 0 10px;
  padding: 0;
  color: var(--cfe-card-white);
  font-family: "Barlow Condensed", Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  text-transform: uppercase;
}

.cfe-service-card__description {
  margin: 0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  color: var(--cfe-card-text-muted);
  font-size: 12px;
  line-height: 1.6;
  transition: max-height 0.4s ease, opacity 0.3s ease;
}

.cfe-service-card:hover .cfe-service-card__description,
.cfe-service-card:focus-visible .cfe-service-card__description {
  max-height: 90px;
  opacity: 1;
}

.cfe-service-card__link-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  color: var(--cfe-card-green);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cfe-service-card:hover .cfe-service-card__link-text,
.cfe-service-card:focus-visible .cfe-service-card__link-text {
  opacity: 1;
  transform: translateY(0);
}


/* Performance / Build for Performance treatment.
 * Uses the same image, overlay, and content layers, but shows a badge,
 * headline, and description at all times and fills the space provided by
 * the parent/Divi layout.
 */
.cfe-service-card--performance {
  width: 100%;
  height: 100%;
  min-height: 240px;
  aspect-ratio: auto;
}

.cfe-service-card--performance .cfe-service-card__bg {
  filter: brightness(0.65);
  transition: transform 0.5s ease, filter 0.3s ease;
}

.cfe-service-card--performance:hover .cfe-service-card__bg,
.cfe-service-card--performance:focus-visible .cfe-service-card__bg {
  transform: scale(1.04);
  filter: brightness(0.8);
}

.cfe-service-card--performance .cfe-service-card__overlay {
  background: linear-gradient(
    to top,
    rgba(0,0,0,0.80) 0%,
    rgba(0,0,0,0.35) 42%,
    transparent 70%
  );
}

.cfe-service-card--performance .cfe-service-card__content {
  padding: 24px;
}

.cfe-service-card--performance .cfe-service-card__number {
  display: inline-block;
  width: auto;
  margin: 0 0 10px;
  padding: 4px 10px;
  border-radius: 2px;
  background: var(--cfe-card-green);
  color: var(--cfe-card-white);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cfe-service-card--performance .cfe-service-card__title {
  margin: 0 0 6px;
  font-size: 24px;
}

.cfe-service-card--performance .cfe-service-card__description {
  max-height: none;
  overflow: visible;
  opacity: 1;
  color: rgba(255,255,255,0.55);
  font-size: 12px;
  line-height: 1.5;
}

.cfe-service-card--performance .cfe-service-card__link-text {
  display: none;
}

/* Respect users who prefer less motion. */
@media (prefers-reduced-motion: reduce) {
  .cfe-service-card__bg,
  .cfe-service-card__description,
  .cfe-service-card__link-text {
    transition: none;
  }

  .cfe-service-card:hover .cfe-service-card__bg,
  .cfe-service-card:focus-visible .cfe-service-card__bg {
    transform: none;
  }
}

/* Tablet */
@media (max-width: 1024px) {
  .cfe-service-card {
    min-height: 340px;
    aspect-ratio: 4 / 3;
  }
}

/* Mobile: show the hidden content because hover is unreliable. */
@media (max-width: 768px) {
  .cfe-service-card {
    min-height: 360px;
    aspect-ratio: 3 / 4;
  }

  .cfe-service-card__description {
    max-height: 90px;
    opacity: 1;
  }

  .cfe-service-card__link-text {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 400px) {
  .cfe-service-card {
    min-height: 300px;
    aspect-ratio: 4 / 3;
  }
}

/* Keep Performance cards fluid at responsive breakpoints. */
@media (max-width: 1024px) {
  .cfe-service-card--performance {
    min-height: 240px;
    aspect-ratio: auto;
  }
}

@media (max-width: 768px) {
  .cfe-service-card--performance {
    min-height: 240px;
    aspect-ratio: auto;
  }
}

@media (max-width: 400px) {
  .cfe-service-card--performance {
    min-height: 220px;
    aspect-ratio: auto;
  }
}
