/* ─────────────────────────────────────────────────────────────────────────
   HORMACHUELOS — motion and touch (fx.js).

   Loaded after the sketchbook theme on every page. It only adds behaviour to
   what is already there: sections rise in as they scroll into view, paper
   cards catch a warm spotlight under the pointer and lean toward it, the
   main buttons lean toward the pointer too, and a thin line along the top
   shows how far down the page you are.

   Everything waits for html.fx, which fx.js sets, so a page without the
   script still shows every word. Reduced motion turns all of it off.
   ───────────────────────────────────────────────────────────────────────── */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Rise in on scroll ── */

html.fx [data-reveal] {
  opacity: 0;
  translate: 0 22px;
  transition:
    opacity 0.7s cubic-bezier(0.2, 0.7, 0.2, 1),
    translate 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
  transition-delay: calc(var(--reveal-i, 0) * 70ms);
}

html.fx [data-reveal].is-in {
  opacity: 1;
  translate: 0 0;
}

/* ── The spotlight: a warm glow that follows the pointer across a card ── */

.fx-spot {
  position: relative;
  isolation: isolate;
}

.fx-glow {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    320px circle at var(--mx, 50%) var(--my, 50%),
    rgba(214, 120, 58, 0.16),
    rgba(214, 120, 58, 0) 70%
  );
  transition: opacity 0.3s ease;
}

.fx-spot:hover > .fx-glow {
  opacity: 1;
}

/* ── Lean toward the pointer ── */

[data-tilt] {
  transform-style: preserve-3d;
  transition: transform 0.35s cubic-bezier(0.2, 0.7, 0.2, 1);
}

html.fx [data-tilt].is-tilting {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-3px);
  transition-duration: 0.12s;
}

/* Magnetic buttons use the separate `translate` property, so their own
   hover nudge (a transform) still plays on top. */
.fx-magnet {
  translate: var(--tx, 0) var(--ty, 0);
  transition: translate 0.25s cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* ── How far down the page ── */

.fx-progress {
  position: fixed;
  inset: 0 0 auto;
  z-index: 60;
  height: 3px;
  pointer-events: none;
  background: linear-gradient(90deg, #e9a24a, var(--sanguine, #8e3a1c));
  transform-origin: 0 50%;
  transform: scaleX(var(--progress, 0));
}

/* ── Questions open smoothly where the browser can animate to auto ── */

@supports (interpolate-size: allow-keywords) {
  :root {
    interpolate-size: allow-keywords;
  }

  details::details-content {
    block-size: 0;
    overflow: hidden;
    transition:
      block-size 0.35s cubic-bezier(0.2, 0.7, 0.2, 1),
      content-visibility 0.35s allow-discrete;
  }

  details[open]::details-content {
    block-size: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.fx [data-reveal] {
    opacity: 1;
    translate: none;
    transition: none;
  }

  html.fx [data-tilt].is-tilting {
    transform: none;
  }

  .fx-magnet {
    translate: none;
  }

  .fx-progress {
    display: none;
  }

  details::details-content {
    transition: none;
  }
}
