/* ==========================================================================
   How we work: the four-step chain (a port of BH Studios' three principles)
   The titles stay put in a sticky column while the drawings scroll by. The
   drawing at mid-screen is .is-on (site.js): its title lights up, the others
   dim, the line between two numbers fills (--fill) with the scroll. Each
   drawing plays once and holds its last frame; Replay starts it over.
   Without the script the column still sticks and every drawing plays once;
   with reduced motion every drawing shows its finished state.
   ========================================================================== */

.method {
  --m-top: calc(var(--header-h) + 1.5rem);
  display: grid;
  gap: clamp(1.5rem, 0.75rem + 3vw, 4rem);
}

.method__side {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.75rem;
}

.method__titles {
  --m-n: 2.75rem;
  --m-gap: clamp(1.4rem, 0.9rem + 2vh, 2.4rem);
  display: grid;
  gap: var(--m-gap);
}

.method__t {
  position: relative;
  display: grid;
  grid-template-columns: var(--m-n) minmax(0, 1fr);
  gap: 1.1rem;
  transition: opacity 0.35s var(--ease-out);
}

/* The line from each number to the next, and its fill as the page scrolls. */
.method__t:not(:last-child)::before,
.method__t:not(:last-child)::after {
  content: "";
  position: absolute;
  left: calc(var(--m-n) / 2 - 1px);
  top: var(--m-n);
  width: 2px;
  height: calc(100% - var(--m-n) + var(--m-gap));
}

.method__t:not(:last-child)::before {
  background: repeating-linear-gradient(to bottom, var(--line-strong) 0 6px, transparent 6px 11px);
}

.method__t:not(:last-child)::after {
  background: var(--gold-line);
  transform: scaleY(var(--fill, 0));
  transform-origin: 50% 0;
  transition: transform 0.25s linear;
}

.method__num {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--m-n);
  height: var(--m-n);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--bg);
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--gold);
  transition: background-color var(--dur) var(--ease-out), color var(--dur), border-color var(--dur), box-shadow var(--dur);
}

.method__tx {
  padding-top: 0.45rem;
}

.method__t h3 {
  font-family: var(--font-display);
  font-size: calc(var(--step-2) * var(--display-scale));
  font-weight: var(--display-weight-strong);
  letter-spacing: var(--display-tracking);
  line-height: 1.15;
}

.method__t h3 a {
  text-decoration: none;
  background: linear-gradient(var(--gold-line), var(--gold-line)) 0 100% / 0 1px no-repeat;
  transition: background-size 0.5s var(--ease-out);
}

.method__t p {
  margin-top: 0.5rem;
  max-width: 26em;
  font-size: 0.9375rem;
  color: var(--fg-muted);
}

.method.m-on .method__t:not(.is-on) {
  opacity: 0.4;
}

.method__t.is-done .method__num {
  border-color: var(--gold-line);
}

.method__t.is-on .method__num {
  background: var(--gold-line);
  border-color: var(--gold-line);
  color: var(--yr-ink-deep);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--gold-line) 18%, transparent);
}

.method__t.is-on h3 a {
  background-size: 100% 1px;
}

.method__replay {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 1.1rem 0.4rem 0.4rem;
  background: transparent;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fg);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease-out);
}

.method__replay:hover {
  border-color: var(--gold-line);
}

.method__replay-ic {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 50%;
  background: var(--gold-line);
  color: var(--yr-ink-deep);
}

.method__replay svg {
  width: 0.85rem;
  height: 0.85rem;
  margin-left: 0.1rem;
  fill: currentColor;
}

.method__replay[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .method__replay { display: none; }
}

.method__art {
  display: grid;
  gap: clamp(2.5rem, 1.5rem + 4vw, 5rem);
}

.method__art > li {
  scroll-margin-top: var(--m-top);
}

.method__art figure {
  margin: 0;
  padding: clamp(1rem, 0.5rem + 2vw, 2rem);
  background: var(--plate);
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  transition: opacity 0.4s var(--ease-out);
}

.method.m-on .method__art > li:not(.is-on) figure {
  opacity: 0.45;
}

