/* Saturday at the market: a post on Small Kitchen Notes, a made-up cooking blog. Warm white paper, black ink, one
   tomato accent for the time of each stop. In a tall section a stage stays still: the post on the left (under the
   table on a phone) and a light wooden table where five instant photos land one after the other. Every position of
   the prints is written by the script; the sizes come from the table and are measured again on resize. */
:root {
  --carta: #f6f1e9;         /* the paper of the page */
  --luce: #fffbf4;          /* the soft morning light on the paper */
  --inchiostro: #1b1712;    /* the words */
  --tenue: #948a7c;         /* the small words and the lines already read */
  --sottile: #e2d9cb;       /* hairlines */
  --accento: #c9472b;       /* tomato: the time of each stop */
  --legno: #e6d2b2;         /* the light oak of the table */
  --legno-scuro: #cfb48c;   /* the far edge of the table */
  --bianco: #fbfaf6;        /* the white border of the instant photos */
  --matita: #2d3a5a;        /* the blue-black pen of the handwriting */
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(110% 80% at 0% -10%, var(--luce) 0%, rgba(255, 251, 244, 0) 60%),
    var(--carta);
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', 'Mona Sans', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* a fine grain over the page, so the paper is never flat */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0.28;
  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");
}

/* ------------------------------------------------------------ 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(10px, 2.6vh, 24px) clamp(14px, 4vw, 52px);
}

.marchio {
  display: flex;
  white-space: nowrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 15px;
  font-weight: 640;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.015em;
}

.marchio__segno {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.barra__voci {
  display: flex;
  gap: clamp(12px, 2.2vw, 28px);
  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: 10px;
  margin: 0;
  font-size: 13px;
  font-weight: 500;
}

.piccolo__accento {
  color: var(--accento);
  font-weight: 600;
}

.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: 10em;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(40px, min(8vw, 12vh), 116px);
  font-weight: 380;
  font-variation-settings: 'opsz' 120, 'SOFT' 60;
  line-height: 0.98;
  letter-spacing: -0.03em;
}

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

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

.pulsante {
  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(27, 23, 18, 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: 640vh;
}

.palco {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100lvh;
  overflow: hidden;
  padding: clamp(52px, 10vh, 92px) clamp(14px, 4vw, 52px) clamp(14px, 4.5vh, 44px);
}

/* the post on the left, the table on the right */
.scena {
  display: grid;
  grid-template-columns: minmax(230px, 340px) minmax(0, 1fr);
  gap: clamp(24px, 4vw, 64px);
  height: 100%;
  max-width: 1240px;
  margin: 0 auto;
}

/* ------------------------------------------------------------ the post */
.post {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  align-self: center;
  height: min(100%, 460px);
  min-width: 0;
}

.ora {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--sottile);
  font-size: 12px;
  font-weight: 560;
  letter-spacing: 0.01em;
  color: var(--tenue);
}

.ora__rullo {
  position: relative;
  display: inline-block;
  width: 4em;
  height: 1.3em;
  overflow: hidden;
  color: var(--accento);
  font-weight: 620;
  vertical-align: bottom;
}

.ora__rullo span {
  position: absolute;
  left: 0;
  top: 0;
  line-height: 1.3;
  opacity: 0;
}

.post__finestra {
  position: relative;
  overflow: hidden;
  min-height: 0;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 5%, #000 80%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 5%, #000 80%, transparent 100%);
}

.post__testo {
  padding-top: 1.6em;
}

.post__testo p {
  margin: 0 0 1.05em;
  font-size: clamp(15px, min(1.45vw, 2.5vh), 19px);
  line-height: 1.45;
  letter-spacing: -0.006em;
  color: var(--inchiostro);
  transition: color 0.5s ease;
}

.post__testo p.letto {
  color: var(--tenue);
}

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

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

