/* Sección "Selected Projects" de la portada: al bajar, el fondo pasa de un
   proyecto al siguiente (de obra a edificio terminado) y las tarjetas van
   apareciendo una a una. Sin JS o con prefers-reduced-motion se ve estática:
   primera foto de fondo y las 4 tarjetas visibles. */

.co-projects {
  position: relative;
  background: #121212;
  color: #fff;
}

.co-projects a {
  color: inherit;
  text-decoration: none;
}

.co-projects__stage {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 640px;
  padding: 7rem 0 3rem;
}

.co-projects__bgs {
  position: absolute;
  inset: 0;
  transform: scale(calc(1.08 - 0.06 * var(--p, 0)));
  transform-origin: center;
  will-change: transform;
}

.co-projects__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.co-projects__bg:first-child {
  opacity: 1;
}

.co-projects img:hover {
  transform: none;
}

.co-projects__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(18, 18, 18, 0.9) 0%,
    rgba(18, 18, 18, 0.5) 40%,
    rgba(18, 18, 18, 0.42) 62%,
    rgba(18, 18, 18, 0.92) 100%
  );
  pointer-events: none;
}

.co-projects__inner {
  position: relative;
  display: flex;
  flex: 1;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
}

.co-projects__head {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.co-projects__head-text {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.co-projects__eyebrow {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.75);
}

.co-projects__eyebrow::before {
  content: "";
  width: 2.5rem;
  height: 1px;
  background: #d45500;
}

.co-projects__title {
  margin: 0;
  font-size: clamp(2.25rem, 7vw, 5.25rem);
  line-height: 0.95;
  letter-spacing: -0.02em;
  color: #fff;
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.5);
}

.co-projects__title span {
  color: #d45500;
}

.co-projects__all {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  align-self: flex-start;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #d45500 !important;
  transition: gap 0.3s;
}

.co-projects__all:hover {
  gap: 0.75rem;
}

.co-projects__cards {
  margin: auto 0 0;
  padding: 3rem 0 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.co-card a {
  display: block;
  height: 100%;
  box-sizing: border-box;
  padding: 0.9rem 0.9rem 1rem;
  background: rgba(18, 18, 18, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-top: 2px solid rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: border-color 0.4s, background 0.4s;
}

.co-card a:hover,
.co-card a:focus-visible {
  background: rgba(18, 18, 18, 0.88);
  border-top-color: #d45500;
}

.co-card.is-current a {
  border-top-color: #d45500;
}

.co-card__num {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 1.25rem;
  line-height: 1;
  color: #d45500;
}

.co-card__badge {
  display: none;
  margin-bottom: 0.35rem;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.65);
}

.co-card__title {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.25;
  color: #fff;
}

@media (min-width: 768px) {
  .co-projects__stage {
    min-height: 720px;
    padding: 8rem 0 4rem;
  }

  .co-projects__head {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .co-projects__cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    padding-top: 4rem;
  }

  .co-card a {
    padding: 1.5rem 1.5rem 1.75rem;
  }

  .co-card__num {
    margin-bottom: 0.75rem;
    font-size: 1.75rem;
  }

  .co-card__badge {
    display: block;
  }

  .co-card__title {
    font-size: 1.25rem;
  }
}

/* Modo anclado (lo activa el JS): la sección ocupa varias pantallas de scroll
   y el escenario se queda fijo mientras cambian fondo y tarjetas. */
.co-projects--pinned .co-projects__track {
  height: 340vh;
}

.co-projects--pinned .co-projects__stage {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  min-height: 0;
}

.co-projects--pinned .co-projects__bg {
  transition: opacity 0.9s cubic-bezier(0.4, 0, 0.2, 1);
}

.co-projects--pinned .co-card {
  opacity: 0;
  visibility: hidden;
  transform: translateY(28px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.7s;
}

.co-projects--pinned .co-card.is-on {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

@media (max-width: 767px) {
  .co-projects--pinned .co-projects__track {
    height: 300vh;
  }
}

@media (max-height: 560px) {
  .co-projects--pinned .co-projects__stage {
    padding-top: 5rem;
    padding-bottom: 1.5rem;
  }

  .co-projects__cards {
    padding-top: 1.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .co-projects__bgs {
    transform: none;
  }

  .co-card {
    transition: none;
  }
}
