/* ==========================================================================
   Service page devices — the shared house kit.

   Every commercial page built on components/marketing/ServicePage.tsx loads
   this first, then its own thin sheet for layout that is genuinely its own.

   WHY THIS FILE EXISTS. /medspa-seo/ built these devices; /medspa-marketing/
   copied them, with a header comment saying that if a third page ever wanted
   them the copies should be consolidated. /rocklin-seo/ is the third page, so
   they were. Two copies drift slowly and quietly; three would have been a
   guarantee.

   The recipes come from src/app/(frontend)/how-it-works/how-it-works.html,
   which is the reference implementation of this visual language. Where a rule
   was lifted from there the comment says so.

   NAMESPACE. `svcd-` for components this file owns. Rules keyed on `.svc-*`
   are patching the template's own markup (service-page.css) and are shared by
   definition. Page sheets must not redefine anything in here; they add layout
   only.

   MOTION CONTRACT. Everything ships in its finished state. Animated
   from-states live only behind `html.has-motion`, which motion.js adds solely
   under prefers-reduced-motion: no-preference. So a visitor with reduced
   motion, and a page with JS disabled, both get a complete static drawing
   rather than a blank frame. `.is-in` is set by the [data-stage] primitive in
   motion.js. This mirrors the [data-reveal] baseline in base.css.

   TYPE. No font-size on any heading; typography.css owns that scale. The one
   exception is .svcd-figure-num, a named role lifted from
   (home)/from-invisible.html and commented at its definition.
   ========================================================================== */

/* Sections that carry the page's own markup rather than the template's. Any
   page-owned <section> should take .svcd-section so it inherits the palette
   and the sitewide vertical rhythm. */
.svcd-section {
  --surface: #0a0a0f;
  --surface-2: #101018;
  --card-border: #1a1a24;
  --purple: #6119ac;
  --purple-light: #8b5cf6;
  --purple-glow: #7c3aed;
  --purple-border: rgba(139, 92, 246, 0.22);
  --text-primary: #ffffff;
  --text-body: #e8e8f0;
  --text-secondary: #a1a1b5;
  --text-muted: #6a6a77;
  background: var(--surface);
  color: var(--text-body);
  font-family: var(--font-body);
  font-stretch: var(--wdth-body, 100%);
  padding: var(--section-y, clamp(5rem, 10vw, 11rem)) var(--gutter, 24px);
  -webkit-font-smoothing: antialiased;
}

.svcd-inner {
  max-width: var(--shell, 1180px);
  margin-inline: auto;
}

/* --- Section dividers ------------------------------------------------------
   The house separator: a hairline that glows in the middle and fades at both
   ends, with a light beam travelling along it. how-it-works.html:270-281 and
   :1009-1050. Sections never change background colour; this codebase has an
   explicit anti-banding doctrine and a surface change leaves a seam at every
   join.

   The beam is a background-position shift rather than a moving child element,
   because half of these dividers are ::before pseudo-elements on the
   template's own sections, and a pseudo-element cannot clip a child. */

.svcd-rule,
.svc-problem::before,
.svc-includes::before,
.svc-proof::before,
.svc-faq::before {
  content: "";
  display: block;
  height: 1px;
  max-width: 1040px;
  margin-inline: auto;
  background:
    linear-gradient(90deg, transparent, rgba(196, 181, 253, 0.55), transparent) -20% 0 / 150px 100%
      no-repeat,
    linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.18), transparent);
  animation: svcd-beam 9s ease-in-out infinite;
}

/* Template-owned section tops. service-page.css only sets position on the
   hero, so these four need it before a pseudo-element can pin to them. */
.svc-problem,
.svc-includes,
.svc-proof,
.svc-faq {
  position: relative;
}

.svc-problem::before,
.svc-includes::before,
.svc-proof::before,
.svc-faq::before {
  position: absolute;
  top: 0;
  left: var(--gutter, 24px);
  right: var(--gutter, 24px);
}

/* Out of phase, so the page pulses rather than blinking in unison. */
.svc-includes::before {
  animation-delay: 3s;
}

.svc-proof::before {
  animation-delay: 5.5s;
}

.svc-faq::before {
  animation-delay: 7s;
}

@keyframes svcd-beam {
  0% {
    background-position: -20% 0, 0 0;
  }
  55%,
  100% {
    background-position: 120% 0, 0 0;
  }
}

/* --- Hero flourishes -------------------------------------------------------
   The hero itself is the shared .svc-hero composition in service-page.css. */

/* Gradient shimmer across the accent half of the H1. how-it-works.html:154-171.
   The flat colour is declared first so the text stays readable wherever
   background-clip does not apply. */
