/* Method page: title, intro, and the pinned chart with six scroll steps
   Source: Figma "Northbeam-Final", node 100:9858 (header, title, step block with chart + card, contact, footer).
   Behaviour: js/method-scroll.js. Values: css/tokens.css (Method page block + the Outputs layout tokens). Reveal: data-reveal (js/motion.js).

   How it works: the chart is pinned (sticky) under the header while the six cards scroll over it. The card nearest the middle of the chart is the
   active step: its card shows, the chart plays that scene and the number / title / tag in the top-left corner change.
   The header scrolls away on this page (it never sticks). A small ring in the top-right corner of the chart shows how far through its animation the scene is.
   Breakpoints: 901px and wider = card on the right of the chart (Figma). 900px and below = card centred and a little smaller.
   Without JavaScript the chart is hidden and the six cards are simply listed. With "reduce motion" the chart shows a still frame per step. */

.page-method { background: var(--color-snow); }
html:has(.page-method) { scroll-padding-top: 0; }   /* the header does not stick here, so anchors need no offset */
.page-method .header { background: var(--color-snow); }   /* Figma: the header is the page colour on this page */

/* ---------- Title + intro ---------- */
.mintro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--outputs-gap);
  padding: var(--outputs-pad-y) var(--outputs-pad-x) var(--mintro-pad-bottom);
  text-align: center;
}
.mintro__titles { display: flex; flex-direction: column; gap: 30px; width: min(100%, 540px); }   /* centre column of the 1fr / 2fr / 1fr grid in Figma */
.mintro__label {
  margin: 0;
  font: var(--type-weight-regular) var(--type-size-32)/var(--type-line-height-36) var(--type-family-display);
  color: var(--color-ink-70);
}
.mintro__title {
  margin: 0;
  font: var(--type-weight-regular) var(--type-size-section-title)/1 var(--type-family-display);
  letter-spacing: var(--type-tracking-minus-064);
  color: var(--color-ink);
}
.mintro__title em { font-style: normal; color: var(--color-accent); }
.mintro__text {
  margin: 0;
  width: min(100%, 640px);
  font: var(--type-weight-regular) var(--type-size-18)/var(--type-line-height-26) var(--type-family-body);
  letter-spacing: var(--type-tracking-03);
  color: var(--color-ink-80);
}
.mintro__text strong { font-weight: var(--type-weight-semibold); }

/* ---------- Pinned chart + scroll steps ---------- */
.mscroll { padding: 0 var(--outputs-pad-x) var(--mscroll-pad-bottom); }
.mscroll__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-width: var(--outputs-max-width);
  margin-inline: auto;
}
.mscroll__grid > * { grid-area: 1 / 1; }

.mscroll__figure {
  position: sticky;
  top: var(--mfig-top);
  align-self: start;
  height: var(--mfig-h);
  z-index: 1;
}
.mfig { position: relative; height: 100%; }
.mfig__canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }

/* Step number, title and tag (top-left, 80% opacity as in Figma) */
.mfig__head {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  max-width: min(calc(100% - var(--mring-size) - var(--mfig-pad)), 566px);
  padding: 20px var(--mfig-pad);
  opacity: 0.8;
  pointer-events: none;
}
.mfig__num {
  font: var(--type-weight-regular) var(--type-size-step-number)/var(--type-line-height-66) var(--type-family-display);
  letter-spacing: var(--type-tracking-minus-082);
  color: var(--color-ink);
}
.mfig__text { display: flex; flex-direction: column; gap: var(--space-8); min-width: 0; width: 440px; max-width: 100%; }
.mfig__title {
  margin: 0;
  font: var(--type-weight-regular) var(--type-size-32)/var(--type-line-height-36) var(--type-family-display);
  color: var(--color-ink);
}
.mfig__tag {
  margin: 0;
  font: var(--type-weight-regular) var(--type-size-14)/var(--type-line-height-20) var(--type-family-body);
  letter-spacing: var(--type-tracking-03);
  color: var(--color-ink-70);
}
@media (prefers-reduced-motion: no-preference) {
  .mfig__head.is-in { animation: mfig-in 400ms var(--ease) both; }
}
@keyframes mfig-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 0.8; transform: none; } }

