/* services.css: the services stage on the home page (js/services.js drives it).
   One render a service fills the section behind the words. The row in use (mouse hover, keyboard focus, a tap, or
   on a phone and tablet the row crossing the middle of the screen) lights up: its name turns white and steps 10px
   right, its number turns gold, a gold line draws under it, and the render behind crossfades to that service's
   picture while it settles from 1.06. A large numeral at the top right rolls to the row's number.
   On the way in, the picture opens from a rounded inset to full bleed as the section scrolls up (a scroll-driven
   animation where the browser has them; elsewhere it simply stands full bleed), the heading's lines rise, and
   the rows rise one after another while their dividers draw (js/scroll-motion.js, .sm-rise).
   Only opacity, transform, scale, translate and clip-path move. Hovers are for fine pointers only; under reduced
   motion the pictures fade (no settle, no opening), the numeral and the rows change in place. */

#services.svc {
  --svc-gold: #d6b47e;                      /* the brand gold lifted for a dark ground (8.4:1 on the scrim) */
  --svc-dim: rgb(255 255 255 / 0.56);
  --svc-line: rgb(255 255 255 / 0.2);
  --ink: #ffffff; --muted: rgb(255 255 255 / 0.8); --line: var(--svc-line);
  --svc-ease: var(--ease-out, cubic-bezier(0.23, 1, 0.32, 1));
  --svc-move: var(--ease-in-out, cubic-bezier(0.77, 0, 0.175, 1));
  color: #fff; background: #1d1915;
}
/* the stage and the words share one grid cell; the stage sticks to the screen while a tall section (a phone)
   scrolls its rows over it, and on a desktop it is simply as tall as the section */
main > #services.svc {
  display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  height: auto; min-height: 100vh; min-height: 100svh; padding: 0; isolation: isolate;
}
main > #services.svc > .svc__stage {
  grid-area: 1 / 1; align-self: start; position: sticky; top: 0; z-index: 0;
  height: 100vh; height: 100svh; overflow: clip; background: #1d1915;
}
main > #services.svc > .wrap {
  grid-area: 1 / 1; z-index: 1; height: auto; box-sizing: border-box;
  min-height: 100vh; min-height: 100svh; padding-block: var(--padt) var(--padb);
}

/* ---- the pictures: the newest sits on top and fades in; the one it covers hides at once when the fade is done */
.svc__bg {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; scale: 1.06;
  transition: opacity 0ms linear 760ms, scale 0ms linear 760ms;
}
.svc__bg.is-on { opacity: 1; scale: 1; transition: opacity 700ms var(--svc-ease), scale 1400ms var(--svc-ease); }
/* the scrim: an even shade, a deeper fall behind the words on the left and under the rows at the foot
   (white text holds AA on the brightest render, the white bedroom) */
.svc__stage::after {
  content: ""; position: absolute; inset: 0; z-index: 9999; pointer-events: none;
  background:
    linear-gradient(to top, rgb(20 16 12 / 0.72), rgb(20 16 12 / 0.4) 45%, rgb(20 16 12 / 0) 75%),
    linear-gradient(to right, rgb(20 16 12 / 0.62), rgb(20 16 12 / 0.3) 55%, rgb(20 16 12 / 0) 85%),
    rgb(20 16 12 / 0.36);
}

