:root {
  --bg:        #07070c;
  --bg-2:      #0c0c16;
  --ink:       #efeaf0;
  --ink-dim:   #b3aec6;
  --ink-faint: #6a6680;
  --gold:      #f4c879;
  --warm:      #ff9f6b;
  --line:      rgba(244,200,121,.16);
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body:    "Spectral", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  cursor: none;            /* il cursore è disegnato sul campo */
}
/* Quando il puntatore non è disponibile (touch), ripristina il cursore di sistema */
@media (hover: none) { body { cursor: auto; } }

/* ---- IL CAMPO ---- */
#field {
  position: fixed; inset: 0; z-index: 1;
  width: 100%; height: 100%;
  display: block;
}

/* ---- ACCESSIBILITÀ ---- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 4px;
}

/* ---- STRATO UI ---- */
.ui {
  position: fixed; inset: 0; z-index: 2;
  pointer-events: none;                 /* il campo riceve gli eventi… */
  display: flex; flex-direction: column;
  padding: clamp(1rem, 3vw, 2rem);
}
.ui button, .ui [role="slider"] { pointer-events: auto; }  /* …tranne i controlli */

/* Brand defilato: una firma, non un titolo invadente. Svanisce appena interagisci. */
.brand { text-align: left; transition: opacity 1.1s ease; }
.brand.gone { opacity: 0; }
.brand-name {
  font-family: var(--display);
  font-weight: 300; font-style: italic;
  font-size: clamp(1rem, .8rem + 1vw, 1.4rem);
  letter-spacing: .14em;
  color: var(--ink-dim);
  opacity: .6;
  text-shadow: 0 0 24px rgba(244,200,121,.12);
}

/* Sussurro del bisogno attivo */
.whisper {
  position: absolute; top: clamp(14%, 18vh, 22%); left: 50%;
  transform: translateX(-50%);
  font-family: var(--display);
  font-weight: 300; font-style: italic;
  font-size: clamp(2rem, 1.4rem + 4vw, 4.2rem);
  letter-spacing: .04em;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;                         /* pilotata da JS in base alla concentrazione */
  transition: opacity .6s ease;
  text-shadow: 0 0 40px rgba(0,0,0,.7);
  will-change: opacity;
}

/* Gancio d'apertura: la domanda che dà senso */
.intro {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  max-width: min(86vw, 30rem);
  transition: opacity 1.1s ease;
}
.intro-q {
  font-family: var(--display);
  font-weight: 300; font-style: italic;
  font-size: clamp(2.4rem, 1.8rem + 5vw, 4.6rem);
  line-height: 1.05;
  color: var(--ink);
  text-shadow: 0 2px 40px rgba(0,0,0,.7);
}
.intro-a {
  font-family: var(--body);
  font-size: clamp(1rem, .9rem + .8vw, 1.4rem);
  color: var(--ink-dim);
  margin-top: .6rem;
}
.intro-cue {
  margin-top: 1.8rem;
  font-size: .74rem; letter-spacing: .26em; text-transform: uppercase;
  color: var(--ink-faint);
  animation: breathe 4s ease-in-out infinite;
}
.intro.gone { opacity: 0; pointer-events: none; }
@keyframes breathe { 0%,100%{opacity:.45} 50%{opacity:.85} }

/* ---- QUADRANTE DELLO STATO ---- */
.dial-wrap {
  margin-top: auto;
  display: flex; justify-content: center;
  margin-bottom: clamp(.5rem, 2vh, 1.2rem);
}
.dial {
  width: clamp(116px, 26vw, 168px);
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}
.dial:active { cursor: grabbing; }
.dial-svg { width: 100%; height: 100%; overflow: visible; }

.dial-ring {
  fill: rgba(12,12,22,.42);
  stroke: var(--line);
  stroke-width: 1;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.anchor { transition: r .3s ease, opacity .3s ease; }
.anchor-mark { opacity: .55; }
.dial-tether {
  stroke: var(--gold); stroke-width: 1; opacity: .35;
  stroke-linecap: round;
}
.dial-puck {
  fill: var(--ink);
  stroke: var(--gold); stroke-width: 1.5;
  filter: drop-shadow(0 0 8px rgba(244,200,121,.5));
}

/* ---- CONTROLLI ---- */
.controls {
  display: flex; justify-content: center; gap: .5rem;
  flex-wrap: wrap;
}
.ctl {
  display: inline-flex; align-items: center; gap: .5rem;
  background: rgba(12,12,22,.5);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--body); font-size: .82rem;
  letter-spacing: .12em; text-transform: lowercase;
  padding: .5rem .95rem;
  cursor: pointer;
  transition: color .25s ease, border-color .25s ease, background .25s ease, transform .2s ease;
}
.ctl:hover { color: var(--ink); border-color: var(--gold); transform: translateY(-1px); }
.ctl[aria-pressed="true"] { color: var(--bg); background: var(--gold); border-color: var(--gold); }
.ctl-glyph { font-size: 1rem; line-height: 1; }

/* Pulsazione discreta sul tasto suono finché è spento */
#soundBtn:not([aria-pressed="true"]) .ctl-glyph { animation: pulseGlyph 2.6s ease-in-out infinite; }
@keyframes pulseGlyph { 0%,100%{opacity:.55} 50%{opacity:1} }

/* ---- CHIUSA / RIVELAZIONE ---- */
.coda {
  position: fixed; left: 0; right: 0; bottom: clamp(2rem, 7vh, 4.5rem);
  z-index: 3;
  text-align: center;
  font-family: var(--display);
  font-weight: 300; font-style: italic;
  font-size: clamp(1.15rem, 1rem + 1.4vw, 1.9rem);
  line-height: 1.35;
  color: var(--ink);
  padding: 0 1.4rem;
  text-shadow: 0 2px 30px rgba(0,0,0,.8);
  opacity: 0;
  transition: opacity 1.4s ease 0.3s;
}
.coda.show { opacity: 1; }

/* ---- MODALITÀ AMBIENT (salvaschermo / loop autogenerativo) ----
   Nasconde ogni comando; resta il campo e il sussurro del bisogno. */
body.ambient { cursor: none; }
body.ambient .brand,
body.ambient .intro,
body.ambient .dial-wrap,
body.ambient .controls,
body.ambient .install-btn {
  opacity: 0 !important;
  pointer-events: none !important;
  transition: opacity 1.2s ease;
}

/* ---- INSTALLA ---- */
.install-btn {
  position: fixed; right: clamp(1rem,3vw,2rem); top: clamp(1rem,3vw,2rem);
  z-index: 4;
  background: transparent; color: var(--gold);
  border: 1px solid var(--gold); border-radius: 999px;
  padding: .45rem 1.1rem; font-family: var(--body);
  font-size: .8rem; letter-spacing: .12em; cursor: pointer;
  transition: background .25s ease, color .25s ease;
}
.install-btn:hover { background: var(--gold); color: var(--bg); }

/* Su schermi stretti accorcia le etichette dei controlli */
@media (max-width: 420px) {
  .ctl-lab { display: none; }
  .ctl { padding: .6rem; }
  .ctl-glyph { font-size: 1.15rem; }
}

/* ---- MOTO RIDOTTO ---- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .intro-cue, #soundBtn .ctl-glyph { animation: none; }
  .coda { transition: opacity .2s ease; }
}
