/**
 * Process steps — the layout behind the "Steps" style on core/columns.
 *
 * The variation is registered in styles/blocks/process-steps.json, but the
 * layout lives here because theme.json's `css` property cannot carry media
 * queries: WP rewrites every selector in that string, so it prepends the
 * variation selector to the `@media` at-rule itself and the block breaks.
 *
 * Enqueued for the editor and the WordPress front end by inc/process-steps.php,
 * and mirrored verbatim in web/app/globals.css for the headless frontend. Every
 * value therefore resolves through a var() fallback chain — the WordPress
 * preset first, then the Next app's token, then a literal — so the same file
 * works unchanged in all three places.
 */

.is-style-process-steps {
  --brainforest-process-step-size: 3rem;
  --brainforest-process-step-gap: var(--wp--preset--spacing--4, 1rem);
  --brainforest-process-step-line: color-mix(in srgb, currentColor 15%, transparent);
  --brainforest-process-step-circle: var(--wp--preset--color--cream, #f4efe9);
  --brainforest-process-step-number-color: var(--wp--preset--color--accent, var(--color-accent, #b03a22));
  --brainforest-process-step-number-size: var(--wp--preset--font-size--text-base, 1rem);
  --brainforest-process-step-number-font: var(
    --wp--preset--font-family--merriweather,
    var(--font-merriweather, Georgia, serif)
  );
  --brainforest-process-step-title-font: var(
    --wp--preset--font-family--poppins,
    var(--font-poppins, ui-sans-serif, sans-serif)
  );

  position: relative;
  counter-reset: brainforest-process-step;
}

/*
 * Stacked: number beside the text, no connecting line. A grid rather than a
 * flex row so a step with more than one paragraph keeps every block in the
 * text column instead of wrapping under the number.
 */
.is-style-process-steps > .wp-block-column {
  counter-increment: brainforest-process-step;
  display: grid;
  grid-template-columns: var(--brainforest-process-step-size) 1fr;
  column-gap: var(--brainforest-process-step-gap);
  align-content: start;
}

.is-style-process-steps > .wp-block-column > * {
  grid-column: 2;
}

/* The number is generated, so adding or removing a step renumbers the rest. */
.is-style-process-steps > .wp-block-column::before {
  content: counter(brainforest-process-step, decimal-leading-zero);
  grid-column: 1;
  grid-row: 1 / span 2;
  align-self: start;
  display: flex;
  align-items: center;
  justify-content: center;
  inline-size: var(--brainforest-process-step-size);
  block-size: var(--brainforest-process-step-size);
  border: 1px solid var(--brainforest-process-step-line);
  border-radius: 9999px;
  /* Opaque, so the circle masks the connecting line behind it. */
  background-color: var(--brainforest-process-step-circle);
  color: var(--brainforest-process-step-number-color);
  font-family: var(--brainforest-process-step-number-font);
  font-size: var(--brainforest-process-step-number-size);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.02em;
}

/*
 * Step titles use the body face at a lighter weight than a heading normally
 * gets in this theme — at this size the 900 serif reads as a section heading.
 */
.is-style-process-steps > .wp-block-column > :is(h1, h2, h3, h4, h5, h6) {
  font-family: var(--brainforest-process-step-title-font);
  font-weight: 700;
  line-height: 1.4;
}

/* 782px is where core stops stacking columns. */
@media (min-width: 782px) {
  .is-style-process-steps {
    --brainforest-process-step-size: 3.5rem;
    --brainforest-process-step-number-size: var(--wp--preset--font-size--text-lg, 1.125rem);
  }

  /* The rule the numbers sit on. */
  .is-style-process-steps::before {
    content: '';
    position: absolute;
    inset-inline: 0;
    inset-block-start: calc(var(--brainforest-process-step-size) / 2);
    block-size: 1px;
    background-color: var(--brainforest-process-step-line);
  }

  .is-style-process-steps > .wp-block-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    /*
     * Positioned so the column paints after the parent's ::before line. No
     * z-index needed: the pseudo-element is the parent's first child.
     */
    position: relative;
  }

  .is-style-process-steps > .wp-block-column::before {
    /* `start` from the stacked layout would pin the circle to the left here. */
    align-self: center;
    margin-block-end: var(--wp--preset--spacing--5, 1.25rem);
  }
}
