/* Chat pubblica di Altea, l'assistente AI di TAU Software — design system "Altea" (src/___docs/altea, colori di
   "TAU - Applicativi", tema chiaro) con le animazioni della Home di TAU AI.
   Due stati: .is-empty (marchio, hero e barra al centro) e conversazione (barra in basso, messaggi al centro).
   Stati aggiunti dallo script: .has-text (si sta scrivendo: il marchio si anima), .is-waiting sulla barra (risposta in arrivo). */

/* Angolo animabile del bordo della barra in attesa (dove @property non c'è, il bordo resta fermo) */
@property --angle { syntax: "<angle>"; inherits: false; initial-value: 0deg; }

:root {
    --primary: #02A4B9;
    --primary-dark: #016C7A;          /* testo turchese su bianco: 5.6:1 */
    --secondary: #5C01B7;
    --cyan: #22D3EE;
    --gradient: linear-gradient(90deg, #5C01B7 0%, #02A4B9 100%);
    --gradient-shimmer: linear-gradient(120deg, #5C01B7 0%, #02A4B9 30%, #22D3EE 50%, #02A4B9 70%, #5C01B7 100%);
    --gradient-user: linear-gradient(120deg, #5C01B7 0%, #016C7A 100%);   /* testo bianco leggibile su tutta la bolla */
    --bg: #F6F6F6;
    --glass: rgba(255, 255, 255, .82);
    --glass-strong: rgba(255, 255, 255, .94);
    --text: #101828;
    --text-2: #344054;
    --muted: #667085;
    --border: rgba(16, 24, 40, .09);
    --error: #b42318;
    --column: 780px;
    --gutter: max(16px, calc((100% - var(--column)) / 2));
    --ease-out: cubic-bezier(.2, .8, .2, 1);
    color-scheme: light;
}

* { box-sizing: border-box; }

/* L'attributo hidden vince sui display impostati qui sotto */
[hidden] { display: none !important; }

html, body { height: 100%; margin: 0; }

body {
    font-family: "Montserrat", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

button { font: inherit; }

button:focus-visible, textarea:focus-visible, a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ================= Sfondo: velo, aloni che si muovono lentamente, particelle ================= */
.backdrop {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background:
        radial-gradient(1200px 600px at 10% -10%, rgba(2, 164, 185, .14), transparent 60%),
        radial-gradient(900px 600px at 110% 110%, rgba(92, 1, 183, .12), transparent 60%),
        var(--bg);
}

.backdrop canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: .9;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .38;
    will-change: transform;
}

.glow-1 { width: 520px; height: 520px; background: #02A4B9; top: -160px; left: -140px; animation: drift-1 22s ease-in-out infinite alternate; }
.glow-2 { width: 460px; height: 460px; background: #5C01B7; bottom: -180px; right: -120px; opacity: .26; animation: drift-2 26s ease-in-out infinite alternate; }
.glow-3 { width: 340px; height: 340px; background: #22D3EE; top: 40%; left: 55%; opacity: .2; animation: drift-3 30s ease-in-out infinite alternate; }

@keyframes drift-1 { to { transform: translate(180px, 120px) scale(1.15); } }
@keyframes drift-2 { to { transform: translate(-200px, -140px) scale(1.1); } }
@keyframes drift-3 { to { transform: translate(-260px, 90px) scale(.9); } }

/* ================= Struttura ================= */
.chat {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    height: 100dvh;
}

/* A pagina vuota, se lo schermo è basso (telefono in orizzontale), si scorre invece di tagliare barra e suggerimenti */
.chat.is-empty { overflow-x: hidden; overflow-y: auto; }

/* ---- Barra in alto: trasparente a pagina vuota, vetro con filetto di marca nella conversazione ---- */
.topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px var(--gutter);
    position: relative;
    transition: background-color .4s ease, box-shadow .4s ease;
}

.chat:not(.is-empty) .topbar {
    background: var(--glass);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    box-shadow: 0 1px 0 var(--border);
}

.chat:not(.is-empty) .topbar::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -2px;
    height: 2px;
    background: var(--gradient);
    animation: line-in .6s var(--ease-out) both;
    transform-origin: left;
}

@keyframes line-in { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Logo TAU a colori (gradiente di TAU Flotta, logo-tau-colori.svg): a pagina vuota è al centro e grande, nella
   conversazione torna nella barra accanto ad Altea */
.topbar-logo { flex: 0 0 auto; display: block; width: 46px; height: auto; transition: width .5s var(--ease-out); }
.chat.is-empty .topbar { justify-content: center; padding-top: 28px; }
.chat.is-empty .topbar-logo { width: 150px; }
.chat.is-empty .topbar-sep, .chat.is-empty .topbar-avatar,
.chat.is-empty .topbar-heading, .chat.is-empty #btn-reset { display: none; }
.chat.is-empty #btn-close { position: absolute; right: 14px; top: 12px; }

/* Separatore e avatar di Altea accanto al logo TAU, nella conversazione */
.topbar-sep { flex: 0 0 auto; width: 1px; height: 28px; background: var(--border); transition: opacity .35s ease; }
.topbar-avatar { flex: 0 0 auto; display: block; width: 32px; height: 32px; border-radius: 50%; transition: opacity .35s ease, transform .35s ease; }

.topbar-heading {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    transition: opacity .35s ease, transform .35s ease;
}

.topbar-title { font-size: 15px; font-weight: 700; line-height: 1.25; }

.topbar-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #079455;
    box-shadow: 0 0 0 0 rgba(7, 148, 85, .5);
    animation: status-pulse 2.4s ease-out infinite;
}

@keyframes status-pulse {
    0% { box-shadow: 0 0 0 0 rgba(7, 148, 85, .45); }
    70%, 100% { box-shadow: 0 0 0 7px rgba(7, 148, 85, 0); }
}

.icon-btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    transition: background-color .2s ease, transform .2s ease;
}

.icon-btn:hover { background: rgba(2, 164, 185, .1); transform: rotate(-12deg); }
#btn-close:hover { transform: none; }
.icon-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* ---- Hero (solo a pagina vuota) ---- */
.hero {
    display: none;
    text-align: center;
    padding: 0 var(--gutter);
}

.chat.is-empty .hero {
    display: block;
    margin-top: auto;
}

/* Marchio di Altea (design system "Altea"): all'apertura la A si disegna e la scintilla si accende; poi respira e la
   scintilla brilla; mentre si scrive il marchio si ingrandisce e la scintilla gira. Livelli separati perché entrata,
   respiro e scintilla usano tutte transform */
.mark {
    position: relative;
    width: 88px;
    height: 88px;
    margin: 0 auto 22px;
    animation: mark-in .9s var(--ease-out) both;
}

.mark::before {
    content: "";
    position: absolute;
    inset: -22px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(34, 211, 238, .32) 0%, rgba(92, 1, 183, .16) 45%, transparent 70%);
    filter: blur(8px);
    animation: halo 5s ease-in-out infinite;
}

.mark-core {
    position: absolute;
    inset: 0;
    animation: breathe 5s ease-in-out 1.4s infinite;
    transition: transform .5s var(--ease-out);
}

.mark-core svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    filter: drop-shadow(0 10px 22px rgba(92, 1, 183, .28));
}

.mark-a { stroke-dasharray: 100; animation: draw 1.1s var(--ease-out) .1s both; }

.mark-spark {
    transform-box: fill-box;
    transform-origin: center;
    animation: spark-in .6s var(--ease-out) .9s both, twinkle 4s ease-in-out 1.6s infinite;
}

.chat.has-text .mark-core { transform: scale(1.08); }
.chat.has-text .mark-spark { animation: spark-in .6s var(--ease-out) .9s both, spin 1.4s linear infinite; }
.chat.has-text .mark::before { animation-duration: 1.6s; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes breathe { 50% { transform: scale(1.06); } }
@keyframes halo { 0%, 100% { opacity: .65; transform: scale(.95); } 50% { opacity: 1; transform: scale(1.12); } }
@keyframes draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes spark-in { from { opacity: 0; transform: scale(0) rotate(-90deg); } to { opacity: 1; transform: none; } }
@keyframes twinkle { 0%, 100% { transform: none; } 50% { transform: scale(1.2) rotate(90deg); } }
@keyframes mark-in {
    from { opacity: 0; transform: translateY(14px); filter: blur(8px); }
    to { opacity: 1; transform: none; filter: blur(0); }
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--glass);
    border: 1px solid var(--border);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--secondary);
}

