/* ══════════════════════════════════════════════
   WELCOME POPUP — Righetto Immobiliare
   ULTRA-PREMIUM — Foto reale Sara con effetti cinematografici
   ══════════════════════════════════════════════ */

/* Overlay */
#welcome-overlay {
  position: fixed; inset: 0;
  background: rgba(10,18,28,0.72);
  backdrop-filter: blur(8px) saturate(1.2);
  -webkit-backdrop-filter: blur(8px) saturate(1.2);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0;
  transition: opacity 0.5s ease;
  padding: 16px;
}
#welcome-overlay.visible { opacity: 1; }

/* Card — glassmorphism premium */
#welcome-card {
  background: linear-gradient(180deg, #F9F7F3 0%, #F2EDE6 100%);
  border-radius: 28px;
  box-shadow:
    0 30px 100px rgba(0,0,0,0.4),
    0 0 0 1px rgba(255,255,255,0.08) inset;
  max-width: 540px;
  width: 100%;
  overflow: hidden;
  transform: translateY(40px) scale(0.93);
  transition: transform 0.6s cubic-bezier(0.16,1,0.3,1);
  position: relative;
}
#welcome-overlay.visible #welcome-card {
  transform: translateY(0) scale(1);
}

/* Header con foto avatar — sfondo scuro cinematografico */
.welcome-header {
  background:
    radial-gradient(ellipse at 50% 80%, rgba(184,212,74,0.08) 0%, transparent 60%),
    linear-gradient(160deg, #1A2E44 0%, #2C4A6E 40%, #3D5F87 100%);
  padding: 36px 32px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

/* Particelle decorative sfondo header */
.welcome-header::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background:
    radial-gradient(circle at 20% 30%, rgba(184,212,74,0.06) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(255,255,255,0.03) 0%, transparent 35%);
  animation: header-shimmer 8s ease-in-out infinite;
}

@keyframes header-shimmer {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-2%, -1%); }
}

/* Avatar wrapper — più grande, più impatto */
.welcome-avatar-wrap {
  width: 220px; height: 220px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: visible;
  background: none;
  position: relative;
  z-index: 1;
}

/* Contenitore foto con effetti */
.welcome-avatar-photo {
  width: 100%; height: 100%;
  position: relative;
  border-radius: 50%;
}

/* Foto reale — premium styling */
.welcome-avatar-img {
  width: 100%; height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: center 45%;
  display: block;
  border: 3px solid rgba(255,255,255,0.5);
  box-shadow:
    0 12px 40px rgba(0,0,0,0.4),
    0 0 0 1px rgba(255,255,255,0.1) inset,
    0 0 80px rgba(184,212,74,0.08);
  transition: transform 0.5s cubic-bezier(0.25,0.46,0.45,0.94), box-shadow 0.5s ease;
  position: relative;
  z-index: 2;
  filter: contrast(1.03) brightness(1.02);
}

/* Hover sulla foto */
.welcome-avatar-img:hover {
  transform: scale(1.02);
  box-shadow:
    0 16px 50px rgba(0,0,0,0.45),
    0 0 0 1px rgba(255,255,255,0.15) inset,
    0 0 100px rgba(184,212,74,0.12);
}

/* Idle — leggero respiro sempre attivo quando popup è aperto */
.welcome-avatar-img.idle {
  animation: sara-idle 7s ease-in-out infinite;
}

@keyframes sara-idle {
  0%, 100% { transform: scale(1) translate(0, 0) rotate(0deg); filter: contrast(1.03) brightness(1.02); }
  30% { transform: scale(1.012) translate(0.3px, -0.4px) rotate(0.1deg); filter: contrast(1.03) brightness(1.025); }
  60% { transform: scale(1.008) translate(-0.2px, -0.2px) rotate(-0.1deg); filter: contrast(1.03) brightness(1.02); }
}

