/* Il muro di Polyphorm (prototipo): avorio, nero, Geist. I colori sono dei progetti. */

@font-face { font-family: "Geist"; src: url("fonts/Geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/GeistMono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --paper: #F1EEE6;
  --paper-2: #E7E3D9;
  --ink: #111110;
  --ink-2: #4A4843;
  --ink-3: #7A776F;
  --line: rgba(17, 17, 16, .14);
  --live: #0E8A5F;
  --sans: "Geist", "Helvetica Neue", Arial, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, Menlo, monospace;
  --pad: clamp(16px, 2.6vw, 36px);
  --ease: cubic-bezier(.2, .7, .1, 1);
  --ease-io: cubic-bezier(.7, 0, .2, 1);
  /* cartolina e assistente, come nel sito di prima */
  --font: var(--sans);
  --hand: "Bradley Hand", "Segoe Print", "Noteworthy", "Segoe Script", cursive;
  --pen: #1E2B4F;
  --night: #111110;
  --night-hi: #23221F;
  --glass-line: rgba(255, 255, 255, .72);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
html.has-muro, html.has-muro body { overflow: hidden; overscroll-behavior: none; }
h1, h2, p, ol, figure { margin: 0; padding: 0; }
ol { list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img, svg, video, canvas { display: block; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 4px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .02em; text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
/* finché i testi non sono nella lingua giusta la pagina non si mostra (lo script in testa a muro.html) */
.i18n-wait body { opacity: 0; }
/* scritture che il Geist non ha: il carattere di sistema, e niente maiuscolo forzato né spaziatura */
:lang(zh-Hans) .mono, :lang(zh-Hant) .mono, :lang(ja) .mono, :lang(ar) .mono, :lang(ur) .mono, :lang(hi) .mono, :lang(bn) .mono { font-family: var(--sans); letter-spacing: 0; font-size: 13px; }
:lang(zh-Hans), :lang(zh-Hant), :lang(ja) { word-break: keep-all; line-break: strict; }

/* ---------- il muro ---------- */

#muro { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; opacity: 0; transition: opacity .4s; }
.has-muro #muro { opacity: 1; }
#muro.is-dragging { cursor: grabbing; }
.no-muro #muro { display: none; }
/* il vetro liquido sta ai bordi dello schermo, su ogni schermo (telefono, tablet, computer, orologio): lo disegna muro.js,
   qui solo il raggio degli angoli. Marchio, pulsanti, motto e partita IVA stanno sopra le carte in capsule di vetro satinato.
   --ui-b: sopra le capsule in fondo, dove stanno il suggerimento e il banner dei cookie. */
:root {
  --ui-b: calc(env(safe-area-inset-bottom) + 58px);
  --glass-x: max(14px, env(safe-area-inset-left), env(safe-area-inset-right));
  --page-r: clamp(24px, 3.4vw, 44px);
}
@media (max-width: 760px) { :root { --glass-x: max(10px, env(safe-area-inset-left), env(safe-area-inset-right)); } }
@media (max-width: 560px) { :root { --ui-b: calc(env(safe-area-inset-bottom) + 56px); } }
@media (max-width: 300px) { :root { --ui-b: calc(env(safe-area-inset-bottom) + 40px); --pad: 8px; } }
/* il vetro segue esattamente lo schermo, angoli dritti */
.m-glass { position: fixed; inset: 0; visibility: hidden; pointer-events: none; }
/* iPhone e iPad (Safari): le carte e il vetro scendono anche sotto la barra degli indirizzi, che è trasparente.
   100lvh è l'altezza dello schermo con le barre ritirate; marchio, pulsanti e P.IVA restano sopra la barra */
.ios #muro, .ios .m-glass { bottom: auto; height: 100vh; height: 100lvh; }
/* senza vetro (il disegno fuori schermo non riesce): in alto e in basso il muro sfuma nell'avorio, come prima */
.has-muro.no-glass body::before, .has-muro.no-glass body::after {
  content: "";
  position: fixed;
  inset-inline: 0;
  z-index: 15;
  pointer-events: none;
}
.has-muro.no-glass body::before { top: 0; height: calc(env(safe-area-inset-top) + 92px); background: linear-gradient(var(--paper) 30%, rgba(241, 238, 230, 0)); }
.has-muro.no-glass body::after { bottom: 0; height: calc(env(safe-area-inset-bottom) + 72px); background: linear-gradient(rgba(241, 238, 230, 0), var(--paper) 70%); }

.m-top {
  position: fixed;
  inset: 0 0 auto;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 18px) var(--pad) 0;
  pointer-events: none;
}
.m-top > * { pointer-events: auto; }
/* con l'indice o lo studio aperti, i testi che scorrono passano sotto un fondo avorio, mai sotto i pulsanti */
.m-top::before {
  content: "";
  position: absolute;
  inset: 0 0 -22px;
  z-index: -1;
  background: linear-gradient(var(--paper) calc(100% - 22px), rgba(241, 238, 230, 0));
  opacity: 0;
  transition: opacity .35s var(--ease);
  pointer-events: none;
}
.is-layer .m-top::before { opacity: 1; }
.m-brand { display: inline-grid; place-items: center; width: 54px; height: 54px; padding: 0; }
.m-brand__p { width: 27px; height: 27px; }
@media (max-width: 560px) { .m-brand { width: 50px; height: 50px; } .m-brand__p { width: 25px; height: 25px; } }
.m-top__end { display: flex; align-items: center; gap: 6px; }
.m-nav { display: flex; gap: 6px; }
.m-nav button, .m-lang__btn {
  height: 34px;
  padding: 0 14px;
  font-size: 14px;
  transition: background .2s, border-color .2s;
}
.m-nav button:hover, .m-lang__btn:hover { background: rgba(255, 255, 255, .72); }

/* la lingua: un cerchietto con il mondo e la sigla, l'elenco si apre sotto */
.m-lang { position: relative; }
.m-lang__btn { display: inline-flex; align-items: center; gap: 6px; padding: 0 11px 0 9px; font-family: var(--mono); font-size: 11px; letter-spacing: .04em; }
.m-lang__btn svg { width: 16px; height: 16px; }
.m-lang__panel {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  z-index: 50;
  list-style: none;
  margin: 0;
  padding: 6px;
  width: 220px;
  max-height: min(72svh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border-radius: 18px;
  background: rgba(241, 238, 230, .97);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: 0 26px 54px -24px rgba(0, 0, 0, .35);
  transform-origin: top right;
  animation: langDown .3s var(--ease);
}
[dir="rtl"] .m-lang__panel { transform-origin: top left; }
.m-lang__panel a { display: block; padding: 9px 12px; border-radius: 11px; font-size: 15px; }
.m-lang__panel a:hover { background: rgba(17, 17, 16, .06); }
.m-lang__panel a[aria-current] { background: var(--ink); color: var(--paper); }
@keyframes langDown { from { opacity: 0; transform: translateY(-6px) scale(.97); } }

.m-line {
  position: fixed;
  inset-block-end: calc(env(safe-area-inset-bottom) + 14px);
  inset-inline-start: var(--pad);
  z-index: 20;
  padding: 8px 13px;
  line-height: 1;
  color: var(--ink);
  pointer-events: none;
  transition: opacity .4s var(--ease);
}
.no-muro .m-line { display: none; }

/* ---------- il suggerimento: compare se per qualche secondo non si fa niente ---------- */

.m-hint {
  position: fixed;
  left: 50%;
  bottom: var(--ui-b);
  z-index: 21;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 18px 0 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
  pointer-events: none;
}
.m-hint.is-on { opacity: 1; transform: translate(-50%, 0); }
.no-muro .m-hint { display: none; }
.m-hint__ico { position: relative; flex: none; width: 28px; height: 14px; }
.m-hint__ico::before, .m-hint__ico::after { content: ""; position: absolute; border-radius: 999px; }
/* trascinare: un punto che va e viene su una corta guida */
.m-hint[data-kind="drag"] .m-hint__ico::before { inset: 6px 0; background: rgba(241, 238, 230, .3); }
.m-hint[data-kind="drag"] .m-hint__ico::after { top: 2px; left: 0; width: 10px; height: 10px; background: var(--paper); animation: hintDrag 1.6s var(--ease-io) infinite alternate; }
/* aprire: un punto che preme, con l'onda intorno */
.m-hint[data-kind="open"] .m-hint__ico { width: 14px; }
.m-hint[data-kind="open"] .m-hint__ico::after { inset: 2px; background: var(--paper); animation: hintTap 1.4s var(--ease) infinite; }
.m-hint[data-kind="open"] .m-hint__ico::before { inset: 0; box-shadow: 0 0 0 0 rgba(241, 238, 230, .6); animation: hintRing 1.4s var(--ease) infinite; }
@keyframes hintDrag { from { transform: translateX(0); } to { transform: translateX(18px); } }
@keyframes hintTap { 0%, 100% { transform: scale(1); } 30% { transform: scale(.7); } }
@keyframes hintRing { 0% { box-shadow: 0 0 0 0 rgba(241, 238, 230, .6); } 100% { box-shadow: 0 0 0 10px rgba(241, 238, 230, 0); } }

/* ---------- livelli: indice e studio ---------- */

.m-layer {
  position: fixed;
  inset: 0;
  z-index: 25;
  overflow-y: auto;
  background: rgba(241, 238, 230, .97);
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s var(--ease), visibility 0s .35s;
}
.m-layer.is-open { opacity: 1; visibility: visible; transition: opacity .35s var(--ease); }
.m-layer__in { position: relative; width: min(1180px, 100% - 2 * var(--pad)); margin: 0 auto; padding: calc(env(safe-area-inset-top) + 98px) 0 80px; }
.m-layer__head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 14px; border-bottom: 1px solid var(--ink); margin-bottom: 8px; }
.m-x { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); }
.m-x:hover { border-color: var(--ink); }
.m-x svg, .m-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }

/* senza muro l'elenco è la pagina */
.no-muro .m-indice { position: static; opacity: 1; visibility: visible; background: none; overflow: visible; }
.no-muro .m-indice .m-x { display: none; }


.m-row + .m-row { border-top: 1px solid var(--line); }
.m-row__go {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr) minmax(0, 1.4fr) auto;
  align-items: center;
  gap: 8px 28px;
  padding: 14px 0;
}
.m-row__thumb { aspect-ratio: 16 / 10; overflow: hidden; border-radius: 14px; background: var(--paper-2); }
.m-row__thumb video { width: 100%; height: 100%; object-fit: cover; }
.m-row__name { font-size: clamp(22px, 2vw, 30px); font-weight: 500; letter-spacing: -.03em; }
.m-row__line { font-size: 15px; color: var(--ink-2); line-height: 1.4; }
.m-row__info { display: flex; gap: 14px; color: var(--ink-3); white-space: nowrap; }
.m-row:hover .m-row__name { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.m-row.is-paused video { filter: grayscale(1); }
.m-row.is-ghost video { filter: grayscale(1) contrast(.8); opacity: .5; }
.m-row.is-ghost .m-row__name { color: var(--ink-3); }

.m-state { display: inline-flex; align-items: center; gap: 7px; }
.m-state::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--live); }
.m-state--making::before { background: linear-gradient(90deg, var(--ink-3) 50%, transparent 50%); box-shadow: inset 0 0 0 1px var(--ink-3); }
.m-state--paused::before { background: none; box-shadow: inset 0 0 0 1px var(--ink-3); }
.m-state--ghost::before { background: none; border: 1px dotted var(--ink-3); width: 8px; height: 8px; }

