/* The article with the still photograph: a long read in two columns, the photograph stays and changes with the chapters */
:root {
  --carta: #f6f3ec;        /* the paper */
  --inchiostro: #1c1b19;   /* the ink */
  --tenue: #6f6b62;        /* captions, bylines */
  --filetto: #d8d2c4;      /* the hairlines */
  --accento: #94462a;      /* the kicker */
  --fondo-foto: #d9d1c2;   /* behind the photographs while they load */
  --serif: 'Newsreader Variable', 'Iowan Old Style', Georgia, serif;
  --sans: 'Instrument Sans Variable', 'Helvetica Neue', Arial, sans-serif;
  --margine: clamp(16px, 4vw, 56px);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--carta); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--carta);
  color: var(--inchiostro);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }

/* ---------------------------------------------------------------- masthead */
.testata {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  margin: 0 var(--margine);
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--inchiostro);
}
.testata__nome {
  grid-column: 2;
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
}
.testata__motto {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
  font-size: 12px;
  color: var(--tenue);
}
.testata__voci {
  grid-column: 3;
  justify-self: end;
  display: flex;
  gap: 18px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.testata__voci a { transition: color 0.3s ease; }
@media (hover: hover) {
  .testata__voci a:hover { color: var(--accento); }
}

/* ---------------------------------------------------------------- opening */
.apertura {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(48px, 9vh, 104px) var(--margine) clamp(40px, 7vh, 80px);
  text-align: center;
}
.apertura__occhiello {
  margin: 0 0 18px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accento);
}
.apertura__titolo {
  margin: 0 auto;
  max-width: 14ch;
  font-family: var(--serif);
  font-size: clamp(42px, 7.4vw, 104px);
  font-weight: 380;
  line-height: 0.98;
  letter-spacing: -0.025em;
}
.apertura__titolo .riga { display: block; overflow: hidden; padding-bottom: 0.08em; margin-bottom: -0.08em; }
.apertura__titolo .riga__dentro { display: block; }
.apertura__catenaccio {
  max-width: 34em;
  margin: 28px auto 0;
  font-family: var(--serif);
  font-size: clamp(19px, 2vw, 23px);
  font-style: italic;
  font-weight: 350;
  line-height: 1.45;
  color: #3b3934;
}
.apertura__firma {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 0;
  margin: 30px 0 0;
  font-size: 13px;
  color: var(--tenue);
}
.apertura__firma span { padding: 0 14px; }
.apertura__firma span + span { border-left: 1px solid var(--filetto); }
.apertura__firma b { font-weight: 600; color: var(--inchiostro); }

/* ---------------------------------------------------------------- the two columns */
.articolo {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: clamp(32px, 5vw, 88px);
  margin: 0 var(--margine);
  border-top: 1px solid var(--filetto);
}

/* the still photograph: sticky, as tall as the screen (lvh: on iPhone Safari it does not jump with the toolbar) */
.foto {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100lvh;
  padding: 24px 0;
}
.foto__palco { display: flex; flex-direction: column; height: 100%; }
.foto__cornice {
  position: relative;
  flex: 1;
  margin: 0;
  overflow: hidden;
  background: var(--fondo-foto);
}
/* one layer per photograph: GSAP moves the layer (clip-path), the svg inside takes the scale */
.foto__strato {
  position: absolute;
  inset: 0;
  overflow: hidden;
  visibility: hidden;
}
.foto__strato svg {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: 50% 60%;
}
/* the grain and the vignette above every photograph: what makes the drawings read as prints */
.foto__grana {
  position: absolute;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background-size: 180px 180px;
  mix-blend-mode: overlay;
  opacity: 0.32;
}
.foto__cornice::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 21;
  pointer-events: none;
  background: radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(20, 16, 12, 0.22));
}

.foto__piede {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: start;
  padding-top: 14px;
}
.foto__didascalia {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}
/* the caption: old and new stacked in the same cell, every word is a small window for its letters */
.foto__righe { display: grid; min-height: 1.45em; }
.foto__riga { grid-area: 1 / 1; word-spacing: 0.06em; }
.parola { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.12em; margin-bottom: -0.12em; }
.lettera { display: inline-block; will-change: transform; }
.foto__credito { display: block; margin-top: 4px; font-size: 11px; color: var(--tenue); letter-spacing: 0.02em; }

