<?php
/**
 * WeCodeArt Framework
 *
 * WARNING: This file is part of the core WeCodeArt Framework. DO NOT edit this file under any circumstances.
 * Please do all modifications in the form of a child theme.
 *
 * @package		WeCodeArt Framework
 * @subpackage  Gutenberg\Blocks
 * @copyright   Copyright (c) 2025, WeCodeArt Framework
 * @since		6.2.0
 * @version		6.5.7
 */

namespace WeCodeArt\Gutenberg\Blocks\Design\Accordion;

defined( 'ABSPATH' ) || exit;

use WeCodeArt\Singleton;
use WeCodeArt\Gutenberg\Blocks\Dynamic;
use function WeCodeArt\Functions\get_prop;

/**
 * Gutenberg details block.
 */
class Item extends Dynamic {

	use Singleton;

	/**
	 * Block namespace.
	 *
	 * @var string
	 */
	protected $namespace = 'core';

	/**
	 * Block name.
	 *
	 * @var string
	 */
	protected $block_name = 'accordion-item';

	/**
	 * Block styles
	 *
	 * @return 	string 	The block styles.
	 */
	public function styles(): string {
		return <<<CSS
			.wp-block-accordion-item { 
				border: var(--wp--accordion-border-width) solid var(--wp--accordion-border-color);
				display: grid;
				grid-template-rows: 0fr;

				&.is-open {
					--wp--accordion-btn-icon-transform: rotate(180deg);
					grid-template-rows: 1fr;
					
					.wp-block-accordion-heading__toggle {
						background-color: var(--wp--accordion-active-bg);
						color: var(--wp--accordion-active-color);
					}

					.wp-block-accordion-panel {
						visibility: visible;
					}
				}
			}

			.wp-block-accordion-item:first-of-type {
				border-top-left-radius: var(--wp--accordion-border-radius);
				border-top-right-radius: var(--wp--accordion-border-radius);
			}

			.wp-block-accordion-item:last-of-type {
				border-bottom-left-radius: var(--wp--accordion-border-radius);
				border-bottom-right-radius: var(--wp--accordion-border-radius);
			}

			.wp-block-accordion-item:not(:first-of-type) {
				border-top: 0;
			}

			@media (prefers-reduced-motion:no-preference) {
				.wp-block-accordion-item {
					transition: grid-template-rows .3s ease-out
				}
			}
		CSS;
	}
}