/* -- Process Step (website · Company) -------------------------------------
   Explains one numbered stage of a workflow - steps joined by a line, vertical or across, with the current one highlighted. */

@layer components {
  /* every box in the block measures border-box - the same on any page */
  :where(.mk-process-step, .mk-process-step *, .mk-process-step ::before, .mk-process-step ::after) {
    box-sizing: border-box;
  }

  .mk-process-steps {
    container: mk-process-steps / inline-size;
    display: flex;
    flex-direction: column;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
  }
  .mk-process-step {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: start;
    gap: 1.25rem;
    padding-block-end: 2rem;

    /* the line to the next step */
    &:not(:last-child)::before {
      content: "";
      position: absolute;
      inset-inline-start: 1.25rem;
      top: 2.75rem;
      bottom: 0.25rem;
      width: 2px;
      translate: -50% 0;
      background: var(--border);
    }
    &:last-child {
      padding-block-end: 0;
    }
  }
  .mk-process-step-number {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 2px solid var(--border);
    border-radius: 50%;
    background: var(--background);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 600;
  }
  .mk-process-step[aria-current] .mk-process-step-number {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--primary-foreground);
  }
  .mk-process-step-body {
    display: grid;
    gap: 0.25rem;
    padding-block-start: 0.375rem;
  }
  .mk-process-step-title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
  }
  .mk-process-step-desc {
    margin: 0;
    color: var(--muted-foreground);
    font-size: 0.9375rem;
    line-height: 1.6;
    text-wrap: pretty;
  }

  /* horizontal: a wrapping row - the list is the container, so only its
     steps change with its width (a container cannot query itself) */
  .mk-process-steps[data-variant="horizontal"] {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .mk-process-steps[data-variant="horizontal"] > .mk-process-step {
    flex: 1 1 100%;
  }

  @container mk-process-steps (min-width: 40rem) {
    .mk-process-steps[data-variant="horizontal"] > .mk-process-step {
      flex: 1 1 0;
      grid-template-columns: minmax(0, 1fr);
      gap: 1rem;
      padding: 0 1.5rem 0 0;

      &:not(:last-child)::before {
        inset-inline-start: 3.25rem;
        inset-inline-end: 0.5rem;
        top: 1.25rem;
        bottom: auto;
        width: auto;
        height: 2px;
        translate: 0 -50%;
      }
    }
  }

  /* -- Accessibility ------------------------------------------- */
  @media (forced-colors: active) {
    .mk-process-step:not(:last-child)::before {
      background: CanvasText;
    }
    .mk-process-step[aria-current] .mk-process-step-number {
      border-color: Highlight;
      background: Highlight;
      color: HighlightText;
    }
  }
}
