/* The tear-off calendar: six days of a made-up print room, in the minimal style. A warm white page, black ink,
   one vermilion kept for the last day. In a tall section the stage stays still while you scroll: a pad of thin
   sheets under an ink binding, the perforation between them. The script folds the corner, tears, throws the sheet
   and lands the next day. */
:root {
  --carta: #f3f0e8;        /* the warm white of the page */
  --foglio: #fbfaf6;       /* the sheets, a touch lighter than the page */
  --retro: #e7e2d6;        /* the back of a sheet, seen in the folded corner */
  --inchiostro: #141414;   /* the binding, the lines, the numbers */
  --tenue: #8f8a80;        /* the small text */
  --accento: #e8431f;      /* the last day */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

body {
  background: var(--carta);
  color: var(--inchiostro);
  font-family: 'Anybody Variable', '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(48px, 8.4vw, 124px);
  font-weight: 300;
  font-stretch: 78%;
  line-height: 0.94;
  letter-spacing: -0.035em;
}

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

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

.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: 700;
  font-stretch: 84%;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------ the pad */
/* --l is the width of the pad: it fits the screen both ways, so the pad never touches the header */
.blocco {
  --l: min(360px, calc(100vw - 56px), calc((100lvh - 190px) / 1.3));
  --b: 34px;               /* the height of the binding */
  --s: 6px;                /* the stub of paper left under the binding */
  position: relative;
  width: var(--l);
  height: calc(var(--l) * 1.3);
  margin-top: 30px;
}

/* the ink binding, on top of everything except the sheet that flies away */
.testata {
  position: absolute;
  left: -4px;
  right: -4px;
  top: 0;
  height: var(--b);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 14px;
  background: var(--inchiostro);
  color: var(--carta);
  font-size: 10.5px;
  font-weight: 600;
  font-stretch: 112%;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  z-index: 20;
}

/* the perforation: one dash per span, written by the script, on the line where every sheet starts */
.perfora {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--b) + var(--s));
  height: 1px;
  z-index: 21;
  pointer-events: none;
}

.perfora i {
  position: absolute;
  top: 0;
  width: 4px;
  height: 1px;
  background: var(--inchiostro);
}

/* the stub between the binding and the sheets: two thin sides, like the paper glued under the binding */
.blocco::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: var(--b);
  height: var(--s);
  border-left: 1px solid var(--inchiostro);
  border-right: 1px solid var(--inchiostro);
  background: var(--foglio);
  z-index: 19;
}

.fogli {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--b) + var(--s));
  bottom: 0;
  perspective: 1400px;
}

/* a sheet: the outer element is moved by the script (tear and flight), the paper inside is cut at the folded corner */
.foglio {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.foglio__carta {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  justify-items: center;
  padding: 18px 20px 20px;
  background:
    repeating-linear-gradient(90deg, var(--inchiostro) 0 4px, transparent 4px 7px) top / 100% 1px no-repeat,
    var(--foglio);
  border: 1px solid var(--inchiostro);
  border-top: 0;
}

.foglio__giorno {
  margin: 0;
  font-size: 11px;
  font-weight: 560;
  font-stretch: 112%;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--tenue);
}

.foglio__numero {
  align-self: center;
  margin: 0;
  font-size: calc(var(--l) * 0.6);
  font-weight: 640;
  font-stretch: 92%;
  line-height: 1;
  letter-spacing: -0.04em;
  will-change: transform;
}

.foglio--ultimo .foglio__numero {
  color: var(--accento);
}

/* the line of the day: a hairline above it, the words in small windows so they can rise one after the other */
.foglio__evento {
  position: relative;
  justify-self: stretch;
  margin: 0;
  padding-top: 12px;
  border-top: 1px solid var(--inchiostro);
  font-size: 15px;
  font-weight: 420;
  font-stretch: 94%;
  letter-spacing: -0.005em;
  text-align: center;
  white-space: nowrap;
}

.w {
  display: inline-block;
  overflow: hidden;
  padding: 0.12em 0 0.1em;
  vertical-align: top;
}

.wi {
  display: inline-block;
}

/* the accent rule under the last line, drawn by GSAP at the very end */
.foglio__sotto {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 14px;
  height: 1px;
  background: var(--accento);
  transform-origin: 0 50%;
}

/* the folded corner: the back of the paper, drawn by the script on the fold line */
.foglio__piega {
  position: absolute;
  left: 0;
  top: 0;
  overflow: visible;
  pointer-events: none;
}

.piega__retro {
  fill: var(--retro);
  stroke: var(--inchiostro);
  stroke-width: 1;
  stroke-linejoin: round;
}

.piega__ombra {
  fill: var(--inchiostro);
}

/* the thickness of the pad: one thin line for every sheet still under the top one */
.spessore {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
}

.spessore i {
  position: absolute;
  height: 1px;
  background: var(--inchiostro);
  transform-origin: 50% 50%;
}

/* ------------------------------------------------------------ phone: the same, a little tighter */
@media (max-width: 640px) {
  .blocco {
    --l: min(360px, calc(100vw - 48px), calc((100lvh - 170px) / 1.3));
    --b: 30px;
  }

  .foglio__carta {
    padding: 14px 14px 16px;
  }

  .foglio__evento {
    font-size: 13px;
    padding-top: 10px;
  }

  .foglio__sotto {
    left: 14px;
    right: 14px;
    bottom: 11px;
  }
}
