/* The founder's letter that lights up on scroll. Colours in :root (the Playground palette). */
:root {
  --pagina: #e7e1d7;        /* the desk under the letter */
  --carta: #f8f3ea;         /* the cream paper */
  --carta-bordo: #efe7da;   /* the paper towards its edges */
  --inchiostro: #24201c;    /* the ink of the words */
  --spento: #d3c9ba;        /* the words still waiting, pressed into the paper */
  --vino: #7b1e2e;          /* the wine colour of the key words and the mark */
  --busta: #5d1a26;         /* the envelope behind */
  --penna: #1d2740;         /* the blue black of the signature */
  --secondario: #8b7f70;    /* the small words */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { overflow-x: clip; }

body {
  background:
    radial-gradient(120% 80% at 50% 38%, #f1ece4 0%, var(--pagina) 55%, #d9d1c4 100%);
  color: var(--inchiostro);
  font-family: 'Newsreader Variable', Georgia, serif;
  -webkit-font-smoothing: antialiased;
}

.corsa { position: relative; height: 520vh; }

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

/* ---------- the envelope behind, only its edges show ---------- */
.busta {
  position: absolute;
  width: min(560px, 80vw);
  height: min(560px, 76vh);
  border-radius: 6px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--busta) 88%, #ffffff) 0%, var(--busta) 45%, color-mix(in srgb, var(--busta) 80%, #000000) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 1px 2px rgba(40, 10, 14, 0.25),
    0 18px 40px -18px rgba(40, 10, 14, 0.55);
  transform: translate(5%, 5%) rotate(3.2deg);
  opacity: 0;
}
.busta__lembo {
  position: absolute;
  inset: 0 0 auto 0;
  height: 46%;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.12));
}

/* ---------- the letter ---------- */
.carta {
  position: relative;
  width: min(600px, 90vw);
  height: min(640px, 86vh);
  display: flex;
  flex-direction: column;
  border-radius: 5px;
  background:
    radial-gradient(130% 90% at 30% 0%, #fffdf8 0%, var(--carta) 48%, var(--carta-bordo) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 0 0 1px rgba(120, 95, 60, 0.08),
    0 1px 1px rgba(60, 40, 20, 0.08),
    0 4px 8px -2px rgba(60, 40, 20, 0.08),
    0 22px 40px -16px rgba(60, 40, 20, 0.22),
    0 48px 90px -40px rgba(60, 40, 20, 0.35);
  opacity: 0;
  will-change: transform;
}

/* the grain of the paper */
.carta::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.36 0 0 0 0 0.25 0 0 0 0.09 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
}

/* the two folds of a letter that travelled in an envelope */
.carta__pieghe {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
  background:
    linear-gradient(180deg,
      transparent calc(33.3% - 10px), rgba(110, 85, 55, 0.035) calc(33.3% - 1px), rgba(110, 85, 55, 0.12) 33.3%, rgba(255, 255, 255, 0.7) calc(33.3% + 1px), rgba(255, 255, 255, 0) calc(33.3% + 14px),
      transparent calc(66.6% - 10px), rgba(110, 85, 55, 0.035) calc(66.6% - 1px), rgba(110, 85, 55, 0.11) 66.6%, rgba(255, 255, 255, 0.7) calc(66.6% + 1px), rgba(255, 255, 255, 0) calc(66.6% + 14px));
  mix-blend-mode: multiply;
}

/* the sheen that follows the pointer */
.carta__luce {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  background: radial-gradient(360px circle at var(--mx, 50%) var(--my, 30%), rgba(255, 252, 240, 0.55), transparent 60%);
  mix-blend-mode: soft-light;
  transition: opacity 0.5s ease;
}
@media (hover: hover) {
  .carta:hover .carta__luce { opacity: 1; }
}

