/* od-header.css — restyle novembre 2026, area header / menu mobile / ricerca / riga utility del footer.
 * Riferimento: organizzazione e comportamento del tema Malva (Dawn), aspetto Orange Duke.
 * Markup: templates/_partials/header.tpl, od-icon.tpl, od-lang-switch.tpl, footer.tpl,
 *         modules/ps_shoppingcart/ps_shoppingcart.tpl, modules/ps_searchbar/ps_searchbar.tpl.
 * Comportamento: assets/js/od-header.js. Token: od-base.css.
 *
 * Livelli (z-index) dentro #header (contesto proprio, z 500):
 *   riga 1 < scrim menu 2 < drawer 3 < scrim ricerca 4 < overlay ricerca 5
 * La barra/chat di Valen (z ~2147483000) resta sopra a tutto.
 */

/* ------------------------------------------------------------------ */
/* Contenitore sticky: nascosto scorrendo giu', rivelato scorrendo su  */
/* ------------------------------------------------------------------ */
#header {
  position: sticky;
  top: 0;
  z-index: 500;
  background: var(--od-surface);
  color: var(--od-ink);
  box-shadow: none;
  transition: top 200ms ease-out, box-shadow 200ms ease-out;
}
#header.od-header--hidden { top: calc(-1 * var(--od-header-h) - 2px); }
/* Ombra leggera solo quando l'header galleggia sopra il contenuto (non in cima alla pagina). */
#header.od-header--floating { box-shadow: 0 1px 0 var(--od-line); }

.od-header { position: relative; font-family: var(--od-font); }

/* ---- Riga: [sinistra 1fr] [logo auto] [icone 1fr] ---- */
.od-header__bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: var(--od-space-4);
  max-width: 1440px;
  min-height: 60px;
  margin: 0 auto;
  padding: var(--od-space-2) var(--od-gutter);
}
.od-header__left { display: flex; align-items: center; justify-self: start; min-width: 0; margin-left: -11px; }
.od-header__icons { display: flex; align-items: center; justify-self: end; margin-right: -11px; }

/* ---- Logo (immagine PS_LOGO 349x90) ---- */
.od-header__logo { display: flex; align-items: center; justify-content: center; line-height: 0; }
.od-header__logo-h1 { margin: 0; line-height: 0; font-size: inherit; }
.od-header__logo a { display: inline-block; line-height: 0; }
.od-header__logo img,
#header .od-header__logo .logo {
  display: block;
  width: clamp(80px, calc(100vw - 274px), 112px); /* 274 = gutter x2 + i due gruppi di icone */
  max-width: none;
  height: auto;
}
.od-header__wordmark { font-weight: 800; font-size: var(--od-text-lg); color: var(--od-ink); line-height: 1; }

/* ---- Bottoni icona: area 44px, glifo 22px ---- */
.od-icon { width: 22px; height: 22px; flex: none; display: block; }
.od-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--od-control-h);
  height: var(--od-control-h);
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: var(--od-radius-pill);
  background: none;
  color: var(--od-ink);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 160ms ease;
}
#header .od-icon-btn,
#header .od-icon-btn:hover,
#header .od-icon-btn:focus { color: var(--od-ink); text-decoration: none; }
.od-icon-btn .od-icon { transition: transform 160ms ease; }
@media (hover: hover) {
  .od-icon-btn:hover { opacity: .6; }
  .od-icon-btn:hover .od-icon { transform: scale(1.07); }
}

/* Burger <-> X */
.od-header__burger-close { display: none; }
.od-header__burger[aria-expanded="true"] .od-header__burger-open { display: none; }
.od-header__burger[aria-expanded="true"] .od-header__burger-close { display: block; }
.od-header__burger span { line-height: 0; }

/* Il vecchio trigger Valen aveva regole in custom.css (.orangeduke-valen-trigger): annullate qui. */
#header .od-header__valen.orangeduke-valen-trigger {
  width: var(--od-control-h); height: var(--od-control-h);
  padding: 0; margin: 0; border: 0; background: none; box-shadow: none; color: var(--od-ink);
}

