/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #edefee;
  --ink: #0a0a0a;
}

html { -webkit-text-size-adjust: 100%; }

body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Helvetica Neue", Helvetica, Arial, "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }

/* contenuto accessibile/indicizzabile ma non visibile */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* ---------- Rumore statico (grana fine) ---------- */
.noise {
  position: absolute;
  inset: 0;
  z-index: 2;          /* sotto l'avatar (3): la trasparenza del canvas lascia passare la grana */
  pointer-events: none;
  background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  background-size: 180px 180px;
  animation: grain 0.45s steps(8) infinite;
}
/* grana scura sul chiaro (sfondo) */
.noise--mul { mix-blend-mode: multiply; opacity: 0.8; }
/* grana chiara sul scuro (testo SILVIO LUCHETTI) = fusione, discreta */
.noise--scr { mix-blend-mode: screen; opacity: 0.18; }
@keyframes grain {
  from { background-position: 0 0; }
  to   { background-position: 180px 180px; }
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(18px, 3vw, 34px) clamp(24px, 4vw, 56px);
  font-size: clamp(11px, 1vw, 13px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav__group { display: flex; gap: clamp(10px, 1.2vw, 18px); }

/* bottoni a pillola — stessa forma/animazione per tutti */
.btn {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: inherit;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #fff;
  background: var(--ink);
  border: 0;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.2s ease, filter 0.2s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.18); }
.btn--links    { background: #2b1064; } /* viola scuro */
.btn--about    { background: #0a3b40; } /* teal scuro */
.btn--contact  { background: var(--ink); }

/* ---------- Hero ---------- */
/* area di scroll: più è alta, più scroll serve per completare il giro */
.stage {
  position: relative;
  height: 220vh;
}

.hero {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
  background: var(--bg);   /* opaco: la grana multiply ci si fonde sopra */
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero__title {
  position: absolute;
  top: clamp(96px, 14vh, 170px);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  text-align: center;
  z-index: 1;
  font-family: "Bowlby One SC", "Arial Black", Helvetica, sans-serif;
  font-weight: 400;
  line-height: 0.8;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  font-size: clamp(58px, 17vw, 250px);
  user-select: none;
}
/* ogni riga su una sola linea: il JS scala il font per riempire la
   stessa larghezza, così SILVIO e LUCHETTI risultano identici */
.hero__line { display: block; white-space: nowrap; }
/* la seconda riga (LUCHETTI) ha lettere più ravvicinate nel font:
   un filo di tracking per non far toccare E-T-T-I */
.hero__line:last-child { letter-spacing: 0.005em; }

/* Avatar ancorato al fondo: piedi sempre visibili above-the-fold,
   testa che arriva sulla seconda riga del titolo */
.hero__avatar {
  position: absolute;
  z-index: 3;   /* sopra la grana: l'avatar non è toccato dal rumore */
  bottom: clamp(16px, 4vh, 48px);
  left: 50%;
  transform: translateX(-50%);
  height: 64svh; max-height: 640px;
  width: calc(64svh * 0.4491); max-width: 287px;   /* proporzione frame 300/668 */
}

.hero__avatar {
  touch-action: manipulation;   /* tap = spin, swipe verticale = scroll */
  /* cursore a freccia circolare (icona rotate con alone bianco) */
  cursor: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='22' height='22' viewBox='0 0 24 24' fill='none'><g stroke='%23ffffff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'><path d='M21 12a9 9 0 1 1-2.64-6.36'/><path d='M21 3v6h-6'/></g><g stroke='%230a0a0a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M21 12a9 9 0 1 1-2.64-6.36'/><path d='M21 3v6h-6'/></g></svg>") 11 11, pointer;
}

.hero__video {            /* <canvas> con i frame trasparenti */
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  /* bottoni ancorati in basso, centrati — senza riquadro */
  .nav {
    top: auto;
    left: 50%;
    right: auto;
    bottom: calc(26px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    width: max-content;
    max-width: calc(100vw - 28px);
    justify-content: center;
    flex-wrap: wrap;
    gap: 9px;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
  }
  /* i 3 bottoni del gruppo diventano figli diretti → tutti allineati/centrati */
  .nav__group--left { display: contents; }
  .btn { padding: 10px 14px; }

  /* scritta in alto (con un po' più di respiro dal top); avatar più
     piccolo, leggermente sovrapposto. Le larghezze righe le fa il JS */
  .hero__title {
    top: clamp(96px, 15vh, 170px);
    font-size: clamp(50px, 16.5vw, 108px);
    padding: 0 16px;
  }
  .hero__avatar {
    top: clamp(146px, 22vh, 270px);
    bottom: auto;
    height: 55svh; max-height: 480px;
    width: calc(55svh * 0.4491); max-width: 215px;   /* proporzione frame */
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav__cta:hover { transform: none; }
  .noise { animation: none; }
}

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ============ Vista contatto (chat nera) ============ */
.contact {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  background: transparent;   /* il nero lo fornisce .contact__bg che si espande */
  color: #fff;
}
body.contact-open { overflow: hidden; }
body.contact-open .contact { display: flex; }

/* layer nero che si espande in modo liquido (più grande della viewport,
   così i bordi deformati dal filtro restano fuori schermo a fine espansione) */
/* canvas WebGL: reveal fluido che si espande dal bottone — DIETRO alla chat */
.contact__bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

/* il contenuto della pagina compare solo a espansione completata, poi sfuma */
.page, .contact__close { opacity: 0; transition: opacity 0.3s ease; }
.contact--open .page, .contact--open .contact__close { opacity: 1; }
.contact--opening .contact__close { opacity: 1; } /* la X resta cliccabile */

/* pagine: sopra il canvas; solo quella attiva è visibile */
.page {
  position: relative;
  z-index: 1;
  font-family: "Space Mono", ui-monospace, monospace; /* testo pagine = mono come la nav */
}
.page[hidden] { display: none !important; }

/* pagine semplici (Project / Link tree / About) */
.page--simple {
  margin: auto;
  max-width: min(90vw, 900px);
  text-align: center;
  color: #fff;
  padding: 0 24px;
}
.page__title {
  font-family: "Bowlby One SC", "Arial Black", Helvetica, sans-serif;
  font-size: clamp(48px, 13vw, 150px);
  line-height: 0.9;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.page__sub { margin-top: 18px; font-size: clamp(15px, 1.4vw, 18px); opacity: 0.65; }

/* ============ Pagina About (minimal & elegante) ============ */
.about {
  --mint: #6fe0c4;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  color: #fff;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  scrollbar-width: thin;
}
.about::-webkit-scrollbar { width: 6px; }
.about::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 4px; }

.about__inner {
  max-width: 600px;
  margin: 0 auto;
  padding: clamp(96px, 15vh, 150px) 24px clamp(80px, 12vh, 120px);
}

/* testo base coerente */
.about p { font-size: clamp(15px, 2.3vw, 16px); line-height: 1.75; color: rgba(255,255,255,0.74); margin: 0 0 16px; }
.about strong { color: #fff; font-weight: 600; }
.about em { font-style: normal; color: var(--mint); }

/* intestazione */
.about__eyebrow {
  font-family: "Space Mono", monospace;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--mint); margin: 0 0 16px;
}
.about__title {
  font-size: clamp(40px, 7vw, 60px);
  font-weight: 700; letter-spacing: -0.02em; line-height: 1;
  white-space: nowrap; margin: 0 0 26px;
}
.about__lead { font-size: clamp(18px, 2.7vw, 21px) !important; line-height: 1.55 !important; color: #fff !important; margin-bottom: 16px !important; }
.about__note { color: rgba(255,255,255,0.55) !important; }

/* sezioni: micro-label mono coerente per tutte */
.about__sec { margin-top: clamp(46px, 7vh, 74px); }
.about__kicker {
  font-family: "Space Mono", monospace;
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--mint); margin: 0 0 16px !important;
}

/* callout unico, pulito */
.quote {
  margin: 22px 0 4px;
  padding: 2px 0 2px 22px;
  border-left: 2px solid var(--mint);
  font-size: clamp(19px, 2.9vw, 23px);
  line-height: 1.42;
  font-weight: 500;
  color: #fff;
}
.quote em { color: var(--mint); }
.quote--final { font-size: clamp(21px, 3.3vw, 27px); margin-top: 0; }

/* "Cosa faccio" come lista pulita */
.about__list { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 22px; }
.about__list li { display: flex; flex-direction: column; gap: 5px; }
.about__list strong { font-size: 17px; color: #fff; font-weight: 600; }
.about__list span { font-size: clamp(15px, 2.3vw, 16px); line-height: 1.6; color: rgba(255,255,255,0.68); }

.about__close { margin-top: clamp(54px, 8vh, 84px); }

/* ============ Pagina Links (bento board) ============ */
.links {
  --acc: #c4b1ff;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  color: #fff;
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif;
  scrollbar-width: thin;
}
.links::-webkit-scrollbar { width: 6px; }
.links::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.16); border-radius: 4px; }

.links__inner {
  max-width: 780px;
  margin: 0 auto;
  padding: clamp(96px, 15vh, 150px) 24px clamp(80px, 12vh, 120px);
}
.links__eyebrow {
  font-family: "Space Mono", monospace;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--acc); margin: 0 0 16px;
}
.links__title {
  font-size: clamp(40px, 7vw, 60px);
  font-weight: 700; letter-spacing: -0.02em; line-height: 1;
  white-space: nowrap; margin: 0 0 8px;
}

.cluster { margin-top: clamp(34px, 5vh, 52px); }
.cluster__label {
  font-family: "Space Mono", monospace;
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--acc); margin: 0 0 16px;
}

/* lista di chip lean */
.chips { display: flex; flex-direction: column; gap: 9px; }

.chip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 15px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.chip:hover { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.32); transform: translateY(-1px); }
.chip:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* favicon = anteprima del sito */
.chip__fav {
  width: 28px; height: 28px;
  flex: 0 0 auto;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.1);
  object-fit: cover;
}
/* micro-vibrazione della favicon all'hover */
@keyframes favShake {
  0%, 100% { transform: none; }
  20% { transform: translateX(-1.5px) rotate(-7deg); }
  40% { transform: translateX(1.5px) rotate(7deg); }
  60% { transform: translateX(-1px) rotate(-4deg); }
  80% { transform: translateX(1px) rotate(3deg); }
}
.chip:hover .chip__fav { animation: favShake 0.45s ease; }

.chip__txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.chip__txt b { font-weight: 600; font-size: 15px; }
.chip__txt small { font-family: "Space Mono", monospace; font-size: 12px; color: rgba(255, 255, 255, 0.55); }
.chip__arrow { flex: 0 0 auto; font-family: "Space Mono", monospace; font-size: 15px; color: rgba(255, 255, 255, 0.5); transition: transform 0.18s ease, color 0.18s ease; }
.chip:hover .chip__arrow { transform: translate(2px, -2px); color: #fff; }

/* chip in evidenza (con descrizione) */
.chip--feature { align-items: flex-start; padding: 16px; }
.chip--feature .chip__fav { width: 34px; height: 34px; }
.chip--feature .chip__arrow { margin-top: 2px; }
.chip__desc {
  font-family: "Inter", "Helvetica Neue", Arial, sans-serif !important;
  font-size: 13.5px !important;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.72) !important;
  margin: 4px 0 5px;
  max-width: 46ch;
}


.contact__close {
  position: absolute;
  top: clamp(16px, 3vw, 32px);
  right: clamp(16px, 3vw, 36px);
  z-index: 2;
  width: 44px; height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}
.contact__close:hover { background: rgba(0, 0, 0, 0.45); transform: rotate(90deg); }

/* ====== Chat in stile terminale ====== */
:root { --mc-accent: #6fe0c4; }

/* ===== Sentiamoci: conversazione con avatar su nero, input ghost ===== */
.sentiamoci {
  position: relative;
  z-index: 1;                       /* sopra il canvas */
  margin: auto;
  width: min(94vw, 600px);
  height: min(92svh, 800px);
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2.4vh, 26px);
}
.sentiamoci__title {
  font-family: "Bowlby One SC", "Arial Black", Helvetica, sans-serif;
  font-size: clamp(34px, 8.5vw, 92px);
  line-height: 0.9;
  letter-spacing: 0.01em;
  text-align: center;
  color: #fff;
  flex: 0 0 auto;
  padding: 0 56px;            /* lascia spazio alla X di chiusura */
}

/* log: nessun riquadro, le bolle galleggiano sul nero */
.mc__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 6px 4px 10px;
  scrollbar-width: thin;
}
.mc__log::-webkit-scrollbar { width: 5px; }
.mc__log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.14); border-radius: 4px; }

