/* Services (services.html): layout and motion (docs/design-atmosphere.md).
 * The hero is one full picture of everything on the page: a travertine terrace above the peach mist, holding a
 * glass website panel, a speech bubble, a voice waveform, a node network, a modular cube and the light threads
 * that join them. Small lights mark each object; they take turns glowing, and the matching service chip
 * lights with them. Below, each service picture opens from a smaller window and drifts slower than the page,
 * its copy arrives line by line, a light visits each integration in turn and the closing call shows the
 * shared energy ring. Colours are tokens from css/falmera-palette.css. Moving states run only when
 * js/falmera-services.js adds .fm-svc-live (JavaScript and motion allowed); otherwise all is shown still. */

/* ── Hero: the full picture ────────────────────────────────────────────── */
.fm-svc-hero.fm-page-hero {
  position: relative; isolation: isolate; overflow: clip;
  padding: 0; background: var(--at-porcelain);
  display: flex; flex-direction: column;
}
.fm-svc-hero__media { position: relative; order: 2; overflow: hidden; aspect-ratio: 6 / 5; background: var(--at-blush); }
.fm-svc-hero__stage { position: absolute; inset: 0; }
.fm-svc-hero__stage img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 92% 50%; }
/* The picture melts into the page above and below. */
.fm-svc-hero__media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(180deg, var(--at-porcelain) 0%, rgb(247 239 234 / 0) 22%),
    linear-gradient(0deg, var(--at-porcelain) 0%, rgb(247 239 234 / 0) 18%);
}
.fm-svc-hero__inner { order: 1; padding-block: calc(var(--fm-header-h) + clamp(1.5rem, 1rem + 2vw, 2.5rem)) var(--fm-space-4); }
.fm-svc-hero .fm-svc-hero__copy { max-width: 40rem; gap: var(--fm-space-5); }
.fm-svc-hero .fm-h1 { text-wrap: balance; }
.fm-svc-hero .fm-chip { min-height: 44px; text-decoration: none; transition: background-color 400ms var(--at-ease), border-color 400ms var(--at-ease), color 400ms var(--at-ease); }
.fm-svc-hero .fm-chip.is-lit { border-color: var(--at-violet); background: var(--at-shell); color: var(--at-action-ink); }
@media (max-width: 1023px) {
  .fm-svc-hero.fm-page-hero { margin-top: calc(-1 * var(--fm-header-h)); }
}
@media (min-width: 600px) and (max-width: 1023px) {
  .fm-svc-hero__media { aspect-ratio: 16 / 10; }
  .fm-svc-hero__stage img { object-position: 80% 50%; }
}

/* Desktop: the picture fills the first screen and the copy sits in the open sky. */
@media (min-width: 1024px) {
  .fm-svc-hero.fm-page-hero {
    display: grid; align-items: center;
    margin-top: calc(-1 * var(--fm-header-h));
    min-height: clamp(40rem, 100svh, 62rem);
  }
  .fm-svc-hero__media { position: absolute; inset: 0; aspect-ratio: auto; z-index: -1; }
  .fm-svc-hero__stage img { object-position: 72% 50%; }
  .fm-svc-hero__media::after {
    background:
      linear-gradient(90deg, rgb(247 239 234 / 0.9) 0%, rgb(247 239 234 / 0.72) 28%, rgb(247 239 234 / 0.18) 50%, rgb(247 239 234 / 0) 62%),
      linear-gradient(0deg, var(--at-porcelain) 0%, rgb(247 239 234 / 0) 16%);
  }
  .fm-svc-hero__inner { padding-block: calc(var(--fm-header-h) + 3rem) 5rem; width: 100%; }
  .fm-svc-hero .fm-svc-hero__copy { max-width: min(36rem, 44vw); }
}

/* Phones and tablets: the picture fills the hero behind the copy, as on desktop. The sharp picture holds the lower
   part with its objects (and their lights) in view; above it a soft blur of the same picture carries the sky up
   behind the copy. */