/* ---- Carrello: niente box grigio di Classic (.blockcart), bollino arancione ---- */
#header .od-cart.blockcart {
  background: transparent; height: auto; padding: 0; margin: 0; min-width: 0; border: 0;
}
.od-cart-widget { display: flex; }
.od-cart__count {
  position: absolute;
  top: 5px;
  right: 3px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--od-radius-pill);
  background: var(--od-orange);
  color: #fff;
  font: 600 11px/18px var(--od-font);
  text-align: center;
  box-shadow: 0 0 0 2px var(--od-surface);
  pointer-events: none;
}

/* ---- Nav categorie desktop ---- */
.od-header__nav { display: none; }
.od-header__nav ul { display: flex; align-items: center; flex-wrap: nowrap; margin: 0; padding: 0; list-style: none; }
.od-header__nav-link {
  display: block;
  padding: var(--od-space-2) 10px;
  font-size: var(--od-text-sm);
  font-weight: 500;
  line-height: 1.2;
  color: var(--od-ink);
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 100ms linear;
}
#header .od-header__nav-link:hover,
#header .od-header__nav-link:focus { color: var(--od-ink); opacity: .65; text-decoration: none; }
.od-header__nav-link:hover span,
.od-header__nav-link.is-current span {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
  text-decoration-color: var(--od-orange);
}
#header .od-header__nav-link.is-current { opacity: 1; }

/* ---- Pillola ricerca (solo desktop) ---- */
.od-header__search-pill {
  display: none;
  align-items: center;
  gap: var(--od-space-2);
  height: 36px;
  padding: 0 var(--od-space-4) 0 var(--od-space-3);
  margin-right: var(--od-space-2);
  border: 0;
  border-radius: var(--od-radius-pill);
  background: var(--od-surface-alt);
  color: var(--od-muted);
  font: 400 13px/1 var(--od-font);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 160ms ease;
}
.od-header__search-pill .od-icon { width: 16px; height: 16px; }
.od-header__search-pill:hover { background: var(--od-line); }

/* ---- Desktop >= 992 ---- */
@media (min-width: 992px) {
  /* 992-1199: spazio stretto, la nav (5 voci) deve stare nella colonna 1fr senza toccare il logo */
  .od-header__bar { min-height: 72px; padding: var(--od-space-3) var(--od-gutter); column-gap: var(--od-space-4); }
  .od-header__burger,
  .od-header__search-icon { display: none; }
  .od-header__nav { display: block; }
  .od-header__search-pill { display: inline-flex; }
  .od-header__left { margin-left: -10px; }
  .od-header__logo img,
  #header .od-header__logo .logo { width: 120px; }
  .od-header__nav-link { padding: var(--od-space-2) var(--od-space-1); font-size: 13px; }
}
@media (min-width: 1200px) {
  .od-header__bar { padding: var(--od-space-3) var(--od-space-6); column-gap: var(--od-space-6); }
  .od-header__logo img,
  #header .od-header__logo .logo { width: 170px; }
  .od-header__nav-link { padding: var(--od-space-2) 10px; font-size: var(--od-text-sm); }
}

/* ------------------------------------------------------------------ */
/* Overlay di ricerca                                                  */
/* ------------------------------------------------------------------ */
.od-search {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--od-surface);
}
.od-search:not([hidden]) { animation: od-search-in 200ms var(--od-ease); }
@keyframes od-search-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.od-search__inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--od-space-2);
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--od-space-2) 0 var(--od-gutter);
}
.od-search__field { position: static; flex: 1 1 auto; min-width: 0; max-width: 740px; }
.od-search__form { position: relative; margin: 0; }
.od-search__glass {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--od-muted); line-height: 0; pointer-events: none;
}
.od-search__glass .od-icon { width: 18px; height: 18px; }
.od-search__input {
  display: block;
  width: 100%;
  height: var(--od-control-h);
  padding: 0 46px 0 42px;
  border: 1px solid rgba(41, 43, 44, .2);
  border-radius: var(--od-radius-pill);
  background: var(--od-surface);
  color: var(--od-ink);
  font: 400 var(--od-text-md)/1 var(--od-font); /* 16px: iOS non zooma */
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.od-search__input::placeholder { color: var(--od-muted); opacity: 1; }
.od-search__input:focus { border-color: var(--od-ink); box-shadow: 0 0 0 3px rgba(242, 106, 27, .15); }
.od-search__input:focus-visible { outline: none; }
.od-search__clear {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--od-radius-pill);
  background: none; color: var(--od-muted); cursor: pointer;
}
.od-search__clear .od-icon { width: 18px; height: 18px; }
.od-search__clear:hover { color: var(--od-ink); }
.od-search__close { flex: none; }

