<?php

/**
 * HoverEffectsAttributes handles hover effect related block styles and classes.
 *
 * @package Axvart
 */

if (! defined('ABSPATH')) {
    exit; // Exit if accessed directly
}

if (! class_exists('HoverEffectsAttributes')) {
    class HoverEffectsAttributes {

        /**
         * Get hover effect classes based on attributes.
         *
         * @param array $attrs Block attributes.
         * @return array
         */
        public static function get_classes($attrs) {
            $classes = [];

            if (! empty($attrs['axvartHoverEffect']) && $attrs['axvartHoverEffect'] !== 'none') {
                $classes[] = 'axvart-hover-enabled';
                $classes[] = 'axvart-hover-' . sanitize_html_class($attrs['axvartHoverEffect']);
            }

            return $classes;
        }

        /**
         * Get hover effect inline styles based on attributes.
         *
         * @param array $attrs Block attributes.
         * @return array
         */
        public static function get_styles($attrs) {
            $styles = [];

            if (! empty($attrs['axvartHoverIntensity'])) {
                $styles['--axvart-intensity'] = esc_attr($attrs['axvartHoverIntensity']);
            }

            if (! empty($attrs['axvartHoverDuration'])) {
                $styles['--axvart-duration'] = esc_attr($attrs['axvartHoverDuration']) . 's';
            }

            if (! empty($attrs['axvartHoverScale'])) {
                $styles['--axvart-scale'] = esc_attr($attrs['axvartHoverScale']);
            }

            return $styles;
        }
    }
}
