/* ════════════════════════════════════════════════════════════
   RICERCA LIVE GLOBALE — modal dell'header (tema "Emerald Noir")
   Markup: partials/search-modal.php · JS: public/js/search-modal.js
   Token (--en-*) definiti in header.css.
════════════════════════════════════════════════════════════ */

/* ── Pulsante lente nell'header ── */
/* Cerchio verde con la lente (come il pulsante della barra del catalogo, recre.css). */
.gs-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--en-text-dim);
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.gs-trigger-ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34d399, #059669);
  color: #06140d;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s ease;
}
.gs-trigger-ico svg { width: 17px; height: 17px; }
.gs-trigger:hover .gs-trigger-ico,
.gs-trigger[aria-expanded="true"] .gs-trigger-ico {
  filter: brightness(1.08);
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.16), 0 6px 20px rgba(16, 185, 129, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}
.gs-trigger:active .gs-trigger-ico { transform: scale(.94); }
.gs-trigger:focus-visible { outline: 2px solid var(--en-em-bright); outline-offset: 3px; }
.gs-trigger + .H_account_wrap { margin-left: 12px; }

/* Blocca lo scroll della pagina con il modal aperto */
html.gs-lock, html.gs-lock body { overflow: hidden; }

/* ── Modal ── */
.gs-modal {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: min(12vh, 110px) 16px 24px;
}
.gs-modal[hidden] { display: none; }

.gs-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 5, 0.62);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .16s ease;
}

.gs-dialog {
  position: relative;
  width: 100%;
  max-width: 42rem;
  max-height: calc(100vh - min(12vh, 110px) - 24px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(52, 211, 153, 0.07), transparent 45%, rgba(110, 231, 183, 0.04)),
    rgba(11, 18, 14, 0.92);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--en-line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.03) inset, 0 0 60px rgba(52, 211, 153, 0.06);
  opacity: 0;
  transform: translateY(-10px) scale(.985);
  transition: opacity .16s ease, transform .2s cubic-bezier(.2, .8, .2, 1);
}

.gs-modal.gs-open .gs-backdrop { opacity: 1; }
.gs-modal.gs-open .gs-dialog { opacity: 1; transform: none; }
/* Trasformazione barra del catalogo → pannello: l'animazione la guida il JS (Web Animations API) */
.gs-modal.gs-morphing .gs-dialog { transition: none; opacity: 1; transform: none; will-change: transform, clip-path; }
.gs-modal.gs-morphing .gs-backdrop { transition: none; }

/* ── Barra di ricerca ── */
.gs-bar {
  position: relative;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--en-line-soft);
}
.gs-bar-icon {
  position: absolute;
  left: 16px;
  display: grid;
  place-items: center;
  padding: 5px;
  border-radius: 9px;
  color: var(--en-em);
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.18), rgba(5, 150, 105, 0.10));
  transition: transform .25s ease;
  pointer-events: none;
}
.gs-bar-icon svg { width: 18px; height: 18px; }
.gs-bar:focus-within .gs-bar-icon { transform: scale(1.1); }

.gs-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--en-text);
  font: 500 1.05rem/1.2 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  padding: 20px 16px 20px 58px;
  -webkit-appearance: none;
  appearance: none;
}
.gs-input::placeholder { color: rgba(232, 245, 238, 0.4); }
.gs-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

.gs-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 14px;
  flex-shrink: 0;
}

.gs-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(52, 211, 153, 0.25);
  border-top-color: var(--en-em);
  animation: spin .7s linear infinite;
  visibility: hidden;
}
.gs-loading .gs-spinner { visibility: visible; }

.gs-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 11px;
  border-radius: 9px;
  background: rgba(52, 211, 153, 0.10);
  color: var(--en-em-bright);
  font: 600 0.8rem/1 'DM Sans', system-ui, sans-serif;
  white-space: nowrap;
  transition: background .15s ease;
}
.gs-filters svg { width: 15px; height: 15px; }
.gs-filters:hover { background: rgba(52, 211, 153, 0.2); color: var(--en-em-bright); }

.gs-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--en-line-soft);
  background: var(--en-glass);
  color: var(--en-text-dim);
  cursor: pointer;
  transition: color .15s ease, background .15s ease, border-color .15s ease, transform .2s ease;
}
.gs-close svg { width: 15px; height: 15px; }
.gs-close:hover { color: #fff; background: rgba(248, 113, 113, 0.16); border-color: rgba(248, 113, 113, 0.35); transform: rotate(90deg); }
.gs-close:focus-visible { outline: 2px solid var(--en-em); outline-offset: 2px; }

/* ── Corpo / risultati ── */
.gs-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px 10px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(52, 211, 153, 0.25) transparent;
}

.gs-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 8px 6px;
}
.gs-head[hidden] { display: none; }
.gs-head-label {
  font: 600 0.78rem/1 'DM Sans', system-ui, sans-serif;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--en-text-dim);
}
.gs-badge {
  padding: 3px 8px;
  border-radius: 999px;
  font: 700 0.7rem/1 'DM Sans', system-ui, sans-serif;
  color: var(--en-em-bright);
  background: rgba(52, 211, 153, 0.14);
}
.gs-badge[hidden] { display: none; }
.gs-clear {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--en-text-dim);
  font: 500 0.78rem/1 'DM Sans', system-ui, sans-serif;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.gs-clear:hover { color: var(--en-em-bright); background: var(--en-glass); }
