/* ==========================================================================
   Service Template (Servizi) — OPTIMIZED & CLEAN
   - Keeps existing layout choices (hero offset, intro 2 columns, full-bleed image)
   - Unifies duplicated rules
   - Updates "Come funziona / Cosa offriamo" cards to match prototype (wide, low cards, 3 cols desktop)
   ========================================================================== */

/* ---------------- VARIABLES ---------------- */
:root{
  --site-max: 1180px;
  --container-pad: 20px;

  --primary-blue: #2050f2;
  --text-color: #0f1724; /* near-black for headings */
  --muted: #6b7280;

  /* header offset (fallback; JS may override) */
  --site-header-offset: 84px;

  /* Spacing */
  --hero-to-intro-gap: 32px;          /* gap between hero and intro */
  --intro-bottom-desktop: 64px;       /* gap between intro and next block */
  --intro-bottom-mobile: 36px;
  --how-subgap-desktop: 32px;         /* gap between how subtitle and grid */
  --how-grid-top-desktop: 28px;       /* extra top margin for how grid */
  --content-gap-lg: 48px;

  /* Cards (services) */
  --svc-card-border: rgba(16,24,40,0.08);
  --svc-card-shadow: 0 10px 30px rgba(16,24,40,0.06);
}

/* ---------------- BOX-SIZING & CONTAINER ---------------- */
*, *::before, *::after { box-sizing: border-box; }
.container { max-width: var(--site-max); margin: 0 auto; padding: 0 var(--container-pad); }

/* ---------------- HERO ---------------- */
/* Respect fixed header offset; a JS helper may set --site-header-offset dynamically */
.news-hero,
.sp-hero,
.news-hero-block {
  padding-top: var(--site-header-offset) !important;
  background-size: cover;
  background-position: center center;
  box-sizing: border-box;
}

.news-hero .news-hero-inner,
.sp-hero .sp-hero-inner {
  position: relative;
  z-index: 3;
  width: 100%;
  text-align: center;
  padding: 48px 20px;
}

/* Hero typography */
.sp-hero-title,
.news-hero .news-hero-title {
  font-size: clamp(1.6rem, 2.6vw, 2.8rem);
  font-weight: 700;
  color: #fff;
  margin: 0;
  text-shadow: 0 6px 20px rgba(2,10,30,0.18);
}
.sp-hero-sub,
.news-hero .news-hero-sub {
  color: rgba(255,255,255,0.92);
  margin-top: 8px;
}

/* ---------------- INTRO (title single col, body two cols) ---------------- */
.sp-intro {
  padding: 0;
  margin-top: var(--hero-to-intro-gap);
  margin-bottom: var(--intro-bottom-desktop);
  text-align: center;
  position: relative;
  z-index: 1;
}
.sp-intro-inner { max-width: 980px; margin: 0 auto; }
.sp-intro-title { margin: 0 0 28px; font-size: 1.9rem; font-weight:700; color: var(--text-color); }

.sp-intro-body {
  color: var(--muted);
  line-height: 1.8;
  column-count: 2;
  column-gap: var(--content-gap-lg);
  text-align: left;
  font-size: 1.02rem;
  margin: 0 auto;
}

@media (max-width:1100px) {
  .sp-intro { margin-bottom: calc(var(--intro-bottom-desktop) * 0.85); }
}
@media (max-width:900px) {
  .sp-intro { margin-bottom: var(--intro-bottom-mobile); margin-top: 20px; }
  .sp-intro-body { column-count: 1; padding: 0 18px; text-align:center; }
}

/* ---------------- FULL-BLEED IMAGE ---------------- */
/* full-bleed figure: extend to viewport */
.sp-full-image {
  width: 100vw;
  position: relative;
  left: 50%;
  margin-left: -50vw;
  margin-right: -50vw;
  overflow: hidden;
  padding: 0;
  box-sizing: border-box;

  margin-top: 24px;
  margin-bottom: 56px;
}

/* Image: cover + responsive height using existing theme var (fallback 450px) */
.sp-full-image img.service-full-image {
  display: block;
  width: 100%;
  height: var(--service-group-image-height, 450px);
  max-width: none;
  object-fit: cover;
  object-position: 50% 50%;
}

/* Responsive image heights */
@media (min-width: 1200px) {
  .sp-full-image img.service-full-image {
    height: calc(var(--service-group-image-height, 450px) * 1.2);
  }
}
@media (max-width: 900px) {
  .sp-full-image img.service-full-image {
    height: 160px !important;          /* tuned mobile height */
    object-position: center 35% !important;
  }

  /* Optional overlay for readability (kept because it was in your file) */
  .sp-full-image::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(255,255,255,0) 30%, rgba(255,255,255,0.2) 100%);
  }
}

/* ---------------- HOW IT WORKS / COSA OFFRIAMO ---------------- */
.sp-how {
  padding: 44px 0 12px;
  text-align: center;
  margin-bottom: 96px; /* spacing before next blocks (e.g., reviews) */
}

.sp-section-header { margin-bottom: 18px; }
.sp-section-header .sp-section-sub {
  color: var(--muted);
  margin-top: 8px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: var(--how-subgap-desktop);
}

