/* ==========================================================================
   04 · SERVICES — seven flash sheets from the studio's art book
   State model: every sheet carries --on (0 → 1). Hover, keyboard focus and the
   JS-driven .is-active (touch: sheet nearest the centre of the scroller /
   sheets inside the reading band on tablets) all just flip --on, so the whole
   choreography lives in one place and is identical for every input type.
   ========================================================================== */
.services {
  --svc-gap: clamp(.55rem, .95vw, 1.05rem);
  --svc-pad: clamp(.7rem, .95vw, 1.05rem);
  --svc-step: clamp(.9rem, 1.5vw, 1.7rem);          /* unit of the vertical stagger */
  --card-w: 12.2vw;                                  /* refined with container units below */
  position: relative;
  padding-block: clamp(5.5rem, 9.5vw, 10rem) clamp(5rem, 8.5vw, 8.5rem);
  overflow-x: clip;
}

/* ---- drifting kumo linework behind the heading ---- */
.services__sky { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.services__cloud { position: absolute; color: var(--ink); will-change: transform; }
.services__cloud--a {
  top: clamp(2.5rem, 5.5vw, 6rem); left: 47%; width: clamp(300px, 31vw, 600px); opacity: .15;
  animation: services-drift 48s var(--ease-in-out) infinite alternate;
}
.services__cloud--b {
  top: clamp(7rem, 13vw, 15rem); right: -5%; width: clamp(200px, 19vw, 380px); opacity: .1;
  animation: services-drift 64s var(--ease-in-out) infinite alternate-reverse;
}
@keyframes services-drift { from { transform: translate3d(-14px, 0, 0); } to { transform: translate3d(26px, -4px, 0); } }

/* ---- heading row ---- */
.services__head {
  position: relative; z-index: var(--z-content);
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label ." "title aside";
  align-items: end; column-gap: clamp(1.5rem, 4vw, 4rem);
}
.services__label { grid-area: label; letter-spacing: .36em; margin-bottom: clamp(1rem, 1.5vw, 1.5rem); }
.services__title { grid-area: title; }
.services__aside { grid-area: aside; display: flex; align-items: flex-end; gap: clamp(1rem, 1.6vw, 1.6rem); padding-bottom: .55rem; }
.services__motto { gap: 1.05em; color: var(--ink-80); }
/* plumb line: hairline dropping to a ring */
.services__plumb { position: relative; display: block; flex: none; width: 1px; height: clamp(5.5rem, 7.4vw, 7.5rem); margin: 0 6px 13px; background: var(--line-strong); }
.services__plumb::before { content: ""; position: absolute; left: -2px; top: -2px; width: 5px; height: 5px; border-radius: 50%; background: var(--ink); }
.services__plumb::after { content: ""; position: absolute; left: -6px; bottom: -13px; width: 13px; height: 13px; border-radius: 50%; border: 1px solid var(--ink); }

/* ---- the deck ---- */
.services__deck {
  position: relative; z-index: var(--z-content);
  container-type: inline-size;
  width: 100%; max-width: var(--maxw); margin-inline: auto;
  margin-top: clamp(2.5rem, 4.4vw, 4.5rem);
  padding-inline: calc(var(--rail-w) + var(--gutter) * .5) calc(var(--gutter) * .5);
}
.services__list { display: flex; align-items: flex-start; gap: var(--svc-gap); }
@supports (width: 1cqw) { .services__list { --card-w: calc((100cqw - 6 * var(--svc-gap)) / 7); } }

.services__item { position: relative; flex: 1 1 0; min-width: 0; transition: flex-grow 1s var(--ease-out); }
.services__item:nth-child(1) { margin-top: calc(var(--svc-step) * .9); }
.services__item:nth-child(2) { margin-top: calc(var(--svc-step) * 2.6); }
.services__item:nth-child(3) { margin-top: 0; }
.services__item:nth-child(4) { margin-top: calc(var(--svc-step) * 1.9); }
.services__item:nth-child(5) { margin-top: calc(var(--svc-step) * 3.2); }
.services__item:nth-child(6) { margin-top: calc(var(--svc-step) * .5); }
.services__item:nth-child(7) { margin-top: calc(var(--svc-step) * 1.7); }
.services__item--plate { align-self: stretch; }

/* ---- one flash sheet ---- */
.services__card {
  --on: 0; --dim: 0;
  position: relative; display: flex; flex-direction: column; height: 100%;
  padding: var(--svc-pad);
  color: var(--ink);
  opacity: calc(1 - .4 * var(--dim));
  transition: opacity .7s var(--ease-soft);
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) and (pointer: fine) { .services__card:hover { --on: 1; } }
.services__card:focus-visible, .services__card.is-active { --on: 1; }
.services__card:focus-visible { outline-offset: 5px; }

/* neighbours step back */
.services__list.has-active .services__card:not(.is-active) { --dim: 1; }
.services__list:has(.services__card:focus-visible) .services__card:not(:focus-visible) { --dim: 1; }
@media (hover: hover) and (pointer: fine) {
  .services__list:has(.services__card:hover) .services__card:not(:hover) { --dim: 1; }
}

/* paper: fibre texture that shifts a few px under the light + aged edge */
.services__paper { position: absolute; inset: 0; overflow: hidden; border-radius: inherit; pointer-events: none; }
.services__paper::before {
  content: ""; position: absolute; inset: -18px; opacity: .55;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='p' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.02 .22' numOctaves='3' seed='11' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .34 0 0 0 0 .2 0 0 0 .3 -.1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23p)'/%3E%3C/svg%3E"),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='q' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' seed='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .18 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23q)'/%3E%3C/svg%3E");
  transform: translate3d(calc(var(--on) * -12px), calc(var(--on) * -8px), 0);
  transition: transform 1.8s var(--ease-out);
}
.services__paper::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 38px rgba(120, 92, 44, .09), inset 0 -22px 30px -26px rgba(120, 92, 44, .16); }

