@font-face {
  font-family: "Mozilla Text";
  src: url("fonts/mozilla-text-latin.woff2") format("woff2");
  font-weight: 200 700;
  font-display: swap;
}
@font-face {
  font-family: "Noto Sans";
  src: url("fonts/noto-sans-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --blue: #234d9a;
  --blue-light: #2857af;
  --navy: #17336e;
  --navy-dark: #122a5c;
  --yellow: #ffd503;
  --yellow-dark: #f2c800;
  --red: #e5261e;
  --red-dark: #b0120c;
  --green: #008d37;
  --ink: #262221;
  --muted: #5f6673;
  --bg: #f2f2f2;
  --card: #ffffff;
  --line: #dfe3ea;
  --bubble: #eef2f9;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(18, 42, 92, .12);
  --head: "Mozilla Text", "Noto Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
main { flex: 1; }
[hidden] { display: none !important; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Barra superiore, come l'header del sito Pewex */
.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 10; box-shadow: 0 2px 10px rgba(0,0,0,.18); }
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 10px 20px; display: flex; align-items: center; gap: 14px; }
.brand img { display: block; width: 56px; height: 56px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title { font-family: var(--head); font-weight: 700; font-size: 20px; }
.brand-sub { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; opacity: .8; }
.badge { margin-left: auto; background: var(--yellow); color: var(--blue); font-weight: 700; font-size: 12px; text-transform: uppercase; padding: 5px 12px; border-radius: var(--radius); }

/* Hero */
.hero {
  background: url("img/p-texture.svg") center / cover no-repeat, linear-gradient(160deg, var(--blue-light), var(--blue) 45%, var(--navy));
  color: #fff;
}
.hero-inner { max-width: 1120px; margin: 0 auto; padding: 48px 20px 56px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; }
.eyebrow { display: inline-block; background: var(--red); color: #fff; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; padding: 6px 12px; border-radius: 8px; }
.hero h1 { font-family: var(--head); font-weight: 700; font-size: clamp(30px, 4.2vw, 46px); line-height: 1.08; margin: 18px 0 14px; }
.hero p { font-size: 17px; line-height: 1.55; margin: 0; opacity: .92; max-width: 34em; }

.start-card { background: var(--card); color: var(--ink); border-radius: 16px; padding: 26px; box-shadow: var(--shadow); border-top: 6px solid var(--yellow); }
.start-card h2 { font-family: var(--head); color: var(--blue); font-size: 24px; margin: 0 0 16px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px; }
label { font-size: 13px; font-weight: 600; color: var(--blue); display: flex; flex-direction: column; gap: 6px; }
.opt { font-weight: 400; color: var(--muted); font-size: 11px; }
input { font: inherit; font-size: 15px; padding: 11px 12px; border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); background: #fff; min-width: 0; }
input:focus { outline: 3px solid rgba(35, 77, 154, .18); border-color: var(--blue); }
.actions { display: flex; flex-direction: column; gap: 10px; }
.hint { font-size: 12px; line-height: 1.5; color: var(--muted); margin: 16px 0 0; }

/* Bottoni: giallo con testo blu e maiuscolo, come le call to action del sito */
.btn { font: inherit; cursor: pointer; border: 2px solid transparent; border-radius: var(--radius); padding: 12px 20px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 600; font-size: 16px; text-transform: uppercase; letter-spacing: .02em; transition: background .15s, transform .1s; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-yellow { background: var(--yellow); color: var(--blue); }
.btn-yellow:hover { background: var(--yellow-dark); }
.btn-outline { background: #fff; color: var(--blue); border-color: var(--blue); }
.btn-outline:hover { background: var(--bubble); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-dark); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-sm .ic { width: 16px; height: 16px; }

/* Reparti e passaggi */
.section { max-width: 1120px; margin: 0 auto; padding: 40px 20px 48px; }
.section-title { font-family: var(--head); color: var(--blue); font-size: 28px; text-align: center; margin: 0 0 22px; }
.section-title:not(:first-child) { margin-top: 44px; }
.reparti { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.reparti li { background: var(--card); border-radius: 14px; padding: 20px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; box-shadow: 0 2px 10px rgba(18, 42, 92, .06); }
.reparti strong { font-family: var(--head); color: var(--blue); font-size: 18px; }
.reparti span:last-child { font-size: 13px; color: var(--muted); line-height: 1.4; }
.rep-ic { width: 56px; height: 56px; border-radius: 50%; background: var(--yellow); color: var(--blue); display: grid; place-items: center; }
.rep-ic .ic { width: 28px; height: 28px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.steps li { background: var(--card); border-radius: 14px; padding: 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: 0 2px 10px rgba(18, 42, 92, .06); }
.steps b { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-family: var(--head); font-size: 18px; }
.steps strong { display: block; font-family: var(--head); color: var(--blue); font-size: 17px; margin-bottom: 4px; }
.steps span { font-size: 14px; color: var(--muted); line-height: 1.45; }

/* Conversazione */
#call { position: relative; padding: 24px 16px 32px; }
#call::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 200px; background: url("img/p-texture.svg") center / cover no-repeat, linear-gradient(160deg, var(--blue-light), var(--blue) 45%, var(--navy)); }
.call-panel { position: relative; max-width: 760px; margin: 0 auto; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.call-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--navy); color: #fff; }
.call-title { display: flex; flex-direction: column; flex: 1; line-height: 1.2; }
.call-title strong { font-family: var(--head); font-size: 17px; }
.state { font-size: 13px; opacity: .85; }
.state::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); margin-right: 6px; vertical-align: 1px; }

.stage { display: flex; justify-content: center; padding: 22px 16px 8px; background: linear-gradient(var(--bubble), #fff); }
#call.is-chat .stage { display: none; }
#avatar-video { width: 100%; max-height: 380px; border-radius: 12px; background: #000; object-fit: cover; }
.orb { width: 132px; height: 132px; border-radius: 50%; position: relative; display: grid; place-items: center; }
.orb img { width: 100%; height: 100%; position: relative; z-index: 1; filter: drop-shadow(0 6px 14px rgba(18, 42, 92, .25)); transition: transform .25s; }
.orb::before, .orb::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 3px solid var(--yellow); opacity: 0; }
.orb.listening::before { animation: ring 2.4s ease-out infinite; border-color: var(--blue); }
.orb.speaking img { animation: pulse .9s ease-in-out infinite; }
.orb.speaking::before { animation: ring 1.2s ease-out infinite; }
.orb.speaking::after { animation: ring 1.2s ease-out .6s infinite; }
.orb.thinking::before { opacity: 1; inset: -8px; border-color: var(--yellow) transparent var(--blue) transparent; animation: spin 1.1s linear infinite; }
.orb.connecting img, .orb.initializing img, .orb.ended img { opacity: .6; }
@keyframes ring { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(1.45); opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.06); } }
@keyframes spin { to { transform: rotate(360deg); } }

.log { height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 16px; }
#call.is-chat .log { height: min(560px, calc(100vh - 290px)); }
.msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; line-height: 1.45; font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--blue); color: #fff; border-bottom-right-radius: 4px; }
.msg.agent { align-self: flex-start; background: var(--bubble); color: var(--ink); border-bottom-left-radius: 4px; }
.msg.sys { align-self: center; background: transparent; color: var(--muted); font-size: 12px; padding: 2px 8px; }
.msg img { max-width: 200px; border-radius: 10px; display: block; }

.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fafbfd; }
.composer #text { flex: 1; border-radius: 999px; padding-left: 16px; }
.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center; background: var(--bubble); color: var(--blue); transition: background .15s; }
.icon-btn:hover { background: #dfe6f3; }
.icon-btn.send { background: var(--yellow); color: var(--blue); }
.icon-btn.send:hover { background: var(--yellow-dark); }
.icon-btn.mic { background: var(--blue); color: #fff; }
.icon-btn.mic.off { background: var(--red); }

.footer { background: var(--navy); color: rgba(255,255,255,.8); font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px 20px; }

@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; gap: 28px; padding: 32px 18px 40px; }
  .reparti { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .topbar-inner { padding: 8px 14px; }
  .brand img { width: 46px; height: 46px; }
  .brand-title { font-size: 17px; }
  .fields { grid-template-columns: 1fr; }
  .start-card { padding: 20px; }
  .btn { font-size: 15px; }
  #call { padding: 0; }
  #call::before { display: none; }
  .call-head img { display: none; }
  .call-panel { border-radius: 0; min-height: calc(100vh - 62px); }
  .log, #call.is-chat .log { height: auto; flex: 1; min-height: 240px; }
  .footer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .orb img, .orb::before, .orb::after { animation: none !important; }
}
