<?php
$defaults = [
  'title' => 'The Liberating Power of Minimalism',
  'textPrimary' => "Decluttering begins with the act of letting go. It's about freeing ourselves from the weight of excess possessions that no longer serve us. By evaluating each item and asking ourselves whether it brings us joy or serves a practical purpose, we can make mindful decisions about what to keep and what to release. Letting go of the unnecessary allows us to create a physical and mental space that promotes clarity and tranquility.",
  'textSecondary' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer facilisis lorem quis pretium posuere. Nam gravida orci in massa convallis vestibulum. Sed venenatis hendrerit gravida. In nec lectus diam. Sed tellus justo, aliquam id eros sit amet, condimentum ullamcorper justo. In lacinia, purus ut congue pharetra, elit sapien aliquam turpis, non viverra dui ante id orci. Nam laoreet ornare urna, in varius nibh finibus sit amet. Quisque sed.',
  'showTextSecondary' => true,
  'backgroundColor' => '',
  'textColor' => '',
];

$values = array_merge($defaults, array_filter((array) $attributes, static function ($value) {
  return $value !== null && $value !== '';
}));

$styles = [];
if ($values['backgroundColor'] !== '') {
  $styles[] = 'background:' . $values['backgroundColor'];
}
if ($values['textColor'] !== '') {
  $styles[] = 'color:' . $values['textColor'];
}
$style_attr = $styles ? ' style="' . esc_attr(implode(';', $styles)) . '"' : '';
?>
<article class="fjord-about-card fjord-about-card--mission"<?php echo $style_attr; ?>>
  <h2><?php echo esc_html($values['title']); ?></h2>
  <p><?php echo esc_html($values['textPrimary']); ?></p>
  <?php if (!empty($values['showTextSecondary']) && trim((string) $values['textSecondary']) !== '') : ?>
    <p><?php echo esc_html($values['textSecondary']); ?></p>
  <?php endif; ?>
</article>
