/* Service Pillars
   Width, side gutter and vertical padding follow the theme Spacing settings
   via --fs-container-width / --fs-side-gutter / --fs-section-spacing (set in
   theme-overrides.css).
   Colour scheme comes from the Style tab dropdown:
   - light / dark: Flipside palette presets below
   - theme / custom: variables set inline from theme Global colours or the colour pickers */

.sp {
  --sp-bg: #FFFFFF;
  --sp-text: #211A21;
  --sp-muted: #58504E;
  --sp-accent: #F7931E;
  --sp-marker: #F26522;
  --sp-card: #FFFFFF;
  --sp-border: #E2DEDD;
  --sp-bar: 5px;
  --sp-gap: clamp(16px, 1.8vw, 24px);
  --sp-pad: clamp(24px, 2.4vw, 28px);
  --sp-shadow-hover: 0 30px 60px -34px rgba(33, 26, 33, .32), 0 2px 10px rgba(33, 26, 33, .04);
  --sp-ease: cubic-bezier(.22, 1, .36, 1);

  background: var(--sp-bg);
  color: var(--sp-text);
  padding: var(--fs-section-spacing, 80px) 0;
}

.sp--bordered {
  border-bottom: 1px solid var(--sp-section-border, #B0AAA8);
}

.sp--dark {
  --sp-bg: #211A21;
  --sp-text: #FFFFFF;
  --sp-muted: rgba(255, 255, 255, .75);
  --sp-card: #2D252D;
  --sp-border: rgba(176, 170, 168, .28);
  --sp-shadow-hover: 0 30px 60px -30px rgba(0, 0, 0, .6);
}

.sp *,
.sp *::before,
.sp *::after {
  box-sizing: border-box;
}

/* Same box as the theme's .content-wrapper */
.sp__inner {
  width: 100%;
  max-width: calc(var(--fs-container-width, 1240px) + (var(--fs-side-gutter, 16px) * 2));
  margin: 0 auto;
  padding: 0 var(--fs-side-gutter, 16px);
}

/* Heading block, centred */

.sp__head {
  max-width: 52em;
  margin: 0 auto clamp(40px, 6vw, 80px);
  text-align: center;
}

.sp__heading {
  margin: 0;
  font-family: var(--fs-heading-font);
  font-size: clamp(calc(var(--fs-h2-size) * 0.6), 5.6vw, var(--fs-h2-size));
  font-weight: var(--fs-h2-weight);
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--sp-text);
}

.sp__heading-accent {
  display: block;
  color: var(--sp-accent);
}

.sp__intro {
  max-width: 36em;
  margin: clamp(20px, 2.6vw, 32px) auto 0;
  font-size: var(--fs-lead-size);
  line-height: 1.55;
  color: var(--sp-muted);
}

.sp__intro p { margin: 0; }
.sp__intro p + p { margin-top: 0.6em; }

.sp__intro a {
  color: inherit;
  text-decoration-color: var(--sp-accent);
  text-underline-offset: 3px;
}

/* Cards
   Each card spans three rows of the parent grid (title, summary, list) and
   uses subgrid, so the dividers line up across a row whatever the text length.
   The vertical gap between card rows is a margin on the card, because row-gap
   would also open up between a card's own rows. */

.sp__grid {
  display: grid;
  grid-template-columns: repeat(var(--sp-cols, 4), minmax(0, 1fr));
  column-gap: var(--sp-gap);
  row-gap: 0;
  margin: 0 0 calc(var(--sp-gap) * -1);
  padding: 0;
  list-style: none;
}

.sp__card {
  position: relative;
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  row-gap: 0;
  margin: 0 0 var(--sp-gap);
  padding: calc(var(--sp-pad) + var(--sp-bar)) var(--sp-pad) calc(var(--sp-pad) + 12px);
  background: var(--sp-card);
  border: 1px solid var(--sp-border);
  color: var(--sp-text);
  transition:
    translate .5s var(--sp-ease),
    box-shadow .5s var(--sp-ease);
}

/* Older browsers without subgrid: plain stacked card */
@supports not (grid-template-rows: subgrid) {
  .sp__card {
    display: flex;
    flex-direction: column;
  }
}

/* Accent bar across the top, covering the border so it sits flush */
.sp__card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  height: var(--sp-bar);
  background: var(--sp-accent);
  transform-origin: left center;
}

.sp__title {
  margin: 0 0 16px;
  font-family: var(--fs-heading-font);
  font-size: clamp(calc(var(--fs-h3-size) * 0.72), 1.9vw, calc(var(--fs-h3-size) * 0.8));
  font-weight: var(--fs-h3-weight);
  line-height: 1.22;
  letter-spacing: -0.01em;
  color: var(--sp-text);
}

.sp__summary {
  margin: 0;
  padding-bottom: clamp(22px, 2.2vw, 28px);
  font-size: var(--fs-body-size);
  line-height: 1.55;
  color: var(--sp-muted);
}

/* Divider sits on top of the list, so it starts the same row in every card */
.sp__points {
  display: grid;
  align-content: start;
  gap: 14px;
  margin: 0;
  padding: clamp(24px, 2.4vw, 30px) 0 0;
  border-top: 1px solid var(--sp-border);
  list-style: none;
}

