:root {
  --carta: #fbfaf7;          /* warm white paper */
  --inchiostro: #171717;     /* the ink (the site uses #171717) */
  --pallido: rgba(23, 23, 23, .3); /* unpainted text: 30% ink, as on the site */
  --grigio: #8a8782;         /* small labels */
  --filo: rgba(23, 23, 23, .12); /* hairlines */
  --ceralacca: #b4472f;      /* the one accent: sealing wax */
  --ceralacca-chiara: #f0b7a6; /* the accent on ink */
  --font: "Geist Mono Variable", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { background: var(--carta); overflow-x: clip; }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
body {
  background: var(--carta);
  color: var(--inchiostro);
  font-family: var(--font);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
ol, ul { list-style: none; }

/* ---- the bar that uncovers: a cover the colour of the paper pulls away while an ink bar sweeps across ---- */
.svela { position: relative; display: inline-block; overflow: clip; overflow-clip-margin: .2em; }
.svela-pronta { overflow: visible; }
.svela.riga { display: block; width: fit-content; }
.svela__copri, .svela__barra {
  position: absolute; inset: 0 -.2em; pointer-events: none;
}
.svela__copri { background: var(--carta); transform-origin: 0 50%; }
.svela__barra { background: var(--inchiostro); }
/* our detail: the leading edge of the bar is a hair of sealing wax */
.svela__barra::after {
  content: ""; position: absolute; top: 0; bottom: 0; right: 0; width: 2px; background: var(--ceralacca);
}
.svela-pronta .svela__copri, .svela-pronta .svela__barra { display: none; }

/* ---- header ---- */
.barra {
  position: fixed; z-index: 5; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between; gap: 2rem;
  padding: clamp(12px, 2.4vh, 22px) clamp(14px, 2.4vw, 32px);
  font-size: clamp(10px, .8vw + 2px, 13px); letter-spacing: .02em; text-transform: uppercase;
  padding-bottom: calc(clamp(12px, 2.4vh, 22px) + 18px);
  background: linear-gradient(var(--carta) 68%, rgba(251, 250, 247, 0));
}
.barra__voci { display: flex; gap: 1.6em; color: var(--grigio); }
.barra__voci a { transition: color .3s; }
.barra__qui { position: relative; }
.barra__qui::after { content: ""; position: absolute; left: 0; right: 0; bottom: -4px; height: 1px; background: var(--inchiostro); }
@media (hover: hover) {
  .barra__voci a:hover { color: var(--inchiostro); }
}

/* ---- side index: follows the paragraph being painted ---- */
.indice {
  position: fixed; z-index: 4; left: clamp(14px, 2.4vw, 32px); top: 50%; transform: translateY(-50%);
  width: clamp(150px, 15vw, 210px);
  font-size: clamp(10px, .7vw + 2px, 12px); letter-spacing: .02em; text-transform: uppercase;
}
.indice__titolo { color: var(--grigio); margin-bottom: 1.6em; }
.indice__voci li + li { margin-top: 1.15em; }
.indice__voci a { display: block; padding-left: 14px; color: var(--grigio); transition: color .35s; }
.indice__voci li.attiva a { color: var(--inchiostro); }
.indice__nome { display: block; }
.indice__riga { display: block; position: relative; height: 1px; margin-top: .55em; background: var(--filo); overflow: hidden; }
.indice__riga span { position: absolute; inset: 0; background: var(--inchiostro); transform: scaleX(0); transform-origin: 0 50%; }
.indice__tacca {
  position: absolute; left: 0; top: 0; width: 2px; height: 1.15em; background: var(--ceralacca);
}
@media (hover: hover) {
  .indice__voci a:hover { color: var(--inchiostro); }
}

/* ---- phone: the index becomes one line under the header ---- */
.segno { display: none; }

/* ---- page ---- */
.pagina {
  width: min(36ch * 1.02, 100%);
  margin: 0 auto;
  font-size: clamp(16px, min(1.25vw, 2.5vh) + 5px, 26px);
  padding: 0 0 18vh;
}
.apertura {
  min-height: min(100vh, 900px);
  display: flex; flex-direction: column; justify-content: center;
  padding-top: 10vh;
}
.etichetta, .capitolo__nome, .sotto, .nota, .piede__info, .nome__conto {
  font-size: clamp(10px, .7vw + 3px, 13px); letter-spacing: .03em; text-transform: uppercase; color: var(--grigio);
}
.titolo {
  margin: .9em 0 1.1em;
  font-weight: 400;
  font-size: clamp(30px, min(4.3vw, 8.4vh), 66px);
  line-height: 1.04; letter-spacing: -.045em;
}
.titolo .riga, .piede__frase .riga { white-space: nowrap; }
.titolo .riga + .riga { margin-top: .04em; }
.sotto { display: flex; flex-wrap: wrap; gap: .5em 2.2em; color: var(--inchiostro); }

.capitolo { position: relative; margin-top: 16vh; }
.capitolo__nome { margin-bottom: 1.6em; }
.capitolo__corpo { position: relative; }

/* ---- the painted paragraph: one variable, --paint, moves a soft edge of .8em from top to bottom ---- */
.dipinto {
  --paint: 0%;
  position: relative;
  line-height: 1.5; letter-spacing: -.01em;
  background-image: linear-gradient(to bottom, var(--inchiostro) calc(var(--paint) - .4em), var(--pallido) calc(var(--paint) + .4em));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  -webkit-box-decoration-break: clone;
}
/* our detail: a hair of sealing wax in the margin rides the wet edge of the ink */
.dipinto__pennino {
  position: absolute; left: -1.1em; width: 1px; height: .8em; top: -.4em;
  background: var(--ceralacca); opacity: 0; pointer-events: none;
}
.dipinto--breve { margin-bottom: 1.6em; }

/* margin note, in the right margin on a wide screen */
.nota {
  position: absolute; top: .35em; left: calc(100% + clamp(28px, 5vw, 84px)); width: clamp(140px, 13vw, 200px);
  line-height: 1.6; color: var(--inchiostro);
}
.nota .svela { display: block; width: fit-content; }
.nota::before {
  content: ""; position: absolute; left: -14px; top: .3em; bottom: .3em; width: 1px; background: var(--ceralacca);
  transform: scaleY(var(--nota, 0)); transform-origin: 50% 0;
}

/* ---- names ---- */
.nomi { border-top: 1px solid var(--filo); }
.nomi li { border-bottom: 1px solid var(--filo); }
.nome {
  position: relative; display: flex; align-items: baseline; justify-content: space-between; gap: 1em;
  padding: .55em .5em; font-size: .86em; letter-spacing: -.01em; isolation: isolate;
}
.nome::before {
  content: ""; position: absolute; inset: 0; z-index: -1; background: var(--inchiostro);
  transform: scaleX(0); transform-origin: 100% 50%;
  transition: transform .45s cubic-bezier(.33, 0, 0, 1);
}
.nome__conto { transition: color .3s; white-space: nowrap; }
.nome > .svela { transition: color .3s, transform .45s cubic-bezier(.33, 0, 0, 1); }
.nome:focus-visible { outline: none; }
.nome:focus-visible::before { transform: scaleX(1); transform-origin: 0 50%; }
.nome:focus-visible > .svela { color: var(--carta); transform: translateX(.4em); }
.nome:focus-visible .nome__conto { color: var(--ceralacca-chiara); }
@media (hover: hover) {
  .nome:hover::before { transform: scaleX(1); transform-origin: 0 50%; }
  .nome:hover > .svela { color: var(--carta); transform: translateX(.4em); }
  .nome:hover .nome__conto { color: var(--ceralacca-chiara); }
  .nome:active::before { transform: scaleX(.985); }
}

/* ---- footer ---- */
.piede { margin-top: 22vh; }
.piede__frase { font-size: clamp(22px, min(2.6vw, 5vh), 40px); line-height: 1.15; letter-spacing: -.035em; }
.piede__info { display: flex; flex-wrap: wrap; gap: .5em 2em; margin-top: 2.4em; }

/* ---- narrower desktop: index and notes need room ---- */
@media (max-width: 1100px) and (min-width: 641px) {
  .pagina { width: min(36ch, calc(100% - 2 * clamp(150px, 15vw, 210px) - 40px)); margin-left: calc(clamp(150px, 15vw, 210px) + 60px); }
  .nota { position: static; width: auto; margin-top: 1.4em; display: flex; flex-wrap: wrap; gap: 0 .6em; }
  .nota::before { display: none; }
}

/* ---- phone ---- */
@media (max-width: 640px) {
  .barra__voci, .indice { display: none; }
  .barra { padding: 12px 16px; height: 40px; background: var(--carta); }
  .segno {
    display: block; position: fixed; z-index: 4; left: 0; right: 0; top: 39px;
    font-size: 10px; letter-spacing: .03em; text-transform: uppercase; color: var(--inchiostro);
    background: var(--carta); padding: 6px 16px 0;
  }
  .segno::after {
    content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 18px;
    background: linear-gradient(var(--carta), rgba(251, 250, 247, 0)); pointer-events: none;
  }
  .segno__riga { display: block; position: relative; height: 1px; margin-top: 6px; background: var(--filo); }
  .segno__riga span { position: absolute; inset: 0; background: var(--inchiostro); transform: scaleX(0); transform-origin: 0 50%; }
  .pagina { width: auto; margin: 0 22px; font-size: clamp(15px, min(4.4vw, 3.9vh), 19px); }
  .apertura { min-height: min(100vh, 640px); padding-top: 12vh; }
  .titolo { font-size: min(9.6vw, 8.2vh); }
  .capitolo { margin-top: 12vh; }
  .nota { position: static; width: auto; margin-top: 1.2em; display: flex; flex-wrap: wrap; gap: 0 .6em; }
  .nota::before { display: none; }
  .dipinto__pennino { left: -.7em; }
  .nome { padding: .5em .35em; }
}

@media (prefers-reduced-motion: reduce) {
  .dipinto { --paint: 100%; }
  .svela__copri, .svela__barra { display: none; }
}
