/* La tastiera di pianoforte */
:root {
  --fondo: #F2EBDC;
  --inchiostro: #1F1A16;
  --tenue: #7C7062;
  --cassa: #15110E;
  --feltro: #A51F2B;
  --avorio: #F8F3E8;
  --ebano: #1A1612;
  --nota-grave: #2E44B4;
  --nota-media: #D6432E;
  --nota-acuta: #DE8C0F;
  --margine: clamp(16px, 4vw, 56px);
  --alto: 100vh;
}
@supports (height: 100svh) {
  :root { --alto: 100svh; }
}

* { box-sizing: border-box; }
html,
body {
  margin: 0;
  overflow: hidden;
}
body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: 'Instrument Sans Variable', system-ui, sans-serif;
}

.sala {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  height: var(--alto);
  padding: clamp(28px, 6vh, 64px) 0 clamp(18px, 3.4vh, 34px);
  /* un alone caldo dietro alla tastiera */
  background: radial-gradient(120% 60% at 50% 100%, rgba(165, 31, 43, 0.08), transparent 60%);
}

/* ---------------------------------------------------------------- l'insegna */
.insegna {
  position: relative;
  z-index: 3;
  padding: 0 var(--margine);
  text-align: center;
}
.insegna__sopra,
.insegna__sotto {
  margin: 0;
  color: var(--tenue);
  font-size: clamp(0.78rem, 0.72rem + 0.3vw, 0.98rem);
  font-weight: 520;
  letter-spacing: 0.02em;
}
.insegna__titolo {
  margin: 0.18em 0 0.26em;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(2.3rem, 1.2rem + 5.4vw, 6.4rem);
  font-weight: 560;
  font-variation-settings: 'SOFT' 80, 'WONK' 1, 'opsz' 120;
  letter-spacing: -0.025em;
  line-height: 0.96;
  text-wrap: balance;
}
.parola {
  display: inline-block;
  white-space: nowrap;
}
.lettera {
  display: inline-block;
  will-change: transform;
}

/* ---------------------------------------------------------------- la tastiera */
.pianoforte {
  position: relative;
  z-index: 1;
  grid-row: 3;
  width: 100%;
  height: var(--altezza-piano, 300px);
  perspective: 1500px;
  perspective-origin: 50% -40%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.piano {
  position: absolute;
  bottom: var(--sotto-piano, 30px);
  left: 0;
  width: 100%;
  height: var(--L, 300px);
  transform-style: preserve-3d;
  transform-origin: 50% 100%;
  transform: rotateX(var(--incl, 38deg));
}
/* il letto: quello che si vede fra un tasto e l'altro */
.piano__letto {
  position: absolute;
  inset: 0;
  transform: translateZ(calc(var(--pozzo, 40px) * -1));
  background: linear-gradient(#0c0907, #2a211b);
}
.piano__tasti {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
/* la parete dietro ai tasti, in piedi, laccata */
.piano__parete {
  position: absolute;
  left: 0;
  bottom: 100%;
  width: 100%;
  height: var(--parete, 70px);
  transform-origin: 50% 100%;
  transform: rotateX(-90deg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16) 0, rgba(255, 255, 255, 0) 22%),
    linear-gradient(180deg, transparent 58%, rgba(255, 255, 255, 0.07) 64%, transparent 72%),
    var(--cassa);
}
.piano__filetto {
  position: absolute;
  left: 0;
  right: 0;
  top: 30%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(222, 180, 110, 0.55) 20%, rgba(222, 180, 110, 0.55) 80%, transparent);
}
/* il feltro rosso, alla base della parete, dove finiscono i tasti */
.piano__feltro {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--feltro-h, 14px);
  background:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.07) 0 1px, transparent 1px 2px),
    linear-gradient(180deg, color-mix(in srgb, var(--feltro) 72%, #fff) 0, var(--feltro) 40%, color-mix(in srgb, var(--feltro) 60%, #000) 100%);
}
/* il listello davanti ai tasti, che scende in verticale */
.piano__listello {
  position: absolute;
  left: 0;
  top: 100%;
  width: 100%;
  height: var(--listello, 26px);
  transform-origin: 50% 0;
  transform: translateZ(calc(var(--pozzo, 40px) * -1)) rotateX(-90deg);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 40%),
    var(--cassa);
}