.eyebrow::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 10px var(--primary);
}

/* Titolo con il gradiente che scorre ("onda" della Home di TAU AI) */
.hero-title {
    margin: 22px 0 14px;
    font-size: clamp(34px, 6.2vw, 64px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -.03em;
    background: var(--gradient-shimmer);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: rise-in .8s var(--ease-out) .14s both, shimmer 7s ease-in-out 1s infinite alternate;
    filter: drop-shadow(0 8px 30px rgba(2, 164, 185, .18));
}

@keyframes shimmer { from { background-position: 0% 50%; } to { background-position: 100% 50%; } }

.hero-subtitle {
    margin: 0 auto;
    max-width: 560px;
    font-size: 16px;
    color: var(--text-2);
    animation: rise-in .7s var(--ease-out) .22s both;
}

.eyebrow { animation: rise-in .7s var(--ease-out) .08s both; }

/* Entrata sfocata dal basso, come i titoli della Home */
@keyframes rise-in {
    from { opacity: 0; transform: translateY(26px); filter: blur(12px); }
    to { opacity: 1; transform: none; filter: blur(0); }
}

/* ---- Messaggi (solo nella conversazione) ---- */
.messages {
    display: none;
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 28px var(--gutter) 12px;
    flex-direction: column;
    gap: 18px;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    position: relative;               /* riferimento di offsetTop per portare in vista l'inizio delle risposte lunghe */
}

.chat:not(.is-empty) .messages { display: flex; }

.msg {
    display: flex;
    gap: 10px;
    max-width: 92%;
    animation: msg-in .45s var(--ease-out) both;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.msg-user { align-self: flex-end; }
.msg-bot { align-self: flex-start; }

/* Avatar: altea-avatar.svg; mentre Altea cerca, la scintilla dell'avatar (SVG in linea) gira e l'avatar pulsa */
.avatar {
    position: relative;
    overflow: hidden;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(2, 164, 185, .35);
}

.avatar img, .avatar svg { display: block; width: 100%; height: 100%; }

.avatar-spark { transform-box: fill-box; transform-origin: center; }
.msg-typing .avatar-spark { animation: spin 1.6s linear infinite; }
.msg-typing .avatar { animation: avatar-glow 1.6s ease-in-out infinite; }

@keyframes avatar-glow {
    50% { box-shadow: 0 0 0 4px rgba(2, 164, 185, .14), 0 4px 18px rgba(92, 1, 183, .4); }
}

.msg-body { min-width: 0; display: flex; flex-direction: column; }
.msg-user .msg-body { align-items: flex-end; }

.bubble {
    padding: 11px 16px;
    border-radius: 18px;
    overflow-wrap: anywhere;
}

.msg-user .bubble {
    background: var(--gradient-user);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 8px 22px rgba(92, 1, 183, .22);
}

.msg-user { animation: msg-user-in .5s var(--ease-out) both; }

@keyframes msg-user-in {
    from { opacity: 0; transform: translate(24px, 10px) scale(.94); }
    to { opacity: 1; transform: none; }
}

.msg-bot .bubble {
    background: var(--glass-strong);
    border: 1px solid var(--border);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top-left-radius: 6px;
    box-shadow: 0 8px 26px rgba(16, 24, 40, .06);
}

.msg-bot.refusal .bubble { background: rgba(242, 244, 247, .94); }
.msg-bot.error .bubble { border-color: rgba(217, 45, 32, .35); color: var(--error); }
.msg-bot.error .avatar { background: #d92d20; box-shadow: none; }
.msg-bot.error .avatar img { width: 55%; height: 55%; }

/* Risposta appena arrivata: paragrafi e punti compaiono a cascata (ritardi dallo script). Il testo è già tutto nella
   pagina: i lettori di schermo lo leggono subito */
.reveal { animation: block-in .5s var(--ease-out) both; }

@keyframes block-in {
    from { opacity: 0; transform: translateY(8px); filter: blur(4px); }
    to { opacity: 1; transform: none; filter: blur(0); }
}

.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px; padding-left: 20px; }
.bubble li { margin-bottom: 4px; }
.bubble li::marker { color: var(--primary); }
.bubble strong { font-weight: 700; }
.msg-bot .bubble strong { color: var(--primary-dark); }
.bubble a { color: var(--secondary); font-weight: 600; }

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.source {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    color: var(--primary-dark);
    background: rgba(2, 164, 185, .1);
    border: 1px solid rgba(2, 164, 185, .22);
}

/* Domande suggerite sotto l'ultima risposta */
.followups {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.followup {
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid rgba(2, 164, 185, .35);
    background: var(--glass);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--primary-dark);
    cursor: pointer;
    animation: rise-in .5s var(--ease-out) both;
    transition: transform .2s ease, background-color .2s ease, box-shadow .2s ease;
}

.followup::before { content: "↳ "; color: var(--primary); }

.followup:hover {
    transform: translateY(-2px);
    background: rgba(2, 164, 185, .1);
    box-shadow: 0 6px 16px rgba(2, 164, 185, .15);
}

body.embed .followup { font-size: 12.5px; padding: 6px 12px; }

/* Attesa: tre puntini che pulsano in sequenza (indicatore del design system) e una frase che cambia per fasi,
   attraversata da un riflesso */
.typing { display: inline-flex; align-items: center; gap: 12px; padding: 12px 16px; }
.dots { display: inline-flex; gap: 5px; }
.dots i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gradient);
    animation: dot 1.2s infinite ease-in-out;
}
.dots i:nth-child(2) { animation-delay: .15s; }
.dots i:nth-child(3) { animation-delay: .3s; }

