<?php
/**
 * Card Opening Tag - Template
 * 
 * @package OrokuBlocks
 * @author OrokuBlocks (https://orokublocks.com/)
 * 
 * @since 1.0.0
 * 
 * @param array $args {
 *   @type string $version          Card template version.
 *   @type array  $options          Template options.
 * }
 */

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

$options = $args['options'];

$card_style_attributes = [
  /**
   * Font
   */
  '--font-family'                           => $options['use_plugin_font'] ? '"Inter", sans-serif' : 'inherit',
  '--font-scale'                            => $options['font_scale'],
  /**
   * Card
   */
  '--card-border-radius'                    => $options['card_border_radius'],
  '--card-image-border-radius'              => $options['card_image_border_radius'],
  /**
   * Light Theme
   */
  '--light-primary-color'                   => $options['light_primary_color'],
  '--light-background-color'                => $options['light_background_color'],
  '--light-background-alt-color'            => $options['light_background_alt_color'],
  '--light-line-color'                      => $options['light_line_color'],
  '--light-text-color'                      => $options['light_text_color'],
  /**
   * Dark Theme
   */
  '--dark-primary-color'                    => $options['dark_primary_color'],
  '--dark-background-color'                 => $options['dark_background_color'],
  '--dark-background-alt-color'             => $options['dark_background_alt_color'],
  '--dark-line-color'                       => $options['dark_line_color'],
  '--dark-text-color'                       => $options['dark_text_color'],
  /**
   * Status
   */
  '--status-tag-enabled-icon-color'         => $options['status_tag_enabled_icon_color'],
  '--status-tag-enabled-background-color'   => $options['status_tag_enabled_background_color'],
  '--status-tag-disabled-icon-color'        => $options['status_tag_disabled_icon_color'],
  '--status-tag-disabled-background-color'  => $options['status_tag_disabled_background_color'],
  /**
   * Progress Bar
   */
  '--progress-bar-underline-color'          => $options['progress_bar_underline_color'],
  /**
   * Rating
   */
  '--rating-color'                          => $options['rating_color'],
  '--rating-underline-color'                => $options['rating_underline_color']
];

if ( $options['progress_bar_gradient'] ) {
  $card_style_attributes['--progress-bar-gradient-start-color'] = $options['progress_bar_gradient_start_color'];
  $card_style_attributes['--progress-bar-gradient-end-color'] = $options['progress_bar_gradient_end_color'];
} else {
  $card_style_attributes['--progress-bar-color'] = $options['progress_bar_color'];
}

if ( $options['width'] !== 0 ) {
  $card_style_attributes['max-width'] = $options['width'] . 'px';
}

$card_style_attributes_string = '';

foreach ( $card_style_attributes as $property => $value ) {
  $card_style_attributes_string .= $property . ': ' . $value . ';';
}

?>
<div
  class="orokublocks-itemreview orokublocks-widget orokublocks-widget--theme--<?php echo esc_attr( $options['theme'] ); ?>"
  style="<?php echo esc_attr( $card_style_attributes_string ); ?>"
  data-decimalpoints="<?php echo esc_attr( $options['decimal_points'] ); ?>"
  data-animateonscroll="<?php echo esc_attr( $options['animate_on_scroll'] ); ?>"
  data-progressbar-width="<?php echo esc_attr( $options['progress_bar_width'] ); ?>"
  data-progressbar-breakpoint-width="<?php echo esc_attr( $options['progress_bar_breakpoint_width'] ); ?>"
  data-progressbar-split-parts="<?php echo esc_attr( $options['progress_bar_split_parts'] ); ?>"
>