/* Podere Puellae — assistente (chat). Usa i colori e i font di style.css. */

.ppb { --ppb-w: 400px; --ppb-h: min(640px, calc(100vh - 120px)); font-family: var(--sans); color: var(--basalt); }

/* ---------- pulsante ---------- */
.ppb-launch {
  position: fixed; z-index: 55; right: 16px;
  bottom: calc(var(--mbar-h) + 16px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; gap: 10px;
  height: 56px; padding: 0 20px 0 8px; border: 0; border-radius: 999px;
  background: var(--bordo); color: #fff; cursor: pointer;
  font: 600 .95rem/1 var(--sans); letter-spacing: .01em;
  box-shadow: 0 6px 20px rgba(100, 39, 54, .35), 0 1px 3px rgba(38, 36, 31, .2);
  transition: transform .2s ease, background .2s ease, opacity .2s ease;
}
.ppb-launch:hover { background: var(--bordo-d); transform: translateY(-2px); }
.ppb-launch:active { transform: scale(.97); }
.ppb-launch__icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--cream); color: var(--bordo);
}
.ppb-launch__icon svg { width: 22px; height: 22px; }
.ppb-launch__dot {
  position: absolute; top: 6px; left: 38px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--rose); box-shadow: 0 0 0 2px var(--bordo);
}
.ppb.is-open .ppb-launch { opacity: 0; pointer-events: none; transform: scale(.9); }
@media (max-width: 420px) { .ppb-launch__label { display: none; } .ppb-launch { padding: 0 8px; } }
@media (min-width: 960px) { .ppb-launch { right: 24px; bottom: 24px; } }

/* ---------- pannello ---------- */
.ppb-panel {
  position: fixed; z-index: 56; inset: 0;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--cream);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.15 0 0 0 0 0.14 0 0 0 0 0.12 0 0 0 .05 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0; transform: translateY(16px); transition: opacity .22s ease, transform .22s ease;
}
.ppb.is-open .ppb-panel { opacity: 1; transform: none; }
@media (min-width: 560px) {
  .ppb-panel {
    inset: auto 24px 24px auto; width: var(--ppb-w); height: var(--ppb-h);
    border-radius: 20px; border: 1px solid var(--line);
    box-shadow: 0 24px 60px rgba(38, 36, 31, .22), 0 2px 6px rgba(38, 36, 31, .08);
  }
}
@media (min-width: 560px) and (max-width: 959px) {
  .ppb-panel { bottom: calc(var(--mbar-h) + 16px); height: min(600px, calc(100vh - var(--mbar-h) - 100px)); }
}
/* планшеты: окно чуть шире и выше, чтобы карточки помещались лучше */
@media (min-width: 700px) and (min-height: 900px) {
  .ppb-panel { width: 440px; height: min(720px, calc(100vh - var(--mbar-h) - 120px)); }
}
/* телефон, повёрнутый горизонтально: невысокий экран → чат на весь экран */
@media (max-height: 560px) {
  .ppb-panel { inset: 0; width: auto; height: auto; border-radius: 0; border: 0; }
  .ppb-hello { display: none; }
  .ppb-head { padding-block: 8px; }
  .ppb-foot { display: none; }
}

/* intestazione */
.ppb-head {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 14px 18px; padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: var(--bordo); color: #fff;
}
.ppb-head::after { /* pennellata come nel sito */
  content: ''; position: absolute; left: 0; right: 0; bottom: -6px; height: 7px;
  background: var(--bordo);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 7' preserveAspectRatio='none'%3E%3Cpath d='M0 0h400v3c-30 3-60-2-95 1s-70 3-110 0-75 2-105 1S30 1 0 4z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 7' preserveAspectRatio='none'%3E%3Cpath d='M0 0h400v3c-30 3-60-2-95 1s-70 3-110 0-75 2-105 1S30 1 0 4z'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.ppb-head__avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--cream); color: var(--bordo);
}
.ppb-head__avatar svg { width: 24px; height: 24px; }
.ppb-head__txt { flex: 1; min-width: 0; }
.ppb-head__title { margin: 0; font: 500 1.25rem/1.15 var(--serif); font-variation-settings: 'SOFT' 100, 'WONK' 1; letter-spacing: -.01em; }
.ppb-head__sub { margin: 3px 0 0; font-size: .78rem; opacity: .85; display: flex; align-items: center; gap: 6px; }
.ppb-head__sub::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #9FD3A8; }
.ppb-head__btn {
  flex: none; width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: transparent; color: #fff; cursor: pointer; opacity: .85; transition: background .2s, opacity .2s;
}
.ppb-head__btn:hover { background: rgba(255, 255, 255, .14); opacity: 1; }
.ppb-head__btn svg { width: 20px; height: 20px; }
.ppb :focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; }