.typing-text {
    font-size: 13px;
    font-weight: 500;
    background: linear-gradient(90deg, var(--muted) 0%, var(--muted) 38%, var(--primary) 50%, var(--muted) 62%, var(--muted) 100%);
    background-size: 250% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: text-shine 2.2s linear infinite;
}

.typing-text.swap { animation: text-shine 2.2s linear infinite, swap-in .45s var(--ease-out); }

@keyframes text-shine { from { background-position: 100% 0; } to { background-position: 0% 0; } }
@keyframes swap-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@keyframes dot {
    0%, 80%, 100% { opacity: .3; transform: translateY(0) scale(.8); }
    40% { opacity: 1; transform: translateY(-4px) scale(1); }
}

/* ---- Barra di input: al centro a pagina vuota, in basso nella conversazione ---- */
.composer-wrap {
    position: relative;
    flex: 0 0 auto;
    padding: 12px var(--gutter) 6px;
}

/* "Torna in fondo": compare sopra la barra quando si risale in una conversazione lunga */
.to-end {
    position: absolute;
    left: 50%;
    top: -38px;
    width: 40px;
    height: 40px;
    margin-left: -20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    background: var(--glass-strong);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    color: var(--primary-dark);
    box-shadow: 0 8px 22px rgba(16, 24, 40, .12);
    cursor: pointer;
    opacity: 0;
    transform: translateY(10px) scale(.8);
    pointer-events: none;
    transition: opacity .25s ease, transform .3s var(--ease-out), background-color .2s ease;
}

