<?php

/**
 * Register custom block styles for the Blynex theme.
 *
 * This file defines custom block styles that extend the default
 * WordPress block styles with theme-specific variations.
 *
 * @package Blynex
 * @since 1.0.0
 */

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

if (!function_exists('blynex_register_block_styles')) {
    /**
     * Register custom block styles.
     *
     * Adds theme-specific variations to WordPress core blocks.
     * Currently includes a checkmark list style for the list block.
     *
     * @return void
     */
    function blynex_register_block_styles() {
        // Register checkmark list style for core/list block
        register_block_style(
            'core/list',
            [
                'name'         => 'checkmark-list',
                'label'        => __('Checkmark', 'blynex'),
                'inline_style' => '
                    /* Remove default list styling */
                    ul.is-style-checkmark-list {
                        list-style: none;
                        padding-left: 0;
                    }

                    /* Style list items with custom checkmark */
                    ul.is-style-checkmark-list li {
                        position: relative;
                        padding-inline-start: 4ch;
                        margin-bottom: 0.75em;
                    }

                    /* Create checkmark using pseudo-element */
                    ul.is-style-checkmark-list li::before {
                        content: "\\2713"; /* Unicode checkmark */
                        position: absolute;
                        left: 0.5ch;
                        top: 50%;
                        transform: translateY(-50%);
                        width: 1.2em;
                        height: 1.2em;
                        border: 2px solid currentColor;
                        border-radius: 50%;
                        display: flex;
                        align-items: center;
                        justify-content: center;
                        font-size: 0.9em;
                        background-color: transparent;
                    }
                ',
            ]
        );

        // Register image mask styles for core/image block
        register_block_style(
            'core/image',
            [
                'name'  => 'circle',
                'label' => __('Circle', 'blynex'),
                'inline_style' => '
                    .wp-block-image.is-style-circle {
                        clip-path: circle(50% at center) !important;
                        overflow: hidden;
                    }
                    .wp-block-image.is-style-circle img {
                        clip-path: inherit !important;
                    }
                ',
            ]
        );

        register_block_style(
            'core/image',
            [
                'name'  => 'rounded-corners',
                'label' => __('Rounded Corners', 'blynex'),
                'inline_style' => '
                    .wp-block-image.is-style-rounded-corners {
                        border-radius: 20px !important;
                        overflow: hidden;
                    }
                    .wp-block-image.is-style-rounded-corners img {
                        border-radius: inherit !important;
                    }
                ',
            ]
        );

        register_block_style(
            'core/image',
            [
                'name'  => 'star',
                'label' => __('Star', 'blynex'),
                'inline_style' => '
                    .wp-block-image.is-style-star {
                        clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%) !important;
                        overflow: hidden;
                    }
                    .wp-block-image.is-style-star img {
                        clip-path: inherit !important;
                    }
                ',
            ]
        );

       

        register_block_style(
            'core/image',
            [
                'name'  => 'hexagon',
                'label' => __('Hexagon', 'blynex'),
                'inline_style' => '
                    .wp-block-image.is-style-hexagon {
                        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%) !important;
                        overflow: hidden;
                    }
                    .wp-block-image.is-style-hexagon img {
                        clip-path: inherit !important;
                    }
                ',
            ]
        );


        // Register same mask styles for core/cover block
        register_block_style(
            'core/cover',
            [
                'name'  => 'circle',
                'label' => __('Circle', 'blynex'),
                'inline_style' => '
                    .wp-block-cover.is-style-circle {
                        clip-path: circle(50% at center) !important;
                        overflow: hidden;
                    }
                    .wp-block-cover.is-style-circle .wp-block-cover__image-background,
                    .wp-block-cover.is-style-circle .wp-block-cover__video-background {
                        clip-path: inherit !important;
                    }
                ',
            ]
        );

        register_block_style(
            'core/cover',
            [
                'name'  => 'rounded-corners',
                'label' => __('Rounded Corners', 'blynex'),
                'inline_style' => '
                    .wp-block-cover.is-style-rounded-corners {
                        border-radius: 20px !important;
                        overflow: hidden;
                    }
                    .wp-block-cover.is-style-rounded-corners .wp-block-cover__image-background,
                    .wp-block-cover.is-style-rounded-corners .wp-block-cover__video-background {
                        border-radius: inherit !important;
                    }
                ',
            ]
        );
        register_block_style(
            'core/cover',
            [
                'name'  => 'hexagon',
                'label' => __('Hexagon', 'blynex'),
                'inline_style' => '
                    .wp-block-cover.is-style-hexagon {
                        clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%) !important;
                        overflow: hidden;
                    }
                    .wp-block-cover.is-style-hexagon .wp-block-cover__image-background,
                    .wp-block-cover.is-style-hexagon .wp-block-cover__video-background {
                        clip-path: inherit !important;
                    }
                ',
            ]
        );
    }
    add_action('init', 'blynex_register_block_styles');
}