/* ---------- messaggi ---------- */
.ppb-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 16px 12px; display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.ppb-log > * { flex-shrink: 0; }
.ppb-msg { max-width: 86%; padding: 11px 14px; border-radius: 18px; font-size: .95rem; line-height: 1.5; word-wrap: break-word; animation: ppb-in .25s ease both; }
.ppb-msg p { margin: 0 0 .5em; } .ppb-msg p:last-child { margin: 0; }
.ppb-msg a { color: inherit; }
.ppb-msg strong { font-weight: 700; }
.ppb-msg ul { margin: .3em 0 .5em; padding-left: 1.2em; }
.ppb-msg--bot { align-self: flex-start; background: #FBF8F2; border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.ppb-msg--bot a { color: var(--bordo); }
.ppb-msg--user { align-self: flex-end; background: var(--bordo); color: #fff; border-bottom-right-radius: 6px; }
.ppb-msg--note { align-self: center; max-width: 92%; background: transparent; color: var(--ash); font-size: .8rem; text-align: center; padding: 4px 8px; }
.ppb-msg--note a { color: var(--ash); }
@keyframes ppb-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* benvenuto */
.ppb-hello { text-align: center; padding: 6px 8px 8px; animation: ppb-in .3s ease both; }
.ppb-hello__kicker { font: 600 .7rem/1.3 var(--sans); letter-spacing: .14em; text-transform: uppercase; color: var(--bordo); margin: 0 0 6px; }
.ppb-hello__title { font: 500 1.55rem/1.15 var(--serif); font-variation-settings: 'SOFT' 100, 'WONK' 1; margin: 0 0 6px; }
.ppb-hello__text { color: var(--ash); font-size: .9rem; margin: 0 auto; max-width: 30ch; }

/* digitazione */
.ppb-typing { align-self: flex-start; display: inline-flex; gap: 5px; padding: 14px 16px; background: #FBF8F2; border: 1px solid var(--line); border-radius: 18px; border-bottom-left-radius: 6px; }
.ppb-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--bordo); opacity: .35; animation: ppb-dot 1.1s infinite ease-in-out; }
.ppb-typing span:nth-child(2) { animation-delay: .15s; } .ppb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ppb-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: .9; transform: translateY(-3px); } }

/* ---------- schede vino ---------- */
.ppb-wines { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 6px; margin: 0 -16px; padding-inline: 16px; animation: ppb-in .3s ease both; }
.ppb-wines::-webkit-scrollbar { height: 0; }
.ppb-wine {
  --accent: var(--bordo);
  flex: 0 0 224px; scroll-snap-align: start; display: grid; grid-template-columns: 56px 1fr; gap: 4px 12px; align-items: start;
  padding: 12px; border-radius: 16px; background: #FBF8F2; border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
}
.ppb-wines--one .ppb-wine { flex-basis: 100%; }