.gs-clear[hidden] { display: none; }

.gs-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.gs-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 10px;
  border-radius: 12px;
  color: var(--en-text);
  text-decoration: none;
  transition: background .18s ease;
}
.gs-link:hover { color: var(--en-text); }
.gs-active .gs-link,
.gs-link:hover,
.gs-link:focus-visible {
  outline: none;
  background: linear-gradient(90deg, rgba(52, 211, 153, 0.13), rgba(52, 211, 153, 0.04) 70%, transparent);
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.18);
}

/* Miniatura */
.gs-thumb {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #13241b, #0a120e);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 4px 14px rgba(0, 0, 0, 0.4);
  transition: box-shadow .2s ease;
}
.gs-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gs-active .gs-thumb,
.gs-link:hover .gs-thumb { box-shadow: 0 0 0 1px rgba(52, 211, 153, 0.45), 0 0 16px rgba(52, 211, 153, 0.28); }
.gs-initial { font: 700 1.2rem/1 'DM Sans', system-ui, sans-serif; color: var(--en-em); }

/* Testi */
.gs-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.gs-name {
  font: 600 0.98rem/1.25 'DM Sans', 'Segoe UI', system-ui, sans-serif;
  color: var(--en-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .18s ease;
}
.gs-active .gs-name,
.gs-link:hover .gs-name { color: var(--en-em-bright); }
.gs-bank {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  font: 500 0.82rem/1.2 'DM Sans', system-ui, sans-serif;
  color: var(--en-text-dim);
}
.gs-bank > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-logo {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border-radius: 5px;
  object-fit: cover;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.gs-list mark {
  background: none;
  color: var(--en-em);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: rgba(52, 211, 153, 0.4);
  text-underline-offset: 3px;
}

.gs-arrow {
  flex-shrink: 0;
  color: rgba(232, 245, 238, 0.3);
  transition: color .2s ease, transform .25s ease;
}
.gs-arrow svg { width: 18px; height: 18px; display: block; }
.gs-active .gs-arrow,
.gs-link:hover .gs-arrow { color: var(--en-em); transform: translateX(4px); }

/* Ricerche recenti */
.gs-recent .gs-link { padding: 10px 12px; gap: 12px; }
.gs-recent-ico { color: var(--en-text-dim); display: grid; place-items: center; }
.gs-recent-ico svg { width: 17px; height: 17px; }
.gs-recent .gs-name { font-weight: 500; font-size: 0.93rem; }

/* Messaggi */
.gs-msg {
  margin: 0;
  padding: 26px 12px 22px;
  text-align: center;
  color: var(--en-text-dim);
  font: 500 0.92rem/1.5 'DM Sans', system-ui, sans-serif;
}
.gs-msg[hidden] { display: none; }
.gs-msg strong { color: var(--en-text); }

/* Vedi tutti */
.gs-all {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--en-line-soft);
  color: var(--en-text-dim);
  font: 600 0.88rem/1 'DM Sans', system-ui, sans-serif;
  background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0), transparent);
  transition: color .2s ease, background .2s ease;
}
.gs-all[hidden] { display: none; }
.gs-all svg { width: 16px; height: 16px; transition: transform .25s ease; }
.gs-all:hover {
  color: var(--en-em-bright);
  background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.08), transparent);
}
.gs-all:hover svg,
.gs-all:focus-visible svg { transform: translateX(4px); }
.gs-all:focus-visible { outline: none; color: var(--en-em-bright); background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.12), transparent); }

/* Legenda tasti (desktop/tablet; nascosta sui touch ≤640px) */
.gs-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--en-line-soft);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(232, 245, 238, 0.5);
  font: 500 0.74rem/1 'DM Sans', system-ui, sans-serif;
}
.gs-foot span { display: inline-flex; align-items: center; gap: 7px; }
.gs-foot kbd {
  display: inline-block;
  min-width: 22px;
  padding: 4px 6px;
  color: var(--en-text);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  border: 1px solid var(--en-line-soft);
  background: rgba(255, 255, 255, 0.04);
  font: inherit;
  text-align: center;
}

/* ── Header mobile: lente accanto all'hamburger ── */
@media (max-width: 768px) {
  .gs-trigger { order: 2; }
  .nav-hamburger { order: 3; margin-left: 10px; }
}

/* ── Mobile: modal a tutto schermo ── */
@media (max-width: 640px) {
  .gs-modal { padding: 0; }
  .gs-dialog {
    max-width: none;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(9, 15, 12, 0.98);
    transform: translateY(12px);
  }
  .gs-input { font-size: 16px; padding: 18px 10px 18px 54px; } /* 16px: niente zoom automatico su iOS */
  .gs-bar-icon { left: 12px; }
  .gs-bar-actions { padding-right: 10px; gap: 6px; }
  .gs-filters span { display: none; }
  .gs-filters { padding: 8px; }
  .gs-body { padding: 4px 6px 10px; }
  .gs-link { gap: 12px; padding: 8px; }
  .gs-thumb { width: 42px; height: 56px; border-radius: 9px; }
  .gs-name { font-size: 0.95rem; }
  .gs-foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gs-dialog, .gs-backdrop, .gs-arrow, .gs-all svg, .gs-bar-icon { transition: none; }
  .gs-dialog { transform: none; }
  .gs-spinner { animation-duration: 1.5s; }
}
