/* Components of the Voxaris site — style «Metamorfosi» (piano 18; before «Onda», piano 06 ·
   G-01/G-02). Colours only from tokens.css. */

/* Buttons: pills; on hover the red fills them from the point where the pointer came in
   (--x/--y from effects.js), the label can roll (.roll with two copies), the button leans
   toward the pointer (--mx/--my, only with a mouse and without «riduci movimento»). */
.btn { --x: 50%; --y: 50%; --mx: 0px; --my: 0px; position: relative; isolation: isolate; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 52px; padding: 0 var(--s-5); border-radius: var(--r-pill); border: 1px solid transparent; max-width: 100%; font-weight: 620; font-stretch: 106%; letter-spacing: 0.005em; text-align: center; text-decoration: none; cursor: pointer; transform: translate3d(var(--mx), var(--my), 0); transition: transform var(--dur-section) var(--ease-standard), color var(--dur-ui) var(--ease-standard), box-shadow var(--dur-ui) var(--ease-standard), border-color var(--dur-ui) var(--ease-standard), background var(--dur-ui) var(--ease-standard); }
.btn::before { content: ""; position: absolute; inset: -1px; z-index: -1; background: var(--btn-fill, var(--verm)); clip-path: circle(0% at var(--x) var(--y)); transition: clip-path var(--dur-section) var(--ease-standard); }
.btn:hover::before, .btn:focus-visible::before { clip-path: circle(150% at var(--x) var(--y)); }
.btn:hover, .btn:focus-visible { color: var(--ink); }
.btn:active { transform: translate3d(var(--mx), var(--my), 0) scale(0.98); }
.btn-primary { background: var(--text); color: var(--on-text); }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.btn-ghost:hover, .btn-ghost:focus-visible { border-color: transparent; }
/* On the red sections the fill is the paper. */
[data-theme="accent"] .btn { --btn-fill: var(--paper); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn[disabled]::before { display: none; }
.btn-block { width: 100%; }
.btn-lg { min-height: 64px; padding: 0 var(--s-6); font-size: var(--fs-18); }
.btn .icon { width: 19px; height: 19px; }
.roll { display: inline-grid; overflow: hidden; line-height: 1.25; }
.roll > span { grid-area: 1 / 1; transition: transform var(--dur-section) var(--ease-standard); }
.roll > span + span { transform: translateY(115%); }
.btn:hover .roll > span:first-child { transform: translateY(-115%); }
.btn:hover .roll > span + span { transform: none; }
.text-link { background: none; border: 0; padding: 0; color: var(--text-soft); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: var(--fs-14); }
.text-link:hover { color: var(--text); }

/* Fields: white-ish on the ivory, a red ring when focused. */
.field { display: grid; gap: var(--s-2); }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
.field label, .field .label { font-size: var(--fs-14); font-weight: 560; color: var(--text-soft); }
.input, .select { width: 100%; min-height: 54px; padding: 0 var(--s-4); border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); transition: border-color var(--dur-ui) var(--ease-standard), box-shadow var(--dur-ui) var(--ease-standard); }
textarea.input { padding-block: var(--s-3); }
.input::placeholder { color: var(--text-faint); }
.input:focus, .select:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--focus) 22%, transparent); }
.phone-row { display: grid; grid-template-columns: minmax(96px, 128px) 1fr; gap: var(--s-2); }
.error-text { color: var(--danger); font-size: var(--fs-14); margin: 0; }
.hint { color: var(--text-faint); font-size: var(--fs-12); margin: 0; }

/* Scenario chips: the chosen one becomes a solid pill in the text colour. */
.chips { display: flex; flex-wrap: wrap; gap: var(--s-2); border: 0; padding: 0; margin: 0; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; inset: 0; }
.chip span { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 42px; padding: 0 var(--s-4); border-radius: var(--r-pill); border: 1px solid var(--line-strong); color: var(--text-soft); font-size: var(--fs-14); font-weight: 560; cursor: pointer; transition: color var(--dur-ui) var(--ease-standard), background var(--dur-ui) var(--ease-standard), border-color var(--dur-ui) var(--ease-standard), transform var(--dur-section) var(--ease-spring); }
.chip span:hover { color: var(--text); border-color: var(--text-soft); }
.chip input:checked + span { color: var(--on-text); border-color: var(--text); background: var(--text); }
.chip input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Cards, pills, empty states */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s-5); box-shadow: var(--shadow-1); }
.card-elevated { box-shadow: var(--shadow-2); }
.card h3 { margin-bottom: var(--s-2); }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--r-pill); font-size: var(--fs-12); font-weight: 620; background: var(--surface-2); color: var(--text-soft); border: 1px solid var(--line); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-live { color: var(--success); }
.pill-wait { color: var(--warning); }
.pill-error { color: var(--danger); }
.empty { text-align: center; color: var(--text-faint); padding: var(--s-6) var(--s-4); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }
.notice { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-3) var(--s-4); font-size: var(--fs-14); color: var(--text-soft); }

