/* ============================================================
   COMPONENTS.CSS — Navbar e componenti shared
   ============================================================ */

/* ── Navbar: posizionamento statico nel normale flusso del documento ── */
.navbar {
  background-color: white;
  border-bottom: 1px solid var(--color-border);
}

/* ── Fallback verticale (< 420px): logo centrato e CTA a larghezza piena ── */
.navbar__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding-block: var(--space-3);
}

.navbar__logo-area {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
}

.navbar__logo-area:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

.navbar__logo-img {
  height: 32px;
  width: auto;
  display: block;
}

.navbar__cta {
  width: 100%;
  padding: 0.75rem 1.25rem;
  font-size: var(--text-base);
  text-align: center;
  justify-content: center;
}

/* ── Layout principale orizzontale (>= 420px): logo a sinistra e CTA a destra ── */
@media (min-width: 420px) {
  .navbar__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    min-height: 80px;
    padding-block: 1rem;
  }

  .navbar__logo-area {
    justify-content: flex-start;
  }

  .navbar__logo-img {
    height: 30px;
  }

  .navbar__cta {
    width: auto;
    font-size: var(--text-sm);
    padding: 0.625rem 1.125rem;
    flex-shrink: 0;
  }
}

/* ── Tablet e Desktop (>= 768px): padding e tipografia standard ── */
@media (min-width: 768px) {
  .navbar__inner {
    min-height: 92px;
    gap: var(--space-4);
  }

  .navbar__logo-img {
    height: 32px;
  }

  .navbar__cta {
    font-size: var(--text-base);
    padding: 0.875rem 1.75rem;
  }
}

/* ── Sticky CTA bar (solo smartphone < 768px) ──
   Nascosta di default: la classe .is-visible è aggiunta da initStickyBar() in main.js
   solo nelle sezioni consentite. Da 768px in su resta display: none (nessun clic né focus):
   su desktop la sostituiscono le CTA contestuali nelle sezioni. La classe continua a essere
   aggiornata a ogni larghezza perché initPromo() la usa per sapere in che sezione si è. */
.sticky-bar {
  display: none;
}

@media (max-width: 767px) {
  .sticky-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    align-items: stretch;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem calc(0.625rem + env(safe-area-inset-bottom, 0px));
    background-color: var(--color-dark);
    /* Stato nascosto: fuori schermo e non focalizzabile (visibility) */
    opacity: 0;
    visibility: hidden;
    transform: translate3d(0, 100%, 0);
    transition:
      opacity 220ms ease,
      transform 220ms ease,
      visibility 0s linear 220ms;
  }

  .sticky-bar.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate3d(0, 0, 0);
    transition-delay: 0s;
  }

  .sticky-bar__cta,
  .sticky-bar__wa {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 3rem;
    border-radius: var(--radius-btn);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }

  .sticky-bar__cta {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0 1rem;
    background-color: var(--color-white);
    color: var(--color-dark);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
  }

  .sticky-bar__wa {
    flex: 0 0 3.5rem;
    background-color: #25D366;
    color: #FFFFFF;
  }

  .sticky-bar__wa svg {
    width: 1.625rem;
    height: 1.625rem;
  }

  .sticky-bar__cta:active,
  .sticky-bar__wa:active {
    opacity: 0.85;
  }

  .sticky-bar__cta:focus-visible,
  .sticky-bar__wa:focus-visible {
    outline: 3px solid var(--color-cta);
    outline-offset: 2px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sticky-bar,
  .sticky-bar.is-visible {
    transition: none;
  }
}

/* ── Promozione (placeholder): testi comuni a popup desktop e pannello mobile ──
   Componenti indipendenti dalla sticky bar: nessuna regola qui la modifica. */
.promo__label {
  display: inline-block;
  max-width: 100%;
  padding: 0.3rem 0.625rem;
  border-radius: 999px;
  background-color: var(--color-cta);
  color: var(--color-dark);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  line-height: 1.3;
}

.promo__title {
  margin-top: var(--space-3);
  font-size: var(--text-xl);
}

.promo__desc {
  margin-top: var(--space-2);
  font-size: var(--text-base);
  line-height: 1.6;
}

.promo__cta {
  margin-top: var(--space-5);
}

/* ── Promo mobile (< 768px): notifica NON modale che scende dall'alto ──
   Niente backdrop, niente blocco dello scroll, nessun focus automatico.
   L'area fissa va dalla cima dello schermo fino sopra la sticky bar mobile
   (pulsanti 3rem + padding 2 × 0.625rem = 4.25rem, più safe area): la notifica
   sta in alto e, se espansa, cresce verso il basso senza mai raggiungere la barra. */
.promo-mobile {
  display: none;
}