@media (max-width: 1023px) {
  .fm-svc-hero.fm-page-hero { min-height: max(100svh, 46rem); }
  .fm-svc-hero__media { position: absolute; inset: 0; aspect-ratio: auto; z-index: -1; }
  .fm-svc-hero__media::before {
    content: ""; position: absolute; inset: -8%;
    background: url("../assets/img/services/hero/services-hero-960.webp") 70% 0 / cover no-repeat;
    filter: blur(26px) saturate(1.05);
  }
  .fm-svc-hero__stage {
    inset: auto 0 0 0; height: max(60%, 26rem);
    -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 22%); mask-image: linear-gradient(180deg, transparent 0, #000 22%);
  }
  .fm-svc-hero__stage img { object-position: 78% 50%; }
  .fm-svc-hero__media::after {
    background:
      linear-gradient(180deg, rgb(247 239 234 / 0.9) 0%, rgb(247 239 234 / 0.66) 34%, rgb(247 239 234 / 0) 56%),
      linear-gradient(0deg, var(--at-porcelain) 0%, rgb(247 239 234 / 0) 12%);
  }
  .fm-svc-hero__inner { padding-bottom: max(38svh, 17rem); }
  .fm-svc-hero .fm-chip { background: rgb(252 246 242 / 0.8); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
}
@media (min-width: 600px) and (max-width: 1023px) {
  .fm-svc-hero__stage img { object-position: 72% 50%; }
}
/* Small phones: a slightly shorter picture keeps all five objects (and their lights) inside the crop. */
@media (max-width: 380px) {
  .fm-svc-hero__stage { height: 21rem; }
  .fm-svc-hero__stage img { object-position: 74% 50%; }
}

/* The lights on each object. Placed by js/falmera-services.js over the picture; hidden until placed. */
.fm-svc-hero__spots { position: absolute; inset: 0; pointer-events: none; }
.fm-svc-spot {
  position: absolute; left: var(--x, 50%); top: var(--y, 50%); translate: -50% -50%;
  display: none; width: 44px; height: 44px; place-items: center;
  color: var(--at-ink); text-decoration: none; pointer-events: auto;
}
.fm-svc-hero.is-placed .fm-svc-spot { display: grid; }
.fm-svc-hero.is-placed .fm-svc-spot[hidden] { display: none; }
.fm-svc-spot i {
  position: relative; width: 12px; height: 12px; border-radius: 50%;
  background: var(--at-snow); box-shadow: 0 0 0 4px rgb(255 255 255 / 0.32), 0 0 18px 4px rgb(246 148 119 / 0.55);
  transition: scale 500ms var(--at-ease), box-shadow 500ms var(--at-ease);
}
.fm-svc-spot i::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 1.5px solid rgb(255 255 255 / 0.8); opacity: 0; scale: 0.4;
}
.fm-svc-spot span {
  position: absolute; bottom: calc(100% + 2px); left: 50%; translate: -50% 6px;
  padding: 0.4rem 0.75rem; border-radius: 999px; white-space: nowrap;
  background: rgb(252 246 242 / 0.86); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  box-shadow: 0 10px 24px -12px rgb(42 34 56 / 0.45);
  font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.01em; color: var(--at-ink);
  opacity: 0; transition: opacity 400ms var(--at-ease), translate 500ms var(--at-ease);
}
.fm-svc-spot.is-start span { left: 0; translate: -12px 6px; }
.fm-svc-spot.is-end span { left: auto; right: 0; translate: 12px 6px; }
.fm-svc-spot.is-lit i { scale: 1.25; box-shadow: 0 0 0 5px rgb(255 255 255 / 0.45), 0 0 26px 8px rgb(118 82 193 / 0.5); }
.fm-svc-spot.is-lit span { opacity: 1; translate: -50% 0; }
.fm-svc-spot.is-start.is-lit span { translate: -12px 0; }
.fm-svc-spot.is-end.is-lit span { translate: 12px 0; }

/* ── Service rows ──────────────────────────────────────────────────────── */
.fm-svc-page .fm-service-detail__media { box-shadow: 0 40px 80px -44px rgb(58 34 54 / 0.5); }

/* ── Integrations: one light visits each card ─────────────────────────── */
.fm-svc-page #integrations .fm-card { position: relative; isolation: isolate; }
.fm-svc-page #integrations .fm-card::before {
  content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: inherit; padding: 1.5px;
  background: linear-gradient(135deg, var(--at-action), var(--at-violet) 45%, var(--at-coral));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0; transition: opacity 700ms var(--at-ease);
}
.fm-svc-page #integrations .fm-card h3::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 0.6rem; vertical-align: 0.15em;
  border-radius: 50%; background: rgb(118 82 193 / 0.35); transition: background-color 600ms var(--at-ease), box-shadow 600ms var(--at-ease);
}
.fm-svc-page #integrations .fm-card.is-lit::before { opacity: 1; }
.fm-svc-page #integrations .fm-card.is-lit h3::before { background: var(--at-violet); box-shadow: 0 0 0 4px rgb(118 82 193 / 0.16), 0 0 14px 2px rgb(246 148 119 / 0.6); }

