/* A column that adds itself up: the quarter of a made-up ceramics studio, in the minimal style. A warm white page,
   black ink, one electric blue kept for the very end. In a tall section the stage stays still while you scroll: a
   column of figures aligned on the right, a rule and a total. The script splits the figures into digits, makes the
   copies that drop into the total and draws them. */
:root {
  --carta: #f3f0e8;        /* the warm white of the page */
  --inchiostro: #141414;   /* the figures and the words */
  --tenue: #8f8a80;        /* the small text, and the total while it is still zero */
  --spento: #aca69b;       /* a line once it has been added to the total */
  --accento: #2b3cff;      /* the total, when everything is added up */
}

* {
  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;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------ 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(52px, 9vw, 132px);
  font-weight: 280;
  font-stretch: 88%;
  line-height: 0.92;
  letter-spacing: -0.04em;
}

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

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

.palco {
  position: sticky;
  top: 0;
  display: grid;
  place-items: center;
  height: 100lvh;
  overflow: hidden;
}

.testa {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  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-stretch: 92%;
  letter-spacing: -0.02em;
}

/* ------------------------------------------------------------ the column */
.conto {
  position: relative;
  width: min(620px, calc(100vw - 32px));
  margin-top: 24px;
}

.righe {
  display: grid;
}

/* a line: the name on the left, the figure on the right; both sit in windows that hide them until they rise */
.riga {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin: 0;
  padding: 0.16em 0;
  font-size: clamp(18px, 1.9vw, 27px);
  line-height: 1.2;
}

.riga__nome {
  display: inline-block;
  overflow: hidden;
  padding: 0.14em 0 0.08em;
  font-weight: 380;
  letter-spacing: -0.01em;
}

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

.riga__cifra {
  font-weight: var(--w, 430);
  white-space: nowrap;
}

/* every digit of a figure has its own window, so they can rise one after the other */
.m {
  display: inline-block;
  overflow: hidden;
  padding: 0.14em 0 0.08em;
  vertical-align: top;
}

.g {
  display: inline-block;
}

/* the rule under the column: the outer element is moved by the script (the shiver), the inner one is drawn by GSAP */
.tratto {
  position: relative;
  height: 1px;
  margin: 0.55em 0 0;
  font-size: clamp(18px, 1.9vw, 27px);
}

.tratto__linea {
  position: absolute;
  inset: 0;
  background: var(--inchiostro);
  transform-origin: 100% 50%;
}

.totale {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  margin: 0;
  padding-top: 0.1em;
}

.totale__nome {
  font-size: clamp(18px, 1.9vw, 27px);
  font-weight: 520;
  letter-spacing: -0.01em;
}

.totale__cifra {
  display: inline-block;
  font-size: clamp(44px, 7vw, 104px);
  font-weight: 200;
  line-height: 1.1;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

/* the double underline of the total: its width is written by the script, on the measure of the final figure */
.doppia {
  position: relative;
  height: 6px;
  margin: 2px 0 0 auto;
}

.doppia__linea {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--accento);
  transform-origin: 100% 50%;
}

.doppia__linea:first-child {
  top: 0;
}

.doppia__linea:last-child {
  bottom: 0;
}

/* the well the copies drop into: it ends exactly on the rule, so a copy that goes past it sinks out of sight */
.pozzo {
  position: absolute;
  left: 0;
  right: 0;
  top: -24px;
  overflow: hidden;
  pointer-events: none;
}

.fantasma {
  position: absolute;
  right: 0;
  top: 0;
  font-size: clamp(18px, 1.9vw, 27px);
  line-height: 1.2;
  white-space: nowrap;
  will-change: transform;
}

/* ------------------------------------------------------------ phone: the same, a little tighter */
@media (max-width: 640px) {
  .riga,
  .tratto,
  .fantasma,
  .totale__nome {
    font-size: 17px;
  }

  .riga {
    padding: 0.22em 0;
  }

  .totale__cifra {
    font-size: min(14vw, 60px);
  }
}
