/* ==========================================================================
   Section motion — everything between the hero and the contact form.

   Each block is gated on a class that js/motion.js adds, so a phone, a
   reduced-motion visitor or a failed script gets the page exactly as it was.
   Matte black and one bright white throughout; nothing here introduces a
   colour the rest of the site does not already use.

   A  .mq        the cards below the hero: dealt out, then leaning into the scroll
   B  .about     a light swarm of cursors places the four facts
   C  .services  the row you are level with is the one that is lit
   D  .others    one clean arrival instead of three competing ones
   E  .ribbon    the process, written across the screen as you scroll
   F  .stk-show  a cursor showing one tool per group, on a loop
   ========================================================================== */

/* ===========================  A — CARDS BELOW THE HERO  ==================== */

/* Dealt out on arrival, a beat apart, then the rows lean into the scroll. */
.motion .mq-row {
  transform: skewX(calc(var(--lean, 0) * 1deg));
  transition: transform 0.45s var(--ease-soft);
}
.motion .mq-tile {
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  transition:
    opacity 0.7s var(--ease),
    transform 0.9s var(--ease);
  transition-delay: calc(var(--mi, 0) * 0.055s);
}
.motion .mq-row.dealt .mq-tile {
  opacity: 1;
  transform: none;
}
/* Dragging a row should feel direct, so the lean gets out of the way. */
.motion .mq-row.dragging {
  transform: none;
  transition: none;
}

/* ==========================  B — ABOUT: THE LIGHT SWARM  =================== */

.about {
  position: relative;
}
.about-swarm {
  display: none;
}
.motion-swarm .about-swarm {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* The four facts wait for a cursor to come and put them down. The stylesheet's
   own reveal is switched off here so the two are never both running. */
.motion-swarm .about-floats .float[data-reveal] {
  opacity: 1;
  transform: none;
  transition: none;
}
.motion-swarm .about-floats .float-card {
  opacity: 0;
  transform: scale(0.92) rotate(var(--r, 0deg));
  transition:
    opacity 0.45s var(--ease),
    transform 0.75s var(--pop);
}
.motion-swarm .about-floats .float.placed .float-card {
  opacity: 1;
  transform: scale(1) rotate(var(--r, 0deg));
}
/* A ring of light where the cursor set the card down. */
.motion-swarm .about-floats .float-card::after {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5), 0 0 46px rgba(255, 255, 255, 0.28);
  opacity: 0;
  pointer-events: none;
}
.motion-swarm .about-floats .float.placed .float-card::after {
  animation: about-land 0.85s var(--ease) forwards;
}
@keyframes about-land {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* =============================  C — SERVICES  ============================= */

/* The row you are level with is the one that is lit; the rest step back.
   Paper and ink, the same two tones the section already uses. */
.motion .svc-item {
  --f: 0;
}
.motion .svc-item > div {
  opacity: calc(0.34 + 0.66 * var(--f));
  transform: translateX(calc((1 - var(--f)) * -10px));
}
.motion .svc-item .svc-num {
  color: transparent;
  -webkit-text-stroke-color: rgba(10, 10, 10, 0.25);
}
/* Fills in as the row reaches the middle of the screen. */
.motion .svc-item.lead .svc-num {
  color: var(--ink);
  -webkit-text-stroke-color: transparent;
}
.motion .svc-item {
  position: relative;
}
.motion .svc-item::after {
  content: '';
  position: absolute;
  top: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--ink);
  transform: scaleX(var(--f, 0));
  transform-origin: 0 50%;
}
/* Hover still answers, it just cannot fight the scroll for the number. */
.motion .svc-item:hover > div {
  opacity: 1;
}

/* =========================  D — MORE SYSTEMS, CLEANED  ==================== */

/* The preview used to arrive three ways at once: a clip-path opening, the art
   drifting, and each child fading up. The deal-in in rail.css is the arrival
   now, so the rest is settled before it starts. */
.rest.on .mini .stage {
  clip-path: inset(0 0 0 0 round var(--radius-lg));
  transition: none;
}
.rest.on .mini .stage .art > * {
  opacity: 1;
  transform: none;
  transition: none;
}
/* The drift stays, at half strength, so the preview still answers the scroll. */
.rest.on .mini .art {
  transform: translate3d(0, calc(var(--q) * 22px), 0);
}

/* ======================  E — PROCESS, WRITTEN ACROSS  ===================== */

.ribbon {
  display: none;
}
.motion .ribbon {
  display: block;
  position: relative;
  width: var(--rvw, 100vw);
  margin: clamp(1.5rem, 4vw, 3rem) 0 clamp(2.5rem, 5vw, 4rem);
  margin-left: calc(50% - var(--rvw, 100vw) / 2);
}

/* Pinned: the section holds the screen while the words are read past, and the
   band gives itself the height that takes. Without .pin — a phone, or a screen
   too short to hold a line this size — it is a band that passes as you scroll. */
