<?php

namespace Mtc\Plugins\BlockManager\Support;

/**
 * Derives the stable per-instance CSS class used to scope a container's
 * generated layout/style rules (e.g. `.bm-ci-el-1780302677469-236`).
 *
 * Derived ONLY here (PHP) so the composer live preview and the shipped
 * live-site CSS produce byte-identical class names from the same instance_id.
 * The Vue layer never computes it — it receives the rendered markup/CSS.
 */
final class InstanceClass
{
    public static function for(string $instanceId): string
    {
        $safe = preg_replace('/[^a-zA-Z0-9_-]/', '-', $instanceId) ?? '';
        return 'bm-ci-' . $safe;
    }
}
