/*
 * ConSellWeb - Stili della testata del sito
 * Percorso: assets/css/frontend/head.css
 * Versione: 1.0.0 [MATRIX DIAMANTE]
 * Ruolo: stili di testata, piè di pagina e comportamento della testata fissa.
 * Filosofia: Zero Zavorra & Iniezione Atomica
 */

/* 01) AZZERAMENTI E UTILITA (usati dai template e dallo script della testata) */
html { scroll-behavior: smooth; }
.overflow-hidden { overflow: hidden; }
.sticky { position: sticky; top: 0; }
.z-index { z-index: 999; }

/* 02) TESTATA FISSA (funzionamento con header.js) */
header.sticky-header {
  background: inherit;
  transition: transform 160ms linear;
}

.home header.sticky-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 999;
  background: transparent;
  transition:
    transform 160ms linear,
    background-color 180ms ease,
    box-shadow 180ms ease;
  --csw-header-cover-progress: 0;
}

.admin-bar.home header.sticky-header {
  top: 32px;
}

.home header.sticky-header.is-scrolled {
  background: color-mix(
    in srgb,
    var(--wp--preset--color--background) calc(100% * var(--csw-header-cover-progress, 1)),
    transparent
  );
  box-shadow: 0 4px 12px rgba(0,0,0,calc(.08 * var(--csw-header-cover-progress, 1)));
}

.home header.sticky-header.is-past-cover {
  --csw-header-cover-progress: 1;
}

header.sticky-header.nav-open {
  transform: none;
  will-change: auto;
}

header.sticky-header.nav-open.is-hidden {
  transform: none;
}

/* Scomparsa della testata */
header.sticky-header.is-hidden {
  transform: translateY(-100%);
}

/* Riduzione del movimento per chi la richiede */
@media (prefers-reduced-motion: reduce) {
  header.sticky-header {
    transition: none;
  }
}

@media (max-width: 782px) {
  .admin-bar.home header.sticky-header {
    top: 46px;
  }
}

/* 03) NAVIGAZIONE DELLA TESTATA */
.wp-block-navigation .wp-block-navigation__container a:hover {
  color: var(--wp--preset--color--identity);
  text-decoration: none;
}

/* 04) NAVIGAZIONE CON SOTTOLINEATURA (.is-style-csw-underline) */
.wp-block-navigation.is-style-csw-underline .wp-block-navigation-item__content {
  position: relative;
}

.wp-block-navigation.is-style-csw-underline .wp-block-navigation-item__content::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -10px;
  width: 100%;
  height: 2px;
  background: var(--wp--preset--color--identity);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .3s ease-in-out;
}

.wp-block-navigation.is-style-csw-underline .wp-block-navigation-item__content:hover::after,
.wp-block-navigation.is-style-csw-underline .current-menu-item .wp-block-navigation-item__content::after {
  transform: scaleX(1);
}

/* 05) HOME / LOGO DELLA TESTATA */
header.sticky-header a[rel="home"] > img,
header.sticky-header a[rel="home"] > svg {
  width: auto;
  height: 22.08px;
}

@media (min-width: 783px) {
  body.home header.sticky-header a[rel="home"] {
    display: inline-flex;
    align-items: center;
    transform-origin: left center;
    transition: transform 0.18s cubic-bezier(0.2, 0, 0, 1) 0.12s;
  }

  body.home header.sticky-header .wp-block-group.alignwide > p:has(> a[rel="home"] > img),
  body.home header.sticky-header .wp-block-group.alignwide > p:has(> a[rel="home"] > svg) {
    position: relative;
    left: 50%;
  }

  body.home header.sticky-header a[rel="home"]:has(> img),
  body.home header.sticky-header a[rel="home"]:has(> svg) {
    transform-origin: center;
  }

  body.home header.sticky-header:not(.is-scrolled) a[rel="home"] {
    transform: translateX(28vw) scale(2);
  }

  body.home header.sticky-header:not(.is-scrolled) a[rel="home"]:has(> img),
  body.home header.sticky-header:not(.is-scrolled) a[rel="home"]:has(> svg) {
    transform: translateX(-50%) scale(2);
  }

  body.home header.sticky-header.is-scrolled a[rel="home"] {
    transform: none;
  }

  body.home header.sticky-header.is-scrolled a[rel="home"]:has(> img),
  body.home header.sticky-header.is-scrolled a[rel="home"]:has(> svg) {
    transform:
      translateX(calc(max(10px, (100vw - 1400px) / 2) - 50vw))
      scale(1);
  }
}

@media (max-width: 782px) {
  body.home header.sticky-header a[rel="home"] {
    transform: none;
    transition: none;
  }
}
