/**
 * Internal service pages
 *
 * This layer extends the Services page without repeating its hub-card layout.
 * It is loaded only for service descendants and in their Gutenberg iframe.
 */

:where(.progesto-service-detail, .editor-styles-wrapper) {
  --service-detail-space: clamp(88px, 8vw, 112px);
}

.page--service-detail {
  color: var(--ink);
  background: transparent;
  font-family: var(--font);
}

.page--service-detail > section,
.page--service-detail > .wp-block-progesto-demo-section {
  width: 100%;
}

.page--service-detail .container {
  width: var(--container);
  max-width: none;
  margin-inline: auto;
}

:where(.page--service-detail, .editor-styles-wrapper) .panel-section,
:where(.page--service-detail, .editor-styles-wrapper) .demo-section {
  padding-block: var(--service-detail-space);
}

:where(.page--service-detail, .editor-styles-wrapper) .section-head {
  margin-bottom: clamp(34px, 4vw, 50px);
}

:where(.page--service-detail, .editor-styles-wrapper) :is(#percorso, #documentazione) > .container > .section-head {
  max-width: none;
}

:where(.page--service-detail, .editor-styles-wrapper) :is(#percorso, #documentazione) > .container > .section-head .sec-sub {
  max-width: none;
}

/* Hero: related to the Services hub, but more compact for a detail page. */
:where(.page--service-detail, .editor-styles-wrapper) .hero {
  min-height: min(840px, 92svh);
}

:where(.page--service-detail, .editor-styles-wrapper) .hero-layout {
  align-items: center;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
  gap: clamp(40px, 5vw, 64px);
}

:where(.page--service-detail, .editor-styles-wrapper) .hero h1 {
  max-width: 850px;
  font-size: clamp(54px, 6.5vw, 96px);
  overflow-wrap: normal;
  text-wrap: balance;
  hyphens: none;
}

:where(.page--service-detail, .editor-styles-wrapper) .hero-card {
  align-self: center;
}

