/* Font in locale (latin), licenza SIL OFL: vedi fonts/OFL-*.txt */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 300 400;
  font-display: swap;
  src: url(fonts/cormorant-garamond.woff2) format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 300 400;
  font-display: swap;
  src: url(fonts/cormorant-garamond-italic.woff2) format('woff2');
}
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(fonts/dm-mono-300.woff2) format('woff2');
}

:root {
  --notte: #1c0a1d;
  --prugna: #3b0f3a;
  --magenta: #d12f74;
  --rosa: #f3bfd6;
  --avorio: #fbeef3;
  --lilla: #b892c4;
  --serif: 'Cormorant Garamond', Georgia, serif;
  --mono: 'DM Mono', ui-monospace, monospace;
}

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

[hidden] { display: none !important; }

body {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--notte);
  color: var(--avorio);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#tela {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  /* il pigmento si accende sul fondo scuro invece di coprirlo */
  mix-blend-mode: screen;
}
#tela.morbida { filter: blur(2px); }

/* grana della carta */
.grana {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 .9 0 0 0 0 .95 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* --- impaginazione ------------------------------------------------------ */

.pagina {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(24px, 5vw, 96px);
  padding: 64px clamp(16px, 7vw, 140px) 96px;
  pointer-events: none;
}

.testo { max-width: 34rem; }

.sopra,
.stato,
.margine,
footer {
  font-family: var(--mono);
  font-weight: 300;
  letter-spacing: .22em;
  text-transform: lowercase;
}

.sopra {
  font-size: .72rem;
  color: var(--lilla);
  margin-bottom: 1.4rem;
  opacity: 0;
  animation: emergi 1.6s .2s ease-out forwards;
}

h1 {
  font-weight: 300;
  font-style: italic;
  line-height: .84;
  font-size: clamp(3.6rem, 9.5vw, 9.5rem);
  letter-spacing: -.02em;
}

.riga {
  display: block;
  opacity: 0;
  filter: blur(14px);
  animation: affiora 2.4s cubic-bezier(.2, .7, .2, 1) forwards;
}
.riga:first-child { animation-delay: .4s; }

.eks {
  padding-left: .9em;
  font-style: normal;
  animation-delay: 1.1s;
}
.eks::after {
  content: '';
  display: inline-block;
  width: .12em;
  height: .12em;
  margin-left: .06em;
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 .25em var(--magenta);
}

.stato {
  margin-top: 2.4rem;
  font-size: clamp(.95rem, 1.5vw, 1.15rem);
  letter-spacing: .16em;
  opacity: 0;
  animation: emergi 1.6s 2.2s ease-out forwards;
}

.punti i { font-style: normal; animation: goccia 1.8s infinite; }
.punti i:nth-child(2) { animation-delay: .3s; }
.punti i:nth-child(3) { animation-delay: .6s; }

.nota {
  margin-top: .7rem;
  font-style: italic;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  line-height: 1.2;
  color: var(--rosa);
  opacity: 0;
  animation: emergi 1.6s 2.8s ease-out forwards;
}

/* --- pulsanti ----------------------------------------------------------- */

.scrivi,
.invia {
  pointer-events: auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .9em;
  padding: 1.05em 1.9em;
  border: 1px solid color-mix(in srgb, var(--rosa) 85%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--magenta) 22%, rgba(28, 10, 29, .55));
  color: #fff;
  font: 300 .95rem/1 var(--mono);
  letter-spacing: .14em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .35);
  box-shadow: 0 0 24px -6px color-mix(in srgb, var(--magenta) 70%, transparent);
  text-transform: lowercase;
  cursor: pointer;
  overflow: hidden;
  isolation: isolate;
  transition: border-color .5s;
}

/* il colore si spande dentro il pulsante come una goccia */
.scrivi::before,
.invia::before {
  content: '';
  position: absolute;
  inset: 50% auto auto 50%;
  width: 0;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--magenta) 55%, color-mix(in srgb, var(--magenta) 40%, transparent) 72%, transparent 74%);
  transform: translate(-50%, -50%);
  transition: width .7s cubic-bezier(.2, .7, .2, 1);
  z-index: -1;
}
.scrivi:hover::before,
.scrivi:focus-visible::before,
.invia:hover::before,
.invia:focus-visible::before { width: 260%; }
.scrivi:hover, .invia:hover { border-color: var(--magenta); }
.scrivi:focus-visible, .invia:focus-visible { outline: 1px solid var(--rosa); outline-offset: 4px; }

