:root {
  --carta: #f4f0e8;
  --inchiostro: #151411;
  --accento: #ff5a1f;
  /* the nine rows, from cream to near black */
  --r0: #e9e4d8;
  --r1: #dbd4c4;
  --r2: #c7bfad;
  --r3: #afa591;
  --r4: #8b8270;
  --r5: #696153;
  --r6: #4a453b;
  --r7: #2f2c26;
  --r8: #181714;
  --riga: clamp(22px, 5.4vh, 54px);
  --fs-riga: clamp(10.5px, min(1.35vh, 1.05vw) + 4px, 15px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--carta); color: var(--inchiostro); }
html.lenis, html.lenis body { height: auto; }
body {
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.sep { display: inline-block; width: 1em; height: 1px; background: currentColor; opacity: .4; vertical-align: middle; margin: 0 .5em; }

/* ---- the opening ---- */
.apertura {
  height: 100vh;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  gap: clamp(10px, 2.4vh, 22px);
  padding: 0 6vw;
  position: relative;
}
.sopra, .testa__sopra, .chiusura__sopra {
  font-family: "JetBrains Mono Variable", ui-monospace, monospace;
  font-size: clamp(9.5px, 1.4vh, 12px);
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: .62;
  white-space: nowrap;
}
.titolo {
  font-size: min(10.5vw, 11vh);
  font-weight: 640;
  font-stretch: 88%;
  line-height: .92;
  letter-spacing: -.035em;
}
.sotto { font-size: clamp(12px, 1.9vh, 17px); opacity: .7; max-width: 34ch; }
.invito {
  position: absolute; left: 50%; bottom: clamp(14px, 4vh, 34px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  font-family: "JetBrains Mono Variable", ui-monospace, monospace; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .5;
}
.invito svg { width: 10px; height: 14px; }

/* ---- the day ---- */
.giornata {
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: clamp(10px, 2.6vh, 26px);
  overflow-x: clip;
}
.testa { display: grid; justify-items: center; gap: clamp(4px, 1vh, 10px); }

/* the big word rolls like the rows: front face Day, bottom face Night */
.parola {
  --h: min(15vw, 12.5vh);
  width: 100%;
  height: var(--h);
  margin: calc(var(--h) * .14) 0 calc(var(--h) * .08);
  perspective: 1600px;
}
.blocco {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: scale3d(var(--k, 1), var(--k, 1), var(--k, 1)) rotateX(calc(var(--t, 0) * 90deg));
}
.parola .faccia {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  backface-visibility: hidden;
  font-size: calc(var(--h) * .8);
  font-weight: 660;
  font-stretch: 84%;
  letter-spacing: -.04em;
  line-height: 1;
}
.parola .faccia span { display: block; line-height: 1; }
.parola .faccia--fronte { transform: translateZ(calc(var(--h) / 2)); opacity: clamp(0, (1 - var(--t, 0)) * 50, 1); }
.parola .faccia--sotto { transform: rotateX(-90deg) translateZ(calc(var(--h) / 2)); opacity: clamp(0, var(--t, 0) * 50, 1); }

/* the ladder */
.scala {
  position: relative;
  perspective: 1600px;
  perspective-origin: 50% 50%;
  overflow: clip;
  /* the soft shadow that grows halfway through the roll */
  filter: drop-shadow(0 calc(var(--ombra, 0) * 18px) calc(var(--ombra, 0) * 26px) rgba(21, 20, 17, calc(var(--ombra, 0) * .22)));
}
.riga { position: relative; height: var(--riga); transform-style: preserve-3d; }
.riga__blocco {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transform: scale3d(var(--k, 1), var(--k, 1), var(--k, 1)) rotateX(calc(var(--t, 0) * 90deg));
}
.riga .faccia {
  position: absolute;
  inset: -1px 0;
  backface-visibility: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr) minmax(0, 1fr);
  align-items: center;
  padding: 0 clamp(12px, 3.2vw, 40px);
  font-size: var(--fs-riga);
  overflow: hidden;
}
.riga .faccia--fronte { background: var(--cf); color: var(--tf); transform: translateZ(calc(var(--h) / 2)); opacity: clamp(0, (1 - var(--t, 0)) * 50, 1); }
.riga .faccia--sotto { background: var(--cb); color: var(--tb); transform: rotateX(-90deg) translateZ(calc(var(--h) / 2)); opacity: clamp(0, var(--t, 0) * 50, 1); }
/* the face turning away darkens, the one coming in lightens: shade, not paint */
.riga .faccia::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: #000;
}
.riga .faccia--fronte::before { opacity: calc(var(--t, 0) * .38); }
.riga .faccia--sotto::before { opacity: calc((1 - var(--t, 0)) * .38); }
/* a thread of light on the edge the two faces share, only while it rolls */
.riga .faccia::after {
  content: ""; position: absolute; left: 0; right: 0; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 252, 244, .9) 18%, rgba(255, 252, 244, .9) 82%, transparent);
  opacity: calc(var(--luce, 0) * .85);
}
.riga .faccia--fronte::after { bottom: 1px; }
.riga .faccia--sotto::after { top: 1px; }

.ora, .luogo {
  font-family: "JetBrains Mono Variable", ui-monospace, monospace;
  font-size: .86em;
  letter-spacing: .04em;
  white-space: nowrap;
  opacity: .78;
}
.luogo { text-align: right; }
.cosa {
  justify-self: center;
  text-align: center;
  white-space: nowrap;
  font-weight: 560;
  font-stretch: 92%;
  letter-spacing: -.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
/* the slot at the centre of the ladder carries the accent */
.riga--centro .cosa { font-weight: 680; position: relative; overflow: visible; }
.riga--centro .cosa::after {
  content: ""; position: absolute; left: 50%; top: calc(100% + .22em); height: 1.5px; width: 1.6em; margin-left: -.8em; background: var(--accento); border-radius: 1px;
}
.nota { text-align: center; font-size: clamp(11px, 1.6vh, 14px); opacity: .6; padding: 0 6vw; }

/* ---- the close ---- */
.chiusura {
  height: 100vh;
  display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center;
  background: var(--r8); color: var(--carta);
}
.chiusura__titolo { font-size: min(7.4vw, 7.6vh); font-weight: 620; font-stretch: 88%; line-height: 1; letter-spacing: -.03em; }

@media (max-width: 460px) {
  .riga .faccia { grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr); }
  .luogo { display: none; }
  .cosa { justify-self: end; text-align: right; }
  .riga--centro .cosa::after { left: auto; right: 0; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .riga__blocco, .blocco { transform: none !important; }
  .riga .faccia, .parola .faccia { transform: none !important; transition: opacity .6s ease; }
  .riga .faccia::before, .riga .faccia::after { display: none; }
}
