<?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_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'],
  /**
   * Progress Bar
   */
  '--progress-bar-underline-color'                          => $options['progress_bar_underline_color'],
  /**
   * Achievement Unlocked
   */
  '--achievement-unlocked-background-color'                 => $options['achievement_unlocked_background_color'],
  '--achievement-unlocked-background-gradient-start-color'  => $options['achievement_unlocked_background_gradient_start_color'],
  '--achievement-unlocked-background-gradient-end-color'    => $options['achievement_unlocked_background_gradient_end_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-gamipressachievement orokublocks-widget orokublocks-widget--theme--<?php echo esc_attr( $options['theme'] ); ?>"
  style="<?php echo esc_attr( $card_style_attributes_string ); ?>"
  data-scale-end="<?php echo esc_attr( $options['score_max_value'] ); ?>"
  data-scale-stop="<?php echo esc_attr( $options['score_value'] ); ?>"
  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'] ); ?>"
  data-progressbar-empty-text="<?php echo esc_attr( $options['locked_text'] ); ?>"
  data-progressbar-complete-text="<?php echo esc_attr( $options['unlocked_text'] ); ?>"
>