@media (max-width: 760px) {
  .services-layout {
    transform: translateY(-4svh);
    padding-bottom: 38px;
  }
}

@media (max-width: 760px) and (max-height: 700px) {
  .services-layout {
    transform: translateY(-5svh);
    padding-bottom: 42px;
  }
}

@media (max-width: 640px) {
  body.services-page {
    overflow: hidden;
    background: #071d18;
  }

  .services-showcase {
    height: 100dvh;
    min-height: 100dvh;
    background: #071d18;
  }

  .services-background {
    will-change: opacity, transform;
    transition:
      opacity .48s cubic-bezier(.22, .61, .36, 1),
      transform .62s cubic-bezier(.22, .61, .36, 1);
  }

  .services-background img {
    filter: saturate(.76) contrast(1.05) brightness(.52);
  }

  .services-background::after {
    background:
      linear-gradient(180deg, rgba(2, 20, 16, .54) 0%, rgba(2, 20, 16, .22) 42%, rgba(2, 20, 16, .68) 100%);
  }

  .services-shade {
    background:
      radial-gradient(circle at 50% 42%, rgba(14, 122, 87, .14) 0%, transparent 44%),
      linear-gradient(180deg, rgba(1, 18, 14, .08), rgba(1, 18, 14, .34));
  }

  .services-home {
    top: max(16px, env(safe-area-inset-top));
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(3, 27, 22, .44);
    backdrop-filter: blur(8px);
  }

  .services-home svg {
    width: 18px;
    height: 18px;
  }

  .services-rail {
    display: none;
  }

  .services-layout {
    position: relative;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    transform: none;
    display: block;
  }

  .services-carousel {
    position: absolute;
    inset: max(58px, calc(env(safe-area-inset-top) + 48px)) 0 0;
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0;
    overflow: visible;
    touch-action: pan-y;
    cursor: grab;
  }

  .services-carousel.is-dragging {
    cursor: grabbing;
  }

  .services-track {
    height: 100%;
    counter-reset: mobile-service-card;
  }

  .service-category-card,
  .service-category-card.is-active {
    top: auto;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    width: min(72vw, 304px);
    height: min(69dvh, 575px);
    padding: 12px 12px 0;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 20px 20px 0 0;
    background: #FBFBF7;
    box-shadow: 0 24px 68px rgba(0, 0, 0, .3);
    opacity: var(--card-opacity, 0);
    transform: translate3d(var(--card-x, 0px), 0, 0) scale(var(--card-scale, .82));
    transform-origin: 50% 100%;
    transition:
      transform .5s cubic-bezier(.16, 1, .3, 1),
      opacity .38s ease,
      box-shadow .42s ease;
    will-change: transform, opacity;
    counter-increment: mobile-service-card;
  }

  .service-category-card.is-active {
    box-shadow: 0 30px 82px rgba(0, 0, 0, .38);
  }

  .service-category-card::after {
    content: "Contáctanos";
    position: static;
    inset: auto;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    min-height: 44px;
    margin: 9px 0 12px;
    border-radius: 2px;
    background: #020A14;
    color: #FBFBF7;
    font-family: "Montserrat", system-ui, sans-serif;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .02em;
    pointer-events: none;
  }

  .service-category-card img,
  .service-category-card.is-active img {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    min-height: 0;
    border-radius: 14px;
    object-fit: cover;
    filter: saturate(.9) brightness(.94);
    transform: none !important;
    transition: filter .32s ease;
  }

  .service-category-card.is-active img {
    filter: saturate(1) brightness(1);
  }

  .service-card-label {
    position: static;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0;
    min-height: 0;
    padding: 11px 6px 0;
    color: #013D2E;
    text-align: center;
  }

  .service-card-label > div:first-child {
    width: 100%;
  }

  .service-card-label span {
    display: none;
  }

  .service-card-label strong {
    display: block;
    margin: 0 auto;
    max-width: 230px;
    color: #013D2E;
    font-size: .96rem;
    line-height: 1.08;
    letter-spacing: -.028em;
    text-align: center;
  }

  .service-card-index {
    position: static;
    margin-top: 7px;
    transform: none;
    color: #065B42;
    font-size: 0;
    font-weight: 700;
    letter-spacing: .08em;
    opacity: .68;
  }

  .service-card-index::before {
    content: counter(mobile-service-card) " / 5";
    font-size: .6rem;
  }

  .services-copy {
    display: none;
  }

  .service-category-card:has(+ .service-category-card.is-active) {
    transform: translate3d(calc(var(--card-x, 0px) - 28px), 0, 0) scale(var(--card-scale, .82));
  }

  .service-category-card.is-active + .service-category-card {
    transform: translate3d(calc(var(--card-x, 0px) + 28px), 0, 0) scale(var(--card-scale, .82));
  }

  .services-track:has(> .service-category-card:first-child.is-active) > .service-category-card:last-child {
    transform: translate3d(calc(var(--card-x, 0px) - 28px), 0, 0) scale(var(--card-scale, .82));
  }

  .services-track:has(> .service-category-card:last-child.is-active) > .service-category-card:first-child {
    transform: translate3d(calc(var(--card-x, 0px) + 28px), 0, 0) scale(var(--card-scale, .82));
  }

  .services-mobile-detail {
    position: fixed;
    inset: 0;
    z-index: 30;
    width: 100vw;
    height: 100dvh;
    overflow: hidden;
    background: #FBFBF7;
    color: #013D2E;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translate3d(0, 28px, 0);
    transition:
      opacity .28s ease,
      transform .42s cubic-bezier(.16, 1, .3, 1),
      visibility 0s linear .42s;
  }

  .services-mobile-detail.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate3d(0, 0, 0);
    transition-delay: 0s;
  }

  .services-mobile-detail-close {
    position: fixed;
    top: max(16px, env(safe-area-inset-top));
    left: 16px;
    z-index: 4;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(1, 61, 46, .24);
    border-radius: 50%;
    background: rgba(251, 251, 247, .9);
    color: #013D2E;
    appearance: none;
    -webkit-appearance: none;
  }

  .services-mobile-detail-close::before,
  .services-mobile-detail-close::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 15px;
    height: 1.5px;
    background: currentColor;
    border-radius: 999px;
  }

  .services-mobile-detail-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
  }

  .services-mobile-detail-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
  }

  .services-mobile-detail-sheet {
    width: 100%;
    height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    box-sizing: border-box;
    padding:
      max(76px, calc(env(safe-area-inset-top) + 66px))
      22px
      max(28px, env(safe-area-inset-bottom));
    background: #FBFBF7;
    color: #013D2E;
    -webkit-overflow-scrolling: touch;
  }

  .services-mobile-detail-title {
    margin: 0 auto;
    max-width: 330px;
    color: #013D2E;
    font-size: clamp(1.75rem, 8.6vw, 2.45rem);
    line-height: .98;
    letter-spacing: -.045em;
    text-align: center;
  }

  .services-mobile-detail-heading {
    margin: 34px 0 16px;
    color: #013D2E;
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -.02em;
    text-align: center;
  }

  .services-mobile-subservices {
    display: flex;
    gap: 14px;
    margin: 0 -22px;
    padding: 0 22px 10px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .services-mobile-subservices::-webkit-scrollbar {
    display: none;
  }

  .services-mobile-subservice {
    flex: 0 0 118px;
    margin: 0;
    scroll-snap-align: start;
  }

  .services-mobile-subservice img {
    display: block;
    width: 118px;
    height: 88px;
    margin: 0;
    border-radius: 14px;
    object-fit: cover;
    background: #E8E7E0;
  }

  .services-mobile-subservice figcaption {
    margin-top: 8px;
    color: #29493F;
    font-size: .62rem;
    font-weight: 600;
    line-height: 1.28;
    text-align: left;
  }

  .services-mobile-detail-description {
    max-width: 360px;
    margin: 28px auto 0;
    color: #456057;
    font-size: .76rem;
    line-height: 1.68;
    text-align: left;
  }

  .services-mobile-detail-contact {
    display: block;
    width: 100%;
    margin: 30px 0 0;
    padding: 14px 20px;
    border: 0;
    border-radius: 2px;
    background: #020A14;
    color: #FBFBF7;
    font: inherit;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
  }

  .services-showcase.mobile-detail-open .services-home {
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 640px) and (max-height: 700px) {
  .services-carousel {
    top: max(54px, calc(env(safe-area-inset-top) + 44px));
  }

  .service-category-card,
  .service-category-card.is-active {
    height: min(68dvh, 475px);
  }

  .services-mobile-detail-sheet {
    padding-top: max(68px, calc(env(safe-area-inset-top) + 58px));
  }

  .services-mobile-detail-heading {
    margin-top: 26px;
  }
}

@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .services-background,
  .service-category-card,
  .services-mobile-detail {
    transition-duration: .01ms !important;
  }
}