/* the chapter index: names, a hairline track and an ink mark that moves to the current one */
.indice {
  position: relative;
  display: flex;
  flex-direction: column;
  padding-left: 14px;
  border-left: 1px solid var(--filetto);
}
.indice__voce {
  padding: 1px 0;
  font-size: 12px;
  line-height: 1.5;
  text-align: left;
  white-space: nowrap;
  color: #9a958a;
  transition: color 0.4s ease;
}
.indice__voce span { display: inline-block; transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1); }
.indice__voce[aria-current='true'] { color: var(--inchiostro); }
@media (hover: hover) {
  .indice__voce:hover { color: var(--inchiostro); }
  .indice__voce:hover span { transform: translateX(3px); }
}
.indice__voce:focus-visible { outline: 1px solid var(--inchiostro); outline-offset: 2px; }
.indice__segno {
  position: absolute;
  left: -1px;
  top: 0;
  width: 1px;
  height: 18px;
  background: var(--inchiostro);
}

/* ---------------------------------------------------------------- the text */
.testo { padding: 18vh 0 34vh; max-width: 34em; }
.capitolo { padding: 10vh 0; }
.capitolo__titolo {
  margin: 0 0 22px;
  padding-top: 18px;
  border-top: 1px solid var(--filetto);
  font-family: var(--serif);
  font-size: clamp(28px, 2.8vw, 38px);
  font-weight: 420;
  line-height: 1.1;
  letter-spacing: -0.015em;
}
.capitolo p { margin: 0 0 1.1em; text-wrap: pretty; }
.capitolo__primo::first-letter {
  float: left;
  margin: 0.08em 0.1em 0 0;
  font-family: var(--serif);
  font-size: 3.4em;
  font-weight: 400;
  line-height: 0.8;
}

.fine {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  margin: 0 var(--margine);
  padding: 22px 0 64px;
  border-top: 1px solid var(--inchiostro);
}
.fine__nota { margin: 0; max-width: 40em; font-size: 13px; color: var(--tenue); }
.fine__testata { margin: 0; font-family: var(--serif); font-size: 22px; }

/* ---------------------------------------------------------------- phone: the photograph on top, shorter, still sticky */
@media (max-width: 760px) {
  body { font-size: 16px; }
  .testata { grid-template-columns: 1fr; justify-items: center; gap: 8px; }
  .testata__nome { grid-column: 1; font-size: 26px; }
  .testata__motto { grid-row: 2; grid-column: 1; }
  .testata__voci { grid-column: 1; justify-self: center; gap: 14px; font-size: 11px; }
  .apertura { padding-top: 40px; padding-bottom: 36px; }
  .apertura__catenaccio { margin-top: 20px; }
  .apertura__firma { flex-direction: column; align-items: center; margin-top: 22px; }
  .apertura__firma span + span { border-left: 0; }

  .articolo { display: block; }
  .foto {
    z-index: 5;
    height: auto;
    margin: 0 calc(var(--margine) * -1);
    padding: 10px var(--margine) 0;
    background: var(--carta);
    box-shadow: 0 1px 0 var(--filetto);
  }
  .foto__cornice { flex: none; height: 34vh; height: 34lvh; }
  .foto__piede { grid-template-columns: 1fr; gap: 8px; padding: 10px 0 10px; }
  .foto__righe { min-height: 2.9em; align-content: start; }
  .foto__credito { display: none; }
  .indice {
    flex-direction: row;
    gap: 16px;
    padding: 6px 0 0;
    border-left: 0;
    border-top: 1px solid var(--filetto);
    overflow-x: auto;
    scrollbar-width: none;
  }
  .indice::-webkit-scrollbar { display: none; }
  .indice__segno { left: 0; top: -1px; width: 40px; height: 2px; }
  .testo { padding: 4vh 0 46vh; }
  .capitolo { padding: 7vh 0; }
  .fine { flex-direction: column; gap: 10px; }
}
