.service-detail-overlay {
  position: fixed;
  inset: 50% auto auto 40px;
  z-index: 46;
  width: min(760px, calc(100vw - 80px));
  max-height: min(760px, calc(100vh - 96px));
  overflow-y: auto;
  padding: clamp(78px, 8vw, 96px) clamp(34px, 5vw, 64px) clamp(46px, 5vw, 64px);
  color: #111;
  background: rgba(255, 255, 255, 0.97);
  border-radius: 6px;
  box-shadow: 0 0 0 100vmax rgba(9, 14, 22, 0.76), 0 24px 72px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(16px) saturate(0.88);
  -webkit-backdrop-filter: blur(16px) saturate(0.88);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(calc(-100% - 56px), -50%, 0);
  transition: opacity 300ms cubic-bezier(0.22, 1, 0.36, 1), transform 620ms cubic-bezier(0.22, 1, 0.36, 1), visibility 620ms step-end;
}

.service-detail-overlay.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, -50%, 0);
  transition: opacity 300ms cubic-bezier(0.22, 1, 0.36, 1), transform 620ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s step-start;
}

body.service-detail-is-open { overflow: hidden; }

.service-detail-overlay__close {
  position: absolute;
  top: 32px;
  right: 32px;
  min-width: 42px;
  height: 28px;
  border: 1px solid rgba(17, 17, 17, 0.38);
  border-radius: 4px;
  padding: 0 9px;
  color: #111;
  background: transparent;
  font: 500 1rem/1 "Montserrat", Arial, sans-serif;
  letter-spacing: 0.12em;
  text-transform: lowercase;
  cursor: pointer;
}

.service-detail-overlay__eyebrow {
  margin: 0 0 22px;
  color: rgba(17, 17, 17, 0.58);
  font: 500 1.05rem/1.2 "Montserrat", Arial, sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.service-detail-overlay__title {
  max-width: 660px;
  margin: 0;
  font-family: "Times New Roman", Times, serif;
  font-size: clamp(4.4rem, 6vw, 7.6rem);
  font-style: italic;
  font-weight: 400;
  line-height: 0.96;
  letter-spacing: 0;
}

.service-detail-overlay__intro {
  max-width: 650px;
  margin: 30px 0 0;
  color: rgba(17, 17, 17, 0.75);
  font: 400 clamp(1.55rem, 1.35vw, 1.9rem)/1.55 "Montserrat", Arial, sans-serif;
}

.service-detail-overlay__list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 32px;
  margin: 36px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid rgba(17, 17, 17, 0.18);
}

.service-detail-overlay__list li {
  padding: 16px 0;
  border-bottom: 1px solid rgba(17, 17, 17, 0.18);
  font: 500 1.3rem/1.35 "Montserrat", Arial, sans-serif;
}

.service-detail-overlay__cta {
  display: inline-flex;
  align-items: center;
  min-height: 46px;
  margin-top: 36px;
  border: 1px solid rgba(17, 17, 17, 0.46);
  border-radius: 999px;
  padding: 12px 20px;
  color: #111;
  background: transparent;
  font: 600 1.05rem/1 "Montserrat", Arial, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}

.service-detail-overlay__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 36px;
}

.service-detail-overlay__actions .service-detail-overlay__cta {
  margin-top: 0;
}

.service-catalog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 38px 46px;
  margin-top: 42px;
}

.service-catalog-group {
  padding-top: 20px;
  border-top: 1px solid rgba(17, 17, 17, 0.22);
}

.service-catalog-group h3 {
  margin: 0 0 16px;
  font-family: "Times New Roman", Times, serif;
  font-size: 2.4rem;
  font-weight: 400;
  line-height: 1.05;
}

.service-catalog-group ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: service-item;
}

.service-catalog-group li {
  display: grid;
  grid-template-columns: 2.7rem minmax(0, 1fr);
  gap: 8px;
  padding: 6px 0;
  color: rgba(17, 17, 17, 0.7);
  font: 400 1.22rem/1.45 "Montserrat", Arial, sans-serif;
  counter-increment: service-item;
}

.service-catalog-group li::before {
  content: counter(service-item, decimal-leading-zero);
  color: rgba(17, 17, 17, 0.38);
  font-size: 0.9em;
}

#services .image-card {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#services .image-card p {
  min-height: 4.6em;
}