/* Quando parla: movimenti dinamici testa/corpo — effetto video-like */
.welcome-avatar-img.speaking {
  animation: sara-speaking-move 4s ease-in-out infinite;
}

@keyframes sara-speaking-move {
  0%   { transform: scale(1.02) translate(0, 0) rotate(0deg);         filter: contrast(1.03) brightness(1.02); }
  10%  { transform: scale(1.03) translate(1.5px, -2px) rotate(0.5deg);  filter: contrast(1.04) brightness(1.04); }
  22%  { transform: scale(1.04) translate(-1px, -3px) rotate(-0.3deg);  filter: contrast(1.05) brightness(1.06); }
  35%  { transform: scale(1.035) translate(0.5px, -1.5px) rotate(0.4deg); filter: contrast(1.04) brightness(1.05); }
  48%  { transform: scale(1.04) translate(-1.5px, -2.5px) rotate(-0.5deg); filter: contrast(1.05) brightness(1.06); }
  60%  { transform: scale(1.03) translate(1px, -2px) rotate(0.3deg);   filter: contrast(1.04) brightness(1.04); }
  72%  { transform: scale(1.035) translate(-0.5px, -1px) rotate(-0.2deg); filter: contrast(1.05) brightness(1.05); }
  85%  { transform: scale(1.025) translate(0.5px, -0.5px) rotate(0.2deg); filter: contrast(1.04) brightness(1.03); }
  100% { transform: scale(1.02) translate(0, 0) rotate(0deg);         filter: contrast(1.03) brightness(1.02); }
}

/* Doppio anello luminoso quando parla */
.sara-speaking-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  z-index: 1;
  transition: all 0.5s ease;
}

.sara-speaking-ring.speaking {
  border-color: rgba(184,212,74,0.6);
  animation: sara-ring-pulse 1.8s ease-in-out infinite;
}

.sara-speaking-ring::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  transition: border-color 0.5s ease;
}

.sara-speaking-ring.speaking::after {
  border-color: rgba(184,212,74,0.25);
  animation: sara-ring-outer 2.2s ease-in-out infinite;
}

@keyframes sara-ring-pulse {
  0%, 100% {
    border-color: rgba(184,212,74,0.3);
    box-shadow: 0 0 20px rgba(184,212,74,0.15);
  }
  50% {
    border-color: rgba(184,212,74,0.85);
    box-shadow: 0 0 40px rgba(184,212,74,0.3), 0 0 80px rgba(184,212,74,0.1);
  }
}

@keyframes sara-ring-outer {
  0%, 100% { border-color: rgba(184,212,74,0.1); }
  50% { border-color: rgba(184,212,74,0.35); }
}

/* Glow diffuso premium */
.sara-glow {
  position: absolute;
  inset: -24px;
  border-radius: 50%;
  z-index: 0;
  opacity: 0;
  background: radial-gradient(circle,
    rgba(184,212,74,0.18) 0%,
    rgba(184,212,74,0.06) 40%,
    transparent 70%
  );
  transition: opacity 0.6s ease;
}

.sara-glow.speaking {
  opacity: 1;
  animation: sara-glow-breathe 2.5s ease-in-out infinite;
}

@keyframes sara-glow-breathe {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.12); opacity: 1; }
}