.sp__point {
  display: grid;
  grid-template-columns: 7px minmax(0, 1fr);
  gap: 13px;
  margin: 0;
  font-size: var(--fs-small-size);
  line-height: 1.5;
  color: var(--sp-text);
}

.sp__marker {
  display: block;
  width: 7px;
  height: 7px;
  margin-top: 0.5em;
  background: var(--sp-marker);
}

.sp--marker-dash .sp__point { grid-template-columns: 12px minmax(0, 1fr); }

.sp--marker-dash .sp__marker {
  width: 12px;
  height: 2px;
  margin-top: 0.72em;
}

/* Card buttons: when any card has one, every card takes a fourth subgrid row,
   so the buttons sit on one line across the row whatever the list length. */

.sp--card-cta .sp__card { grid-row: span 4; }

.sp__card-cta {
  display: flex;
  align-items: flex-start;
}

.sp__card-cta:not(:empty) {
  padding-top: clamp(24px, 2.4vw, 30px);
}

/* Push the button to the card bottom in the stacked fallback */
@supports not (grid-template-rows: subgrid) {
  .sp__card-cta { margin-top: auto; }
}

/* Buttons under the list and under the cards: any theme button style
   (Theme settings > Buttons). On Charcoal, .fs-dark switches Tertiary and
   Text link to their on-dark colours and lightens the Secondary border so its
   edge stays visible. */

.sp__footer {
  display: flex;
  justify-content: center;
  margin-top: clamp(36px, 4.5vw, 56px);
}

.sp__footer--left { justify-content: flex-start; }
.sp__footer--right { justify-content: flex-end; }

.sp.fs-dark .sp__button.fs-btn--secondary,
.sp.fs-dark .sp__card-button.fs-btn--secondary {
  --fs-btn-secondary-border: color-mix(in srgb, var(--sp-text) 40%, transparent);
}

/* Mouse hover only, so touch screens don't get a stuck lift */
@media (hover: hover) and (pointer: fine) {
  .sp--hover .sp__card:hover {
    translate: 0 -6px;
    box-shadow: var(--sp-shadow-hover);
  }
}

/* Tablet: two columns. Phone: one */

@media (max-width: 1023px) {
  .sp__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sp--cols-1 .sp__grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 639px) {
  .sp__grid { grid-template-columns: minmax(0, 1fr); }
}

/* Scroll animation
   .is-animated is printed server-side (never in the editor), so content is
   hidden from first paint. The JS adds .is-visible to the heading block and to
   each card as they enter the viewport. Order: heading rises, intro follows,
   cards lift in a stagger, each top bar draws across and its list fades in,
   then the button rises once it scrolls into view. */

.sp.is-animated .sp__head > * {
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  transition: opacity .8s var(--sp-ease), transform .9s var(--sp-ease);
}

.sp.is-animated .sp__intro { transition-delay: .15s; }

.sp.is-animated .sp__card {
  --sp-d: calc(var(--i, 0) * .12s);
  opacity: 0;
  transform: translate3d(0, 44px, 0);
  transition:
    opacity .8s var(--sp-ease) var(--sp-d),
    transform 1s var(--sp-ease) var(--sp-d),
    translate .5s var(--sp-ease),
    box-shadow .5s var(--sp-ease);
}

.sp.is-animated .sp__card::before {
  transform: scaleX(0);
  transition: transform .9s var(--sp-ease) calc(var(--sp-d) + .25s);
}

.sp.is-animated .sp__point {
  opacity: 0;
  transform: translate3d(-10px, 0, 0);
  transition:
    opacity .6s var(--sp-ease) calc(var(--sp-d) + .5s + var(--j, 0) * .08s),
    transform .6s var(--sp-ease) calc(var(--sp-d) + .5s + var(--j, 0) * .08s);
}

/* Card button follows the last list item */
.sp.is-animated .sp__card-cta {
  opacity: 0;
  transform: translate3d(0, 10px, 0);
  transition:
    opacity .6s var(--sp-ease) calc(var(--sp-d) + .75s),
    transform .6s var(--sp-ease) calc(var(--sp-d) + .75s);
}

.sp.is-animated .sp__footer {
  opacity: 0;
  transform: translate3d(0, 20px, 0);
  transition: opacity .8s var(--sp-ease), transform .9s var(--sp-ease);
}

/* In view */

.sp.is-animated .sp__footer.is-visible,
.sp.is-animated .sp__head.is-visible > *,
.sp.is-animated .sp__card.is-visible,
.sp.is-animated .sp__card.is-visible .sp__point,
.sp.is-animated .sp__card.is-visible .sp__card-cta {
  opacity: 1;
  transform: none;
}

.sp.is-animated .sp__card.is-visible::before {
  transform: none;
}

/* Stacked layout: each card reveals as it scrolls in, so no stagger between them */
@media (max-width: 639px) {
  .sp.is-animated .sp__card { --i: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .sp.is-animated .sp__head > *,
  .sp.is-animated .sp__card,
  .sp.is-animated .sp__card::before,
  .sp.is-animated .sp__point,
  .sp.is-animated .sp__footer {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .sp .sp__card {
    translate: none !important;
  }
}
