#servicios {
  position: relative;
  isolation: isolate;
}

#servicios h2 {
  margin: 0 0 28px;
  text-align: center;
  text-wrap: balance;
}

#servicios .service-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px 20px;
  align-items: start;
}

#servicios .service {
  grid-column: auto;
  width: min(100%, 300px);
  justify-self: center;
  overflow: visible;
  border: 0;
  background: none;
  text-align: center;
}

#servicios .service:last-child {
  grid-column: 1 / -1;
}

#servicios .service-copy {
  padding: 8px 0 0;
}

#servicios .service h3 {
  line-height: 1.12;
  text-wrap: balance;
}

.service-stage {
  position: relative;
  display: grid;
  width: 100%;
  aspect-ratio: 1.65;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 53%, #a269f033, transparent 68%);
  perspective: 720px;
}

.service-orbit {
  display: block;
  width: 100%;
  transform-style: preserve-3d;
  animation: service-float 5.6s ease-in-out var(--phase, 0s) infinite;
}

.service-stage img {
  aspect-ratio: auto;
  mask-image: radial-gradient(ellipse 61% 61% at center, black 43%, transparent 86%);
}

@media (min-width: 880px) {
  #servicios {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-template-rows: repeat(3, auto);
    gap: 12px 16px;
  }

  #servicios::before {
    position: absolute;
    z-index: -1;
    inset: 14% 13% 15%;
    border: 1px dashed #a67cdd58;
    border-radius: 50%;
    background: radial-gradient(ellipse at center, #5c33972d, transparent 65%);
    pointer-events: none;
    content: "";
  }

  #servicios h2 {
    grid-area: 2 / 5 / 3 / 9;
    align-self: center;
    margin: 0;
    font-size: clamp(36px, 4.6vw, 64px);
  }

  #servicios .service-grid { display: contents; }
  #servicios .service:nth-child(1) { grid-area: 1 / 5 / 2 / 9; }
  #servicios .service:nth-child(2) { grid-area: 2 / 9 / 3 / 13; }
  #servicios .service:nth-child(3) { grid-area: 3 / 7 / 4 / 11; }
  #servicios .service:nth-child(4) { grid-area: 3 / 3 / 4 / 7; }
  #servicios .service:nth-child(5) { grid-area: 2 / 1 / 3 / 5; }
}

@media (max-width: 540px) {
  #servicios .service-grid { grid-template-columns: minmax(0, 1fr); }
  #servicios .service:nth-child(odd) { justify-self: start; }
  #servicios .service:nth-child(even) { justify-self: end; }
  #servicios .service { width: min(88%, 300px); }
}

.service:nth-child(2) { --phase: -1.2s; }
.service:nth-child(3) { --phase: -2.4s; }
.service:nth-child(4) { --phase: -3.6s; }
.service:nth-child(5) { --phase: -4.8s; }

.service-stage.is-spinning img {
  animation: service-spin .95s cubic-bezier(.45, .05, .25, 1) both;
}

@media (hover: hover) and (pointer: fine) {
  .service-stage:not(.is-spinning):hover img {
    animation: service-swing 1.15s ease-in-out both;
  }
}

@keyframes service-float {
  0%, 100% { transform: translateY(3px) rotateX(6deg) rotateY(-9deg) rotateZ(-2deg); }
  50% { transform: translateY(-9px) rotateX(-5deg) rotateY(10deg) rotateZ(2deg); }
}

@keyframes service-spin {
  0% { transform: rotateY(0); }
  100% { transform: rotateY(360deg); }
}

@keyframes service-swing {
  0%, 100% { transform: rotateY(0); }
  35% { transform: rotateY(30deg); }
  70% { transform: rotateY(-16deg); }
}

@media (prefers-reduced-motion: reduce) {
  .service-orbit,
  .service-stage.is-spinning img,
  .service-stage:not(.is-spinning):hover img {
    animation: none;
  }
}

.service-title span {
  position: relative;
  display: inline-block;
  color: #e9d7ff;
}

@supports (background-clip: text) {
  .service-title span {
    background: linear-gradient(110deg, #f5e8ff 26%, #d3a3ff 44%, #9feadc 51%, #f5e8ff 70%);
    background-size: 250% 100%;
    background-clip: text;
    color: transparent;
    animation: service-title-sweep 6s ease-in-out infinite;
  }
}

@keyframes service-title-sweep {
  0%, 100% { background-position: 100% 50%; }
  48%, 68% { background-position: 0% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .service-title span { animation: none; }
}

@media (forced-colors: active) {
  .service-title span { background: none; color: CanvasText; }
}
