/* Our story, with photos opening from a slit: the story page of Orsa, a made-up studio for furniture and light. A warm
   paper page with a soft window light and a fine grain, black ink, one tungsten accent for the year being told. In a
   tall section a stage stays still while you scroll: the thin line of years on the left, the photo in the middle,
   the rolling year and its sentence on the right (under the photo on a phone). Every position in the stage is
   written by the script. */
:root {
  --carta: #efe9df;        /* the paper of the page */
  --luce: #fbf7f0;         /* the soft window light on the paper */
  --inchiostro: #171410;   /* the words, the year and the line already drawn */
  --tenue: #8b8378;        /* the small words */
  --sottile: #d6cec1;      /* the empty line and the years still to come */
  --accento: #c4581c;      /* tungsten: the tip of the line and the year being told */
  --labbro: #fff1dc;       /* the light on the edges of the slit */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  background:
    radial-gradient(120% 80% at 8% -10%, var(--luce) 0%, rgba(251, 247, 240, 0) 62%),
    radial-gradient(90% 70% at 100% 110%, rgba(196, 88, 28, 0.06), rgba(196, 88, 28, 0) 70%),
    var(--carta);
  background-attachment: fixed;
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', 'Mona Sans', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* the fine grain over the whole page, so the paper is never flat */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.32;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.4 0 0 0 0 0.33 0 0 0 0.35 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

/* ------------------------------------------------------------ the bar at the top */
.barra {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: clamp(12px, 3vh, 26px) clamp(16px, 4.4vw, 56px);
}

.marchio {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 16px;
  font-weight: 660;
  font-variation-settings: 'wdth' 108;
  letter-spacing: -0.02em;
}

.marchio__segno {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.barra__voci {
  display: flex;
  gap: clamp(14px, 2.4vw, 30px);
  font-size: 13px;
}

.barra__voci a {
  color: var(--tenue);
  text-decoration: none;
  transition: color 0.3s ease;
}

.barra__voci a[aria-current] {
  color: var(--inchiostro);
}

@media (hover: hover) {
  .barra__voci a:hover {
    color: var(--inchiostro);
  }
}

/* ------------------------------------------------------------ the opening and the end */
.apertura {
  display: grid;
  align-content: center;
  gap: clamp(12px, 3vh, 22px);
  height: 100vh;
  height: 100lvh;
  padding: 64px clamp(16px, 5vw, 72px) 32px;
}

.apertura--fine {
  justify-items: start;
}

.piccolo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}

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

.giu {
  width: 10px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.titolo {
  margin: 0;
  max-width: 11em;
  font-size: clamp(40px, min(8vw, 12vh), 120px);
  font-weight: 340;
  font-variation-settings: 'wdth' 92;
  line-height: 0.96;
  letter-spacing: -0.035em;
}

.titolo em {
  font-style: normal;
  color: var(--tenue);
}

.titolo--medio {
  font-size: clamp(34px, min(6vw, 9vh), 84px);
}

.pulsante {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-radius: 999px;
  background: var(--inchiostro);
  color: var(--carta);
  font-size: 14px;
  font-weight: 560;
  font-variation-settings: 'wdth' 100;
  text-decoration: none;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.18) inset, 0 10px 24px -12px rgba(23, 20, 16, 0.6);
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pulsante svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@media (hover: hover) {
  .pulsante:hover {
    font-variation-settings: 'wdth' 118;
    transform: scale(1.03);
  }

  .pulsante:hover svg {
    transform: translateX(3px);
  }
}

.pulsante:active {
  transform: scale(0.97);
}

/* ------------------------------------------------------------ the stage */
.racconto {
  position: relative;
  height: 560vh;
}

.palco {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100lvh;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: clamp(56px, 11vh, 96px) clamp(16px, 4.4vw, 56px) clamp(16px, 5vh, 48px);
}

/* the three columns on a computer: the line, the photo, the words */
.scena {
  --foto: min(600px, 46vw, calc((100vh - 230px) * 1.25));
  display: grid;
  grid-template-columns: 64px var(--foto) minmax(200px, 300px);
  align-items: center;
  gap: clamp(28px, 4vw, 60px);
}

/* ------------------------------------------------------------ the line of years */
.linea {
  position: relative;
  align-self: stretch;
  height: calc(var(--foto) * 0.8);
}

.linea__vuota,
.linea__piena {
  position: absolute;
  top: 0;
  right: 0;
  width: 1px;
  height: 100%;
  transform-origin: 50% 0;
}

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

.linea__piena {
  background: var(--inchiostro);
  transform: scaleY(0);
}

/* the tip: a short tungsten tick that rides down the line */
.linea__testa {
  position: absolute;
  top: 0;
  right: -6px;
  width: 13px;
  height: 1.5px;
  background: var(--accento);
  opacity: 0;
}

.linea__anni {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.linea__anni li {
  position: absolute;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(-50%);
}

.linea__anni i {
  order: 2;
  width: 7px;
  height: 1px;
  background: var(--sottile);
  margin-right: -3px;
  transform-origin: 100% 50%;
  transition: background-color 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.linea__anni span {
  font-size: 11px;
  font-weight: 520;
  color: var(--sottile);
  transition: color 0.4s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.linea__anni li.passato i {
  background: var(--inchiostro);
}

.linea__anni li.passato span {
  color: var(--tenue);
}

.linea__anni li.ora i {
  background: var(--accento);
  transform: scaleX(1.9);
}

.linea__anni li.ora span {
  color: var(--inchiostro);
  transform: translateX(-4px);
}

/* ------------------------------------------------------------ the photo */
.foto {
  margin: 0;
  width: var(--foto);
}

.foto__vetro {
  position: relative;
  width: 100%;
  aspect-ratio: 5 / 4;
}

.scatto {
  position: absolute;
  inset: 0;
  transform-origin: 50% 40%;
  visibility: hidden;
}

/* the soft shadow of the print on the paper: its own layer, because the clip would cut it */
.scatto__ombra {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  box-shadow:
    0 1px 2px rgba(40, 28, 16, 0.14),
    0 12px 24px -10px rgba(40, 28, 16, 0.28),
    0 40px 70px -30px rgba(40, 28, 16, 0.32);
  opacity: 0;
}

.scatto__maschera {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 6px;
  background: #1a1612;
  clip-path: inset(50% 50% 50% 50%);
}

/* a hairline of light on the edge of the print */
.scatto__maschera::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  pointer-events: none;
  z-index: 2;
}

.scatto img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

/* a breath of film grain on the real photos, tiled from a small canvas the script paints once */
.scatto__maschera::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: var(--grana, none);
  background-size: 160px 160px;
  mix-blend-mode: overlay;
  opacity: calc(var(--grana-forza, 0.06) * 4);
  pointer-events: none;
}

/* the two edges of the slit, lit as it opens */
.labbro {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 1px;
  z-index: 9;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg, rgba(255, 241, 220, 0), var(--labbro) 22%, #ffffff 50%, var(--labbro) 78%, rgba(255, 241, 220, 0));
  box-shadow: 0 0 10px 1px rgba(255, 196, 130, 0.55), 0 0 28px 2px rgba(255, 170, 90, 0.25);
}

.didascalie {
  position: relative;
  height: 18px;
  margin-top: 14px;
  font-size: 12px;
  color: var(--tenue);
}

.didascalie span {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  opacity: 0;
}

/* ------------------------------------------------------------ the words */
.testo {
  display: grid;
  align-content: center;
  gap: 14px;
}

.etichetta {
  margin: 0;
  font-size: 12px;
  font-weight: 560;
  letter-spacing: 0.02em;
  color: var(--accento);
}

.anno {
  display: flex;
  margin: 0;
  font-size: clamp(56px, min(7.4vw, 12vh), 116px);
  font-weight: 300;
  font-variation-settings: 'wdth' 84;
  line-height: 1;
  letter-spacing: 0;
}

.anno__fissa,
.rullo {
  display: block;
  width: 0.5em;
  height: 1em;
  text-align: center;
}

.rullo {
  overflow: hidden;
}

.striscia {
  display: block;
  will-change: transform;
}

.striscia span {
  display: block;
  height: 1em;
  line-height: 1;
}

.frasi {
  position: relative;
  min-height: 4.4em;
  font-size: clamp(15px, min(1.6vw, 2.6vh), 21px);
  line-height: 1.32;
  border-top: 1px solid var(--sottile);
  padding-top: 14px;
}

.frase {
  position: absolute;
  left: 0;
  right: 0;
  top: 14px;
  margin: 0;
  letter-spacing: -0.01em;
  visibility: hidden;
}

.parola {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-bottom: 0.08em;
  margin-bottom: -0.08em;
}

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

/* ------------------------------------------------------------ narrower screens: the photo on top, the words under it */
@media (max-width: 900px) {
  .scena {
    --foto: min(560px, calc(100vw - 80px), calc((100vh - 190px) * 1.25));
    grid-template-columns: 22px var(--foto);
    grid-template-rows: auto auto;
    column-gap: 14px;
    row-gap: clamp(10px, 2.4vh, 22px);
  }

  .linea {
    grid-row: 1 / span 2;
    height: auto;
  }

  .linea__anni span {
    display: none;
  }

  .testo {
    grid-column: 2;
    grid-template-columns: auto 1fr;
    align-items: start;
    column-gap: clamp(12px, 3vw, 24px);
    row-gap: 2px;
  }

  .etichetta {
    grid-column: 1 / span 2;
  }

  .anno {
    font-size: clamp(36px, min(9vw, 9vh), 72px);
  }

  .frasi {
    min-height: 3.9em;
    font-size: clamp(12.5px, min(2.4vw, 3.3vh), 17px);
    border-top: 0;
    border-left: 1px solid var(--sottile);
    padding: 0 0 0 clamp(10px, 2.4vw, 18px);
  }

  .frase {
    top: 0;
    left: clamp(10px, 2.4vw, 18px);
  }

  .didascalie {
    margin-top: 8px;
    height: 15px;
    font-size: 11px;
  }
}

@media (max-height: 460px) {
  .etichetta {
    display: none;
  }
}