/* The six cards. Each step is as tall as the chart, so one card passes over the chart per screenful of scrolling. */
.mscroll__steps {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}
.mstep {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  min-height: calc(var(--mfig-h) * var(--mstep-scale));   /* longer than the chart: more scrolling before the next step */
  padding: calc(var(--mfig-h) * var(--mcard-rest)) var(--mcard-inset-right) 0 0;
}
.mcard {
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
  box-sizing: border-box;
  width: min(var(--mcard-width), 100%);
  padding: var(--mcard-pad);
  background: var(--color-panel);
  border: 1px solid var(--color-field-border);
  border-radius: var(--radius-field);
  box-shadow: var(--shadow-card);
}
.mcard__title {
  margin: 0;
  font: var(--type-weight-regular) var(--type-size-24)/var(--type-line-height-26) var(--type-family-display);
  color: var(--color-ink);
}
.mcard__text {
  margin: 0;
  font: var(--type-weight-regular) var(--type-size-16)/var(--type-line-height-22) var(--type-family-body);
  letter-spacing: var(--type-tracking-03);
  color: var(--color-ink);
}

/* Progress ring (top-right of the chart): fills over the length of the scene, then starts again with the loop */
.mfig__ring {
  position: absolute;
  top: 28px;
  right: var(--mfig-pad);
  width: var(--mring-size);
  height: var(--mring-size);
  transform: rotate(-90deg);
  pointer-events: none;
}
.mfig__ring circle { fill: none; stroke-width: 2; }
.mfig__ring-track { stroke: rgba(23, 27, 32, 0.15); }
.mfig__ring-bar { stroke: var(--color-ink); stroke-linecap: round; }
html:not(.js) .mfig__ring { display: none; }

/* Closing text and the back link under the last step */
.mback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-24);
  padding: 0 var(--outputs-pad-x) var(--mback-pad-bottom);
  text-align: center;
}
.mback__title {
  margin: 0;
  font: var(--type-weight-regular) var(--type-size-32)/var(--type-line-height-36) var(--type-family-display);
  color: var(--color-ink);
}
.mback__text {
  margin: 0;
  width: min(100%, 640px);
  font: var(--type-weight-regular) var(--type-size-18)/var(--type-line-height-26) var(--type-family-body);
  letter-spacing: var(--type-tracking-03);
  color: var(--color-ink-80);
}

/* With JavaScript only the active card is visible; it fades in and out. */
.js .mstep { opacity: 0; transition: opacity 400ms var(--ease); }
.js .mstep.on { opacity: 1; }

/* Without JavaScript: no pinned chart, just the cards one under the other */
html:not(.js) .mscroll__figure { display: none; }
html:not(.js) .mscroll__steps { padding-bottom: 0; gap: var(--space-24); }
html:not(.js) .mstep { min-height: 0; padding: 0; justify-content: center; }

/* ---------- Tablet and mobile ---------- */
@media (max-width: 900px) {
  .page-method { --mfig-pad: 16px; --mring-size: 28px; }
  .mstep { justify-content: center; padding-right: 0; }
  .mcard { --mcard-pad: 24px; gap: var(--space-12); }
  .mfig__ring { top: 24px; }
  .mfig__head { gap: 12px; }
  .mfig__text { width: auto; }
  .mfig__title { font-size: var(--type-size-24); line-height: var(--type-line-height-32); }
}
@media (max-width: 640px) {
  .mscroll { padding-inline: 16px; }
  .mintro { padding-inline: 24px; }
}

@media (prefers-reduced-motion: reduce) { .mfig__ring { display: none; } }   /* still frames, nothing to count down */
