/* The line of years: the story of a made-up coffee roaster, in the minimal style. A warm white page, black ink, one
   vermilion for the notch of the year being told. In a tall section a stage stays still while you scroll: a single
   hairline from top to bottom, a ruler of small ticks beside it, the big year and one sentence at a time. Every
   position is written by the script from the year the ink has reached. */
:root {
  --carta: #f3f0e8;        /* the warm white of the page */
  --inchiostro: #141414;   /* the ink of the line, the year and the words */
  --tenue: #8f8a80;        /* the small text and the years already told */
  --sottile: #d5d0c4;      /* the empty line and the ticks still to come */
  --accento: #ff4a1c;      /* the needle and the notch of the year being told */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--carta);
  color: var(--inchiostro);
  font-family: 'Archivo Variable', 'Archivo', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.nascosto {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------ the opening and the end */
.apertura {
  display: grid;
  align-content: center;
  gap: 22px;
  min-height: 92vh;
  padding: 80px clamp(16px, 5vw, 72px);
}

.apertura--fine {
  min-height: 70vh;
}

.piccolo {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.piccolo--tenue {
  color: var(--tenue);
}

.titolo {
  margin: 0;
  font-size: clamp(48px, 8.4vw, 124px);
  font-weight: 300;
  font-variation-settings: 'wdth' 88;
  line-height: 0.94;
  letter-spacing: -0.035em;
}

.titolo--medio {
  font-size: clamp(40px, 6vw, 88px);
}

/* ------------------------------------------------------------ the stage */
.racconto {
  position: relative;
  height: 640lvh;
}

.palco {
  position: sticky;
  top: 0;
  height: 100lvh;
  overflow: hidden;
}

.testa {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 26px clamp(16px, 5vw, 72px);
}

.marchio {
  margin: 0;
  font-size: 17px;
  font-weight: 680;
  font-variation-settings: 'wdth' 112;
  letter-spacing: -0.02em;
}

.scena {
  position: absolute;
  inset: 0;
}

/* the line: the empty guide and the ink that runs down it. Both are 1px wide and start at the top; the script
   writes their position and height, the ink grows with scaleY */
.guida,
.traccia {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  transform-origin: 50% 0;
}

.guida {
  background: var(--sottile);
}

.traccia {
  background: var(--inchiostro);
}

/* the ruler: one tick per year on the left of the line, a longer one every ten years */
.righello {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.tick {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  background: var(--sottile);
  transform-origin: 100% 50%;
  will-change: transform;
}

.tappe {
  margin: 0;
  padding: 0;
  list-style: none;
}

.tappa {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

/* the notch: it springs out of the line to the right, in the accent while its year is told, then shrinks and
   goes black */
.tappa__segno {
  position: absolute;
  left: 0;
  top: -1px;
  width: 1px;
  height: 2px;
  background: var(--accento);
  transform-origin: 0 50%;
  will-change: transform;
}

/* the hairline that carries the eye from the notch to the sentence */
.tappa__filo {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  background: var(--inchiostro);
  transform-origin: 0 50%;
}

.tappa__anno {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--tenue);
  font-size: 12px;
  font-weight: 520;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
}

/* the sentence: it unrolls from the notch with a clip and its words slide in one after the other */
.tappa__frase {
  position: absolute;
  left: 0;
  top: 0;
  width: max-content;
  max-width: var(--largo, 30ch);
  margin: 0;
  font-size: clamp(18px, 1.65vw, 25px);
  font-weight: 420;
  font-variation-settings: 'wdth' 96;
  line-height: 1.25;
  letter-spacing: -0.012em;
  clip-path: inset(-30% 100% -30% 0);
}

.parola {
  display: inline-block;
  white-space: pre;
}

/* the needle: the short vermilion stroke across the line where the ink has got to */
.ago {
  position: absolute;
  left: 0;
  top: 0;
  width: 15px;
  height: 2px;
  margin: -1px 0 0 -7px;
  background: var(--accento);
  transform-origin: 50% 50%;
  will-change: transform;
}

/* the big year: tabular digits, so it does not jump while it counts. Width and weight are two variables the
   script moves: narrow and thin while it runs, wide and heavy when it lands */
.anno {
  position: absolute;
  top: 0;
  right: calc(100% - var(--x, 44vw) + clamp(28px, 3.4vw, 52px));
  margin: 0;
  font-size: min(12vw, 19lvh);
  font-weight: var(--wg, 780);
  font-variation-settings: 'wdth' var(--wd, 100);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.015em;
  white-space: nowrap;
  will-change: transform;
}

.cifra {
  display: inline-block;
}

.cifra > span {
  display: inline-block;
}

.sonda {
  display: inline-block;
  width: 0;
  height: 0;
}

/* ------------------------------------------------------------ phone: the line on the left, the year hanging under
   the notch and the sentence under the year */
@media (max-width: 640px) {
  .anno {
    right: auto;
    left: calc(var(--x, 24px) + 18px);
    font-size: min(25vw, 13lvh);
  }

  .tappa__frase {
    font-size: 17px;
  }
}