.scrivi {
  margin-top: 2.6rem;
  opacity: 0;
  animation: emergi 1.6s 3.2s ease-out forwards;
}
.scrivi svg {
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.2;
  transition: transform .5s;
}
.scrivi:hover svg { transform: translateX(4px); }

/* --- l'illustrazione ---------------------------------------------------- */

.opera {
  pointer-events: auto;
  perspective: 1100px;
  height: min(78vh, 760px);
  aspect-ratio: 826 / 1280;
}

.cornice {
  position: relative;
  width: 100%;
  height: 100%;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .9s cubic-bezier(.2, .7, .2, 1);
  animation: respira 7s 4s ease-in-out infinite;
}
.cornice.segue { transition-duration: .15s; }

/* alone magenta che pulsa dietro la stampa */
.cornice::before {
  content: '';
  position: absolute;
  inset: -6%;
  border-radius: 40%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--magenta) 55%, transparent), transparent);
  filter: blur(30px);
  opacity: 0;
  z-index: -1;
  animation: alone 7s 1.5s ease-in-out infinite;
}

.macchia {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  /* "asciugatura": l'opera entra slavata e sfocata, poi prende colore */
  animation: asciuga 4.2s .3s cubic-bezier(.3, .6, .2, 1) both;
}

/* riflesso di luce che segue il puntatore, come su una stampa lucida */
.macchia .luce {
  mix-blend-mode: soft-light;
  opacity: 0;
  transition: opacity .6s;
}
.cornice.segue .luce { opacity: 1; }

/* le gocce staccate compaiono quando la macchia ha finito di allargarsi */
.macchia .schizzi {
  opacity: 0;
  animation: compare 1.2s 3.2s ease-out forwards;
}

/* --- margini e footer --------------------------------------------------- */

.margine {
  position: fixed;
  top: 50%;
  font-size: .62rem;
  color: var(--lilla);
  writing-mode: vertical-rl;
  pointer-events: none;
  opacity: 0;
  animation: compare 2s 3.6s ease-out forwards;
}
.sinistra { left: 18px; transform: translateY(-50%) rotate(180deg); }
.destra   { right: 18px; transform: translateY(-50%); }

footer {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 20px;
  display: flex;
  justify-content: center;
  font-size: .62rem;
  color: var(--lilla);
  pointer-events: none;
}

.crediti {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: .3em .5em;
  text-transform: none;
  letter-spacing: .12em;
}
.crediti a {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  pointer-events: auto;
  transition: background-color .4s, box-shadow .4s;
}
.crediti a:hover,
.crediti a:focus-visible {
  background: var(--avorio);
  box-shadow: 0 0 18px -4px color-mix(in srgb, var(--rosa) 80%, transparent);
  outline: none;
}
.crediti img {
  width: 78px;
  height: 26px;
  /* logo in bianco per stare sul fondo scuro */
  filter: brightness(0) invert(1);
  opacity: .6;
  transition: filter .4s, opacity .4s;
}
.crediti a:hover img,
.crediti a:focus-visible img { filter: none; opacity: 1; }

/* --- modale di contatto ------------------------------------------------- */

.lettera {
  margin: auto;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  padding: clamp(56px, 9vw, 76px) clamp(22px, 6vw, 56px) clamp(28px, 5vw, 44px);
  color: var(--avorio);
  background:
    radial-gradient(120% 60% at 50% 0%, color-mix(in srgb, var(--magenta) 22%, transparent), transparent 70%),
    linear-gradient(var(--prugna), var(--notte));
  border: 1px solid color-mix(in srgb, var(--rosa) 35%, transparent);
  /* arco liberty in alto */
  border-radius: 280px 280px 18px 18px / 200px 200px 18px 18px;
  box-shadow: 0 40px 120px -30px rgba(0, 0, 0, .8), inset 0 0 0 6px var(--notte), inset 0 0 0 7px color-mix(in srgb, var(--rosa) 18%, transparent);
}

.lettera[open] { animation: apri .7s cubic-bezier(.2, .7, .2, 1); }
.lettera::backdrop {
  background: rgba(18, 4, 18, .72);
  backdrop-filter: blur(6px);
}

.chiudi {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--lilla);
  cursor: pointer;
  transition: color .3s, transform .5s;
}
.chiudi:hover, .chiudi:focus-visible { color: var(--avorio); transform: rotate(90deg); }
.chiudi:focus-visible { outline: 1px solid var(--rosa); }
.chiudi svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.3; }