.m-studio__lead { margin-top: 32px; max-width: 22em; font-size: clamp(26px, 3vw, 44px); font-weight: 450; line-height: 1.12; letter-spacing: -.035em; }
.m-studio__text { max-width: 36em; margin-top: 28px; font-size: 17px; line-height: 1.5; color: var(--ink-2); }
.m-studio__mail { margin-top: 28px; display: flex; align-items: center; flex-wrap: wrap; gap: 12px; }
.m-studio__mail a { overflow-wrap: anywhere; font-size: clamp(22px, 2.4vw, 32px); font-weight: 500; letter-spacing: -.03em; border-bottom: 1px solid var(--ink); }
.m-studio__legal { margin-top: 48px; font-size: 13px; color: var(--ink-3); }
.m-studio__legal a { color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- la pagina del progetto ---------- */

.m-page {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  outline: none;
}
.m-page.is-measuring { visibility: hidden; }
.m-page.is-in .m-page__head, .m-page.is-in .m-page__body, .m-page.is-in .m-page__gallery, .m-page.is-in .m-page__bar { animation: pgIn .6s var(--ease) both; }
.m-page.is-in .m-page__body { animation-delay: .06s; }
.m-page.is-in .m-page__gallery { animation-delay: .12s; }
@keyframes pgIn { from { opacity: 0; transform: translateY(16px); } }
.m-page__bar { position: absolute; inset: 0 0 auto; z-index: 2; display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 18px) var(--pad) 0; pointer-events: none; }
.m-page__bar > * { pointer-events: auto; }
.m-page__bar::before {
  content: "";
  position: absolute;
  inset: 0 0 -22px;
  z-index: -1;
  background: linear-gradient(var(--paper) calc(100% - 22px), rgba(241, 238, 230, 0));
  opacity: 0;
  transition: opacity .25s var(--ease);
  pointer-events: none;
}
.m-page.is-scrolled .m-page__bar::before { opacity: 1; }
.m-back { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px 0 8px; border-radius: 999px; background: rgba(241, 238, 230, .86); border: 1px solid var(--line); font-size: 14px; }
.m-back:hover { border-color: var(--ink); }
.m-page__bar .m-x { background: rgba(241, 238, 230, .86); }
.m-page__scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 0 var(--pad) 80px; scroll-padding-top: calc(env(safe-area-inset-top) + 84px); }
/* il progetto aperto riempie lo schermo: da bordo a bordo, alto quanto lo schermo (sul telefono quanto il video) */
.m-page__video {
  height: min(100svh, 100vw / 1.6);
  margin-inline: calc(-1 * var(--pad));
  overflow: hidden;
  border-radius: 0 0 var(--page-r) var(--page-r);
  background: var(--paper-2);
}
.m-page__video video { width: 100%; height: 100%; object-fit: cover; }
.m-page.is-paused .m-page__video video { filter: grayscale(1); }
.m-page.is-ghost .m-page__video video { filter: grayscale(1) contrast(.85); opacity: .7; }
.m-page__head, .m-page__body, .m-page__gallery, .m-page__next { width: min(1180px, 100%); margin-inline: auto; }
.m-page__head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px 32px;
  padding: clamp(24px, 3.4vw, 44px) 0;
  border-bottom: 1px solid var(--line);
}
.m-page__head h1 { font-size: clamp(48px, 8vw, 120px); font-weight: 500; line-height: .92; letter-spacing: -.055em; }
.m-page.is-ghost .m-page__head h1 { color: var(--ink-2); }
/* al posto del nome, il logo ufficiale del progetto */
.m-page__mark { display: flex; align-items: center; gap: .3em; line-height: 0; }
.m-page__mark span { font-size: calc(clamp(52px, 7vw, 108px) * .62); line-height: 1; letter-spacing: -.04em; }
.m-page__mark img { width: auto; max-width: 100%; height: calc(clamp(52px, 7vw, 108px) * var(--mark-h, 1)); object-fit: contain; object-position: left center; }
[dir="rtl"] .m-page__mark img { object-position: right center; }
.m-page.is-ghost .m-page__mark img { filter: grayscale(1); opacity: .5; }
.m-page__side { display: grid; gap: 12px; justify-items: start; }
.m-page__info { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-3); }
.m-visit { display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 999px; background: var(--ink); color: var(--paper); font-size: 14px; }
.m-visit:hover { background: var(--live); }
.m-visit svg { width: 11px; height: 11px; fill: none; stroke: currentColor; stroke-width: 2.2; }
.m-page__body { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px 48px; padding: clamp(24px, 3.4vw, 48px) 0; }
.m-page__line { font-size: clamp(24px, 2.7vw, 40px); font-weight: 450; line-height: 1.14; letter-spacing: -.03em; }
.m-page__text { display: grid; gap: 12px; font-size: 16.5px; line-height: 1.5; color: var(--ink-2); }
.m-page__gallery { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: clamp(10px, 1.4vw, 20px); }
.m-page__gallery figure { grid-column: span 12; overflow: hidden; background: var(--paper-2); }
.m-page__gallery .half { grid-column: span 6; }
.m-page__gallery .third { grid-column: span 4; }
.m-page__gallery .quarter { grid-column: span 3; }
.m-page__gallery img { width: 100%; height: 100%; object-fit: cover; }
.m-page__gallery .contain img { object-fit: contain; }
.m-page.is-ghost .m-page__gallery img { filter: grayscale(1) contrast(.85); opacity: .55; }
.m-page__next { display: flex; justify-content: space-between; align-items: baseline; margin-top: clamp(40px, 6vw, 80px); padding-top: 18px; border-top: 1px solid var(--ink); }
.m-page__next span:last-child { font-size: clamp(32px, 5vw, 72px); font-weight: 500; letter-spacing: -.045em; line-height: 1; }