/* Pagina scurita sotto l'header (click = chiudi) */
.od-search__scrim,
.od-drawer__scrim {
  position: fixed;
  top: var(--od-header-h);
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--od-overlay);
  animation: od-fade-in 200ms ease;
}
.od-search__scrim { z-index: 4; }
.od-drawer__scrim { z-index: 2; }
@keyframes od-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---- Risultati istantanei ---- */
.od-search__results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: calc(100vh - var(--od-header-h) - var(--od-valen-bar-h));
  max-height: calc(100dvh - var(--od-header-h) - var(--od-valen-bar-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--od-surface);
  border-top: 1px solid var(--od-line);
  box-shadow: var(--od-shadow);
}
.od-search__group-title { margin: 0; padding: var(--od-space-4) var(--od-space-4) var(--od-space-2); }
.od-search__list { margin: 0; padding: 0 0 var(--od-space-2); list-style: none; }
.od-search__item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--od-space-3);
  padding: var(--od-space-2) var(--od-space-4);
  color: var(--od-ink);
  text-decoration: none;
}
.od-search__item:hover,
.od-search__item[aria-selected="true"],
.od-search__footer:hover,
.od-search__footer[aria-selected="true"] { background: rgba(41, 43, 44, .04); color: var(--od-ink); text-decoration: none; }
.od-search__item:hover .od-search__name,
.od-search__item[aria-selected="true"] .od-search__name { text-decoration: underline; text-underline-offset: 3px; }
.od-search__thumb {
  width: 56px; height: 56px; border-radius: var(--od-radius-sm);
  background: var(--od-surface-alt); object-fit: contain; display: block;
}
.od-search__name {
  font-size: var(--od-text-sm); font-weight: 500; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.od-search__price { font-size: var(--od-text-sm); font-weight: 600; white-space: nowrap; }
.od-search__price s { margin-right: var(--od-space-1); color: var(--od-muted); font-weight: 400; }
.od-search__empty { margin: 0; padding: var(--od-space-5) var(--od-space-4) var(--od-space-4); color: var(--od-muted); font-size: var(--od-text-sm); }
.od-search__loading { margin: 0; padding: var(--od-space-4); color: var(--od-muted); font-size: var(--od-text-sm); display: flex; align-items: center; gap: var(--od-space-2); }
.od-search__loading::before {
  content: ""; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--od-line); border-top-color: var(--od-orange);
  animation: od-spin 700ms linear infinite;
}
@keyframes od-spin { to { transform: rotate(360deg); } }
.od-search__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--od-space-3);
  min-height: 52px;
  padding: var(--od-space-3) var(--od-space-4);
  border-top: 1px solid var(--od-line);
  color: var(--od-ink);
  font-size: var(--od-text-sm);
  font-weight: 600;
  text-decoration: none;
}
.od-search__footer .od-icon { width: 18px; height: 18px; color: var(--od-orange); }

@media (min-width: 768px) {
  .od-search__inner { padding: 0 var(--od-space-5); }
  /* Da tablet in su i risultati si aprono sotto il campo, larghi quanto il campo (come Malva). */
  .od-search__field { position: relative; }
  .od-search__results {
    top: calc(100% + 6px);
    border: 1px solid var(--od-line);
    border-radius: var(--od-radius-lg);
    max-height: min(560px, calc(100vh - var(--od-header-h) - 32px));
  }
}