.svc-hero__h1 .svc-accent {
  color: var(--purple-light, #8b5cf6);
  background: linear-gradient(
    100deg,
    var(--purple-light, #8b5cf6),
    #c4b5fd 50%,
    var(--purple-light, #8b5cf6)
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.has-motion .svc-hero__h1 .svc-accent {
  animation: svcd-shimmer 7s linear infinite;
}

@keyframes svcd-shimmer {
  to {
    background-position: 200% 0;
  }
}

/* A purple hairline over each stat cell. how-it-works.html:766-775. */
.svc-stats__cell {
  position: relative;
}

.svc-stats__cell::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--purple, #6119ac), transparent);
}

/* Hero entrance. The hero is in view at load, so this is a timed beat rather
   than a scroll trigger. motion.js scopes its own hero timeline to
   .hp-b--hero, and widening that selector would change the pages that do not
   load this sheet, so the sequence lives here. .svc-hero__lead is
   display:contents, which leaves its children in the layout tree, so `> *`
   still matches them. */
.has-motion .svc-hero__lead > *,
.has-motion .svc-hero .svc-stats {
  animation: svcd-rise 0.9s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) both;
}

.has-motion .svc-hero__lead > *:nth-child(2) {
  animation-delay: 0.08s;
}

.has-motion .svc-hero__lead > *:nth-child(3) {
  animation-delay: 0.16s;
}

.has-motion .svc-hero__lead > *:nth-child(4) {
  animation-delay: 0.24s;
}

.has-motion .svc-hero__lead > *:nth-child(5) {
  animation-delay: 0.3s;
}

.has-motion .svc-hero .svc-stats {
  animation-delay: 0.36s;
}

@keyframes svcd-rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
}

/* --- Framed artifacts ------------------------------------------------------
   A screenshot is someone else's UI. It gets a mat and a hairline so it reads
   as a mounted exhibit rather than a pasted screengrab. */

.svcd-frame {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg, 10px);
  padding: clamp(0.6rem, 1.4vw, 1rem);
  overflow: hidden;
}

.svcd-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}

.svcd-caption {
  margin-top: 0.85rem;
  font-size: var(--step--2);
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 52ch;
}

/* --- The "new way" panel ---------------------------------------------------
   how-it-works.html:475-486. Across this site a dashed border means the old
   way and a lit purple panel means ours. */

.svcd-panel {
  position: relative;
  border: 1px solid var(--purple-border);
  border-radius: var(--radius-lg, 10px);
  background: radial-gradient(120% 120% at 50% 0%, rgba(97, 25, 172, 0.22), transparent 60%),
    var(--surface-2);
  box-shadow: 0 20px 60px rgba(97, 25, 172, 0.18);
  overflow: hidden;
}

.svcd-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--purple), transparent);
}

/* --- Badge ------------------------------------------------------------------ */

.svcd-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
  padding: 0.5em 0.9em;
  border: 1px solid var(--purple-border);
  border-radius: var(--radius, 4px);
  font-family: var(--font-display);
  font-stretch: var(--wdth-display, 108%);
}

.svcd-badge__num {
  font-weight: 900;
  font-size: var(--step-1);
  line-height: 1;
  color: var(--purple-light);
}

.svcd-badge__label {
  font-weight: 600;
  font-size: var(--step--2);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* --- The money number -------------------------------------------------------
   The one figure on a page that gets to be enormous. A named role taken
   verbatim from (home)/from-invisible.html:552-575, which is why it carries a
   font-size where nothing else in this file does. */

.svcd-figure-num {
  font-family: var(--font-display);
  font-stretch: var(--wdth-display, 108%);
  font-weight: 900;
  font-size: clamp(44px, 13vw, 108px);
  line-height: 0.86;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  background: linear-gradient(180deg, #ffffff 30%, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 90px rgba(139, 92, 246, 0.32);
}

.svcd-figure-sub {
  margin-top: 0.9rem;
  font-family: var(--font-display);
  font-stretch: var(--wdth-display, 108%);
  font-weight: 600;
  font-size: var(--step--1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--purple-light);
}

/* --- Pull-quote -------------------------------------------------------------
   the-system.html:277-292. */

.svcd-kicker {
  position: relative;
  overflow: hidden;
  margin-top: clamp(1.75rem, 3.5vw, 2.5rem);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg, 10px);
  background: linear-gradient(180deg, rgba(97, 25, 172, 0.14), transparent 85%);
  font-family: var(--font-display);
  font-stretch: var(--wdth-display, 108%);
  font-weight: 700;
  font-size: var(--step-1);
  line-height: 1.4;
  color: var(--text-primary);
  max-width: 46ch;
}

/* Accent on the top edge, matching the stat cards, rather than a bar down the
   left — the tint falls away from it. */
.svcd-kicker::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--purple), transparent);
}

/* --- The stage flow ---------------------------------------------------------
   A spine that draws downward with a halo'd node per stage.
   how-it-works.html:625-745. */