/* Header text — tipografia luxury */
.welcome-header-text {
  color: #fff;
  position: relative;
  z-index: 1;
}
.welcome-header-text h3 {
  margin: 0;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.45rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.welcome-header-text p {
  margin: 4px 0 0;
  font-size: 0.82rem;
  opacity: 0.85;
  font-family: 'Montserrat', sans-serif;
  letter-spacing: 0.03em;
}
.welcome-online {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.welcome-online::before {
  content: '';
  width: 9px; height: 9px;
  background: #B8D44A;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(184,212,74,0.6);
  animation: welcome-pulse 2s ease-in-out infinite;
}
@keyframes welcome-pulse {
  0%,100% { opacity: 1; transform: scale(1); box-shadow: 0 0 8px rgba(184,212,74,0.6); }
  50% { opacity: 0.7; transform: scale(1.4); box-shadow: 0 0 16px rgba(184,212,74,0.8); }
}

/* Body */
.welcome-body {
  padding: 26px 30px;
}
.welcome-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.92rem;
  line-height: 1.7;
  color: #152435;
  min-height: 110px;
}
.welcome-text .cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: linear-gradient(180deg, #2C4A6E, #B8D44A);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: welcome-blink 0.7s step-end infinite;
  border-radius: 1px;
}
@keyframes welcome-blink {
  0%,100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Audio toggle */
.welcome-audio-toggle {
  display: inline-flex;
  align-items: center; gap: 6px;
  background: none; border: none;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.78rem;
  color: #6B7A8D;
  cursor: pointer;
  padding: 4px 0;
  margin-top: 8px;
  transition: color 0.2s;
}
.welcome-audio-toggle:hover { color: #2C4A6E; }

/* CTA buttons — premium con effetti */
.welcome-actions {
  display: flex;
  gap: 12px;
  padding: 0 30px 28px;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.5s cubic-bezier(0.16,1,0.3,1);
}
.welcome-actions.visible {
  opacity: 1;
  transform: translateY(0);
}
.welcome-btn {
  flex: 1;
  padding: 14px 18px;
  border-radius: 14px;
  border: none;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25,0.46,0.45,0.94);
  text-align: center;
  letter-spacing: 0.02em;
  position: relative;
  overflow: hidden;
}
.welcome-btn-primary {
  background: linear-gradient(135deg, #B8D44A, #9EC232);
  color: #152435;
  box-shadow: 0 6px 20px rgba(184,212,74,0.35);
}
.welcome-btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 32px rgba(184,212,74,0.5);
}
.welcome-btn-primary:active {
  transform: translateY(-1px);
}
.welcome-btn-secondary {
  background: #ECE7DF;
  color: #2C4A6E;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.welcome-btn-secondary:hover {
  background: #E1DBD1;
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

/* Close X — più elegante */
.welcome-close {
  position: absolute;
  top: 14px; right: 18px;
  background: rgba(255,255,255,0.08); border: none;
  color: rgba(255,255,255,0.5);
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 3;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  transition: all 0.25s ease;
  backdrop-filter: blur(4px);
}
.welcome-close:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  transform: scale(1.08);
}

/* ── Mobile Play Button — sblocca audio su dispositivi touch ── */
.sara-mobile-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 2.5px solid rgba(255,255,255,0.7);
  border-radius: 50%;
  width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  animation: mobile-play-pulse 2s ease-in-out infinite;
}
.sara-mobile-play svg {
  width: 30px; height: 30px;
  fill: white;
  margin-left: 4px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}
.sara-mobile-play:active {
  background: rgba(184,212,74,0.5);
  border-color: #B8D44A;
  transform: translate(-50%, -50%) scale(1.1);
}
@keyframes mobile-play-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
  50% { box-shadow: 0 0 0 14px rgba(255,255,255,0); }
}

/* Label sotto il play button */
.sara-play-label {
  position: absolute;
  bottom: -30px; left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.85);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
  letter-spacing: 0.03em;
  pointer-events: none;
}

/* ── MOBILE ── */
@media (max-width: 520px) {
  #welcome-card { border-radius: 22px; }
  .welcome-header { padding: 24px 20px 18px; gap: 12px; }
  .welcome-avatar-wrap { width: 170px; height: 170px; }
  .welcome-header-text h3 { font-size: 1.2rem; }
  .welcome-body { padding: 20px 22px; }
  .welcome-text { font-size: 0.85rem; min-height: 90px; }
  .welcome-actions { padding: 0 22px 22px; flex-direction: column; gap: 10px; }
  .welcome-btn { padding: 13px 16px; }
}
