/* ==========================================================================
   HOW THE WORK MOVES · The Ripple Effect (Variation B, official)
   Ported from prototypes/sonder-ripple-effect/ripple.css + ripple-v2.css, scoped to #method.
   The section heading and intro stay the site's own (.section-head), with their approved reveal.
   ?method=ripple (default) shows .rp and hides the previous .cycle; ?method=cycle the reverse.
   Without JavaScript the head script never sets data-method, so the previous cycle (which has a
   static drawn line) shows and nothing depends on script.
   ========================================================================== */
#method .rp { display: none; }
html[data-method="ripple"] #method .rp { display: block; position: relative; }
html[data-method="ripple"] #method .cycle { display: none; }

/* ---------- the field: artwork + movements ------------------------------------------ */
#method .rp__field { position: relative; }
#method .rp__art { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
#method .rp-origin, #method .rp-dropstart, #method .rp-stage__anchor { position: absolute; width: 0; height: 0; pointer-events: none; }

#method .rp-thread, #method .rp-ring { fill: none; stroke: var(--c-orange); stroke-linecap: round; stroke-linejoin: round; }
#method .rp-thread { stroke-width: 1.5; }
#method .rp-ring--loop { stroke-width: 1.6; }
#method .rp-ring--wave { stroke-width: 1.1; }
#method .rp-nucleus, #method .rp-drop, #method .rp-head, #method .rp-node { fill: var(--c-orange); }
#method .rp-echo { fill: none; stroke: var(--c-orange); stroke-width: 1; }

#method .rp__stages { margin: 0; padding: 0; list-style: none; }
#method .rp-stage__num {
  display: block;
  font-size: 0.75rem; font-weight: 500; letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--dark-text-faint);
}
#method .rp-stage__title {
  margin: 0.3rem 0 0.55rem;
  font-family: var(--font-display);
  font-weight: 360;
  font-size: clamp(1.75rem, 1.25rem + 1.1vw, 2.5rem);
  line-height: 1.1;
  /* the heading surfaces through its own lower edge (room left for descenders) */
  overflow: hidden;
  padding-bottom: 0.12em; margin-bottom: calc(0.55rem - 0.12em);
}
#method .rp-stage__title-in { display: inline-block; }
#method .rp-stage__desc { margin: 0; color: var(--dark-text-soft); line-height: 1.5; text-wrap: pretty; }

/* held back before the sequence (only when ripple.js will run it; see the head script) */
.rp-js #method .rp:not([data-state="done"]) .rp-stage__num,
.rp-js #method .rp:not([data-state="done"]) .rp-stage__title-in,
.rp-js #method .rp:not([data-state="done"]) .rp-stage__desc { opacity: 0; }

/* ---------- controls --------------------------------------------------------------- */
#method .rp__controls { display: flex; gap: 1.25rem; justify-content: flex-end; min-height: 2.5rem; margin-top: var(--space-6); }
#method .rp-btn {
  appearance: none; border: 0; background: none; cursor: pointer;
  padding: 0.5rem 0; font: inherit; font-size: 0.875rem; color: var(--dark-text-soft);
  text-decoration: underline; text-decoration-color: rgb(244 233 221 / 0.3); text-underline-offset: 0.3em;
  transition: color 200ms var(--ease-quiet), text-decoration-color 200ms var(--ease-quiet);
}
#method .rp-btn:hover { color: var(--dark-text); text-decoration-color: var(--c-orange); }
#method .rp-btn:focus-visible { outline: 2px solid var(--dark-focus); outline-offset: 4px; border-radius: 2px; }
#method .rp-btn[hidden] { display: none; }

/* ==========================================================================
   WIDE · the thread flows across the page
   ========================================================================== */
@media (min-width: 1080px) {
  #method .rp__head { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: end; }
  #method .rp__intro { justify-self: end; }

  #method .rp__field {
    height: clamp(33rem, 22rem + 16vw, 42rem);
    margin-top: clamp(0.5rem, 2vh, 2rem);
    --rp-loop: 50;          /* the ring that stays, around the nucleus (px) */
    --rp-wave: 122;         /* the quieter ring that passes (px) */
    --rp-nucleus: 7;        /* = the drop's width / 2 */
    --rp-depart: -72;       /* where the thread leaves the ring (deg; 0 = right, clockwise) */
    --rp-weave: 0;          /* extra curvature between nodes (px); the alternation is enough here */
  }
  /* the five nodes (index.html, --x/--y) follow a damped wave: the swing narrows from Hold to
     Integrate as the ripple's energy settles, so the thread comes to rest at the end */
  #method .rp-origin { left: 5.5%; top: 47%; }
  #method .rp-dropstart { left: 5.5%; top: 2%; }

  #method .rp-stage { position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%); width: 0; height: 0; }
  #method .rp-stage__anchor { left: 0; top: 0; }
  #method .rp-stage__text { position: absolute; left: -0.125rem; width: min(16.5rem, 19vw); }
  #method .rp-stage[data-side="below"] .rp-stage__text { top: 1.5rem; }
  #method .rp-stage[data-side="above"] .rp-stage__text { bottom: 1.5rem; }
}

/* ==========================================================================
   NARROW · one column, the thread runs down a gutter on the left
   ========================================================================== */
@media (max-width: 1079.98px) {
  #method .rp__field {
    margin-top: var(--space-6);
    padding: clamp(8.5rem, 7rem + 4vw, 10rem) 0 0 clamp(3.75rem, 2.5rem + 4vw, 5rem);
    --rp-gutter: clamp(1.5rem, 0.9rem + 2.2vw, 2.25rem);   /* the thread's column (centre) */
    --rp-loop: 24;
    --rp-wave: 60;
    --rp-nucleus: 5.5;
    --rp-depart: -12;       /* leaves the right side of the ring, heading down */
    --rp-weave: 11;
  }
  #method .rp-origin { left: var(--rp-gutter); top: clamp(5.5rem, 4.5rem + 3vw, 6.5rem); }
  #method .rp-dropstart { left: var(--rp-gutter); top: 0.25rem; }

  #method .rp-stage { position: relative; max-width: 34rem; }
  #method .rp-stage + .rp-stage { margin-top: clamp(2.5rem, 2rem + 2vw, 3.25rem); }
  /* the node sits on the thread, level with the middle of the heading */
  #method .rp-stage__anchor {
    left: calc(var(--rp-gutter) - clamp(3.75rem, 2.5rem + 4vw, 5rem));
    top: calc(1.05rem + 0.3rem + 0.6em);
    font-size: clamp(1.75rem, 1.25rem + 1.1vw, 2.5rem);
  }
  #method .rp-stage__desc { max-width: 40ch; }
  #method .rp__controls { justify-content: flex-start; padding-left: clamp(3.75rem, 2.5rem + 4vw, 5rem); }
}


/* Variation B: a larger resting ring, a wider second ring, B's departure angle */
/* the ripple has more presence: a slightly larger resting ring, a wider second ring */
@media (min-width: 1080px) {
  #method .rp[data-rp-variant] .rp__field { --rp-loop: 52; --rp-wave: 156; }
  #method .rp[data-rp-variant] .rp-ring--wave { stroke-width: 1.2; }
  #method .rp[data-rp-variant="b"] .rp__field { --rp-depart: -64; }     /* leaves a little more downward, toward the lower Hold */
}
@media (max-width: 1079.98px) {
  #method .rp[data-rp-variant] .rp__field { --rp-loop: 26; --rp-wave: 74; }
}