/* ------------------------------------------------------------------ */
/* Menu mobile (drawer da sinistra sotto l'header)                     */
/* ------------------------------------------------------------------ */
.od-drawer {
  position: fixed;
  top: var(--od-header-h);
  left: 0;
  bottom: 0;
  z-index: 3;
  width: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--od-surface);
  padding-bottom: calc(var(--od-valen-bar-h) + var(--od-space-5));
  transform: translateX(-100%);
  transition: transform 250ms var(--od-ease);
}
.od-drawer.is-open { transform: none; }
.od-drawer:focus { outline: none; }
@media (min-width: 768px) {
  .od-drawer { width: 400px; border-right: 1px solid var(--od-line); }
}
@media (min-width: 992px) {
  .od-drawer, .od-drawer__scrim { display: none !important; }
}
.od-drawer__nav ul { margin: 0; padding: var(--od-space-3) 0; list-style: none; }
.od-drawer__cat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--od-space-3);
  min-height: 56px;
  padding: var(--od-space-2) var(--od-space-5);
  color: var(--od-ink);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  text-decoration: none;
}
.od-drawer__cat .od-icon { width: 20px; height: 20px; color: var(--od-muted); }
#header .od-drawer__cat:hover,
#header .od-drawer__cat:focus { background: rgba(41, 43, 44, .04); color: var(--od-ink); text-decoration: none; }
#header .od-drawer__cat.is-current { color: var(--od-orange); }
.od-drawer__cat.is-current .od-icon { color: var(--od-orange); }

.od-drawer__utility {
  margin: 0 var(--od-space-4);
  padding: var(--od-space-2) var(--od-space-4);
  border-radius: var(--od-radius-lg);
  background: var(--od-surface-alt);
}
.od-drawer__link {
  display: flex;
  align-items: center;
  gap: var(--od-space-3);
  min-height: 52px;
  color: var(--od-ink);
  font-size: var(--od-text-md);
  font-weight: 500;
  text-decoration: none;
}
.od-drawer__link + .od-drawer__link,
.od-drawer__lang { border-top: 1px solid var(--od-line); }
.od-drawer__link .od-icon,
.od-drawer__lang > .od-icon { width: 20px; height: 20px; }
#header .od-drawer__link:hover { color: var(--od-orange-dark); text-decoration: none; }

/* ---- Selettore lingua (menu mobile + footer) ---- */
.od-lang { display: flex; align-items: center; gap: var(--od-space-3); }
.od-drawer__lang { min-height: 60px; }
.od-lang__list { display: flex; gap: var(--od-space-2); margin: 0; padding: 0; list-style: none; }
.od-lang__item {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--od-space-4);
  border: 1px solid var(--od-line);
  border-radius: var(--od-radius-pill);
  background: var(--od-surface);
  color: var(--od-ink);
  font-size: var(--od-text-sm);
  font-weight: 500;
  text-decoration: none;
}
a.od-lang__item:hover { border-color: var(--od-ink); color: var(--od-ink); text-decoration: none; }
.od-lang__item.is-current { background: var(--od-teal); border-color: var(--od-teal); color: #fff; }

/* ---- Riga utility del footer (Contattaci + lingua) ---- */
.od-footer-utility {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--od-space-4) var(--od-space-5);
  margin-top: var(--od-space-4);
  padding: var(--od-space-4) 0;
  border-top: 1px solid var(--od-line);
}
.od-footer-utility__link { font-size: var(--od-text-sm); font-weight: 500; color: var(--od-ink); }
.od-footer-utility .od-lang > .od-icon { width: 18px; height: 18px; color: var(--od-muted); }
.od-footer-utility .od-lang__item { min-height: 36px; }

/* ---- Campo del modulo ps_searchbar (pagina 404 / ricerca senza risultati) ---- */
.od-searchbar { max-width: 560px; margin: var(--od-space-4) auto; }
.od-searchbar__form { position: relative; display: flex; align-items: center; gap: var(--od-space-2); }
.od-searchbar__form > .od-icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--od-muted); pointer-events: none; }
.od-searchbar__form input[type="text"] {
  flex: 1 1 auto; min-width: 0; height: var(--od-control-h); padding: 0 var(--od-space-4) 0 42px;
  border: 1px solid rgba(41, 43, 44, .2); border-radius: var(--od-radius-pill); font-size: var(--od-text-md);
}
.od-searchbar__submit {
  flex: none; height: var(--od-control-h); padding: 0 var(--od-space-5); border: 0;
  border-radius: var(--od-radius-pill); background: var(--od-orange); color: #fff; font-weight: 600; cursor: pointer;
}

/* ---- Accessibilita': niente animazioni se richiesto ---- */
@media (prefers-reduced-motion: reduce) {
  #header, .od-drawer, .od-icon-btn, .od-icon-btn .od-icon { transition: none; }
  .od-search:not([hidden]), .od-search__scrim, .od-drawer__scrim { animation: none; }
}