/* ---- the words */
main > #services.svc > .svc__wrap { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gutter); grid-template-rows: auto 1fr auto; }
.svc__head { grid-column: 1 / span 7; grid-row: 1; margin-bottom: 0; }
.svc__head > h2 { color: #fff; }
.svc__head > p { color: var(--muted); font-size: var(--t-lead); max-width: 40ch; }

/* the numeral: one window 1em tall, the five numbers stacked in it; the stack slides to the row in use */
.svc__count {
  grid-column: 10 / -1; grid-row: 1; justify-self: end; align-self: start; margin: 0;
  display: flex; align-items: flex-start; gap: var(--s-3);
  font-family: var(--font-display); font-weight: 400; line-height: 1; color: var(--svc-gold);
  font-size: clamp(88px, 6.4vw + 8px, 140px); letter-spacing: -0.03em; font-variant-numeric: lining-nums tabular-nums;
}
.svc__count-win { display: block; height: 1em; overflow: clip; }
.svc__count-roll { display: block; transition: transform 600ms var(--svc-move); }
.svc__count-roll > span { display: block; height: 1em; }
.svc__count-of { font-family: var(--font-text); font-size: var(--t-small); letter-spacing: 0.08em; color: var(--svc-dim); padding-top: 0.9em; }

/* the rows */
.svc__list { grid-column: 1 / span 10; grid-row: 3; list-style: none; margin: var(--s-8) 0 0; padding: 0; position: relative; }
.svc__list::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--svc-line); }
.svc__item {
  position: relative; display: grid; grid-template-columns: 3.5rem minmax(0, 1fr) minmax(0, 34ch);
  column-gap: var(--gutter); align-items: baseline; padding-block: 18px; outline: none; cursor: default;
}
/* the divider over each row (it draws in from the left as the row rises) and the gold line under the row in use */
.svc__item::before, .svc__item::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; transform-origin: left center; }
.svc__item::before { top: 0; background: var(--svc-line); transition: scale 900ms var(--svc-ease) var(--sm-delay, 0ms); }
.svc__item::after { bottom: -1px; z-index: 1; background: var(--svc-gold); scale: 0 1; transition: scale 500ms var(--svc-ease); }
.svc__item.is-on::after { scale: 1 1; }
.svc__num {
  font-size: var(--t-label); letter-spacing: 0.12em; color: var(--svc-dim); font-variant-numeric: tabular-nums;
  transition: color var(--d-hover, 220ms) ease;
}
.svc__name {
  margin: 0; font-family: var(--font-display); font-weight: 400; letter-spacing: var(--display-tracking);
  font-size: clamp(26px, 1.25vw + 16px, 38px); line-height: 1.15; color: var(--svc-dim);
  transition: color var(--d-hover, 220ms) ease, transform var(--d-hover, 220ms) var(--svc-ease);
}
.svc__desc { margin: 0; font-size: 15px; line-height: 1.5; color: rgb(255 255 255 / 0.62); transition: color var(--d-hover, 220ms) ease; }
.svc__item.is-on .svc__num { color: var(--svc-gold); }
.svc__item.is-on .svc__name { color: #fff; transform: translateX(10px); }
.svc__item.is-on .svc__desc { color: rgb(255 255 255 / 0.92); }
.svc__item:focus-visible .svc__name { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 6px; text-decoration-color: var(--svc-gold); }
@media (hover: hover) and (pointer: fine) { .svc__item { cursor: pointer; } }

/* a change made from the keyboard shows at once (js/services.js sets the class for that one change) */
#services.svc--instant :is(.svc__bg, .svc__count-roll, .svc__name, .svc__num, .svc__desc),
#services.svc--instant .svc__item::after { transition: none !important; }

/* ---- the way in: the rows' dividers draw as each row rises (js/scroll-motion.js adds .sm-in, in sequence) */
html.sm-js #services .svc__item.sm-rise:not(.sm-in)::before { scale: 0 1; }

/* the picture opens from a rounded inset to full bleed while the section's top travels up the screen */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    #services.svc { view-timeline: --svc-in block; }
    html:not([data-motion="off"]) #services.svc > .svc__stage {
      animation: svc-open linear both; animation-timeline: --svc-in; animation-range: entry 0% entry 100%;
    }
  }
}
@keyframes svc-open {
  from { clip-path: inset(9% 5% 0 5% round 28px); }
  to { clip-path: inset(0 0 0 0 round 0px); }
}

/* ---- a tablet and a phone: the rows stack, each about half a screen apart; the picture stays on the screen behind
   them and follows the row crossing the middle; the numeral rides at the foot of the screen */
@media (max-width: 1023px) {
  main > #services.svc > .svc__wrap { display: flex; flex-direction: column; }
  .svc__head { max-width: 36rem; }
  .svc__list { margin-top: 14svh; }
  .svc__item {
    grid-template-columns: 3rem minmax(0, 1fr); row-gap: var(--s-3); align-items: baseline;
    min-height: 40svh; align-content: center; padding-block: var(--s-6);
  }
  .svc__desc { grid-column: 2; max-width: 36ch; font-size: var(--t-body); }
  .svc__item.is-on .svc__name { transform: none; }
  .svc__count {
    order: 9; position: sticky; bottom: calc(var(--s-5) + env(safe-area-inset-bottom, 0px)); align-self: flex-end;
    margin-top: var(--s-8); font-size: 72px;
  }
  .svc__stage::after {
    background:
      linear-gradient(to top, rgb(20 16 12 / 0.7), rgb(20 16 12 / 0.35) 60%, rgb(20 16 12 / 0.2)),
      rgb(20 16 12 / 0.42);
  }
}
@media (max-width: 639px) {
  .svc__item { min-height: 46svh; grid-template-columns: 2.5rem minmax(0, 1fr); column-gap: var(--s-3); }
  .svc__name { font-size: 28px; }
  .svc__count { font-size: 56px; }
}

/* ---- reduced motion: the pictures fade without settling, nothing slides */
@media (prefers-reduced-motion: reduce) {
  .svc__bg, .svc__bg.is-on { scale: 1; }
  .svc__bg.is-on { transition: opacity 200ms ease; }
  .svc__count-roll, .svc__name, .svc__item::before, .svc__item::after { transition: none; }
  .svc__item.is-on .svc__name { transform: none; }
}
@media print {
  #services.svc { background: none; color: #000; --ink: #000; --muted: #333; }
  .svc__stage, .svc__count { display: none; }
  .svc__head > h2, .svc__name, .svc__desc, .svc__num { color: #000 !important; }
}

/* stacked, the numeral at the foot of the screen marks the row in use; a gold line under a row half a screen tall
   would only run behind that numeral */
@media (max-width: 1023px) { .svc__item::after { display: none; } }