/* Grid: 1 col mobile, 2 cols tablet, 3 cols desktop (prototype) */
.sp-how-grid {
  display: grid;
  gap: 22px;
  grid-template-columns: 1fr;
  align-items: stretch;
  margin-top: var(--how-grid-top-desktop);
  max-width: var(--site-max);
  margin-left: auto;
  margin-right: auto;
}

@media (min-width:760px) { .sp-how-grid { grid-template-columns: repeat(2,1fr); } }
@media (min-width:1100px) { .sp-how-grid { grid-template-columns: repeat(3,1fr); } }

/* Card (prototype-like): wide, low, left aligned, subtle border + soft shadow */
.sp-how-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;

  padding: 22px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--svc-card-border);
  box-shadow: var(--svc-card-shadow);
}

/* Icon: small, calm (still supports uploaded icon from metabox) */
.sp-how-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 12px;

  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(32,80,242,0.10);
  box-shadow: none;
  color: var(--primary-blue);

  margin: 0 0 14px;
}

.sp-how-icon img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  display: block;
  filter: none; /* do not invert; keep original icon colors */
}

/* If SVG fallback exists, keep it readable */
.sp-how-icon svg path,
.sp-how-icon svg rect,
.sp-how-icon svg circle {
  fill: currentColor !important;
  stroke: currentColor !important;
}

.sp-how-title {
  margin: 0 0 8px;
  font-weight: 800;
  color: var(--text-color);
  font-size: 1.05rem;
  line-height: 1.2;
}
.sp-how-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.98rem;
  max-width: none;
}

/* Hover lift (desktop) */
@media (hover:hover){
  .sp-how-item{
    transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
  }
  .sp-how-item:hover{
    transform: translateY(-3px);
    box-shadow: 0 16px 44px rgba(16,24,40,0.10);
    border-color: rgba(32,80,242,0.18);
  }
}

/* Mobile spacing tweaks */
@media (max-width:900px) {
  .sp-section-header .sp-section-sub { margin-bottom: 20px; }
  .sp-how-grid { margin-top: 18px; }
  .sp-how { margin-bottom: 56px; }
}
@media (max-width:520px){
  .sp-how-item{ padding: 18px 16px; border-radius: 12px; }
}

/* ---------------- REVIEWS SECTION ---------------- */
/* Defensive: ensure reviews section doesn't create layout gaps when absent */
.sp-reviews { margin: 0; padding: 0; }
.sp-reviews:empty { display: none !important; }
.sp-reviews .sp-reviews-inner:empty { display: none !important; }
.sp-reviews .sp-reviews-inner:only-child:empty { display: none !important; }

/* ---------------- FINAL CTA fallback (kept unchanged) ---------------- */
.sp-final-cta {
  padding: 48px 0;
  background: linear-gradient(180deg, rgba(43,123,255,0.04), rgba(43,123,255,0.01));
  margin-top: 48px;
}
.sp-final-cta-inner {
  max-width: var(--site-max);
  margin: 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 20px;
  padding: 0 var(--container-pad);
  box-sizing: border-box;
}
.sp-final-cta-text { font-weight:700; color:var(--text-color); }
.sp-final-cta-button {
  background: var(--primary-blue);
  color:#fff;
  padding:10px 18px;
  border-radius:999px;
  text-decoration:none;
  font-weight:700;
  box-shadow: 0 8px 20px rgba(11,95,255,0.12);
}

/* ---------------- ADDITIONAL TEXT BLOCKS ---------------- */
/* (kept but cleaned: single definition, aligned with intro width) */
.sp-additional {
  padding: 32px 0;
}
body.page-template-page-service-template .sp-additional-inner {
  max-width: 980px;
  margin: 0 auto;
  padding-left: var(--container-pad);
  padding-right: var(--container-pad);
  box-sizing: border-box;
}
body.page-template-page-service-template .sp-additional-content {
  max-width: 980px;
  margin: 0 auto;
  text-align: left;
  box-sizing: border-box;
}
body.page-template-page-service-template .sp-additional-title {
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--text-color);
  text-align: left;
}
body.page-template-page-service-template .sp-additional-body {
  color: var(--text-color);
  text-align: left;
  line-height: 1.7;
  font-size: 1rem;
  white-space: normal;
  word-wrap: break-word;
  margin: 0 auto;
}
body.page-template-page-service-template .sp-additional-body p {
  margin: 0 0 1.15rem;
}
body.page-template-page-service-template .sp-additional-body ul,
body.page-template-page-service-template .sp-additional-body ol {
  margin: 0 0 1.15rem 1.25rem;
  padding-left: 0;
  text-align: left;
  display: block;
}

@media (max-width: 900px) {
  body.page-template-page-service-template .sp-additional-inner,
  body.page-template-page-service-template .sp-additional-content {
    max-width: 100%;
    padding-left: 18px;
    padding-right: 18px;
  }
}

/* Aggiunta minima: wrapper per contenuto Gutenberg della pagina servizi */
.sp-content{
  padding: 0;
  margin-top: 8px;
  margin-bottom: 54px;
}
.sp-content-inner{
  max-width: 980px;
  margin: 0 auto;
}

/* Gutenberg: spacing base tra blocchi */
.sp-content-inner > * + *{
  margin-top: 18px;
}

/* Immagini responsive nel contenuto */
.sp-content-inner img{
  max-width: 100%;
  height: auto;
  border-radius: 12px;
}