.motion .ribbon.pin {
  height: var(--rbh, 100vh);
  margin-bottom: 0;
}
.motion .ribbon-stage {
  position: relative;
  display: flex;
  align-items: center;
  overflow: hidden;
  /* Masked at both ends, so words arrive and leave rather than being chopped
     off against the edge of the screen. */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.motion .ribbon.pin .ribbon-stage {
  position: sticky;
  top: 0;
  height: 100vh;
}

.ribbon-track {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: clamp(1.5rem, 3vw, 3.5rem);
  width: max-content;
  padding-inline: 50vw;
  will-change: transform;
}
.rb {
  font-weight: 800;
  font-stretch: 86%;
  font-size: clamp(2.6rem, 11vw, 11rem);
  line-height: 1;
  letter-spacing: -0.045em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--white);
  opacity: var(--o, 1);
}

/* The line that threads from one step to the next, drawn as it arrives. */
.ribbon-track svg {
  flex: none;
  width: clamp(84px, 11vw, 190px);
  height: auto;
  aspect-ratio: 2 / 1;
  overflow: visible;
  opacity: var(--o, 1);
}
.ribbon-track path {
  fill: none;
  stroke: var(--white);
  stroke-width: 11;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: calc(1 - var(--d, 0));
}

/* The last word arrives as an outline and fills with light left to right,
   then its letters spread apart and go. */
.rb-last {
  position: relative;
  display: inline-block;
}
.rb-ghost {
  color: transparent;
  -webkit-text-stroke: 2px #4a4a47;
}
.rb-fill {
  position: absolute;
  inset: 0;
  color: var(--white);
  clip-path: inset(-25% calc((1 - var(--f, 0)) * 100%) -25% -2%);
}
/* Split into letters by the driver, so each one can leave on its own beat. */
.rb-last i {
  display: inline-block;
  font-style: normal;
  transform: translateX(calc(var(--k, 0) * var(--spread, 0px)));
  opacity: var(--lo, 1);
}

/* ========================  F — ONE TOOL AT A TIME  ======================== */

.stack-sec {
  position: relative;
}

/* The readout the cursor is filling in. Hidden until the showcase runs, so it
   never sits there empty on a phone or without JS. */
.stk-show {
  display: none;
}
.motion-show .stk-show {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(1rem, 3vw, 2.5rem);
  margin: clamp(1.75rem, 3vw, 2.5rem) 0 clamp(0.5rem, 1vw, 1rem);
  padding: clamp(1.1rem, 2vw, 1.6rem) clamp(1.25rem, 2.4vw, 2rem);
  border: 1px solid #262624;
  border-radius: var(--radius-lg);
  background: var(--panel);
}
.stk-show .stk-slot {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  min-width: 11ch;
}
.stk-show .stk-slot i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
  animation: stk-beat 1.8s var(--ease-soft) infinite;
}
@keyframes stk-beat {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}
.stk-show .stk-name {
  font-weight: 700;
  font-size: clamp(1.1rem, 2vw, 1.5rem);
  letter-spacing: -0.02em;
  white-space: nowrap;
  color: var(--white);
}
.stk-show .stk-line {
  /* Two lines held open, so the panel does not jump as each one is typed. */
  min-height: 3.1em;
  color: var(--soft);
  font-family: var(--mono);
  font-size: clamp(0.76rem, 1.1vw, 0.88rem);
  line-height: 1.55;
}
/* The caret the line is typed behind. */
.stk-show .stk-line::after {
  content: '';
  display: inline-block;
  width: 7px;
  height: 1em;
  margin-left: 2px;
  background: var(--white);
  vertical-align: -0.14em;
  animation: stk-caret 1s steps(1) infinite;
}
.stk-show.done .stk-line::after {
  animation-duration: 1.4s;
}
@keyframes stk-caret {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* The chip being shown, and the card it belongs to. */
.motion-show .stk-card {
  transition: border-color 0.45s var(--ease), background-color 0.45s var(--ease);
}
.motion-show .stk-card.showing {
  border-color: #5c5c57;
  background: #191918;
}
.motion-show .stk-chips li {
  transition:
    border-color 0.3s var(--ease),
    background-color 0.3s var(--ease),
    color 0.3s var(--ease),
    transform 0.4s var(--pop);
}
.motion-show .stk-chips li.showing {
  border-color: var(--white);
  background: var(--white);
  color: var(--black);
  transform: translateY(-2px);
}

/* The cursor doing the showing. */
.stk-cursor {
  display: none;
}
.motion-show .stk-cursor {
  display: block;
  position: absolute;
  inset: 0;
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ==============================  PHONES  ================================ */

/* The lean is a wide-screen flourish; the driver never sets --lean on a phone,
   and this keeps the row from carrying a transform it will never use. */
@media (max-width: 999px) {
  .motion .mq-row {
    transform: none;
    transition: none;
  }
  /* A phone shows one service at a time anyway, so the rows it is not level
     with only need to step back, not disappear. */
  .motion .svc-item > div {
    opacity: calc(0.62 + 0.38 * var(--f));
    transform: none;
  }
  .rb {
    font-size: clamp(2rem, 13vw, 3.6rem);
  }
  .ribbon-track svg {
    width: clamp(54px, 14vw, 90px);
  }
  .ribbon-track path {
    stroke-width: 13;
  }
  .rb-ghost {
    -webkit-text-stroke-width: 1.2px;
  }
}

/* ===============================  OFF  ================================== */

/* Nothing above runs without motion, and the page keeps its plain reveals. */
@media (prefers-reduced-motion: reduce) {
  .motion .mq-tile,
  .motion .mq-row {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .stk-show .stk-slot i,
  .stk-show .stk-line::after {
    animation: none;
  }
}
