/* eco · la home: il pannello fermo al centro, i ricordi che gli scorrono dietro,
   un obiettivo grandangolare ai bordi della finestra. */

:root {
  --bg: #000;
  --ink: #F4F4F0;
  --muted: #9A9E99;
  --sans: -apple-system, "SF Pro Display", "SF Pro Text", system-ui, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  /* Il pannello: circa metà della finestra, in verticale come nell'app. */
  --ph: min(58vh, 560px);
  --pw: calc(var(--ph) * 0.77);
  --row: 50px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: var(--sans); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
html.intro, html.intro body { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.mono { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; }

/* Una lingua alla volta. */
[data-ui="it"] [lang="en"]:not(html),
[data-ui="en"] [lang="it"]:not(html) { display: none !important; }

/* ---------- I ricordi ---------- */

.wall {
  position: relative;
  z-index: 0;
  /* Le righe ingrandite ai bordi escono dalla finestra: si tagliano qui, così la pagina
     non diventa più larga dello schermo (sul telefono scorreva di lato e il pannello usciva). */
  overflow-x: clip;
  padding: calc(50vh - var(--row) / 2) 0 100vh;
  transition: opacity .5s ease;
}
html.intro .wall { opacity: 0; }

.row { height: var(--row); will-change: transform; }
.row .in {
  height: 100%;
  display: grid;
  grid-template-columns: 1fr calc(var(--pw) + 80px) 1fr;
  align-items: center;
  padding: 0 40px;
}
html.ready .row .in {
  animation: rise .9s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(var(--i) * 35ms);
}
@keyframes rise { from { opacity: 0; transform: translateY(70px); } to { opacity: 1; transform: none; } }

.cell { display: flex; align-items: baseline; gap: 14px; min-width: 0; transition: opacity .25s ease; }
.cell.right { grid-column: 3; justify-content: flex-end; }
.cell .t {
  font-size: 28px; font-weight: 500; letter-spacing: -0.03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0;
}
.cell .w { font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; color: var(--muted); white-space: nowrap; }
.cell.right .w { order: -1; }

/* ---------- L'obiettivo ai bordi ---------- */

.lens-blur, .lens-vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.lens-blur {
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  -webkit-mask-image: radial-gradient(ellipse 62% 60% at 50% 50%, transparent 55%, #000 100%);
  mask-image: radial-gradient(ellipse 62% 60% at 50% 50%, transparent 55%, #000 100%);
}
.lens-vignette { background: radial-gradient(ellipse 75% 70% at 50% 50%, rgba(0,0,0,0) 55%, rgba(0,0,0,.85) 100%); }

/* ---------- Il pannello ---------- */

.panel {
  position: fixed; z-index: 3;
  left: 50%; top: 50%;
  width: var(--pw); height: var(--ph);
  transform: translate(-50%, -50%);
  border-radius: 46px; overflow: hidden;
  background: #3D55C4;
  box-shadow: 0 40px 120px rgba(0,0,0,.7);
  pointer-events: none;
}
.panel canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.panel-ui {
  position: absolute; inset: 0;
  padding: 46px 42px 38px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.panel-top { display: flex; justify-content: space-between; align-items: center; color: rgba(244,244,240,.78); }
.status { display: flex; align-items: center; gap: 8px; }
.status i { width: 6px; height: 6px; border-radius: 3px; background: var(--ink); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.panel-text { display: flex; flex-direction: column; gap: 14px; }
.said { margin: 0; font-size: 28px; font-weight: 500; letter-spacing: -0.03em; line-height: 1.18; }
.caret { display: inline-block; width: 2px; height: .95em; margin-left: 2px; vertical-align: -0.12em; background: var(--ink); animation: caret .9s steps(1) infinite; }
.caret[hidden] { display: none; }
@keyframes caret { 50% { opacity: 0; } }
.answer, .answer-end { margin: 0; font-size: 17px; line-height: 1.4; color: rgba(244,244,240,.66); }
.answer:not([hidden]) { animation: fade .6s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.end h1 { margin: 0 0 14px; font-size: 44px; font-weight: 600; letter-spacing: -0.04em; line-height: 1.02; }
.end:not([hidden]) { animation: fade .7s ease both; }

.panel-bottom { display: flex; align-items: center; justify-content: center; gap: 22px; }
.mic {
  width: 68px; height: 68px; border-radius: 50%;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18);
  display: grid; place-items: center;
  box-shadow: 0 12px 28px rgba(0,0,0,.4);
}
.mic svg { width: 26px; height: 26px; }
.wave { display: flex; align-items: center; gap: 4px; height: 28px; transform: scaleY(.32); transition: transform .25s ease; }
.panel.moving .wave { transform: scaleY(1); }
.wave b { width: 3px; height: 100%; border-radius: 2px; background: rgba(244,244,240,.8); animation: bar .9s ease-in-out infinite; }
.wave b:nth-child(2) { animation-duration: .7s; animation-delay: .1s; }
.wave b:nth-child(3) { animation-duration: 1.1s; animation-delay: .2s; }
@keyframes bar { 0%, 100% { transform: scaleY(.3); } 50% { transform: scaleY(1); } }

/* ---------- Sopra a tutto, in piccolo ---------- */

.top {
  position: fixed; z-index: 4; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 26px 40px;
  padding-top: max(26px, env(safe-area-inset-top));
}
.wordmark { font-size: 22px; font-weight: 600; letter-spacing: -0.03em; display: inline-flex; align-items: center; gap: 0.34em; }
.wordmark .mark { width: 1.05em; height: 1.05em; flex: none; }
.wordmark .mark g { stroke-width: 44; } /* a 22 px il tratto originale sarebbe sotto il pixel */
.langs { display: flex; gap: 14px; }
.lang { color: var(--muted); min-height: 32px; }
.lang[aria-pressed="true"] { color: var(--ink); }
.lang:focus-visible, a:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; border-radius: 4px; }

.bottom {
  position: fixed; z-index: 4; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 24px 40px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  color: var(--muted);
}
.bottom nav { display: flex; gap: 24px; }
.bottom a:hover { color: var(--ink); }

.scroll-hint {
  position: fixed; z-index: 4; left: 0; right: 0; bottom: 70px; margin: 0;
  text-align: center; color: var(--muted);
  opacity: 0; transition: opacity .4s ease; pointer-events: none;
}
html.ready .scroll-hint.on { opacity: 1; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; font-size: 22px; z-index: 9; background: #000; }

/* ---------- Telefono ---------- */

@media (max-width: 760px) {
  :root {
    --pw: min(86vw, 360px);
    --ph: min(52vh, calc(var(--pw) * 1.27));
    --row: 80px;
  }
  .row .in { grid-template-columns: 1fr; grid-template-rows: 40px 40px; padding: 0 20px; }
  .cell { align-items: center; gap: 10px; }
  .cell.right { grid-column: 1; }
  .cell .t { font-size: 22px; }
  .cell .w { font-size: 9px; }
  .panel { border-radius: 42px; }
  .panel-ui { padding: 36px 30px 30px; }
  .said { font-size: 21px; }
  .answer, .answer-end { font-size: 15px; }
  .end h1 { font-size: 34px; }
  .mic { width: 58px; height: 58px; }
  .mic svg { width: 23px; height: 23px; }
  .wave { height: 22px; }
  .panel-bottom { gap: 16px; }
  .top { padding: 18px 22px; padding-top: max(18px, env(safe-area-inset-top)); }
  .wordmark { font-size: 20px; }
  .bottom { padding: 18px 22px; padding-bottom: max(18px, env(safe-area-inset-bottom)); font-size: 10px; }
  .bottom nav { gap: 16px; }
  .scroll-hint { bottom: 62px; }
  .lens-blur {
    -webkit-mask-image: radial-gradient(ellipse 70% 58% at 50% 50%, transparent 55%, #000 100%);
    mask-image: radial-gradient(ellipse 70% 58% at 50% 50%, transparent 55%, #000 100%);
  }
}

/* ---------- Finestre basse (telefono in orizzontale) ---------- */
/* Il pannello si allarga invece di schiacciarsi, e lascia posto a intestazione e piede. */

@media (max-height: 560px) {
  :root {
    --ph: max(200px, calc(100vh - 132px));
    --pw: min(calc(var(--ph) * 1.6), 76vw);
    --row: 44px;
  }
  .row .in { grid-template-columns: 1fr calc(var(--pw) + 40px) 1fr; grid-template-rows: none; padding: 0 24px; }
  .cell.right { grid-column: auto; }
  .cell .t { font-size: 18px; }
  .panel { border-radius: 32px; }
  .panel-ui { padding: 22px 28px 16px; }
  .said { font-size: 19px; }
  .answer, .answer-end { font-size: 14px; }
  .end h1 { font-size: 28px; }
  .mic { width: 48px; height: 48px; }
  .mic svg { width: 20px; height: 20px; }
  .wave { height: 18px; }
  .panel-bottom { gap: 14px; }
  .top { padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 12px; }
  .bottom { padding-top: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .scroll-hint { display: none; }
}

/* Movimento ridotto: niente salite, niente cursore che lampeggia. */
@media (prefers-reduced-motion: reduce) {
  html.ready .row .in { animation: none; }
  .caret, .status i, .wave b { animation: none; }
}