.svcd-stages {
  position: relative;
  margin-top: clamp(2.25rem, 4.5vw, 3rem);
  padding-left: clamp(4.5rem, 8vw, 6rem);
  list-style: none;
  display: grid;
  gap: clamp(1.75rem, 3.5vw, 2.75rem);
}

.svcd-stages::before {
  content: "";
  position: absolute;
  left: clamp(1.75rem, 3.2vw, 2.4rem);
  top: 28px;
  bottom: 28px;
  width: 2px;
  background: linear-gradient(
    180deg,
    var(--purple),
    var(--purple-glow) 60%,
    rgba(139, 92, 246, 0.25)
  );
  transform-origin: top;
}

.has-motion .svcd-stages::before {
  transform: scaleY(0);
  transition: transform 2.4s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) 0.2s;
}

.has-motion .svcd-stages.is-in::before {
  transform: scaleY(1);
}

.svcd-stage {
  position: relative;
}

/* The halo punches a hole in the spine behind the node. */
.svcd-stage__node {
  position: absolute;
  left: clamp(-4.6rem, -6vw, -3.5rem);
  top: 0;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--purple-border);
  color: var(--purple-light);
  font-family: var(--font-display);
  font-stretch: var(--wdth-display, 108%);
  font-weight: 700;
  font-size: var(--step--1);
  box-shadow: 0 0 0 6px var(--surface);
}

.svcd-stage:first-child .svcd-stage__node {
  background: var(--purple);
  border-color: var(--purple-light);
  color: #fff;
  box-shadow: 0 0 0 6px var(--surface), 0 0 30px rgba(124, 58, 237, 0.6);
}

.svcd-stage__body {
  margin-top: 0.5rem;
  font-size: var(--step-0);
  line-height: 1.7;
  color: var(--text-secondary);
  max-width: 62ch;
}

.has-motion .svcd-stage {
  opacity: 0;
  transform: translateX(-14px);
  transition: opacity 0.8s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) var(--fd, 0s),
    transform 0.8s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) var(--fd, 0s);
}

.has-motion .svcd-stages.is-in .svcd-stage {
  opacity: 1;
  transform: none;
}

/* --- Ordinal rows -----------------------------------------------------------
   Numbered, hairline-separated rows: ordinal, heading, answer. Used where a
   section has to read as a set of self-contained answers, which is the shape
   AI Overviews and People Also Ask lift. Deliberately distinct from the stage
   flow above so a page can carry both without them flattening each other. */

.svcd-rows {
  margin-top: clamp(2.5rem, 5vw, 3.5rem);
  border-top: 1px solid var(--card-border);
  list-style: none;
}

.svcd-row {
  display: grid;
  grid-template-columns: auto minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(1.25rem, 3vw, 2.5rem);
  padding: clamp(1.6rem, 3vw, 2.25rem) 0;
  border-bottom: 1px solid var(--card-border);
  align-items: start;
}

.svcd-row__num {
  font-family: var(--font-display);
  font-stretch: var(--wdth-display, 108%);
  font-weight: 900;
  font-size: var(--step-2);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--purple-light);
  min-width: 2.5ch;
}

.svcd-row__title {
  margin-top: -0.15em;
}

.svcd-row__body {
  font-size: var(--step-0);
  line-height: 1.7;
  color: var(--text-secondary);
}

.has-motion .svcd-row {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.8s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) var(--fd, 0s),
    transform 0.8s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) var(--fd, 0s);
}

.has-motion .svcd-rows.is-in .svcd-row {
  opacity: 1;
  transform: none;
}

/* --- Inline links in body copy ---------------------------------------------- */

