/* ==========================================================================
   Services: six panels that wrap into columns as space allows
   Color variants: panel--stone | panel--taupe (both use onyx text)

   Interaction (mouse): the panel fills with onyx rising from the bottom, its
   text inverts, a soft light follows the pointer (--x / --y, set by
   scripts/features/services.js) and the icon and arrow move. Keyboard focus
   gets the same fill. Icons draw themselves in as the panel scrolls into view.
   The whole panel is a link (the panel link stretches over it).
   ========================================================================== */

.services {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  --panel-fg: var(--color-ink);
  position: relative;
  isolation: isolate;
  overflow: hidden;
  box-sizing: border-box;
  min-width: 0;
  min-height: 300px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: clamp(24px, 3vw, 48px);
  color: var(--panel-fg);
  /* repeats the scroll-reveal timing (motion.css), since this rule replaces it */
  transition: color 350ms ease,
              opacity 600ms var(--ease) var(--reveal-delay, 0ms),
              transform 700ms var(--ease) var(--reveal-delay, 0ms);
}

/* Onyx fill that rises from the bottom on hover / focus */
.panel::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--color-ink);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 550ms var(--ease);
}

/* Soft light that follows the pointer */
.panel::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(320px circle at var(--x, 50%) var(--y, 50%), rgb(var(--paper-rgb) / .16), transparent 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.panel:hover,
.panel:focus-within {
  --panel-fg: var(--color-paper);
}

.panel:hover::before,
.panel:focus-within::before {
  transform: scaleY(1);
}

.panel:hover::after {
  opacity: 1;
}

/* ---- Icon + number row ---- */
.panel__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel__icon {
  width: clamp(34px, 3vw, 44px);
  height: auto;
  overflow: visible;
  transition: transform 500ms var(--ease);
}

/* The icon's lines draw in when the panel is revealed (reveal.js) */
.panel__icon > * {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1100ms var(--ease) calc(var(--reveal-delay, 0ms) + 250ms);
}

.panel[data-reveal].is-pending .panel__icon > * {
  stroke-dashoffset: 1;
}

.panel__num {
  font-family: var(--font-display);
  font-stretch: var(--stretch-display);
  font-weight: var(--weight-display);
  font-size: var(--text-num);
  letter-spacing: .12em;
  opacity: .55;
  transition: opacity 300ms ease, transform 500ms var(--ease);
}

.panel--stone { background: var(--color-stone); }
.panel--taupe { background: var(--color-taupe); }

.panel__title {
  margin: 0;
  font-family: var(--font-display);
  font-stretch: var(--stretch-display);
  font-weight: var(--weight-display);
  font-size: clamp(24px, 2.4vw, 36px);
  line-height: 1.1;
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
  overflow-wrap: anywhere;
  transition: transform 250ms var(--ease);
}

.panel__body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 460px;
}

.panel__text {
  margin: 0;
  font-size: var(--text-base);
  font-weight: 400;
  line-height: 1.6;
}

.panel__text strong {
  font-weight: 500;
}

.panel__link {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 44px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  text-underline-offset: 6px;
  color: inherit;
  outline-offset: 4px;
}

/* The link covers the whole panel, so the panel is one big click target */
.panel__link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.panel__link:focus-visible {
  outline-color: var(--color-paper);
}

/* A visible focus ring on the panel itself, since the link covers it */
.panel:has(.panel__link:focus-visible) {
  outline: 2px solid var(--color-paper);
  outline-offset: -8px;
}

.panel__link span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 13px;
  letter-spacing: 0;
  transition: transform 400ms var(--ease), background-color 300ms ease, color 300ms ease;
}

@media (max-width: 1100px) {
  .services { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

@media (hover: hover) and (pointer: fine) {
  .panel:hover .panel__link span {
    background: var(--color-paper);
    color: var(--color-ink);
  }
}

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  html:not(.motion-off):not(.is-keyboard) .panel:hover .panel__title { transform: translateX(8px); }
  html:not(.motion-off):not(.is-keyboard) .panel:hover .panel__icon { transform: translateY(-4px) rotate(-8deg) scale(1.08); }
  html:not(.motion-off):not(.is-keyboard) .panel:hover .panel__num { opacity: 1; transform: translateY(-2px); }
  html:not(.motion-off):not(.is-keyboard) .panel:hover .panel__link span { transform: rotate(45deg); }
}

/* Paused / reduced motion: keep the colour change, skip the movement */
html.motion-off .panel__icon > *,
html.motion-off .panel[data-reveal].is-pending .panel__icon > * {
  stroke-dashoffset: 0;
}

@media (prefers-reduced-motion: reduce) {
  .panel__icon > *,
  .panel[data-reveal].is-pending .panel__icon > * { stroke-dashoffset: 0; }
}

/* ---- Call to action under the six panels (spans the whole grid) ---- */
.services__cta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px 40px;
  padding: clamp(28px, 3.4vw, 48px) var(--gutter);
  background: var(--color-ink);
  color: var(--color-paper);
}

.services__cta-text {
  max-width: 560px;
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 400;
  line-height: 1.3;
}

/* On the onyx strip the solid button is reversed: bone with onyx text */
.services__cta .btn--solid {
  border-color: var(--color-paper);
  background: var(--color-paper);
  color: var(--color-ink);
}

@media (hover: hover) and (pointer: fine) {
  .services__cta .btn--solid:hover {
    border-color: var(--color-stone);
    background: var(--color-stone);
    color: var(--color-ink);
  }
}

.services__cta :focus-visible {
  outline-color: var(--color-paper);
}