/* ink border: a rect that draws itself clockwise from the top-left corner */
.services__ink { position: absolute; left: -1px; top: -1px; width: calc(100% + 2px); height: calc(100% + 2px); overflow: visible; pointer-events: none; z-index: 3; }
.services__ink rect {
  fill: none; stroke: var(--ink); stroke-width: 1.4px; stroke-linecap: butt;
  stroke-dasharray: 1px; stroke-dashoffset: calc(1px - var(--on) * 1px);
  transition: stroke-dashoffset 1.25s var(--ease-in-out);
}

/* plate number + registration mark */
.services__meta { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; min-height: 1.1rem; }
.services__no { font-family: var(--font-display); font-style: italic; font-weight: 400; font-size: clamp(.72rem, .8vw, .85rem); line-height: 1; letter-spacing: .02em; color: var(--ink-60); }
.services__reg {
  position: relative; display: block; width: 11px; height: 11px; border-radius: 50%; border: 1px solid var(--line-strong);
  transform: rotate(calc(var(--on) * 90deg)); transition: transform 1.2s var(--ease-out);
}
.services__reg::before, .services__reg::after { content: ""; position: absolute; left: 50%; top: 50%; background: var(--ink-40); }
.services__reg::before { width: 17px; height: 1px; margin: -.5px 0 0 -8.5px; }
.services__reg::after { width: 1px; height: 17px; margin: -8.5px 0 0 -.5px; }

/* art window: fixed to the resting card width so the sheet can widen without re-rasterising the SVG */
.services__frame { position: relative; z-index: 1; display: grid; place-items: center; height: calc(var(--card-w) * 1.32); margin-top: .35rem; }
.services__frame::before {                         /* printer's corner ticks */
  content: ""; position: absolute; inset: 0; pointer-events: none; --t: 9px; --c: var(--line-strong);
  background:
    linear-gradient(var(--c), var(--c)) 0 0 / var(--t) 1px, linear-gradient(var(--c), var(--c)) 0 0 / 1px var(--t),
    linear-gradient(var(--c), var(--c)) 100% 0 / var(--t) 1px, linear-gradient(var(--c), var(--c)) 100% 0 / 1px var(--t),
    linear-gradient(var(--c), var(--c)) 0 100% / var(--t) 1px, linear-gradient(var(--c), var(--c)) 0 100% / 1px var(--t),
    linear-gradient(var(--c), var(--c)) 100% 100% / var(--t) 1px, linear-gradient(var(--c), var(--c)) 100% 100% / 1px var(--t);
  background-repeat: no-repeat;
  transform: scale(calc(1 - .035 * var(--on))); transition: transform 1.2s var(--ease-out);
}
.services__art {
  height: 92%; width: auto; aspect-ratio: 620 / 905; max-width: none;
  transform: scale(calc(1 + .06 * var(--on))); transition: transform 1.3s var(--ease-out); will-change: transform;
}
.services__art > svg { width: 100%; height: 100%; }