.to-end.show { opacity: 1; transform: none; pointer-events: auto; }
.to-end:hover { background: #fff; }
.to-end svg { width: 22px; height: 22px; fill: currentColor; }

.chat.is-empty .composer-wrap {
    margin-bottom: auto;
    padding-top: 34px;
    animation: rise-in .7s var(--ease-out) .3s both;
}

.composer {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 8px 8px 8px 18px;
    border-radius: 30px;
    border: 1.5px solid transparent;
    background:
        linear-gradient(var(--glass-strong), var(--glass-strong)) padding-box,
        linear-gradient(120deg, rgba(92, 1, 183, .28), rgba(2, 164, 185, .35)) border-box;
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
    box-shadow: 0 18px 50px rgba(2, 164, 185, .16), 0 2px 6px rgba(16, 24, 40, .05);
    transition: box-shadow .3s ease, transform .3s ease;
}

.composer:focus-within {
    background:
        linear-gradient(#fff, #fff) padding-box,
        linear-gradient(120deg, #5C01B7, #02A4B9, #22D3EE) border-box;
    box-shadow: 0 0 0 5px rgba(2, 164, 185, .12), 0 22px 60px rgba(2, 164, 185, .22);
}

/* In attesa della risposta il bordo di marca gira attorno alla barra */
.composer.is-waiting {
    background:
        linear-gradient(#fff, #fff) padding-box,
        conic-gradient(from var(--angle), #5C01B7, #02A4B9, #22D3EE, #7C3AED, #5C01B7) border-box;
    box-shadow: 0 0 0 5px rgba(2, 164, 185, .1), 0 22px 60px rgba(92, 1, 183, .18);
    animation: border-spin 2.2s linear infinite;
}

@keyframes border-spin { to { --angle: 360deg; } }

.chat.is-empty .composer { padding: 10px 10px 10px 20px; }

.composer-icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    margin-bottom: 12px;
    fill: var(--primary);
}

.composer textarea {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    font-size: 16px;
    line-height: 1.45;
    min-height: 46px;
    max-height: 140px;
    padding: 12px 0;
    border: 0;
    outline: none;
    resize: none;
    overflow-y: hidden;
    background: transparent;
    color: var(--text);
}

.composer textarea::placeholder { color: #98a2b3; }

.send-btn {
    position: relative;
    flex: 0 0 auto;
    width: 46px;
    height: 46px;
    border: 0;
    border-radius: 50%;
    background: var(--gradient);
    background-size: 160% 100%;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 20px rgba(92, 1, 183, .28);
    transition: transform .2s ease, box-shadow .2s ease, background-position .4s ease, opacity .2s ease;
}

.send-btn:hover:not(:disabled) { transform: scale(1.07); background-position: 100% 0; box-shadow: 0 10px 26px rgba(2, 164, 185, .4); }
.send-btn:active:not(:disabled) { transform: scale(.96); }
.send-btn svg { width: 20px; height: 20px; fill: currentColor; margin-left: 2px; }
.send-btn:disabled { opacity: .45; cursor: default; box-shadow: none; }

/* Invio: l'aereo parte a destra e rientra da sinistra, con un'onda attorno al pulsante */
.send-btn.launch { opacity: 1; }
.send-btn.launch svg { animation: launch .65s var(--ease-out); }
.send-btn.launch::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--primary);
    animation: ring .65s ease-out forwards;
    pointer-events: none;
}

@keyframes launch {
    0% { transform: none; opacity: 1; }
    40% { transform: translate(24px, -8px) scale(.6); opacity: 0; }
    41% { transform: translate(-20px, 6px) scale(.6); opacity: 0; }
    100% { transform: none; opacity: 1; }
}

@keyframes ring { from { transform: scale(1); opacity: .8; } to { transform: scale(1.8); opacity: 0; } }

/* Suggerimenti: compaiono uno dopo l'altro sotto la barra */
.suggestions {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 18px;
}

.chat.is-empty .suggestions { display: flex; }

.chip {
    font-size: 13.5px;
    font-weight: 500;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--glass);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    color: var(--text-2);
    cursor: pointer;
    animation: rise-in .6s var(--ease-out) both;
    transition: transform .2s ease, border-color .2s ease, color .2s ease, box-shadow .2s ease;
}

.chip:nth-child(1) { animation-delay: .4s; }
.chip:nth-child(2) { animation-delay: .45s; }
.chip:nth-child(3) { animation-delay: .5s; }
.chip:nth-child(4) { animation-delay: .55s; }
.chip:nth-child(5) { animation-delay: .6s; }

.chip:hover {
    transform: translateY(-2px);
    border-color: rgba(2, 164, 185, .5);
    color: var(--primary-dark);
    box-shadow: 0 8px 20px rgba(2, 164, 185, .15);
}

/* ---- Nota in fondo ---- */
.note {
    flex: 0 0 auto;
    padding: 6px var(--gutter) 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    font-size: 11px;
    line-height: 1.45;
    color: var(--muted);
    text-align: center;
}

.note a { color: var(--secondary); font-weight: 600; }

/* ================= Dentro il widget (?embed=1): riquadro stretto ================= */
body.embed { --column: 100%; font-size: 14px; }
body.embed .topbar { padding: 12px 14px; }
body.embed .hero, body.embed .composer-wrap, body.embed .messages { padding-left: 14px; padding-right: 14px; }
body.embed .note { padding-left: 14px; padding-right: 14px; font-size: 10.5px; }
body.embed .hero-title { font-size: 30px; margin: 14px 0 10px; }
body.embed .hero-subtitle { font-size: 13.5px; }
body.embed .eyebrow { font-size: 10.5px; padding: 5px 11px; }
body.embed .chat.is-empty .composer-wrap { padding-top: 22px; }
body.embed .chip { font-size: 12.5px; padding: 7px 12px; }
body.embed .suggestions { gap: 8px; margin-top: 14px; }
body.embed .glow-1 { width: 300px; height: 300px; }
body.embed .glow-2 { width: 280px; height: 280px; }
body.embed .glow-3 { display: none; }
body.embed .avatar { width: 28px; height: 28px; }
body.embed .msg { max-width: 96%; }
body.embed .mark { width: 62px; height: 62px; margin-bottom: 14px; }
body.embed .chat.is-empty .topbar { padding-top: 18px; }
body.embed .chat.is-empty .topbar-logo { width: 100px; }
body.embed .typing-text { font-size: 12.5px; }

/* ================= Telefono ================= */
@media (max-width: 600px) {
    .hero-title { font-size: clamp(30px, 9vw, 40px); }
    .hero-subtitle { font-size: 14.5px; }
    .chip { font-size: 13px; padding: 8px 13px; }
    .glow-3 { display: none; }
    .msg { max-width: 100%; }
    .mark { width: 72px; height: 72px; margin-bottom: 18px; }
    .chat.is-empty .topbar-logo { width: 110px; }
}

/* ================= Schermi bassi (telefono in orizzontale, finestre ridotte) ================= */
@media (max-height: 560px) {
    .topbar, .chat.is-empty .topbar, body.embed .chat.is-empty .topbar { padding-top: 8px; padding-bottom: 8px; }
    .chat.is-empty .topbar-logo, body.embed .chat.is-empty .topbar-logo { width: 90px; }
    .mark, body.embed .mark { width: 48px; height: 48px; margin-bottom: 10px; }
    .hero-title, body.embed .hero-title { font-size: 28px; margin: 10px 0 0; }
    .hero-subtitle { display: none; }
    .chat.is-empty .composer-wrap, body.embed .chat.is-empty .composer-wrap { padding-top: 14px; }
    .suggestions, body.embed .suggestions { margin-top: 10px; gap: 8px; }
    .chip { padding: 6px 12px; }
    .messages { padding-top: 14px; }
}

@media (max-height: 420px) {
    .mark, body.embed .mark { display: none; }
    .chat.is-empty .hero { margin-top: 4px; }
}

/* ================= Riduci movimento ================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        animation-delay: 0s !important;
        transition-duration: .001ms !important;
    }
}