.intestazione, .grazie { text-align: center; }

.fregio {
  display: block;
  color: var(--magenta);
  font-size: 1.1rem;
  text-shadow: 0 0 12px var(--magenta);
  margin-bottom: .8rem;
}

.lettera h2 {
  font-weight: 300;
  font-style: italic;
  font-size: clamp(2rem, 6vw, 2.7rem);
  line-height: 1;
}
.intestazione p {
  margin-top: .7rem;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--rosa);
}

form { margin-top: 2rem; display: grid; gap: 1.3rem; }

.campo { display: grid; gap: .35rem; }
.campo label {
  font: 300 .66rem var(--mono);
  letter-spacing: .22em;
  color: var(--lilla);
}
.campo input,
.campo textarea {
  width: 100%;
  padding: .35rem 0 .5rem;
  border: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--rosa) 35%, transparent);
  border-radius: 0;
  background: transparent;
  color: var(--avorio);
  font: 400 1.2rem/1.4 var(--serif);
  caret-color: var(--magenta);
  transition: border-color .4s, box-shadow .4s;
  resize: vertical;
}
.campo input:focus,
.campo textarea:focus {
  outline: none;
  border-bottom-color: var(--magenta);
  box-shadow: 0 1px 0 var(--magenta);
}
.campo [aria-invalid="true"] { border-bottom-color: #ff7a9c; }

.trappola { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.consenso {
  display: flex;
  gap: .8rem;
  align-items: flex-start;
  font-size: .98rem;
  line-height: 1.35;
  color: var(--rosa);
  cursor: pointer;
}
.consenso input {
  appearance: none;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: .15rem;
  border: 1px solid var(--rosa);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.consenso input::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--magenta);
  box-shadow: 0 0 8px var(--magenta);
  transform: scale(0);
  transition: transform .3s;
}
.consenso input:checked::after { transform: scale(1); }
.consenso input:focus-visible { outline: 1px solid var(--rosa); outline-offset: 3px; }

.errore {
  font: 300 .66rem var(--mono);
  letter-spacing: .1em;
  color: #ff8fab;
}
.errore:empty { display: none; }

.invia { justify-self: center; margin-top: .6rem; }
.invia[disabled] { opacity: .5; cursor: progress; }

.esito {
  text-align: center;
  font: 300 .7rem var(--mono);
  letter-spacing: .12em;
  color: #ff8fab;
}
.esito:empty { display: none; }

.grazie { padding: 1rem 0 .5rem; }
.grazie-titolo {
  font-style: italic;
  font-weight: 300;
  font-size: 2.4rem;
  margin-bottom: .8rem;
}
.grazie p:not(.grazie-titolo) { font-size: 1.15rem; color: var(--rosa); line-height: 1.45; }
.grazie .invia { margin-top: 2rem; }

/* --- animazioni --------------------------------------------------------- */

@keyframes affiora { to { opacity: 1; filter: blur(0); } }
@keyframes emergi {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes compare { to { opacity: 1; } }
@keyframes goccia {
  0%, 100% { opacity: .15; }
  40%      { opacity: 1; }
}
@keyframes asciuga {
  0%   { filter: saturate(.1) brightness(1.5) blur(10px); }
  60%  { filter: saturate(.7) brightness(1.1) blur(1px); }
  100% { filter: none; }
}
@keyframes respira {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -8px; }
}
@keyframes alone {
  0%, 100% { opacity: .6; scale: 1; }
  50%      { opacity: 1;  scale: 1.05; }
}
@keyframes apri {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* --- schermi stretti ---------------------------------------------------- */

@media (max-width: 860px) {
  .pagina {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 40px;
    padding: 40px 16px 120px;
  }
  .opera { grid-row: 1; height: auto; width: min(78vw, 420px); }
  .testo { text-align: center; }
  .eks { padding-left: 0; }
  .margine { display: none; }
  footer { justify-content: center; }
  .crediti { flex-wrap: nowrap; justify-content: center; gap: .5em; letter-spacing: .04em; white-space: nowrap; font-size: min(.62rem, 2.6vw); }
  .crediti img { width: auto; height: min(22px, 6vw); }
}

@media (max-width: 400px) {
  .stato { font-size: .88rem; letter-spacing: .08em; }
  .nota { font-size: 1.35rem; }
  .scrivi { font-size: .84rem; letter-spacing: .08em; padding: 1em 1.4em; gap: .7em; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