/* ---------- l'assistente: lo stesso del sito di prima ---------- */

/* ---------- Chat con l'assistente ---------- */
/* il pannello scorre da sé e non trattiene mai la pagina */


.chat {
  position: fixed;
  inset-block-end: calc(max(16px, env(safe-area-inset-bottom)) + 60px);
  inset-inline-end: 16px;
  z-index: 60;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  align-content: stretch;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100svh - 120px));
  border-radius: 24px;
  background: rgba(242, 242, 242, .9);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--glass-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7), 0 26px 54px -22px rgba(0, 0, 0, .4);
  transform-origin: bottom right;
  animation: langUp .35s var(--ease);
  overflow: hidden;
}
[dir="rtl"] .chat { transform-origin: bottom left; }
.chat[hidden] { display: none; }

.chat__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}
.chat__title { margin: 0; font-size: 16px; font-weight: 600; }
.chat__note { margin: 4px 0 0; font-size: 13px; line-height: 1.4; color: var(--ink-3); }
.chat__tools { flex: none; display: flex; gap: 6px; }
.chat__icon {
  flex: none;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .7);
  color: var(--ink);
  cursor: pointer;
}
.chat__icon[hidden] { display: none; }
.chat__icon:hover { background: rgba(255, 255, 255, .95); }
.chat__icon svg, .chat__send svg, .chat__mic svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.chat__log {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat__msg {
  margin: 0;
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat__msg--agente { align-self: flex-start; background: rgba(255, 255, 255, .85); color: var(--ink); border-end-start-radius: 6px; }
/* mentre l'assistente scrive: «Sto scrivendo» respira tra sfocato e nitido, poi un trattino in fondo al testo */
.chat__typing { display: inline-block; color: var(--ink-3); animation: chatRespiro 1.3s ease-in-out infinite alternate; }
.chat__caret { display: inline-block; width: 2px; height: 1em; margin-inline-start: 2px; vertical-align: -.12em; background: currentColor; border-radius: 1px; animation: chatCursore 1s steps(2, start) infinite; }
@keyframes chatRespiro { from { opacity: .35; filter: blur(2.5px); } to { opacity: .9; filter: blur(0); } }
@keyframes chatCursore { to { visibility: hidden; } }
.chat__msg[aria-busy="true"]:empty::before { content: "\00a0"; }
.chat__msg--persona { align-self: flex-end; background: var(--ink); color: var(--paper); border-end-end-radius: 6px; }

.chat__log[hidden], .chat__form[hidden], .chat__who[hidden], .chat__foot [hidden] { display: none; }

/* prima di parlare: nome ed email */
.chat__who {
  grid-row: 2 / 4;
  align-self: start;
  display: grid;
  gap: 10px;
  padding: 18px 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.chat__intro { margin: 0 0 4px; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.chat__who label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-3); }
.chat__who input {
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .85);
  font: 500 16px/1 var(--font);
  color: var(--ink);
  outline: none;
}
.chat__who input:focus { border-color: var(--ink-3); }
.chat__err { margin: 0; min-height: 1em; font-size: 13px; color: #9B2C24; }
.chat__start {
  justify-self: start;
  height: 44px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: 600 15px/1 var(--font);
  cursor: pointer;
}

/* microfono: anelli che respirano mentre ascolta, più ampi quando sente la voce */
.chat__mic {
  position: relative;
  flex: none;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .85);
  color: var(--ink);
  cursor: pointer;
}
.chat__mic svg { position: relative; z-index: 1; }
.chat__ring { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.chat__mic.is-listening { background: var(--ink); color: var(--paper); }
.chat__mic.is-listening .chat__ring { animation: micRing 1.6s var(--ease) infinite; box-shadow: 0 0 0 0 rgba(14, 14, 14, .35); }
.chat__mic.is-hearing .chat__ring { animation-duration: .8s; }
.chat__mic.is-hearing svg { animation: micBeat .5s ease-in-out infinite alternate; }
@keyframes micRing { 0% { box-shadow: 0 0 0 0 rgba(14, 14, 14, .35); } 100% { box-shadow: 0 0 0 14px rgba(14, 14, 14, 0); } }
@keyframes micBeat { from { transform: scale(1); } to { transform: scale(1.15); } }

.chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 10px 10px 16px;
  border-top: 1px solid var(--line);
}
.chat__form textarea {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  resize: none;
  padding: 9px 0;
  border: 0;
  background: transparent;
  font: 500 16px/1.4 var(--font);
  color: var(--ink);
  outline: none;
}
.chat__send {
  flex: none;
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}
.chat__send:disabled { opacity: .4; cursor: default; }
[dir="rtl"] .chat__send svg { transform: scaleX(-1); }
.chat__foot {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 0;
  padding: 0 16px 12px;
  font-size: 12px;
  color: var(--ink-3);
}
.chat__change { border: 0; padding: 0; background: none; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }
.chat__foot a { color: inherit; }

@keyframes langUp { from { opacity: 0; transform: translateY(8px) scale(.97); } }
.chat__head, .chat__who, .chat__log, .chat__form, .chat__foot { font-family: var(--sans); }
.chat { background: rgba(241, 238, 230, .92); }

@media (max-width: 760px) {
  .m-row__go { grid-template-columns: 112px minmax(0, 1fr); gap: 4px 16px; }
  .m-row__thumb { grid-row: span 3; }
  .m-row__line, .m-row__info { grid-column: 2; }
  .m-row__info { flex-wrap: wrap; gap: 4px 12px; }
  .m-page__head, .m-page__body { grid-template-columns: 1fr; }
  .m-page__gallery .half, .m-page__gallery .third { grid-column: span 12; }
  .m-page__gallery .quarter { grid-column: span 6; }
}
/* la chat prende tutto lo schermo, su ogni dispositivo: ci si concentra sulla conversazione (:root vince su postcard.css).
   Sugli schermi larghi la conversazione sta in una colonna al centro, larga quanto si legge bene */
:root .chat {
  inset: 0;
  width: auto;
  height: auto;
  max-height: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: var(--paper);
  justify-items: center;
}
:root .chat > * { width: min(760px, 100%); }
/* ai lati della chat, solo dove c'è spazio e mai sotto il testo: luci sbiadite nei colori di Polyphorm che salgono piano
   e pulsano, come meduse sotto lo schermo. Stanno nelle fasce fuori dalla colonna (con 24px di margine) e sfumano verso il centro;
   si muovono solo con transform e opacity, così su iPhone e iPad restano fluide */
:root .chat > .chat__meduse {
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc((100% - 760px) / 2 - 24px);
  overflow: hidden;
  pointer-events: none;
}
.chat__meduse--sx { left: 0; -webkit-mask-image: linear-gradient(to right, #000 45%, transparent); mask-image: linear-gradient(to right, #000 45%, transparent); }
.chat__meduse--dx { right: 0; -webkit-mask-image: linear-gradient(to left, #000 45%, transparent); mask-image: linear-gradient(to left, #000 45%, transparent); }
.chat__meduse i {
  position: absolute;
  top: 100%;
  left: 50%;
  width: 260px;
  height: 300px;
  margin-left: -130px;
  border-radius: 50% 50% 46% 46% / 58% 58% 42% 42%;
  filter: blur(36px);
  opacity: 0;
  will-change: transform, opacity;
  animation: medusa 30s ease-in-out infinite;
}
.chat__meduse i:nth-child(1) { background: radial-gradient(closest-side, #0003FE, transparent); animation-duration: 31s; animation-delay: -4s; }
.chat__meduse i:nth-child(2) { background: radial-gradient(closest-side, #FF633C, transparent); animation-duration: 26s; animation-delay: -15s; }
.chat__meduse i:nth-child(3) { background: radial-gradient(closest-side, #FFDC28, transparent); animation-duration: 35s; animation-delay: -24s; }
.chat__meduse--dx i:nth-child(1) { background: radial-gradient(closest-side, #FF6602, transparent); animation-duration: 29s; animation-delay: -19s; }
.chat__meduse--dx i:nth-child(2) { background: radial-gradient(closest-side, #0003FE, transparent); animation-duration: 33s; animation-delay: -7s; }
.chat__meduse--dx i:nth-child(3) { background: radial-gradient(closest-side, #FF633C, transparent); animation-duration: 27s; animation-delay: -12s; }
@keyframes medusa {
  0%   { opacity: 0;   transform: translate(-18px, 0) scale(.86, .96); }
  12%  { opacity: .34; }
  25%  { transform: translate(16px, calc(-30vh - 80px)) scale(1.06, .9); }
  50%  { transform: translate(-12px, calc(-60vh - 160px)) scale(.94, 1.08); }
  75%  { transform: translate(20px, calc(-90vh - 240px)) scale(1.07, .92); }
  88%  { opacity: .34; }
  100% { opacity: 0;   transform: translate(-18px, calc(-120vh - 320px)) scale(.86, .96); }
}
/* dove ai lati non c'è spazio (telefono in verticale, schermi stretti) le meduse non ci sono */
@media (max-width: 919px) { :root .chat > .chat__meduse { display: none; } }
/* telefoni stretti: il marchio resta solo la P, i comandi si stringono */
@media (max-width: 560px) {
  .m-top__end { gap: 4px; }
  .m-nav { gap: 4px; }
  .m-nav button { padding: 0 11px; font-size: 13px; }
  .m-lang__btn { padding: 0 9px 0 8px; }
  .m-lang__code { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}

/* La navigazione e le informazioni in fondo hanno spazi distinti. */
.m-nav button, .m-lang__btn { min-height: 36px; }
.m-nav button[aria-expanded="true"] { background: var(--ink); color: var(--paper); }
.m-footer { position: fixed; inset-inline-end: var(--pad); inset-block-end: calc(env(safe-area-inset-bottom) + 14px); z-index: 20; padding: 7px 13px; line-height: 1.1; color: var(--ink); font-size: 11px; pointer-events: none; }
.m-line { max-width: calc(100vw - 240px - 2 * var(--pad)); }
/* accanto alla partita IVA, «Cookie» riapre la scelta sulle statistiche (consenso.js: data-cookie-prefs) */
.m-footer a { pointer-events: auto; color: inherit; text-decoration: underline; text-underline-offset: 2px; padding: 8px 0; }
.m-footer a:hover { color: var(--ink); }
:is(.is-layer, .is-page, .is-page-open, .is-chat) :is(.m-line, .m-hint, .m-footer) { visibility: hidden; opacity: 0; }
/* mentre la carta vola a schermo intero, e finché il progetto è aperto, i pulsanti del muro non le stanno sopra */
.m-top { transition: opacity .3s var(--ease), visibility 0s; }
:is(.is-page, .is-page-open) .m-top { opacity: 0; visibility: hidden; transition: none; }
.no-muro .m-footer { position: static; padding: 20px var(--pad); }
#studio .hello { max-width: 860px; padding-top: 56px; margin-inline: auto; }
#studio .m-studio__legal { padding-top: 28px; border-top: 1px solid var(--line); }
@media (max-width: 560px) {
  .m-line { display: none; }
  .m-footer { inset-block-end: calc(env(safe-area-inset-bottom) + 12px); font-size: 10px; }
}

/* ---------- il banner dei cookie (assets/consenso.js, testi e colori da assets/muro-cookie.js) ----------
   Sta dentro il vetro, in basso al centro: sopra le carte, mai su motto e partita IVA (sotto il vetro) né sui pulsanti (sopra).
   Con indice, studio, chat o un progetto aperti si fa da parte e torna quando si torna al muro;
   finché è aperto, il suggerimento «Trascina il muro» aspetta. «html .cc» vince sullo stile scritto da consenso.js. */
html .cc {
  bottom: var(--ui-b);
  width: min(760px, calc(100vw - 2 * var(--glass-x) - 28px));
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 20px;
  padding: 14px 14px 14px 20px;
  border-radius: 22px;
  box-shadow: 0 26px 54px -24px rgba(0, 0, 0, .38), 0 1px 0 rgba(255, 255, 255, .6) inset;
  font-size: 13.5px;
  line-height: 1.45;
}
html .cc[dir="rtl"] { padding: 14px 20px 14px 14px; }
html .cc a { font-weight: 500; }
html .cc-row { grid-template-columns: auto auto; gap: 8px; }
html .cc-row button { min-height: 40px; padding: 0 18px; border-radius: 999px; font-weight: 500; font-size: 14px; }
:lang(zh-Hans) .cc, :lang(zh-Hant) .cc, :lang(ja) .cc { word-break: keep-all; line-break: strict; }
:is(.is-layer, .is-page, .is-page-open, .is-chat) .cc { display: none; }
.cc-open .m-hint { display: none; }
@media (max-width: 760px) {
  html .cc { grid-template-columns: 1fr; padding: 14px 16px; gap: 12px; }
  html .cc[dir="rtl"] { padding: 14px 16px; }
  html .cc-row { grid-template-columns: 1fr 1fr; }
}
/* senza muro (movimento ridotto) l'elenco è la pagina: in fondo resta spazio, così la partita IVA non finisce sotto il banner */
.no-muro.cc-open body { padding-bottom: 220px; }

/* ---------- il cerchietto dell'assistente, quello del sito di prima ----------
   Compare solo quando si apre lo studio, sopra al contenuto, con i colori del marchio che girano (assets/muro-chat.js).
   Si sposta trascinandolo dove si vuole (la posizione resta); la chat si apre a tutto schermo. */
.chat-btn {
  position: fixed;
  inset-block-end: calc(env(safe-area-inset-bottom) + 20px);
  touch-action: none;
  inset-inline-end: var(--pad);
  z-index: 46;
  width: 54px; height: 54px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  box-shadow: 0 18px 34px -18px rgba(0, 0, 0, .55);
  opacity: 0;
  visibility: hidden;
  transform: scale(.6);
  transition: transform .45s var(--ease), opacity .3s, visibility 0s .3s, box-shadow .4s;
}
html[data-livello="studio"] .chat-btn { opacity: 1; visibility: visible; transform: none; transition: transform .45s var(--ease), opacity .3s, box-shadow .4s; }
.chat-btn svg { width: 22px; height: 20px; fill: currentColor; }
.chat-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chat-ring { position: absolute; inset: -7px; width: calc(100% + 14px); height: calc(100% + 14px); pointer-events: none; }
html[data-livello="studio"] .chat-btn:hover { transform: translateY(-2px); box-shadow: 0 22px 40px -18px rgba(0, 0, 0, .6); }
html[data-livello="studio"] .chat-btn:active { transform: scale(.97); }
.chat-btn.is-open { background: var(--night-hi); }
html[data-livello="studio"] .chat-btn.is-dragging { cursor: grabbing; transform: scale(1.06); box-shadow: 0 26px 46px -18px rgba(0, 0, 0, .6); }
@media (max-width: 760px) {
  .chat-btn { width: 50px; height: 50px; }
  .chat-btn svg { width: 20px; height: 18px; }
  html[data-livello="studio"] .chat-btn:hover { transform: none; }
}

/* ---------- capsule di vetro satinato, con un filo bianco: marchio, pulsanti, motto, partita IVA ----------
   Stanno sopra le carte: il vetro le sfoca e le schiarisce, il bordino bianco le stacca. */
.m-brand, .m-nav button, .m-lang__btn, .m-line, .m-footer {
  background: rgba(244, 241, 234, .55);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, .8);
  border-radius: 999px;
  box-shadow: 0 10px 26px -16px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .6);
}
.m-nav button[aria-expanded="true"] { background: var(--ink); color: var(--paper); border-color: rgba(255, 255, 255, .5); }
/* il logo in alto a sinistra: un cerchio nero pieno, senza bordo né riflessi, con la P bianca e le tre strisce dell'anteprima dei link */
.m-brand { background: var(--night); border: 0; box-shadow: none; -webkit-backdrop-filter: none; backdrop-filter: none; }
.m-brand:hover { background: var(--night-hi); }
/* orologi e schermi minuscoli: tutto più piccolo, il motto si fa da parte, la partita IVA resta */
@media (max-width: 300px) {
  .m-top { padding-top: calc(env(safe-area-inset-top) + 8px); }
  .m-top__end, .m-nav { gap: 3px; }
  .m-brand { width: 36px; height: 36px; }
  .m-brand__p { width: 18px; height: 18px; }
  .m-nav button, .m-lang__btn { height: 28px; min-height: 28px; padding: 0 8px; font-size: 11px; }
  .m-lang__btn svg { width: 14px; height: 14px; }
  .m-lang__panel { width: min(220px, calc(100vw - 16px)); max-height: calc(100vh - 56px); }
  .m-line { display: none; }
  .m-footer { font-size: 9px; padding: 5px 9px; inset-block-end: calc(env(safe-area-inset-bottom) + 6px); }
  .m-hint { height: 30px; padding: 0 12px 0 10px; font-size: 10px; }
  /* qui il consenso non ci sta senza coprire qualcosa: resta libera la partita IVA, il banner scorre e copre per un momento i pulsanti */
  html .cc { width: calc(100vw - 16px); max-height: calc(100vh - 40px); overflow-y: auto; bottom: calc(env(safe-area-inset-bottom) + 30px); padding: 10px 12px; gap: 8px; font-size: 11px; line-height: 1.35; }
  html .cc-row button { min-height: 32px; padding: 0 10px; font-size: 12px; }
  /* nello studio la fascia del cerchietto si fa bassa, sennò resta poco spazio per leggere */
  .m-layer__in { padding-top: calc(env(safe-area-inset-top) + 58px); padding-bottom: 24px; }
  .m-layer__head { padding-bottom: 8px; }
  .chat-btn { width: 38px; height: 38px; inset-block-end: calc(env(safe-area-inset-bottom) + 10px); }
  .chat-btn svg { width: 15px; height: 14px; }
  /* la chat: la nota si fa da parte, tutto più compatto */
  .chat__head { padding: 8px 8px 6px 10px; }
  .chat__title { font-size: 13px; }
  .chat__note { display: none; }
  .chat__icon { width: 28px; height: 28px; }
  .chat__who { padding: 8px 10px; gap: 6px; }
  .chat__intro { font-size: 12px; }
  .chat__who input { height: 32px; font-size: 13px; }
  .chat__foot { display: none; } /* l'informativa resta raggiungibile dallo studio */
}
/* i campi della chat non sono mai più larghi dello schermo */
.chat { grid-template-columns: minmax(0, 1fr); }
.chat__who label, .chat__who input { min-width: 0; width: 100%; }