@media (max-width: 767px) {
  .promo-mobile {
    position: fixed;
    top: calc(0.5rem + env(safe-area-inset-top, 0px));
    bottom: calc(4.25rem + env(safe-area-inset-bottom, 0px) + 0.75rem);
    left: 0;
    right: 0;
    z-index: 49; /* sotto la sticky bar (50) */
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-inline: 0.5rem;
    pointer-events: none; /* l'area vuota non intercetta tocchi né clic */
  }

  .promo-mobile[hidden] {
    display: none;
  }

  .promo-mobile__card {
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    width: min(26rem, 100%);
    max-height: 100%;
    background-color: var(--color-dark);
    color: var(--color-bg);
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 16px rgba(41, 37, 31, 0.22), 0 18px 40px rgba(41, 37, 31, 0.28);
    /* Stato iniziale: appena sopra il bordo dello schermo, scende come una notifica */
    opacity: 0;
    transform: translate3d(0, calc(-100% - 1rem), 0);
    transition: opacity 260ms ease, transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
  }

  .promo-mobile.is-open .promo-mobile__card {
    opacity: 1;
    transform: none;
  }

  .promo-mobile__head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem;
  }

  .promo-mobile__toggle {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 3rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0.5rem;
    border-radius: var(--radius-btn);
    color: var(--color-bg);
    font-family: var(--font-display);
    font-size: var(--text-md);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.01em;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
  }

  .promo-mobile__icon {
    flex: 0 0 2.25rem;
    height: 2.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: var(--color-cta);
    color: var(--color-dark);
  }

  .promo-mobile__icon svg {
    width: 1.25rem;
    height: 1.25rem;
  }

  .promo-mobile__text {
    flex: 1 1 auto;
    min-width: 0;
  }

  .promo-mobile__chevron {
    flex: 0 0 auto;
    width: 1.25rem;
    height: 1.25rem;
    opacity: 0.8;
    transition: transform 220ms ease;
  }

  .promo-mobile__toggle[aria-expanded="true"] .promo-mobile__chevron {
    transform: rotate(180deg);
  }

  .promo-mobile__close {
    flex: 0 0 2.75rem;
    width: 2.75rem;
    height: 2.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    color: var(--color-bg);
    -webkit-tap-highlight-color: transparent;
  }

  .promo-mobile__close svg {
    width: 1.375rem;
    height: 1.375rem;
  }

  .promo-mobile__toggle:active,
  .promo-mobile__close:active {
    opacity: 0.8;
  }

  .promo-mobile__toggle:focus-visible,
  .promo-mobile__close:focus-visible,
  .promo-mobile .promo__cta:focus-visible {
    outline: 3px solid var(--color-cta);
    outline-offset: 2px;
  }

  /* Pannello espanso: scroll interno se lo spazio sopra la sticky bar non basta */
  .promo-mobile__panel {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem 1.25rem 1.25rem;
    border-top: 1px solid rgba(248, 243, 236, 0.14);
  }

  .promo-mobile__panel[hidden] {
    display: none;
  }

  /* Icona regalo in testa al pannello espanso (come nel popup desktop) */
  .promo-mobile__gift {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.25rem;
    height: 3.25rem;
    margin-bottom: var(--space-3);
    border-radius: 50%;
    background-color: var(--color-cta);
    color: var(--color-dark);
    box-shadow: 0 0 0 5px rgba(255, 204, 0, 0.22);
  }

  .promo-mobile__gift svg {
    width: 1.5rem;
    height: 1.5rem;
  }

  .promo-mobile .promo__title {
    color: var(--color-bg);
  }

  .promo-mobile .promo__desc {
    color: rgba(248, 243, 236, 0.85);
  }

  .promo-mobile .promo__cta {
    width: 100%;
  }
}

/* ── Promo desktop (≥ 768px, mouse): Exit Intent in <dialog> modale ──
   Il <dialog> stesso fa da overlay scuro; la card resta centrata e,
   su laptop poco alti, l'overlay scorre invece di tagliare il contenuto. */
.promo-modal[open] {
  position: fixed;
  inset: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 1.5rem;
  border: 0;
  display: flex;
  overflow-y: auto;
  overscroll-behavior: contain;
  background-color: rgba(41, 37, 31, 0.6);
  color: var(--color-text);
  opacity: 0;
  transition: opacity 240ms ease;
}

.promo-modal.is-open {
  opacity: 1;
}

.promo-modal::backdrop {
  background: transparent;
}

.promo-modal__card {
  position: relative;
  margin: auto;
  width: min(31rem, 100%);
  padding: clamp(2rem, 5vh, 2.75rem) clamp(1.75rem, 4vw, 2.75rem);
  text-align: center;
  background-color: var(--color-bg);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(41, 37, 31, 0.35);
  transform: translate3d(0, 12px, 0) scale(0.98);
  transition: transform 240ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.promo-modal.is-open .promo-modal__card {
  transform: none;
}

.promo-modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-dark);
  transition: background-color var(--transition-fast);
}

.promo-modal__close svg {
  width: 1.375rem;
  height: 1.375rem;
}

.promo-modal__close:hover {
  background-color: rgba(41, 37, 31, 0.08);
}

.promo-modal__close:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

/* Icona regalo sopra l'etichetta (stesso glifo della notifica mobile) */
.promo-modal__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  background-color: var(--color-cta);
  color: var(--color-dark);
  box-shadow: 0 0 0 6px rgba(255, 204, 0, 0.22);
}

.promo-modal__icon svg {
  width: 1.875rem;
  height: 1.875rem;
}

.promo-modal .promo__title {
  margin-top: var(--space-4);
  font-size: clamp(var(--text-2xl), 2.6vw, var(--text-3xl));
}

.promo-modal .promo__desc {
  margin-inline: auto;
  margin-top: var(--space-3);
  font-size: var(--text-md);
  color: var(--color-text-muted);
}

.promo-modal .promo__cta {
  margin-top: var(--space-6);
}

@media (prefers-reduced-motion: reduce) {
  .promo-mobile__card,
  .promo-mobile__chevron,
  .promo-modal[open],
  .promo-modal__card {
    transition: none;
  }
}
