/*
 * WebCreare Commerce — foundation stylesheet.
 * Contiene le custom properties di palette/tipografia (base per tutte le fasi successive)
 * e lo stile dell'header sticky (Fase 3).
 */

/*
 * Font self-hosted (file variabili, coprono tutti i pesi 100–900/200–800 in un solo file
 * a testa): niente richiesta a Google Fonts, niente CLS da FOIT grazie a font-display: swap.
 * I due file vanno anche precaricati in head-seo.tpl (modulo wctheme) per evitare il flash
 * di font di sistema sul contenuto above-the-fold.
 */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('../fonts/inter-var.woff2') format('woff2');
}

@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('../fonts/manrope-var.woff2') format('woff2');
}

:root {
  /* Palette */
  --wc-color-primary: #0B5FFF;
  --wc-color-primary-dark: #0847C4;
  --wc-color-secondary: #111827;
  --wc-color-accent: #FF6B35;
  --wc-color-bg: #F8F9FB;
  --wc-color-surface: #FFFFFF;
  --wc-color-border: #E5E7EB;
  --wc-color-text: #111827;
  --wc-color-text-muted: #6B7280;
  --wc-color-success: #16A34A;
  --wc-color-danger: #DC2626;

  /* Tipografia */
  --wc-font-base: 'Inter', 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --wc-font-heading: 'Manrope', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Dimensioni testo per sezione (preset S/M/L/XL editabili da wccontent, "Dimensione
     testo"): questi sono i valori di default/"M", usati se il modulo non è installato. */
  --wc-fs-hero-title: clamp(32px, 4vw, 46px);
  --wc-fs-hero-body: 16px;
  --wc-fs-section-title: 26px;

  /* Layout */
  --wc-header-topbar-height: 38px;
  --wc-header-main-height: 84px;
  --wc-header-main-height-sticky: 64px;
  --wc-container-max: 1320px;
  --wc-radius-sm: 6px;
  --wc-radius-md: 10px;
  --wc-shadow-sm: 0 1px 2px rgba(17, 24, 39, 0.06);
  --wc-shadow-md: 0 8px 24px rgba(17, 24, 39, 0.08);
  --wc-transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.wc-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Header ---------- */

.wc-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  font-family: var(--wc-font-base);
  background: var(--wc-color-surface);
}

.wc-topbar {
  height: var(--wc-header-topbar-height);
  background: var(--wc-color-secondary);
  color: #F3F4F6;
  font-size: 12.5px;
  transition: height var(--wc-transition), opacity var(--wc-transition);
  overflow: hidden;
}

.wc-topbar__inner {
  max-width: var(--wc-container-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.wc-topbar__contacts {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-shrink: 0;
}

.wc-topbar__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  opacity: 0.9;
  transition: opacity var(--wc-transition);
}

.wc-topbar__link:hover {
  opacity: 1;
  color: var(--wc-color-accent);
}

.wc-topbar__message {
  margin: 0;
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wc-topbar__extra {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.wc-header__main {
  position: relative;
  /* min-height, non height: se il logo configurato è più alto della riga di default,
     la riga deve crescere con lui invece di tagliarlo. */
  min-height: var(--wc-header-main-height);
  border-bottom: 1px solid var(--wc-color-border);
  transition: min-height var(--wc-transition), box-shadow var(--wc-transition);
}

.wc-header__inner {
  max-width: var(--wc-container-max);
  min-height: var(--wc-header-main-height);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.wc-header__burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  background: none;
  color: var(--wc-color-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.wc-header__logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
}

.wc-header__logo-img {
  /* --wc-logo-height arriva come stile inline dal template, valorizzato da wccontent
     (Logo — altezza in header); il fallback 44px vale se il modulo non è installato. */
  height: var(--wc-logo-height, 44px);
  max-height: none;
  width: auto;
  transition: height var(--wc-transition);
}

.wc-header__logo-text {
  font-family: var(--wc-font-heading);
  font-weight: 800;
  font-size: 22px;
  color: var(--wc-color-secondary);
  letter-spacing: -0.01em;
}

.wc-header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.wc-header__action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  background: none;
  color: var(--wc-color-secondary);
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--wc-radius-sm);
  transition: background var(--wc-transition), color var(--wc-transition);
}

.wc-header__action:hover,
.wc-header__action:focus-visible {
  background: var(--wc-color-bg);
  color: var(--wc-color-primary);
}

.wc-header__action--cart {
  color: var(--wc-color-secondary);
}

.wc-header__cart-count {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--wc-color-accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  line-height: 1;
}

.wc-header__cart-count:empty,
.wc-header__cart-count[data-cart-count='0'] {
  display: none;
}

.wc-icon {
  display: block;
}

/* Search panel — collassa via grid-template-rows (Fase 8: apertura smooth, non a scatto) */

.wc-search-panel {
  display: grid;
  grid-template-rows: 0fr;
  background: var(--wc-color-surface);
  border-top: 0px solid transparent;
  transition: grid-template-rows var(--wc-transition), border-color var(--wc-transition);
}

.wc-search-panel.is-open {
  grid-template-rows: 1fr;
  border-top: 1px solid var(--wc-color-border);
}

.wc-search-panel__inner {
  overflow: hidden;
  min-height: 0;
}

.wc-search-panel__form {
  max-width: var(--wc-container-max);
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  gap: 10px;
}

.wc-search-panel__input {
  flex: 1;
  height: 46px;
  padding: 0 16px;
  border: 1px solid var(--wc-color-border);
  border-radius: var(--wc-radius-md);
  font-size: 15px;
  font-family: inherit;
}

.wc-search-panel__input:focus {
  outline: none;
  border-color: var(--wc-color-primary);
  box-shadow: 0 0 0 3px rgba(11, 95, 255, 0.15);
}

.wc-search-panel__submit {
  height: 46px;
  padding: 0 24px;
  border: 0;
  border-radius: var(--wc-radius-md);
  background: var(--wc-color-primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--wc-transition);
}

.wc-search-panel__submit:hover {
  background: var(--wc-color-primary-dark);
}

/* Sticky (shrink) state, toggled by theme.js via IntersectionObserver */

.wc-header.is-sticky .wc-topbar {
  height: 0;
  opacity: 0;
}

.wc-header.is-sticky .wc-header__main {
  min-height: var(--wc-header-main-height-sticky);
  box-shadow: var(--wc-shadow-md);
}

.wc-header.is-sticky .wc-header__inner {
  min-height: var(--wc-header-main-height-sticky);
}

.wc-header.is-sticky .wc-header__logo-img {
  /* Riduzione proporzionale (75%) invece di un valore fisso, così funziona con
     qualunque altezza sia stata impostata da wccontent. */
  height: calc(var(--wc-logo-height, 44px) * 0.75);
}

/* Responsive */

@media (max-width: 991px) {
  .wc-header__burger {
    display: inline-flex;
  }

  .wc-topbar__message {
    display: none;
  }

  .wc-header__inner {
    gap: 16px;
    padding: 12px 16px;
  }

  .wc-topbar__inner {
    padding: 0 16px;
  }
}

@media (max-width: 480px) {
  .wc-topbar__contacts a span:not(.wc-visually-hidden) {
    display: none;
  }
}

/*
 * Accordion generico (Fase 8) — collassa via grid-template-rows: 0fr → 1fr invece di
 * hidden/display:none, così la chiusura/apertura è animata invece che a scatto.
 * Usato da: FAQ (prodotto), sottomenu del menu mobile. Il contenuto interno serve perché
 * grid-template-rows anima la riga solo se ha un unico figlio con overflow:hidden.
 */
.wc-accordion {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--wc-transition);
}

.wc-accordion.is-open {
  grid-template-rows: 1fr;
}

.wc-accordion__inner {
  overflow: hidden;
  min-height: 0;
}

/* Toggle "Privato/Azienda" iniettato via JS nel form dati personali del checkout
   (checkout.js) — stile minimo per non farlo sembrare fuori posto rispetto al resto del
   form nativo di PrestaShop. */
.wc-checkout-mode__options {
  display: flex;
  gap: 20px;
  margin-top: 6px;
}

.wc-checkout-mode__option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
  cursor: pointer;
}

.wc-checkout-mode__option input {
  margin: 0;
}

/* Notifica "Prodotto aggiunto al carrello" (cart.js) */
.wc-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 2000;
  background: var(--wc-color-secondary);
  color: #fff;
  padding: 16px 28px;
  border-radius: var(--wc-radius-md);
  box-shadow: var(--wc-shadow-md);
  font-size: 15px;
  font-weight: 600;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.95);
  transition: opacity var(--wc-transition), transform var(--wc-transition);
  pointer-events: none;
}

.wc-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.wc-toast--error {
  background: var(--wc-color-danger);
}

/* Rispetta la preferenza di sistema: disattiva le animazioni, non lo stato finale */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