#services .image-card .line-link[data-service-open] {
  align-self: flex-start;
  margin-top: auto;
  position: relative;
  padding: 20px 0 8px;
  overflow: hidden;
  white-space: nowrap;
  transform: none !important;
}

#services .image-card .line-link::before,
#services .line-link[data-service-all]::before {
  display: none;
}

#services .image-card .line-link::after,
#services .line-link[data-service-all]::after {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  transform: scaleX(1);
  transform-origin: center;
  transition: transform 450ms cubic-bezier(0.16, 1, 0.3, 1);
}

#services .image-card .line-link:hover::after,
#services .image-card .line-link:focus-visible::after,
#services .line-link[data-service-all]:hover::after,
#services .line-link[data-service-all]:focus-visible::after {
  width: 100%;
  animation: foundation-underline-sweep 800ms cubic-bezier(.5, 0, 0, 1);
}

#services .line-link[data-service-all] {
  position: relative;
  padding-bottom: 8px;
  overflow: hidden;
  white-space: nowrap;
}

.service-detail-overlay__content > * {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  transition: opacity 340ms cubic-bezier(0.22, 1, 0.36, 1), transform 480ms cubic-bezier(0.22, 1, 0.36, 1);
}

.service-detail-overlay.is-open .service-detail-overlay__content > * {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.service-detail-overlay.is-open .service-detail-overlay__title { transition-delay: 70ms; }
.service-detail-overlay.is-open .service-detail-overlay__intro { transition-delay: 120ms; }
.service-detail-overlay.is-open .service-detail-overlay__list,
.service-detail-overlay.is-open .service-catalog-grid { transition-delay: 170ms; }
.service-detail-overlay.is-open .service-detail-overlay__actions { transition-delay: 220ms; }

@media (max-width: 767px) {
  .service-detail-overlay {
    inset: 16px;
    width: auto;
    max-height: none;
    padding: 100px 26px 48px;
    transform: translate3d(calc(-100% - 24px), 0, 0);
  }

  .service-detail-overlay.is-open { transform: translate3d(0, 0, 0); }
  .service-detail-overlay__close { top: 24px; right: 24px; }
  .service-detail-overlay__title { font-size: clamp(3.8rem, 14vw, 5.4rem); }
  .service-detail-overlay__intro { font-size: 1.45rem; }
  .service-detail-overlay__list,
  .service-catalog-grid { grid-template-columns: 1fr; }
  .service-catalog-grid { gap: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .service-detail-overlay,
  .service-detail-overlay__content > * { transition-duration: 1ms !important; }
}

#services .image-card p {
  white-space: pre-line;
}

@keyframes foundation-underline-sweep {
  0% { transform: translateX(0); }
  49% { transform: translateX(101%); }
  50% { transform: translateX(-101%); }
  100% { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  #services .line-link:hover::after,
  #services .line-link:focus-visible::after { animation: none; }
}

/* Keep the four Foundations readable without a long mobile scroll. */
@media (max-width: 767px) {
  #services { padding-block: 44px 36px; }
  #services .carousel-layout { gap: 8px; }
  #services .section-heading__text { margin-top: 16px; }
  #services .section-heading .line-link { display: none; }
  #services-card-track .image-card,
  #services-card-track .image-card:nth-child(even) { padding-block: 20px; }
  #services .image-card h3 { margin-top: 0; }
  #services .image-card p { margin-top: 12px; min-height: 0; }
  #services .image-card .line-link[data-service-open] {
    margin-top: 16px;
    padding-top: 8px;
  }
}

/* Mobile Foundations follow the numbered How we work rows. */
@media (max-width: 767px) {
  #services-card-track { counter-reset: foundation-step; }
  #services-card-track .image-card,
  #services-card-track .image-card:nth-child(even) {
    display: grid;
    grid-template-columns: 2.6rem minmax(0, 1fr);
    align-items: baseline;
    gap: 0 1.6rem;
    height: auto;
    padding-block: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .28);
    counter-increment: foundation-step;
  }
  #services-card-track .image-card:first-child { border-top: 1px solid rgba(255, 255, 255, .28); }
  #services-card-track .image-card::before {
    content: counter(foundation-step, decimal-leading-zero);
    grid-column: 1;
    grid-row: 1;
    color: var(--muted);
    font: 400 1.1rem/1.5 "Helvetica Neue", Arial, sans-serif;
    letter-spacing: .22em;
  }
  #services-card-track .image-card__media { display: none; }
  #services-card-track .image-card h3 {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    color: var(--white);
    font: italic 300 2.4rem/1.1 "Times New Roman", Times, serif;
  }
  #services-card-track .image-card p {
    grid-column: 2;
    margin-top: 12px;
    color: rgba(255, 255, 255, .86);
    font: 300 1.6rem/1.5 "Montserrat", Arial, sans-serif;
  }
  #services-card-track .image-card .line-link[data-service-open] { display: none; }
}