/* ---------------------------------------------------------------- i tasti */
.tasto {
  position: absolute;
  top: 0;
  height: 100%;
  transform-style: preserve-3d;
  transform-origin: 50% 0;
}
.tasto--b {
  padding: 0;
  border-radius: 0 0 3px 3px;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0, transparent 7%, transparent 93%, rgba(0, 0, 0, 0.12) 100%),
    linear-gradient(180deg, color-mix(in srgb, var(--avorio) 82%, #8a7a62) 0, var(--avorio) 16%, var(--avorio) 82%, color-mix(in srgb, var(--avorio) 92%, #fff) 100%);
  /* lo spazio fra un bianco e l'altro */
  background-clip: content-box;
  border-left: 1px solid transparent;
  border-right: 1px solid transparent;
}
.tasto--n {
  height: 64%;
  z-index: 2;
  border-radius: 0 0 2px 2px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0, rgba(255, 255, 255, 0.16) 12%, transparent 26%, transparent 80%, rgba(0, 0, 0, 0.3) 100%),
    linear-gradient(180deg, var(--ebano) 0, color-mix(in srgb, var(--ebano) 82%, #8b8178) 86%, color-mix(in srgb, var(--ebano) 60%, #b9afa4) 100%);
}
/* la faccia davanti: lo spessore del tasto */
.tasto__fronte {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  transform-origin: 50% 0;
  transform: rotateX(-90deg);
}
.tasto--b .tasto__fronte {
  left: 1px;
  right: 1px;
  height: var(--hb, 12px);
  border-radius: 0 0 3px 3px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--avorio) 88%, #6d5e49), color-mix(in srgb, var(--avorio) 68%, #6d5e49));
}
.tasto--n .tasto__fronte {
  height: var(--hn, 10px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--ebano) 80%, #7d736a), var(--ebano));
}
/* i fianchi: si vedono quando un tasto vicino scende */
.tasto__fianco {
  position: absolute;
  top: 0;
  width: var(--hn, 10px);
  height: 100%;
  background: color-mix(in srgb, var(--ebano) 86%, #000);
}
.tasto--b .tasto__fianco {
  width: var(--hb, 12px);
  background: linear-gradient(90deg, color-mix(in srgb, var(--avorio) 70%, #5a4a36), color-mix(in srgb, var(--avorio) 45%, #2a2016));
}
.tasto--b .tasto__fianco--s { left: 1px; }
.tasto--b .tasto__fianco--d { right: 1px; }
.tasto__fianco--s {
  left: 0;
  transform-origin: 0 50%;
  transform: rotateY(90deg);
}
.tasto__fianco--d {
  right: 0;
  transform-origin: 100% 50%;
  transform: rotateY(-90deg);
}
/* l'ombra che il tasto nero lascia sui bianchi */
.tasto__ombra {
  position: absolute;
  left: -4%;
  right: -4%;
  top: 6%;
  height: 102%;
  border-radius: 4px;
  transform: translateZ(calc(var(--hn, 10px) * -1 + 1px));
  background: rgba(20, 12, 6, calc(0.24 - var(--p, 0) * 0.12));
  box-shadow: 0 2px 6px 3px rgba(20, 12, 6, calc(0.2 - var(--p, 0) * 0.1));
}
/* la luce: il tasto premuto si scurisce in alto e prende il colore della sua nota */
.tasto__luce {
  position: absolute;
  inset: 0 1px 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: var(--p, 0);
  background: linear-gradient(180deg, rgba(40, 24, 10, 0.42), rgba(40, 24, 10, 0.08) 50%, color-mix(in srgb, var(--tinta, #d6432e) 40%, transparent));
}
.tasto--n .tasto__luce {
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3), transparent 50%, color-mix(in srgb, var(--tinta, #d6432e) 34%, transparent));
}

/* ---------------------------------------------------------------- le note */
.cielo {
  position: fixed;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}
.nota {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  fill: currentColor;
  will-change: transform, opacity;
}
.disegni {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.invito {
  position: relative;
  z-index: 3;
  grid-row: 4;
  margin: 0;
  padding: 0 var(--margine);
  color: var(--tenue);
  font-size: clamp(0.8rem, 0.74rem + 0.25vw, 0.95rem);
  font-weight: 500;
  text-align: center;
}

@media (max-width: 700px) {
  .insegna__titolo { font-size: clamp(2.1rem, 1rem + 6.4vw, 3rem); }
}
