/* Б-33 Цикл склада, «Кто чем работает». Источник: новый макет (задача 6.3) */

.b-cycle {
  padding-block: var(--space-section);
  background: var(--color-surface);
}

.b-cycle__steps {
  display: grid;
  gap: var(--space-2);
  list-style: none;
  counter-reset: b-cycle;
}

.b-cycle__step {
  position: relative;
  counter-increment: b-cycle;
}

.b-cycle__link {
  display: grid;
  grid-template-columns: 2.5rem minmax(0, 1fr);
  gap: 0.125rem var(--space-3);
  height: 100%;
  padding: var(--space-4);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  color: var(--color-text);
  text-decoration: none;
  transition: transform var(--dur-base) var(--ease-standard);
}

.b-cycle__link::before {
  content: counter(b-cycle);
  grid-row: 1 / span 2;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
  font-weight: var(--font-weight-bold);
}

.b-cycle__link:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
  transform: translateY(-2px);
}

.b-cycle__link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.b-cycle__name {
  font-weight: var(--font-weight-bold);
  line-height: 1.3;
}

.b-cycle__text {
  color: var(--color-text-muted);
  font-size: var(--fs-small);
  line-height: 1.4;
}

.b-cycle__caption {
  margin-top: var(--space-5);
  font-weight: var(--font-weight-semibold);
}

/* «Кто чем работает» */
.b-cycle__roles {
  display: grid;
  gap: var(--space-3);
  margin-top: var(--space-stack);
  list-style: none;
}

.b-cycle__role {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: var(--color-surface-muted);
}

.b-cycle__role-name {
  font-size: var(--fs-h4);
  font-weight: var(--font-weight-bold);
}

.b-cycle__role-tool {
  justify-self: start;
}

.b-cycle__role-text {
  color: var(--color-text-muted);
  font-size: var(--fs-small);
}

/* Серый фон для чередования с соседними блоками */
.b-cycle--muted {
  background: var(--color-bg);
}

.b-cycle--muted .b-cycle__role {
  background: var(--color-surface);
}

/* Сценарий операции шагами («WMS для 1С») */
.b-cycle__flow {
  padding: var(--space-6) var(--space-5);
  border-radius: var(--radius-xl);
  background: var(--color-surface);
}

@media (min-width: 768px) {
  .b-cycle__steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .b-cycle__roles {
    grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  }
}

@media (min-width: 1024px) {
  .b-cycle__steps {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-gutter);
  }

  .b-cycle__link {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
    padding: var(--space-5);
  }

  .b-cycle__link::before {
    grid-row: auto;
    margin-bottom: var(--space-2);
  }

  /* Стрелка к следующему шагу в ряду */
  .b-cycle__step:not(:nth-child(4n))::after {
    content: "→";
    position: absolute;
    top: 1.75rem;
    right: calc(-1 * var(--space-gutter) + 0.1rem);
    color: var(--color-accent);
    font-weight: var(--font-weight-bold);
  }

  .b-cycle__step:last-child::after {
    content: none;
  }

  /* Шаги сценария в строку — с 1024 px: на планшете пять колонок слишком узкие */
  .b-cycle__flow {
    padding: var(--space-8);
  }

  .b-cycle__flow-steps {
    grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
    gap: var(--space-5);
  }

  .b-cycle__flow-steps .c-steps__item {
    grid-template-columns: minmax(0, 1fr);
  }

  .b-cycle__flow-steps .c-steps__item:not(:last-child)::after {
    top: 1.25rem;
    right: calc(-1 * var(--space-5) + var(--space-2));
    bottom: auto;
    left: 3.25rem;
    width: auto;
    height: 2px;
  }
}
