@php
  $muy_header_transparent = get_theme_mod('muy_header_transparent');
  $muy_header_fixed = get_theme_mod('muy_header_fixed');
  $muy_header_background_color = get_theme_mod('muy_header_background_color');
  $muy_smooth_scroll = get_theme_mod('muy_smooth_scroll') ? "smooth-scroll" : "";
  
@endphp
<!doctype html>
<html {!! get_language_attributes() !!} @if($muy_smooth_scroll) class="{{ $muy_smooth_scroll }}" @endif>
  @include('partials.head')
  <body @php body_class() @endphp>
    @php
      do_action('in_body');
    @endphp
    <main id="app">
      @php do_action('get_header') @endphp
      @include('partials.header')
      <div class="
        wrap
        @if($muy_header_transparent) trasparent-bg @endif
        @if($muy_header_transparent && $muy_header_fixed) transparent-bg-fixed @endif
        @if($muy_header_fixed) header-fixed @endif
      " role="document">
        <div class="content">
          <main class="main">
            @yield('content')
          </main>
          @if (App\display_sidebar())
            <aside class="sidebar">
              @include('partials.sidebar')
            </aside>
          @endif
        </div>
      </div>
      @php do_action('get_footer') @endphp
      @include('partials.footer')
    </main>
    @php wp_footer() @endphp
  </body>
</html>



<script>
//Background on scroll for transparent and fixed header


// Variables declaration
var transparentHeader = <?php echo $muy_header_transparent ? 'true' : 'false'; ?>;
var fixedHeader = <?php echo $muy_header_fixed ? 'true' : 'false'; ?>;
var headerFt = '<?php echo $muy_header_background_color ?>';

if(transparentHeader && fixedHeader){
  document.addEventListener('DOMContentLoaded', function () {
  var fixTransparentNav = document.querySelector('.main-header');

  // On page scroll
  window.addEventListener('scroll', function () {
    // If scroll is greater than 50px
    if (window.scrollY > 50) {
      console.log('eccoci qui');
      // Add background to the navbar
      fixTransparentNav.style.backgroundColor = headerFt;
      // Add transition
      fixTransparentNav.style.transition = '0.4s ease';
    } else {
      // Otherwise, remove the background
      fixTransparentNav.style.backgroundColor = 'transparent';
    }
  });
});
};






  // Seleziona tutti i blocchi con classe .is-style-outline
  var blocchiOutline = document.querySelectorAll('.is-style-editorskit-shadow');

  // Itera su ogni blocco trovato
  blocchiOutline.forEach(function(blocco) {
      // All'interno di ciascun blocco, cerca i div con classe .wp-block-cover__background
      var backgroundDivs = blocco.querySelectorAll('.wp-block-cover__background');

      // Itera su ogni div di sfondo trovato all'interno del blocco
      backgroundDivs.forEach(function(backgroundDiv) {
          // Ottieni il valore del colore di sfondo
          var coloreSfondo = window.getComputedStyle(backgroundDiv).backgroundColor;

          // Aggiorna dinamicamente lo stile CSS con il colore di sfondo
          blocco.style.setProperty('--colore-sfondo', coloreSfondo);
      });
  });
</script>

<style>
  .is-style-outline {
    border-color: var(--colore-sfondo) !important;
    border: 2px solid;
  }

  .is-style-outline .wp-block-cover__background {
    background-color: transparent !important;
  }
</style>