/* Process: an alternating technical timeline, clearly separated from cards. */
:where(.page--service-detail, .editor-styles-wrapper) .service-process {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-block: 10px;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--blue), var(--sage-l));
  box-shadow: 0 0 24px rgba(36, 127, 182, .16);
  transform: translateX(-50%);
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step {
  position: relative;
  width: calc(50% - 48px);
  min-width: 0;
  padding: clamp(26px, 3vw, 36px);
  border: 1px solid rgba(4, 77, 118, .12);
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255, 255, 255, .94), rgba(239, 247, 249, .86));
  box-shadow: 0 18px 52px rgba(32, 77, 100, .08);
  transition: transform .3s ease, border-color .3s ease, box-shadow .3s ease;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(odd) {
  align-self: flex-start;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(even) {
  align-self: flex-end;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step:hover {
  border-color: rgba(36, 127, 182, .24);
  box-shadow: 0 24px 64px rgba(32, 77, 100, .12);
  transform: translateY(-3px);
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step::after {
  content: "";
  position: absolute;
  top: 47px;
  width: 48px;
  height: 1px;
  background: rgba(36, 127, 182, .28);
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(odd)::after {
  right: -48px;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(even)::after {
  left: -48px;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step .pill {
  --accent: var(--blue);
  position: absolute;
  top: 25px;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  place-items: center;
  border: 4px solid var(--bg-2);
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--blue-d));
  color: #fff;
  box-shadow: 0 0 0 1px rgba(36, 127, 182, .24), 0 10px 26px rgba(36, 127, 182, .22);
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(odd) .pill {
  right: -70px;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(even) .pill {
  left: -70px;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step h3 {
  margin-top: 0;
  font-size: clamp(25px, 2.2vw, 34px);
  line-height: 1.05;
  letter-spacing: -.035em;
  text-wrap: balance;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-process__step p {
  max-width: 34rem;
  margin-top: 14px;
  color: var(--muted);
  font-size: var(--wp--preset--font-size--body-m);
  line-height: 1.68;
}

/* Cases remain cards because they are independent scenarios. */
:where(.page--service-detail, .editor-styles-wrapper) .service-detail-cases {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-case-card {
  min-height: 200px;
  justify-content: flex-start;
  cursor: default;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-case-card p {
  margin-top: 14px;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-case-card:hover {
  transform: none;
  background: rgba(255, 255, 255, .82);
  border-color: color-mix(in srgb, var(--accent) 42%, transparent);
}

:where(.page--service-detail, .editor-styles-wrapper) .service-case-card h3 {
  margin-top: 0;
}

/* Monitoring: compact technical band with a clear service term. */
:where(.page--service-detail, .editor-styles-wrapper) .service-monitor {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 260px);
  gap: clamp(36px, 6vw, 84px);
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(4, 77, 118, .14);
  border-radius: 28px;
  background: rgba(255, 255, 255, .76);
  box-shadow: 0 20px 60px rgba(32, 77, 100, .09);
  backdrop-filter: blur(16px);
}

:where(.page--service-detail, .editor-styles-wrapper) .service-monitor > .section-head {
  align-self: center;
  margin: 0;
  padding: clamp(34px, 5vw, 60px);
}

:where(.page--service-detail, .editor-styles-wrapper) .service-monitor__aside {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 250px;
  padding: 34px;
  color: #fff;
  background:
    linear-gradient(160deg, rgba(58, 169, 220, .44), transparent 58%),
    linear-gradient(135deg, var(--blue), var(--blue-d));
}

:where(.page--service-detail, .editor-styles-wrapper) .service-monitor__label {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  opacity: .74;
}

:where(.page--service-detail, .editor-styles-wrapper) .service-monitor__value {
  font-size: clamp(38px, 4vw, 58px);
  font-weight: 400;
  line-height: .95;
  letter-spacing: -.045em;
}

/* Final CTA stays on the same grid and below the hero in visual priority. */
:where(.page--service-detail, .editor-styles-wrapper) .contact {
  padding-block: clamp(88px, 8vw, 112px);
}

:where(.page--service-detail, .editor-styles-wrapper) .contact .contact-inner {
  width: var(--container);
  max-width: none;
  margin-inline: auto;
}

:where(.page--service-detail, .editor-styles-wrapper) .contact h2 {
  max-width: 960px;
  font-size: clamp(42px, 5vw, 72px);
  text-wrap: balance;
}

:where(.page--service-detail, .editor-styles-wrapper) .contact p {
  max-width: 700px;
}

/* Gutenberg iframe uses the same real-width canvas. */
.editor-styles-wrapper .wp-block-progesto-demo-section {
  margin-block: 0;
}

.editor-styles-wrapper .wp-block-progesto-demo-section > .container {
  width: var(--container);
  max-width: none;
  margin-inline: auto;
}

@media (max-width: 1080px) {
  :where(.page--service-detail, .editor-styles-wrapper) .hero {
    min-height: auto;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .hero-layout {
    grid-template-columns: 1fr;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .hero-card {
    width: min(100%, 620px);
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-process {
    gap: 16px;
    padding-left: 0;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-process::before {
    left: 22px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step,
  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(odd),
  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(even) {
    align-self: stretch;
    width: auto;
    margin-left: 54px;
    padding: 26px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step::after,
  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(odd)::after,
  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(even)::after {
    top: 47px;
    left: -32px;
    right: auto;
    width: 32px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step .pill,
  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(odd) .pill,
  :where(.page--service-detail, .editor-styles-wrapper) .service-process__step:nth-child(even) .pill {
    top: 25px;
    left: -54px;
    right: auto;
  }
}

@media (max-width: 760px) {
  :where(.progesto-service-detail, .editor-styles-wrapper) {
    --container: min(1240px, calc(100% - 32px));
    --service-detail-space: 80px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .hero {
    padding-top: 124px;
    padding-bottom: 68px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .hero h1 {
    font-size: clamp(46px, 13.5vw, 66px);
  }

  :where(.page--service-detail, .editor-styles-wrapper) .hero-card {
    padding: 24px;
    border-radius: 24px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-detail-cases {
    grid-template-columns: 1fr;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-case-card {
    min-height: auto;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-monitor {
    grid-template-columns: 1fr;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-monitor__aside {
    min-height: auto;
    padding: 24px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .service-monitor__label {
    margin-bottom: 10px;
    letter-spacing: .10em;
    line-height: 1.35;
  }

  :where(.page--service-detail, .editor-styles-wrapper) .contact h2 {
    font-size: clamp(40px, 11.5vw, 56px);
  }
}

/* Progemac cross-sell: keep the real product mockup consistent in frontend and Gutenberg. */
:where(.page--service-detail, .editor-styles-wrapper) #progemac .progemac-product-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 520px;
  padding: clamp(28px, 4vw, 56px);
}

:where(.page--service-detail, .editor-styles-wrapper) #progemac .progemac-product-image {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 0;
}

:where(.page--service-detail, .editor-styles-wrapper) #progemac .progemac-product-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 430px;
  margin-inline: auto;
  object-fit: contain;
}

:where(.page--service-detail, .editor-styles-wrapper) #progemac .product-content {
  min-width: 0;
}

@media (max-width: 1080px) {
  :where(.page--service-detail, .editor-styles-wrapper) #progemac .progemac-product-visual {
    min-height: 420px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) #progemac .progemac-product-image img {
    max-height: 360px;
  }
}

@media (max-width: 760px) {
  :where(.page--service-detail, .editor-styles-wrapper) #progemac .progemac-product-visual {
    min-height: 320px;
    padding: 28px 20px;
  }

  :where(.page--service-detail, .editor-styles-wrapper) #progemac .progemac-product-image img {
    max-height: 280px;
  }
}