/* carosello: frecce per il mouse, punti per sapere quante schede ci sono */
.ppb-winesbox { position: relative; }
.ppb-nav {
  position: absolute; top: calc(50% - 26px); z-index: 2; width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--cream); color: var(--bordo); display: none; place-items: center;
  font: 500 1.5rem/1 var(--serif); padding: 0 0 3px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(38, 36, 31, .18); transition: opacity .2s, background .2s, color .2s;
}
.ppb-nav:hover { background: var(--bordo); color: #fff; }
.ppb-nav[disabled] { opacity: 0; pointer-events: none; }
.ppb-nav--prev { left: -6px; }
.ppb-nav--next { right: -6px; }
@media (hover: hover) and (pointer: fine) { .ppb-winesbox.is-scrollable .ppb-nav { display: grid; } }
.ppb-dots { display: none; justify-content: center; gap: 6px; padding-top: 2px; }
.ppb-winesbox.is-scrollable .ppb-dots { display: flex; }
.ppb-dots span { width: 6px; height: 6px; border-radius: 99px; background: rgba(100, 39, 54, .22); transition: width .2s, background .2s; }
.ppb-dots span.is-on { width: 18px; background: var(--bordo); }
.ppb-wine__img { grid-row: span 3; width: 56px; height: 72px; object-fit: contain; }
.ppb-wine__name { margin: 0; font: 500 1.08rem/1.15 var(--serif); }
.ppb-wine__name a { color: var(--basalt); text-decoration: none; }
.ppb-wine__name a:hover { color: var(--bordo); }
.ppb-wine__vintage { font-family: var(--sans); font-size: .8rem; color: var(--ash); font-weight: 500; }
.ppb-wine__meta { margin: 0; font-size: .76rem; color: var(--ash); line-height: 1.35; }
.ppb-wine__price { margin: 0; font-size: .82rem; }
.ppb-wine__price b { font-size: .95rem; }
.ppb-wine__badges { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.ppb-badge { display: inline-block; padding: 3px 8px; border-radius: 99px; font: 600 .66rem/1.2 var(--sans); letter-spacing: .04em; text-transform: uppercase; background: var(--paper); color: var(--basalt); }
.ppb-badge--forest { background: var(--forest); color: #fff; }
.ppb-badge--rose { background: var(--rose); }
.ppb-badge--ash { background: var(--basalt); color: var(--cream); }
.ppb-wine__act { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.ppb-add {
  flex: 1; min-height: 38px; padding: 0 12px; border-radius: 99px; border: 1.5px solid var(--accent);
  background: transparent; color: var(--accent); font: 600 .84rem/1 var(--sans); cursor: pointer; transition: background .2s, color .2s;
}
.ppb-add:hover { background: var(--accent); color: #fff; }
.ppb-add[disabled] { opacity: .45; cursor: default; background: transparent; color: var(--accent); }
.ppb-step { flex: 1; display: flex; align-items: center; justify-content: space-between; min-height: 38px; border-radius: 99px; background: var(--accent); color: #fff; padding: 0 4px; }
.ppb-step button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .18); color: #fff; font: 600 1.05rem/1 var(--sans); cursor: pointer; }
.ppb-step button:hover { background: rgba(255, 255, 255, .3); }
.ppb-step span { font: 600 .82rem/1 var(--sans); }

/* riepilogo richiesta */
.ppb-cart {
  align-self: stretch; padding: 14px; border-radius: 16px; background: var(--basalt); color: var(--cream);
  animation: ppb-in .3s ease both;
}
.ppb-cart__title { margin: 0 0 8px; font: 500 1.1rem/1.2 var(--serif); }
.ppb-cart ul { list-style: none; margin: 0 0 10px; padding: 0; font-size: .86rem; }
.ppb-cart li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(245, 239, 227, .14); }
.ppb-cart__total { display: flex; justify-content: space-between; align-items: baseline; font-size: .86rem; margin-bottom: 4px; }
.ppb-cart__total b { font-size: 1.05rem; }
.ppb-cart__note { margin: 0 0 12px; font-size: .74rem; opacity: .7; }

/* azioni / contatto umano */
.ppb-actions { display: flex; flex-wrap: wrap; gap: 8px; animation: ppb-in .3s ease both; }
.ppb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 16px; border-radius: 99px; border: 1.5px solid var(--bordo);
  background: var(--bordo); color: #fff; font: 600 .88rem/1 var(--sans); text-decoration: none; cursor: pointer;
  transition: background .2s, color .2s;
}
.ppb-btn:hover { background: var(--bordo-d); color: #fff; }
.ppb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ppb-btn--wa { background: var(--forest); border-color: var(--forest); }
.ppb-btn--wa:hover { background: #243a2d; }
.ppb-btn--ghost { background: transparent; color: var(--bordo); }
.ppb-btn--ghost:hover { background: var(--bordo); color: #fff; }
.ppb-btn--light { background: var(--cream); border-color: var(--cream); color: var(--basalt); }
.ppb-btn--light:hover { background: #fff; color: var(--basalt); }
.ppb-btn--block { width: 100%; }
.ppb-handoff { align-self: stretch; padding: 14px; border-radius: 16px; background: #FBF8F2; border: 1px dashed rgba(47, 74, 58, .45); animation: ppb-in .3s ease both; }
.ppb-handoff p { margin: 0 0 10px; font-size: .88rem; color: var(--ash); }

/* ---------- suggerimenti ---------- */
.ppb-chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px 2px; flex: none; }
.ppb-chips::-webkit-scrollbar { height: 0; }
.ppb-chip {
  flex: none; padding: 8px 14px; border-radius: 99px; border: 1px solid rgba(100, 39, 54, .35);
  background: rgba(251, 248, 242, .8); color: var(--bordo); font: 500 .84rem/1.1 var(--sans); cursor: pointer; white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}
.ppb-chip:hover { background: var(--bordo); color: #fff; border-color: var(--bordo); }

/* ---------- campo di testo ---------- */
.ppb-form { flex: none; display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
.ppb-input {
  flex: 1; min-height: 46px; max-height: 120px; resize: none; padding: 12px 16px; border-radius: 23px;
  border: 1.5px solid var(--line); background: #fff; color: var(--basalt);
  font: 400 16px/1.35 var(--sans); /* 16px: niente zoom su iPhone */
  overflow-y: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.ppb-input::placeholder { color: #9A948A; }
.ppb-input:focus { outline: none; border-color: var(--bordo); box-shadow: 0 0 0 3px rgba(100, 39, 54, .12); }
.ppb-send {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--bordo); color: #fff; cursor: pointer; transition: background .2s, transform .15s, opacity .2s;
}
.ppb-send:hover { background: var(--bordo-d); }
.ppb-send:active { transform: scale(.94); }
.ppb-send[disabled] { opacity: .4; cursor: default; }
.ppb-send svg { width: 20px; height: 20px; }
.ppb-foot { flex: none; margin: 0; padding: 0 16px 10px; text-align: center; font-size: .7rem; color: var(--ash); }
.ppb-foot a { color: var(--ash); }

/* con la chat aperta il messaggio "aggiunto" del sito non copre il campo di testo */
body.ppb-open .toast { bottom: calc(118px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 560px) { body.ppb-open .toast { left: auto; right: 440px; transform: translate(0, 20px); } body.ppb-open .toast.is-on { transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .ppb *, .ppb *::before { animation: none !important; transition: none !important; }
}