/* Stepper (how it works): big numbers in the text colour. */
.steps { counter-reset: step; display: grid; gap: var(--s-5); grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: step; position: relative; padding-top: var(--s-8); }
.steps li::before { content: "0" counter(step); position: absolute; top: 0; left: 0; font: 250 var(--fs-48)/1 var(--font-display); font-stretch: 62%; letter-spacing: -0.02em; color: var(--accent-text); }

/* Transcript bubbles. The scroll stays in the box: at its top or bottom it no longer moves the
   page under it (owner, 26/10, phone and computer). */
.transcript { display: flex; flex-direction: column; gap: var(--s-3); overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.bubble { max-width: 86%; padding: var(--s-3) var(--s-4); border-radius: 20px; font-size: var(--fs-14); line-height: 1.5; animation: bubble-in var(--dur-section) var(--ease-standard) both; }
.bubble-ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.bubble-user { align-self: flex-end; background: color-mix(in srgb, var(--verm) 13%, var(--surface)); border-bottom-right-radius: 6px; }
.bubble .who { display: block; font-size: var(--fs-12); font-weight: 650; font-stretch: 115%; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 2px; }
@keyframes bubble-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }

/* Voice orb: waiting · listening · thinking · speaking (G-02), in the red of the voice. */
.orb { --size: 168px; position: relative; width: var(--size); height: var(--size); margin-inline: auto; }
.orb-core { position: absolute; inset: 18%; border-radius: 50%; background: radial-gradient(circle at 35% 30%, var(--on-voice-soft) 0, transparent 38%), var(--voice); box-shadow: 0 0 60px var(--voice-glow); animation: orb-breathe 4s var(--ease-standard) infinite; }
.orb-ring { position: absolute; inset: 18%; border-radius: 50%; border: 2px solid var(--voice-b); opacity: 0; }
.orb-bars { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 5px; opacity: 0; transition: opacity var(--dur-ui) var(--ease-standard); }
.orb-bars i { width: 5px; height: 18%; border-radius: 3px; background: var(--on-voice); transform-origin: center; }
.orb[data-state="listening"] .orb-ring { animation: orb-ripple 1.6s var(--ease-standard) infinite; }
.orb[data-state="listening"] .orb-ring:nth-child(3) { animation-delay: .53s; }
.orb[data-state="listening"] .orb-ring:nth-child(4) { animation-delay: 1.06s; }
.orb[data-state="thinking"] .orb-core { animation: orb-think 1.2s linear infinite; filter: saturate(1.3); }
.orb[data-state="speaking"] .orb-bars { opacity: 1; }
.orb[data-state="speaking"] .orb-bars i { animation: orb-bar .9s var(--ease-standard) infinite; }
.orb[data-state="speaking"] .orb-bars i:nth-child(2) { animation-delay: .12s; }
.orb[data-state="speaking"] .orb-bars i:nth-child(3) { animation-delay: .24s; }
.orb[data-state="speaking"] .orb-bars i:nth-child(4) { animation-delay: .36s; }
.orb[data-state="speaking"] .orb-bars i:nth-child(5) { animation-delay: .48s; }
.orb-label { text-align: center; margin-top: var(--s-3); font-size: var(--fs-14); color: var(--text-soft); min-height: 1.6em; }
@keyframes orb-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
@keyframes orb-ripple { from { transform: scale(1); opacity: .7; } to { transform: scale(1.75); opacity: 0; } }
@keyframes orb-think { 0% { transform: rotate(0) scale(1.02); } 100% { transform: rotate(360deg) scale(1.02); } }
@keyframes orb-bar { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(2.6); } }

/* Ringing */
.ringing { position: relative; display: grid; place-items: center; width: 168px; height: 168px; margin-inline: auto; }
.ringing .icon { width: 48px; height: 48px; color: var(--on-voice); position: relative; z-index: 1; animation: ring-shake 1.2s var(--ease-standard) infinite; }
.ringing::before { content: ""; position: absolute; inset: 22%; border-radius: 50%; background: var(--voice-strong); }
.ringing span { position: absolute; inset: 22%; border-radius: 50%; border: 2px solid var(--voice-b); animation: orb-ripple 1.8s var(--ease-standard) infinite; }
.ringing span:nth-child(2) { animation-delay: .6s; }
.ringing span:nth-child(3) { animation-delay: 1.2s; }
@keyframes ring-shake { 0%, 50%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(-12deg); } 20%, 40% { transform: rotate(12deg); } }