/* ------------------------------------------------------------ the table */
.tavolo {
  position: relative;
  min-width: 0;
  border-radius: 22px;
  background:
    linear-gradient(176deg, #efdfc4 0%, var(--legno) 46%, var(--legno-scuro) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -1px 0 rgba(120, 84, 40, 0.18),
    0 1px 2px rgba(80, 56, 28, 0.12),
    0 30px 60px -36px rgba(80, 56, 28, 0.45);
  overflow: hidden;
  isolation: isolate;
}

/* the grain of the oak, painted once on a canvas by the script */
.tavolo__venatura {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
  mix-blend-mode: multiply;
  pointer-events: none;
}

/* the morning light from a window on the left, and a hint of the room's shade on the far side */
.tavolo__luce {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(70% 60% at 12% 8%, rgba(255, 248, 232, 0.55), rgba(255, 248, 232, 0) 70%),
    linear-gradient(90deg, rgba(255, 250, 240, 0) 55%, rgba(110, 76, 36, 0.08) 100%);
}

/* ------------------------------------------------------------ the instant photos */
.istantanea,
.biglietto {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: var(--w, 200px);
  margin: 0;
  visibility: hidden;
  will-change: transform;
}

/* the two shadows of a print: a far soft one while it is still in the air, a close tight one once it lies down */
.istantanea__lontana,
.istantanea__vicina {
  position: absolute;
  inset: 0;
  border-radius: 3px;
  pointer-events: none;
}

.istantanea__lontana {
  box-shadow: 0 26px 70px -4px rgba(70, 44, 16, 0.3), 0 8px 30px rgba(70, 44, 16, 0.08);
  opacity: 0;
}

.istantanea__vicina {
  box-shadow:
    0 0.5px 1px rgba(60, 38, 14, 0.3),
    0 3px 6px -2px rgba(60, 38, 14, 0.28),
    0 12px 22px -12px rgba(60, 38, 14, 0.35);
  opacity: 0;
}

.carta {
  position: relative;
  padding: 6.5% 6.5% 0;
  border-radius: 3px;
  background:
    linear-gradient(160deg, #ffffff 0%, var(--bianco) 50%, #f1eee6 100%);
  box-shadow: inset 0 0 0 0.5px rgba(120, 100, 70, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.carta__foto {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: #2a241d;
}

.carta__foto img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  /* one warm grade over all five, so they read as the same morning and the same film */
  filter: saturate(0.92) sepia(0.12) contrast(1.02);
}

/* the edge of the emulsion, a little darker, and its film grain */
.carta__foto::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12), inset 0 0 24px rgba(40, 24, 8, 0.28);
  background-image: var(--grana, none);
  background-size: 120px 120px;
  mix-blend-mode: overlay;
  opacity: 0.14;
  pointer-events: none;
}

/* the sheen of the glossy print, passing once as it lands */
.carta__lucido {
  position: absolute;
  inset: -20%;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0) 38%, rgba(255, 255, 255, 0.32) 50%, rgba(255, 255, 255, 0) 62%);
  transform: translateX(-120%);
}

.carta__scritta {
  display: flex;
  align-items: center;
  height: calc(var(--w, 200px) * 0.25);
  padding: 0 2%;
  font-family: 'Caveat Variable', 'Caveat', 'Bradley Hand', cursive;
  font-size: calc(var(--w, 200px) * 0.1);
  font-weight: 520;
  line-height: 1;
  color: var(--matita);
  white-space: nowrap;
}

/* the handwriting appears from left to right, behind a soft edge, as if the pen were moving */
.carta__scritta span {
  --p: 0%;
  display: inline-block;
  padding-right: 0.3em;
  -webkit-mask-image: linear-gradient(90deg, #000 calc(var(--p) - 8%), transparent var(--p));
  mask-image: linear-gradient(90deg, #000 calc(var(--p) - 8%), transparent var(--p));
}

@media (hover: hover) {
  .istantanea:hover .carta {
    transform: translateY(-4px) rotate(-0.6deg);
  }
}

/* ------------------------------------------------------------ the title slip */
.biglietto {
  z-index: 3;
  width: calc(var(--w, 200px) * 1.32);
}

.biglietto .istantanea__vicina,
.biglietto .istantanea__lontana {
  border-radius: 2px;
}

.biglietto__carta {
  position: relative;
  padding: 9% 9% 7%;
  border-radius: 2px;
  background: linear-gradient(170deg, #fffdf8, #f5efe3);
  box-shadow: inset 0 0 0 0.5px rgba(120, 100, 70, 0.2);
}

/* a strip of paper tape holding it, slightly see-through */
.biglietto__nastro {
  position: absolute;
  left: 50%;
  top: -9%;
  width: 34%;
  height: 20%;
  transform: translateX(-50%) rotate(-3deg);
  background: linear-gradient(180deg, rgba(240, 226, 196, 0.78), rgba(226, 208, 170, 0.7));
  box-shadow: 0 1px 2px rgba(80, 56, 28, 0.15);
  clip-path: polygon(2% 0, 98% 4%, 100% 96%, 0 100%, 3% 50%);
}

.biglietto__titolo {
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: calc(var(--w, 200px) * 0.15);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: 'opsz' 72, 'SOFT' 80;
  line-height: 1.02;
  letter-spacing: -0.02em;
}

.biglietto__firma {
  margin: 0.5em 0 0;
  font-family: 'Caveat Variable', 'Caveat', cursive;
  font-size: calc(var(--w, 200px) * 0.085);
  color: var(--accento);
}

/* ------------------------------------------------------------ narrower screens: the table on top, the post under it */
@media (max-width: 900px) {
  .scena {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    gap: clamp(10px, 2.4vh, 20px);
  }

  .tavolo {
    grid-row: 1;
    border-radius: 16px;
  }

  .post {
    grid-row: 2;
    height: clamp(78px, 23vh, 170px);
    gap: 8px;
  }

  .ora {
    padding-bottom: 6px;
    font-size: 11px;
  }

  .post__testo p {
    font-size: clamp(12.5px, min(3.6vw, 2.6vh), 16px);
    line-height: 1.38;
  }
}

@media (max-width: 400px) {
  .barra__voci a:first-child {
    display: none;
  }

  .marchio {
    font-size: 14px;
  }
}