.method__cap {
  display: none;
  margin-top: 1rem;
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--fg-muted);
}

.method-art {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

@media (min-width: 64em) {
  .method {
    grid-template-columns: minmax(16rem, 4fr) minmax(0, 8fr);
    align-items: start;
  }

  .method__side {
    position: sticky;
    top: var(--m-top);
    min-height: min(calc(100svh - var(--m-top) - 2rem), 40rem);
  }
}

/* Phones and tablets: the column becomes a bar under the site header, numbers in a row,
   the words of the step on screen only. Without the script, the titles sit above the drawings. */
@media (max-width: 63.99em) {
  .method.m-live .method__side {
    position: sticky;
    top: var(--header-h);
    z-index: 5;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    margin-inline: calc(-1 * var(--gutter));
    padding: 0.7rem var(--gutter);
    background: var(--bg);
    box-shadow: 0 1px 0 var(--line);
  }

  .method.m-live .method__titles { --m-n: 2.1rem; flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 0.4rem; }
  .method.m-live .method__t::before,
  .method.m-live .method__t::after { display: none; }
  .method.m-live .method__t { display: flex; gap: 0.6rem; opacity: 1; }
  .method.m-live .method__t:not(.is-on) .method__tx { display: none; }
  .method.m-live .method__t.is-on { flex: 1; min-width: 0; }
  .method.m-live .method__tx { padding-top: 0.1rem; }
  .method.m-live .method__t h3 { font-size: 1.05rem; }
  .method.m-live .method__t p { display: none; }
  .method.m-live .method__cap { display: block; }
  .method.m-live .method__replay { flex: none; padding: 0.25rem; }
  .method.m-live .method__replay-t { display: none; }
  .method__art > li { scroll-margin-top: calc(var(--header-h) + 7rem); }
}

/* --- Drawing parts (classes from tools/method_art.py) ------------------------ */
.ma-leaf { fill: var(--bg); stroke: var(--line-strong); stroke-width: 1; }
.ma-focus,
.ma-select { fill: none; stroke: var(--gold-line); stroke-width: 2; }
.ma-track { fill: var(--line); }
.ma-bar { fill: var(--graphic); }
.ma-gbar { fill: var(--graphic); opacity: 0.85; }
.ma-person { fill: var(--fg-muted); }
.ma-spark { fill: none; stroke: var(--graphic); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ma-status { fill: var(--graphic); }
.ma-cadence { fill: var(--gold-line); }

/* --- Motion: every animation is named ma-*, plays once, holds its last frame ---- */
.ma-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: ma-draw 0.9s var(--ease-out) both;
}

.ma-pop {
  transform-box: fill-box;
  transform-origin: center;
  animation: ma-pop 0.6s var(--ease-out) both;
}

.ma-grow {
  transform-box: fill-box;
  transform-origin: 0 50%;
  animation: ma-grow 0.9s var(--ease-out) both;
}

.ma-fade {
  animation: ma-fade 0.6s ease-out both;
}

.ma-status {
  animation-name: ma-pop, ma-status;
  animation-duration: 0.6s, 0.8s;
}

@keyframes ma-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes ma-pop { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: none; } }
@keyframes ma-grow { from { transform: scaleX(0); } to { transform: none; } }
@keyframes ma-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ma-status { 0%, 40% { fill: var(--gold-line); } 100% { fill: var(--graphic); } }

.ma-d0 { animation-delay: 0s; }
.ma-d1 { animation-delay: 0.25s; }
.ma-d2 { animation-delay: 0.5s; }
.ma-d3 { animation-delay: 0.75s; }
.ma-d4 { animation-delay: 1s; }
.ma-d5 { animation-delay: 1.25s; }
.ma-d6 { animation-delay: 1.5s; }
.ma-d7 { animation-delay: 1.75s; }
.ma-d8 { animation-delay: 2s; }
.ma-d9 { animation-delay: 2.25s; }
.ma-d10 { animation-delay: 2.6s; }
.ma-d11 { animation-delay: 2.85s; }