/* Action card: fields fill one at a time, then a drawn check */
.action-card { display: grid; gap: var(--s-3); }
.action-card .action-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.fields { display: grid; gap: var(--s-2); margin: 0; }
.fields > div { display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-2) 0; border-bottom: 1px solid var(--line); animation: field-in var(--dur-section) var(--ease-standard) both; }
.fields dt { color: var(--text-faint); font-size: var(--fs-14); }
.fields dd { margin: 0; font-weight: 620; text-align: right; }
.fields .is-new dd { background: var(--voice-ink); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes field-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }
.check { width: 28px; height: 28px; }
.check path { fill: none; stroke: var(--success); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw var(--dur-section) var(--ease-emph) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-4); position: relative; }
.timeline li { position: relative; padding-left: var(--s-6); }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--verm); box-shadow: 0 0 0 4px color-mix(in srgb, var(--verm) 20%, transparent); }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 12px; top: 24px; bottom: calc(-1 * var(--s-4)); width: 2px; background: var(--line-strong); }

/* Dialog and toast */
dialog { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); color: var(--text); padding: var(--s-6); width: min(100% - 2 * var(--s-4), 540px); box-shadow: var(--shadow-2); }
dialog::backdrop { background: var(--backdrop); backdrop-filter: blur(6px); }
dialog[open] { animation: dialog-in var(--dur-section) var(--ease-standard) both; }
dialog[open]::backdrop { animation: backdrop-in var(--dur-section) var(--ease-standard) both; }
@keyframes dialog-in { from { opacity: 0; transform: translateY(18px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes backdrop-in { from { opacity: 0; } to { opacity: 1; } }
.toast { position: fixed; left: 50%; bottom: var(--s-5); transform: translateX(-50%); z-index: 60; background: var(--text); color: var(--on-text); border-radius: var(--r-pill); padding: var(--s-3) var(--s-5); font-size: var(--fs-14); font-weight: 560; box-shadow: var(--shadow-2); }

/* Scroll reveals (G-02): blocks rise and appear; inside them, the title lines rise from a mask
   (.ln > span) one after the other. Only when motion is allowed. */
[data-reveal] { opacity: 0; transform: translateY(26px); transition: opacity var(--dur-section) var(--ease-standard), transform calc(var(--dur-section) * 1.4) var(--ease-standard); transition-delay: var(--reveal-delay, 0ms); }
[data-reveal].is-visible { opacity: 1; transform: none; }
.no-js [data-reveal] { opacity: 1; transform: none; }
.ln { display: block; overflow: hidden; padding: 0.05em 0.14em 0.12em 0; margin: -0.05em -0.14em -0.12em 0; }
.ln > span { display: inline-block; transform: translateY(115%) rotate(4deg); transform-origin: 0 100%; transition: transform calc(var(--dur-section) * 2) var(--ease-standard); transition-delay: calc(var(--i, 0) * 110ms + var(--reveal-delay, 0ms)); }
.is-visible .ln > span, .no-js .ln > span { transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; transition: opacity var(--dur-ui) linear; }
  .ln > span { transform: none; transition: none; }
  .orb-core, .orb-ring, .orb-bars i, .ringing span, .ringing .icon, .bubble, .fields > div, dialog[open], dialog[open]::backdrop { animation: none !important; }
  .btn { transform: none; }
}
:root[data-motion="reduce"] [data-reveal] { opacity: 1; transform: none; }
:root[data-motion="reduce"] .ln > span { transform: none; transition: none; }
:root[data-motion="reduce"] .orb-core, :root[data-motion="reduce"] .orb-ring, :root[data-motion="reduce"] .orb-bars i,
:root[data-motion="reduce"] .ringing span, :root[data-motion="reduce"] .ringing .icon, :root[data-motion="reduce"] .bubble,
:root[data-motion="reduce"] .fields > div { animation: none !important; }
:root[data-motion="reduce"] .btn { transform: none; }

/* Simple pages («Metamorfosi», A4-A7 and the Orbita tools): a big title over a red wave that runs,
   like the voice. */
.page-head { display: grid; gap: var(--s-3); margin-bottom: var(--s-6); }
.page-head .eyebrow { margin: 0; }
.page-head h1 { font-size: clamp(2.8rem, 7vw, 6rem); margin: 0; }
.page-head .lead, .page-head .muted { margin: 0; }
.page-wave { width: min(320px, 70%); height: 18px; color: var(--verm); overflow: visible; }
.page-wave path { fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; stroke-dasharray: 10 9; animation: page-wave 2.2s linear infinite; }
@keyframes page-wave { to { stroke-dashoffset: -38; } }
@media (prefers-reduced-motion: reduce) { .page-wave path { animation: none; } }
:root[data-motion="reduce"] .page-wave path { animation: none; }