/* caption */
.services__caption { position: relative; z-index: 1; display: block; margin-top: .55rem; padding-top: clamp(.75rem, 1vw, 1.05rem); border-top: 1px solid var(--line); }
.services__name { font-family: var(--font-sans); font-weight: 600; font-size: clamp(.8rem, .92vw, 1rem); line-height: 1.2; letter-spacing: .17em; text-transform: uppercase; white-space: nowrap; }
.services__rule { position: relative; display: block; height: 7px; margin: .5rem 0 .45rem; overflow: hidden; }
.services__rule::before {
  content: ""; position: absolute; left: 0; right: 9px; top: 3px; height: 1px; background: var(--ink-60);
  transform: scaleX(var(--on)); transform-origin: 0 50%; transition: transform 1s var(--ease-out);
}
.services__rule i { position: absolute; inset: 0; transform: translate3d(calc((var(--on) - 1) * 100%), 0, 0); transition: transform 1.15s var(--ease-out); }
.services__rule i::after { content: ""; position: absolute; right: 0; top: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--vermillion); }
.services__tag { font-size: clamp(.78rem, .84vw, .9rem); line-height: 1.4; color: var(--ink-60); min-height: 2.8em; text-wrap: balance; }

/* circled arrow: the arrow leaves to the right, its twin arrives from the left */
.services__go {
  position: relative; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin-top: clamp(.5rem, .8vw, .9rem);
  border-radius: 50%; border: 1px solid var(--line-strong); overflow: hidden; isolation: isolate;
}
.services__go::before { content: ""; position: absolute; inset: -1px; z-index: -1; border-radius: 50%; background: var(--ink); transform: scale(var(--on)); transition: transform .8s var(--ease-out); }
.services__go .arrow { grid-area: 1 / 1; width: 1.05rem; transition: transform .9s var(--ease-out); }
.services__go .arrow:first-child { transform: translate3d(calc(var(--on) * 2.75rem), 0, 0); }
.services__go .arrow:last-child { color: var(--parchment); transform: translate3d(calc((var(--on) - 1) * 2.75rem), 0, 0); }

/* ---- 7th sheet: the mask plate ---- */
.services__card--plate { min-height: 100%; }
.services__frame--plate { flex: 1 1 auto; height: auto; min-height: calc(var(--card-w) * 1.32); display: grid; place-items: center; margin-bottom: 3.4rem; }
.services__sun {
  position: absolute; left: 50%; top: 50%; width: 74%; aspect-ratio: 1; margin: -37% 0 0 -37%; border-radius: 50%;
  background: var(--vermillion); opacity: .92;
  transform: translate3d(0, calc(-14% - var(--on) * 5%), 0) scale(calc(1 + .04 * var(--on))); transition: transform 1.5s var(--ease-out);
}
.services__splatter { position: absolute; inset: 4% -6% 0; color: var(--vermillion); opacity: .85; }
.services__splatter > svg { width: 100%; height: 100%; }
.services__mask {
  position: relative; width: 100%; height: 100%; max-height: calc(var(--card-w) * 1.9); object-fit: contain;
  transform: scale(calc(1 + .06 * var(--on))); transition: transform 1.3s var(--ease-out); will-change: transform;
}
.services__caption--plate { position: absolute; left: var(--svc-pad); right: var(--svc-pad); bottom: var(--svc-pad); display: flex; align-items: flex-end; justify-content: space-between; margin: 0; padding: 0; border: 0; }
.services__seal { font-size: .95rem; }
.services__caption--plate .services__go { margin-top: 0; }

/* phone-only thread (enabled below) */
.services__thread { display: none; }

/* ==========================================================================
   ≥1200 · one row of seven, staggered; the sheet under the pointer widens
   ========================================================================== */
@media (min-width: 1200px) {
  .services__item.is-wide { flex-grow: 1.4; }                          /* JS fallback where :has() is missing */
  .services__item:has(.services__card:focus-visible) { flex-grow: 1.4; }
}
@media (min-width: 1200px) and (hover: hover) and (pointer: fine) {
  .services__item:has(.services__card:hover) { flex-grow: 1.4; transition-delay: .04s; }
}
@media (min-width: 1800px) {
  .services { --svc-gap: 1.15rem; }
}