/* ── Motion (only with .fm-svc-live) ──────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  /* The picture settles in on arrival, then drifts slower than the page as it scrolls away. */
  .fm-svc-live .fm-svc-hero__stage {
    translate: 0 calc(var(--hv, 0) * 9%);
    animation: fm-svc-settle 2.6s var(--at-ease) both;
  }
  @keyframes fm-svc-settle { from { scale: 1.12; } to { scale: 1; } }
  .fm-svc-live .fm-svc-hero__copy > * { animation: fm-svc-rise 1s var(--at-ease) both; }
  .fm-svc-live .fm-svc-hero__copy > :nth-child(2) { animation-delay: 120ms; }
  .fm-svc-live .fm-svc-hero__copy > :nth-child(3) { animation-delay: 260ms; }
  .fm-svc-live .fm-svc-hero__copy > :nth-child(4) { animation-delay: 400ms; }
  @keyframes fm-svc-rise { from { opacity: 0; translate: 0 18px; } to { opacity: 1; translate: 0 0; } }
  .fm-svc-live .fm-svc-spot.is-lit i::after { animation: fm-svc-ping 1.8s var(--at-ease) infinite; }
  @keyframes fm-svc-ping { 0% { opacity: 0.9; scale: 0.4; } 100% { opacity: 0; scale: 1.6; } }

  /* Each service picture opens from a smaller window. */
  .fm-svc-live .fm-service-detail__media[data-reveal] {
    clip-path: inset(10% 8% 10% 8% round var(--fm-radius-lg));
    transition: opacity 900ms var(--fm-ease), transform 1000ms var(--fm-ease), clip-path 1.5s var(--at-ease);
  }
  .fm-svc-live .fm-service-detail__media img { scale: 1.26; translate: 0 var(--py, 0px); transition: scale 2.2s var(--at-ease); }
  .fm-svc-live .fm-service-detail__media.is-revealed { clip-path: inset(0 0 0 0 round var(--fm-radius-lg)); }
  .fm-svc-live .fm-service-detail__media.is-revealed img { scale: 1.1; }

  /* The copy arrives line by line, then its checklist one item at a time. */
  .fm-svc-live .fm-service-detail__copy > *,
  .fm-svc-live .fm-service-detail__copy .fm-checklist li { transition: opacity 800ms var(--at-ease), translate 900ms var(--at-ease); }
  .fm-svc-live .fm-service-detail__copy:not(.is-revealed) > *,
  .fm-svc-live .fm-service-detail__copy:not(.is-revealed) .fm-checklist li { opacity: 0; translate: 0 18px; }
  .fm-svc-live .fm-service-detail__copy:focus-within > *,
  .fm-svc-live .fm-service-detail__copy:focus-within .fm-checklist li { opacity: 1; translate: 0 0; }
  .fm-svc-live .fm-service-detail__copy > :nth-child(2) { transition-delay: 90ms; }
  .fm-svc-live .fm-service-detail__copy > :nth-child(3) { transition-delay: 180ms; }
  .fm-svc-live .fm-service-detail__copy > :nth-child(4) { transition-delay: 270ms; }
  .fm-svc-live .fm-service-detail__copy > :nth-child(n+5) { transition-delay: 720ms; }
  .fm-svc-live .fm-service-detail__copy .fm-checklist li:nth-child(1) { transition-delay: 340ms; }
  .fm-svc-live .fm-service-detail__copy .fm-checklist li:nth-child(2) { transition-delay: 410ms; }
  .fm-svc-live .fm-service-detail__copy .fm-checklist li:nth-child(3) { transition-delay: 480ms; }
  .fm-svc-live .fm-service-detail__copy .fm-checklist li:nth-child(4) { transition-delay: 550ms; }
  .fm-svc-live .fm-service-detail__copy .fm-checklist li:nth-child(n+5) { transition-delay: 620ms; }
}