.svcd-link {
  color: var(--text-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  text-decoration-color: var(--purple-border);
  transition: text-decoration-color var(--dur, 340ms) var(--ease-out);
}

.svcd-link:hover,
.svcd-link:focus-visible {
  text-decoration-color: var(--purple-light);
}

/* --- Closing contact line ---------------------------------------------------
   Fed by ServicePageData.closingNote. */

.svcd-contact {
  margin-top: 1.25rem;
  font-size: var(--step--1);
  line-height: 1.6;
}

.svcd-contact a {
  display: inline-block;
  /* 44px touch target from padding. An underline rather than a border, because
     a border sits at the bottom of the padded box and parks the rule a dozen
     pixels below the text. */
  padding: 0.7rem 0;
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25em;
}

.svcd-contact a:hover,
.svcd-contact a:focus-visible {
  text-decoration-color: transparent;
}

.svcd-contact__sep {
  padding: 0 0.5rem;
  opacity: 0.5;
}

/* ==========================================================================
   ILLUSTRATIONS

   Schematic drawings, defined per page in that page's illustrations.tsx.
   Thin stroke, no fill, colour from custom properties. Every from-state below
   sits behind .has-motion, per the contract at the top of this file.
   ========================================================================== */

.svcd-ill,
.svcd-mark {
  --ill-accent: var(--purple-light, #8b5cf6);
  display: block;
  width: 100%;
  height: auto;
  color: var(--text-secondary, #a1a1b5);
  overflow: visible;
}

.svcd-mark {
  width: 40px;
  height: 40px;
  margin-bottom: 1rem;
}

.svcd-figure {
  margin: 0;
  padding: clamp(1.25rem, 3vw, 2rem);
  border: 1px solid var(--card-border, #1a1a24);
  border-radius: var(--radius-lg, 10px);
  background: var(--surface-2, #101018);
}

/* The drawings are composed at 320x200. Letting one run the full width of a
   section keeps its 1.5px strokes at 1.5px while everything around them
   trebles in size, which reads as a sparse, empty panel. */
.svcd-figure .svcd-ill {
  max-width: 520px;
  margin-inline: auto;
}

/* Lines that draw themselves. pathLength="1" on the element normalises every
   path to a single unit, so one transition serves all of them. */
.has-motion .svcd-ill__plot,
.has-motion .svcd-ill__strike,
.has-motion .svcd-ill__shot,
.has-motion .svcd-ill__spray {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.4s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.has-motion .is-in .svcd-ill__plot,
.has-motion .is-in .svcd-ill__strike,
.has-motion .is-in .svcd-ill__shot,
.has-motion .is-in .svcd-ill__spray {
  stroke-dashoffset: 0;
}

/* Sequenced draws, for a drawing where several strokes should arrive in turn
   rather than together. */
.has-motion .svcd-ill__spray {
  transition-duration: 0.9s;
  transition-delay: calc(var(--i, 0) * 90ms);
}

/* Things that arrive once a line has reached them. */
.has-motion .svcd-ill__pin,
.has-motion .svcd-ill__chip,
.has-motion .svcd-ill__booked,
.has-motion .svcd-ill__target {
  opacity: 0;
  transform: scale(0.85);
  transform-box: fill-box;
  transform-origin: center;
  transition: opacity 0.5s var(--ease-out) 1.1s, transform 0.5s var(--ease-out) 1.1s;
}

.has-motion .is-in .svcd-ill__pin,
.has-motion .is-in .svcd-ill__chip,
.has-motion .is-in .svcd-ill__booked,
.has-motion .is-in .svcd-ill__target {
  opacity: 1;
  transform: scale(1);
}

/* Bars grow from the axis, left to right. */
.has-motion .svcd-ill--revenue rect {
  transform-box: fill-box;
  transform-origin: 50% 100%;
  scale: 1 0;
  transition: scale 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: calc(var(--i, 0) * 24ms);
}

.has-motion .is-in .svcd-ill--revenue rect {
  scale: 1 1;
}

/* The travelling signal: a dot riding the exact path it illustrates, which is
   this site's signature motion device (how-it-works.html:1197-1235). Purely
   decorative and infinite, so it needs no .is-in gate; base.css already stops
   every looping animation under reduced motion. It stays invisible without
   .has-motion so it never sits as a stray dot on a static drawing. */
.svcd-ill__pulse {
  opacity: 0;
}

.has-motion .svcd-ill__pulse {
  offset-distance: 0%;
  filter: drop-shadow(0 0 8px rgba(139, 92, 246, 0.9));
  animation: svcd-travel 5s linear infinite;
  animation-delay: var(--pd, 0s);
}

@keyframes svcd-travel {
  0% {
    offset-distance: 0%;
    opacity: 0;
  }
  10%,
  88% {
    opacity: 1;
  }
  100% {
    offset-distance: 100%;
    opacity: 0;
  }
}

/* --- Responsive ------------------------------------------------------------- */

@media (max-width: 980px) {
  .svcd-row {
    grid-template-columns: auto minmax(0, 1fr);
  }
  .svcd-row__body {
    grid-column: 2;
  }
}

@media (max-width: 860px) {
  .svcd-stages {
    padding-left: 3.75rem;
  }
  .svcd-stages::before {
    left: 1.4rem;
  }
  .svcd-stage__node {
    left: -3.75rem;
    width: 44px;
    height: 44px;
  }
}

@media (max-width: 640px) {
  .svcd-row {
    gap: 0.6rem 1rem;
  }

  /* A long H1 will not fit a phone gutter at the shared hero size. Narrow the
     width axis rather than the size: Archivo is variable across 62-125%, and
     that axis is the reason the family was chosen, so this buys roughly 14% of
     line width at the same optical scale. A font-size override would fork
     these pages off typography.css. */
  .svc-hero__h1 {
    font-stretch: 92%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .svcd-link {
    transition: none;
  }
}