/* ---------- the letterhead ---------- */
.testata {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(12px, 3.6vh, 30px) clamp(16px, 6vw, 44px) clamp(8px, 2vh, 16px);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
}
.marchio { display: flex; align-items: center; gap: clamp(8px, 1.6vh, 12px); }
.marchio__segno {
  width: clamp(26px, 6vh, 40px);
  height: clamp(26px, 6vh, 40px);
  flex: none;
  fill: none;
  stroke: var(--vino);
  stroke-width: 1.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  /* pressed into the paper: a light edge under, a dark one over */
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.9)) drop-shadow(0 -0.5px 0 rgba(80, 20, 30, 0.25));
}
.marchio__nome { display: flex; flex-direction: column; gap: 2px; }
.marchio__nome b {
  font-weight: 640;
  font-stretch: 120%;
  font-size: clamp(11px, 2.2vh, 14px);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--vino);
}
.marchio__nome span {
  font-size: clamp(9px, 1.7vh, 11.5px);
  font-weight: 460;
  letter-spacing: 0.02em;
  color: var(--secondario);
}
.luogo {
  font-size: clamp(9px, 1.7vh, 11.5px);
  line-height: 1.45;
  font-weight: 460;
  text-align: right;
  color: var(--secondario);
}

/* ---------- the window the letter moves through ---------- */
.finestra {
  position: relative;
  z-index: 2;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin: 0 clamp(16px, 6vw, 44px);
  border-top: 1px solid rgba(123, 30, 46, 0.14);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 14%, #000 82%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 14%, #000 82%, transparent 100%);
}
.colonna {
  position: relative;
  padding: clamp(28px, 9vh, 80px) 0 clamp(26px, 11vh, 96px);
  will-change: transform;
}

.testo {
  font-size: clamp(15px, min(3.2vh, 4.6vw), 23px);
  line-height: 1.42;
  font-weight: 400;
  font-variation-settings: 'opsz' 18;
  letter-spacing: -0.005em;
  color: var(--spento);
  margin-bottom: 0.7em;
}
.congedo { margin-top: 0.4em; margin-bottom: 0.1em; }

/* every word: the pale print underneath, the ink over it, revealed from the left */
.w { position: relative; display: inline-block; white-space: nowrap; }
.w__pale { color: var(--spento); }
.w__ink {
  position: absolute;
  left: 0;
  top: 0;
  color: var(--inchiostro);
  clip-path: inset(-20% 100% -20% -2%);
}
/* a key word: a hidden bold copy keeps its room, both layers sit inside */
.w--chiave .w__spazio { visibility: hidden; font-weight: 640; font-style: italic; }
.w--chiave .w__pale, .w--chiave .w__ink { position: absolute; left: 0; top: 0; font-style: italic; }
.w--chiave .w__pale { font-weight: 520; }
.w--chiave .w__ink { will-change: font-weight; }

/* ---------- the photo that opens from the fold ---------- */
.foto { margin: 0.2em 0 1.1em; }
.foto__cornice {
  position: relative;
  height: 0;
  overflow: hidden;
  border-radius: 3px;
  box-shadow:
    0 0 0 1px rgba(60, 40, 20, 0.08),
    0 10px 24px -14px rgba(40, 25, 10, 0.55);
  clip-path: inset(50% 0 50% 0);
}
.foto__cornice img {
  position: absolute;
  inset: -8% 0;
  width: 100%;
  height: 116%;
  object-fit: cover;
  display: block;
  filter: sepia(0.18) saturate(0.92);
}
/* film grain and a soft vignette over the photo */
.foto__velo {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 90% at 50% 45%, transparent 55%, rgba(30, 18, 8, 0.35) 100%),
    linear-gradient(180deg, rgba(255, 245, 225, 0.85) 0, rgba(255, 245, 225, 0) 8px);
  opacity: 1;
}
.foto figcaption {
  margin-top: 8px;
  font-style: italic;
  font-size: clamp(11px, 2vh, 13.5px);
  color: var(--secondario);
  opacity: 0;
}

/* ---------- the signature ---------- */
.firma { position: relative; padding-top: 2px; }
.firma__tratti {
  display: block;
  width: min(250px, 62%);
  height: auto;
  overflow: visible;
  fill: none;
  stroke: var(--penna);
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.firma__chi {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  opacity: 0;
}
.firma__chi b { font-size: clamp(12px, 2.3vh, 15px); font-weight: 600; color: var(--inchiostro); letter-spacing: -0.005em; }
.firma__chi span { font-size: clamp(10px, 1.9vh, 12.5px); font-weight: 460; color: var(--secondario); }

@media (max-width: 520px) {
  .luogo { display: none; }
  .busta { width: 82vw; }
}