/* riga messaggio: avatar + bolla */
.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 86%;
  opacity: 0;
  transform: translateY(8px);
  animation: msgIn 0.32s cubic-bezier(.2,.8,.2,1) forwards;
}
.msg-row--bot { align-self: flex-start; }
.msg-row--user { align-self: flex-end; flex-direction: row-reverse; }
@keyframes msgIn { to { opacity: 1; transform: none; } }

/* avatar circolari */
.av {
  width: 34px; height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #1b1b1b center/cover no-repeat;
}
.av--silvio { background-image: url("silvio-avatar.webp"); }
.av--you {
  background-color: rgba(255,255,255,0.10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23c9cdcb'%3E%3Ccircle cx='12' cy='8.4' r='3.8'/%3E%3Cpath d='M4.6 20c0-4.2 3.4-6.6 7.4-6.6s7.4 2.4 7.4 6.6z'/%3E%3C/svg%3E");
  background-size: 62%;
  background-position: center 56%;
}

/* bolle */
.msg {
  padding: 11px 15px;
  font-size: 15px;
  line-height: 1.45;
  border-radius: 19px;
  word-break: break-word;
}
.msg--bot { background: rgba(255,255,255,0.085); color: #eceeed; border-bottom-left-radius: 6px; }
.msg--user { background: var(--mc-accent); color: #06281f; font-weight: 700; border-bottom-right-radius: 6px; }
.msg--sys {
  align-self: center;
  color: rgba(255,255,255,0.38);
  font-size: 12px;
  opacity: 0;
  animation: msgIn 0.32s ease forwards;
}

/* indicatore "sta scrivendo" */
.msg--typing { display: inline-flex; gap: 5px; align-items: center; padding: 13px 15px; }
.msg--typing .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255,255,255,0.6);
  animation: mcDot 1.2s infinite ease-in-out;
}
.msg--typing .dot:nth-child(2) { animation-delay: 0.18s; }
.msg--typing .dot:nth-child(3) { animation-delay: 0.36s; }
@keyframes mcDot { 0%,60%,100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* chips opzioni (a pillola, lato utente) */
.mc__options {
  align-self: flex-end;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin: 0 44px 2px 0;       /* allineate alla colonna delle bolle utente */
  max-width: 86%;
}
.mc__opt {
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--mc-accent);
  background: rgba(111, 224, 196, 0.08);
  border: 1.5px solid var(--mc-accent);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.16s, color 0.16s, transform 0.16s;
}
.mc__opt:hover { background: var(--mc-accent); color: #06281f; transform: translateY(-1px); }

/* composer ghost: trasparente, riga appena percettibile */
.mc__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 6px 4px;
  background: none;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.mc__bar.is-hidden { display: none; }
.mc__input {
  flex: 1;
  background: none;
  border: 0;
  outline: none;
  color: #fff;
  font: inherit;
  font-size: 15px;
  caret-color: var(--mc-accent);
}
.mc__input::placeholder { color: rgba(255,255,255,0.26); }   /* ghost */
.mc__send {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: rgba(255,255,255,0.5);
  font-size: 20px;
  cursor: pointer;
  display: grid; place-items: center;
  transition: color 0.2s, transform 0.2s;
}
.mc__send:hover { color: var(--mc-accent); transform: scale(1.1); }
.mc__send:disabled { opacity: 0.3; cursor: default; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .msg-row, .msg--sys { animation: none; opacity: 1; transform: none; }
  .msg--typing .dot { animation: none; }
}