/* ==========================================================================
   768–1199 · art-book spread: 3 × 2 sheets + the tall mask plate as a full-height column
   ========================================================================== */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .services { --svc-gap: clamp(.8rem, 1.7vw, 1.3rem); --svc-pad: clamp(.85rem, 1.5vw, 1.15rem); --card-w: 20vw; }
  .services__deck { padding-inline: calc(var(--gutter) * .7); }
  .services__list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); row-gap: calc(var(--svc-gap) * 1.6); align-items: start; }
  @supports (width: 1cqw) { .services__list { --card-w: calc((100cqw - 3 * var(--svc-gap)) / 4); } }
  .services__item { margin-top: 0 !important; transition: none; }
  .services__item:nth-child(2), .services__item:nth-child(5) { margin-top: calc(var(--svc-step) * 2) !important; }
  .services__item:nth-child(3), .services__item:nth-child(6) { margin-top: calc(var(--svc-step) * .8) !important; }
  .services__item--plate { grid-column: 4; grid-row: 1 / span 2; align-self: stretch; margin-top: calc(var(--svc-step) * 3) !important; }
  .services__frame { height: calc(var(--card-w) * 1.26); }
  .services__name { font-size: clamp(.85rem, 1.5vw, 1rem); }
  .services__tag { font-size: .85rem; }
  .services__mask { max-height: calc(var(--card-w) * 2.4); }
}

/* ==========================================================================
   <768 · horizontal snap scroller, sheet nearest the centre is "inked"
   ========================================================================== */
@media (max-width: 767.98px) {
  .services { --svc-gap: .8rem; --svc-pad: 1rem; padding-block: clamp(4.5rem, 16vw, 6.5rem) clamp(4rem, 14vw, 5.5rem); }
  .services__head { grid-template-columns: minmax(0, 1fr); grid-template-areas: "label" "title" "aside"; }
  .services__title { font-size: clamp(2.7rem, 12.4vw, 4.4rem); }
  .services__aside { align-items: center; gap: .9rem; margin-top: 1.5rem; padding: 0; }
  .services__plumb { order: 0; width: clamp(2.5rem, 14vw, 4.5rem); height: 1px; margin: 0 0 0 13px; }
  .services__plumb::before { left: auto; right: -2px; top: -2px; }
  .services__plumb::after { left: -13px; bottom: -6px; }
  .services__motto { display: flex; flex-wrap: wrap; gap: .35em .9em; max-width: 15em; }

  .services__cloud--a { top: 1.5rem; left: auto; right: -24vw; width: 84vw; opacity: .13; }
  .services__cloud--b { display: none; }

  .services__deck { max-width: none; padding-inline: 0; margin-top: 2.25rem; }
  .services__list {
    --card-w: min(70vw, 19.5rem);
    gap: var(--svc-gap); overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory; scroll-padding-inline: var(--gutter);
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .services__deck .services__list { padding: 6px var(--gutter) 1.6rem; }   /* beats base `ul[class] { padding: 0 }` */
  .services__list::-webkit-scrollbar { display: none; }
  .services__item { flex: 0 0 var(--card-w); scroll-snap-align: center; margin-top: 0 !important; transition: none; }
  .services__item:nth-child(even) { margin-top: 1.4rem !important; }
  .services__item--plate { margin-top: .5rem !important; }
  .services__frame { height: calc(var(--card-w) * 1.22); }
  .services__name { font-size: 1rem; }
  .services__tag { font-size: .95rem; min-height: 0; }
  .services__no { font-size: .85rem; }
  .services__go { width: 3rem; height: 3rem; margin-top: 1rem; }
  .services__go .arrow:first-child { transform: translate3d(calc(var(--on) * 3rem), 0, 0); }
  .services__go .arrow:last-child { transform: translate3d(calc((var(--on) - 1) * 3rem), 0, 0); }
  .services__list.has-active .services__card:not(.is-active) { --dim: .55; }

  .services__thread { display: flex; align-items: center; gap: 1.1rem; padding-inline: var(--gutter); --p: 0; }
  .services__thread-line { position: relative; flex: 1 1 auto; height: 1px; background: var(--line-strong); }
  .services__thread-fill { position: absolute; inset: 0; background: var(--ink); transform: scaleX(var(--p)); transform-origin: 0 50%; }
  .services__thread-bead { position: absolute; left: 0; right: 7px; top: -3px; height: 7px; transform: translate3d(calc(var(--p) * 100%), 0, 0); }
  .services__thread-bead::after { content: ""; position: absolute; left: 0; top: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--vermillion); box-shadow: 0 0 0 3px var(--parchment); }
  .services__hint { display: inline-flex; align-items: center; gap: .8em; color: var(--ink-60); transition: opacity .8s var(--ease-soft); }
  .services__hint .arrow { width: 1.4em; animation: services-nudge 2.4s var(--ease-in-out) infinite; }
  .services__thread.is-touched .services__hint { opacity: .35; }
  .services__thread.is-touched .services__hint .arrow { animation: none; }
}
@keyframes services-nudge { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(.5em); } }

@media (prefers-reduced-motion: reduce) {
  .services__cloud, .services__hint .arrow { animation: none !important; }
  .services__item { transition: none; }
}
