/* «Come funziona»: la conversazione (salto di livello, 25/10/2026, PIANO § 5.1.7)
   I tre passi sono i messaggi di una chat nei colori del sito: in uscita il blu, in entrata il bianco;
   nome, logo, ore e spunte sono decorazione (aria-hidden, data-servizio). L'<ol> resta l'elenco dei passi. */

.come { overflow-x: clip; isolation: isolate; }

/* L'onda di latte del kit, dietro la chat: sfuma su ogni lato, nessun bordo dritto */
.come__latte {
  position: absolute; z-index: -1; pointer-events: none;
  left: 34%; right: -16%; top: 56%;
  transform: translateY(-50%);
  -webkit-mask: linear-gradient(90deg, transparent 0, #000 22%), linear-gradient(180deg, transparent 0, #000 26%, #000 78%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask: linear-gradient(90deg, transparent 0, #000 22%), linear-gradient(180deg, transparent 0, #000 26%, #000 78%, transparent 100%);
          mask-composite: intersect;
}
.come__latte img { width: 100%; height: auto; will-change: transform; }

/* La griglia: titolo e pulsante a sinistra, la chat a destra (un pulsante solo, spostato dalla griglia) */
.come__griglia {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas: "testa chat" "azioni chat";
  grid-template-rows: 1fr 1fr;
  column-gap: clamp(40px, 7vw, 120px);
}
.come__testa { grid-area: testa; align-self: end; margin: 0; }
.come .titolo-sezione { font-size: clamp(2rem, .9rem + 4.2vw, 4.75rem); line-height: 1; letter-spacing: -.02em; }
.come .come__azioni { grid-area: azioni; align-self: start; margin-top: clamp(28px, 18px + 1.6vw, 40px); }

/* ---------- La chat ---------- */
.chat {
  grid-area: chat; justify-self: end; position: relative;
  width: 100%; max-width: 600px;
  border-radius: var(--raggio-l);
  background: #EEF3F9;
  box-shadow: 0 0 0 1px rgba(10, 35, 95, .05), var(--ombra-2);
}
/* un alone di cielo dietro la scheda */
.chat::before {
  content: ""; position: absolute; z-index: -1; inset: -14% -12%; pointer-events: none;
  background: radial-gradient(closest-side, rgba(128, 169, 199, .30), rgba(128, 169, 199, 0));
}

/* La testa, come in un telefono: logo, nome, icona; il bordo basso è un'onda */
.chat__testa {
  position: relative; display: flex; align-items: center; gap: 14px;
  padding: 18px 24px 30px;
  border-radius: var(--raggio-l) var(--raggio-l) 0 0;
  background: var(--notte-fondo); color: var(--bianco);
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 14px) no-repeat, var(--onda-bassa) bottom / 100% 15px no-repeat;
          mask: linear-gradient(#000 0 0) top / 100% calc(100% - 14px) no-repeat, var(--onda-bassa) bottom / 100% 15px no-repeat;
}
.chat__avatar {
  position: relative; flex: none; width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; background: var(--bianco);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .22);
}
.chat__avatar img { width: 78%; height: auto; }
.chat__avatar::after {
  content: ""; position: absolute; right: -1px; bottom: 1px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--verde-wa); box-shadow: 0 0 0 2.5px var(--blu-notte);
}
.chat__nome {
  flex: 1; min-width: 0;
  font-family: var(--serif); font-weight: 600; font-size: 1.125rem; line-height: 1.2; letter-spacing: .005em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat__wa { flex: none; width: 24px; height: 24px; color: rgba(255, 255, 255, .78); }
.chat__wa svg { width: 100%; height: 100%; }

/* I messaggi */
.chat__fili {
  list-style: none; display: grid; gap: 26px;
  padding: 22px 30px 34px;
  border-radius: 0 0 var(--raggio-l) var(--raggio-l);
  background:
    radial-gradient(120% 60% at 100% 100%, rgba(255, 255, 255, .9), rgba(255, 255, 255, 0) 70%),
    linear-gradient(180deg, #EEF3F9 0%, #E7EEF6 100%);
}
.msg { position: relative; display: flex; }
.msg--esce { justify-content: flex-end; }
.msg__fumetto {
  position: relative; max-width: 84%;
  padding: 14px 18px 9px;
  border-radius: 22px;
  font-size: 1.125rem; line-height: 1.45;
}
.msg--esce .msg__fumetto {
  color: var(--bianco);
  background: linear-gradient(180deg, var(--blu-medio), var(--blu));
  border-bottom-right-radius: 6px;
  box-shadow: 0 12px 24px -14px rgba(5, 74, 154, .75);
}
.msg--esce .msg__fumetto p { color: var(--bianco); }
.come .msg--esce .msg__fumetto a:not(.btn), .come .msg--esce .msg__fumetto a:not(.btn):hover {
  color: var(--bianco); font-weight: 600;
  text-decoration: underline; text-decoration-thickness: 1.5px; text-underline-offset: 3px;
  text-decoration-color: rgba(255, 255, 255, .6);
}
.msg--entra .msg__fumetto {
  color: var(--blu-notte); background: var(--bianco);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(10, 35, 95, .06), 0 12px 24px -16px rgba(10, 35, 95, .32);
}
.msg--entra .msg__fumetto p { color: var(--blu-notte); }
.come .msg--entra .msg__fumetto a:not(.btn) { color: var(--blu); font-weight: 600; text-decoration-thickness: 1.5px; text-underline-offset: 3px; text-decoration-color: rgba(5, 74, 154, .4); }

/* ora e spunte, in basso a destra nel fumetto */
.msg__meta {
  display: flex; justify-content: flex-end; align-items: center; gap: 4px;
  margin: 2px -4px 0 0;
  font-size: .75rem; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .02em;
  color: rgba(10, 35, 95, .48);
}
.msg--esce .msg__meta { color: rgba(255, 255, 255, .72); }
.msg__spunte { width: 18px; height: 12px; color: rgba(255, 255, 255, .72); transition: color 300ms ease; }
.msg.letto .msg__spunte { color: #A9E1FF; }

/* il numero del passo, in una goccia sul lato esterno */
.msg__goccia {
  position: absolute; top: -10px; z-index: 2;
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif); font-style: italic; font-weight: 600; font-size: .8125rem; line-height: 1;
  color: var(--bianco); background: var(--blu-medio);
  box-shadow: 0 0 0 3px #EEF3F9, 0 6px 12px -6px rgba(5, 74, 154, .7);
}
.msg--esce .msg__goccia { right: -11px; }
.msg--entra .msg__goccia { left: -11px; }

/* il passo 3: la scheda del posto (la foto apre Google Maps, come l'indirizzo) */
.msg--posto .msg__fumetto { width: min(84%, 400px); padding-top: 5px; }
.msg__foto {
  position: relative; display: block; overflow: hidden;
  margin: 0 -13px 12px; border-radius: 18px 18px 14px 14px;
  aspect-ratio: 16 / 9;
}
.msg__foto img { width: 100%; height: 100%; object-fit: cover; object-position: 56% 63%; transition: transform 700ms var(--ease-out); }
.msg__pin {
  position: absolute; left: 12px; bottom: 12px;
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bianco); color: var(--rosso);
  box-shadow: 0 6px 14px -6px rgba(10, 35, 95, .55);
}
.msg__pin svg { width: 20px; height: 20px; }
@media (hover: hover) and (pointer: fine) {
  .msg__foto:hover img { transform: scale(1.04); }
}

/* «sta scrivendo»: tre puntini nel posto del fumetto che arriva (assoluti: niente salti) */
.msg__scrive {
  position: absolute; left: 0; top: 0; z-index: 1;
  display: flex; gap: 5px; align-items: center;
  padding: 15px 16px; border-radius: 20px 20px 20px 6px;
  background: var(--bianco);
  box-shadow: 0 1px 2px rgba(10, 35, 95, .06), 0 12px 24px -16px rgba(10, 35, 95, .32);
  opacity: 0; transform: scale(.9); transform-origin: 0 100%;
  transition: opacity 180ms ease, transform 180ms var(--ease-out);
  pointer-events: none;
}
.msg__scrive i { width: 6px; height: 6px; border-radius: 50%; background: rgba(10, 35, 95, .42); }
.msg.scrive .msg__scrive { opacity: 1; transform: none; }
.msg.scrive .msg__scrive i { animation: come-puntino 720ms var(--ease-in-out) infinite; }
.msg.scrive .msg__scrive i:nth-child(2) { animation-delay: 120ms; }
.msg.scrive .msg__scrive i:nth-child(3) { animation-delay: 240ms; }
@keyframes come-puntino {
  0%, 60%, 100% { transform: none; opacity: .55; }
  30% { transform: translateY(-3px); opacity: 1; }
}

/* ---------- L'arrivo dei messaggi (solo con JS e senza «meno movimento»: altrimenti tutto è già lì) ---------- */
.chat--attende .msg__fumetto {
  opacity: 0; transform: translateY(12px) scale(.96);
  transition: opacity 420ms var(--ease-out), transform 420ms var(--ease-out);
}
.chat--attende .msg--esce .msg__fumetto { transform-origin: 100% 100%; }
.chat--attende .msg--entra .msg__fumetto { transform-origin: 0 100%; }
.chat--attende .msg__goccia {
  opacity: 0; transform: scale(.5);
  transition: opacity 260ms ease 160ms, transform 420ms var(--ease-out) 160ms;
}
.chat--attende .msg.mostra .msg__fumetto, .chat--attende .msg.mostra .msg__goccia { opacity: 1; transform: none; }

/* ---------- Telefono: segno, titolo, la chat a tutta larghezza, il pulsante sotto ---------- */
@media (max-width: 767px) {
  .come__griglia { grid-template-columns: minmax(0, 1fr); grid-template-areas: "testa" "chat" "azioni"; grid-template-rows: auto; }
  .come__testa { margin-bottom: 28px; }
  .come .come__azioni { margin-top: 28px; }
  .chat { max-width: none; justify-self: stretch; }
  .chat::before { inset: -6% -20%; }
  .chat__testa { padding: 14px 16px 26px; gap: 12px; }
  .chat__avatar { width: 42px; height: 42px; }
  .chat__nome { font-size: 1.0625rem; }
  .chat__fili { gap: 22px; padding: 18px 16px 24px; }
  .msg__fumetto { font-size: 1rem; line-height: 1.45; padding: 11px 14px 8px; border-radius: 20px; }
  .msg--posto .msg__fumetto { width: 86%; max-width: 86%; padding-top: 4px; }
  .msg__foto { margin: 0 -10px 10px; border-radius: 16px 16px 12px 12px; }
  .msg__goccia { width: 24px; height: 24px; font-size: .75rem; top: -9px; }
  .msg--esce .msg__goccia { right: -8px; }
  .msg--entra .msg__goccia { left: -8px; }
  .come__latte { left: -50%; right: -50%; top: 64%; }
}

@media (prefers-reduced-motion: reduce) {
  .come__latte img { transform: none !important; }
  .msg__foto img { transition: none; }
  .msg.scrive .msg__scrive i { animation: none; }
}

/* telefoni stretti (320-359 px): il nome del caseificio entra intero */
@media (max-width: 359px) {
  .chat__testa { gap: 10px; padding-left: 14px; padding-right: 14px; }
  .chat__avatar { width: 38px; height: 38px; }
  .chat__nome { font-size: .9375rem; }
  .chat__wa { width: 20px; height: 20px; }
}