#services .foundations-mobile-action { display: none; }
@media (max-width: 767px) {
  #services .foundations-mobile-action {
    display: inline-flex;
    justify-self: center;
    margin: 12px 24px 0;
    max-width: calc(100% - 48px);
    white-space: normal;
    text-align: start;
  }
}

/* Match the landing hero's primary Get started pill. */
.service-detail-overlay__actions .service-detail-overlay__cta--hero {
  justify-content: center;
  width: min(148px, calc((100vw - 60px) / 2));
  height: 44px;
  min-height: 44px;
  padding: 10px 12px;
  border-color: #1b1b19;
  background: #1b1b19;
  color: #f1ede7;
  font: 400 1.4rem/1.2 "Montserrat", Arial, sans-serif;
  letter-spacing: 0;
  text-transform: none;
  transition: background 360ms ease, border-color 360ms ease;
}
.service-detail-overlay__actions .service-detail-overlay__cta--hero:hover {
  background: #30302c;
  border-color: #30302c;
}
@media (max-width: 767px) {
  .service-detail-overlay__actions .service-detail-overlay__cta--hero { font-size: 1.3rem; }
}

/* Desktop uses the same numbered Foundations and single closing action. */
@media (min-width: 768px) {
  #services .section-heading .line-link { display: none; }
  #services-card-track {
    grid-template-columns: minmax(0, 1fr);
    counter-reset: foundation-step;
  }
  #services-card-track .image-card,
  #services-card-track .image-card:nth-child(even) {
    display: grid;
    grid-template-columns: 3.4rem 13rem minmax(0, 1fr);
    align-items: baseline;
    gap: 0 1.6rem;
    height: auto;
    padding: 24px 0;
    border: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .28) !important;
    counter-increment: foundation-step;
  }
  #services-card-track .image-card:first-child { border-top: 1px solid rgba(255, 255, 255, .28); }
  #services-card-track .image-card::before {
    content: counter(foundation-step, decimal-leading-zero);
    color: var(--muted);
    font: 400 1.1rem/1.5 "Helvetica Neue", Arial, sans-serif;
    letter-spacing: .22em;
  }
  #services-card-track .image-card__media,
  #services-card-track .image-card .fd-line,
  #services-card-track .image-card .line-link[data-service-open] { display: none; }
  #services-card-track .image-card h3 {
    margin: 0;
    color: var(--white);
    font: italic 300 2.4rem/1.1 "Times New Roman", Times, serif;
  }
  #services-card-track .image-card p {
    margin: 0;
    min-height: 0;
    color: rgba(255, 255, 255, .86);
    font: 300 1.6rem/1.5 "Montserrat", Arial, sans-serif;
  }
  #services .foundations-mobile-action {
    display: inline-flex;
    grid-column: 2;
    justify-self: center;
    margin-top: 0;
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }
}
@media (min-width: 768px) and (max-width: 1024px) {
  #services .foundations-mobile-action { grid-column: 1 / -1; }
}
@media (min-width: 768px) {
  #services #services-card-track .image-card {
    border-bottom: 1px solid rgba(255, 255, 255, .28) !important;
  }
}
@media (min-width: 1025px) {
  #services .foundations-mobile-action { margin-inline: 0 92px; }
}

@media (min-width: 768px) {
  #services .section-heading .line-link[data-service-all] { display: inline-flex; }
  #services .foundations-mobile-action { display: none; }
}

/* Foundation copy stays visible without the scroll-reveal animation. */
#services-card-track .image-card h3,
#services-card-track .image-card p {
  opacity: 1;
  transform: none;
  transition: none;
  transition-delay: 0s;
  will-change: auto;
}
