/* Ink blotted dry: minimal style, warm white paper, near black ink and one blue accent for the ink the blotter
   takes. The letters and the blotter are moved by script.js; the colours live here. */

:root {
  --carta: #f3f0e8;        /* the writing paper */
  --inchiostro: #141414;   /* the ink, wet and dry */
  --tenue: #a9a297;        /* small names and the guide ticks */
  --riga: #cfc8bb;         /* the ruled baseline */
  --tampone: #fbfaf6;      /* the top of the blotter */
  --assorbente: #ece6da;   /* the blotting paper underneath */
  --accento: #2b45e8;      /* the ink picked up by the blotter, and the word «dry» */
}

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

html { background: var(--carta); }

body {
  background: var(--carta);
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.racconto {
  position: relative;
  height: 420lvh;
}

.palco {
  position: sticky;
  top: 0;
  height: 100lvh;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(14px, 3.2vh, 32px) clamp(16px, 4vw, 48px);
}

.testa,
.piede {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: clamp(11px, 1.4vh + 0.4vw, 14px);
  letter-spacing: 0.01em;
}

.marchio {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-variation-settings: 'opsz' 36, 'SOFT' 0;
  font-weight: 560;
  font-size: 1.35em;
}

.sezione,
.cenno,
.stato__nome { color: var(--tenue); }

.stato__valore {
  display: inline-block;
  min-width: 2.6em;
  font-weight: 560;
  transition: color 0.4s;
}

.stato__valore.secco { color: var(--accento); }

.foglio {
  display: grid;
  place-items: center;
  min-height: 0;
}

/* the line of writing: the letters, the ruled baseline under them and the blotter on top */
.riga {
  position: relative;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: min(15.5vw, 21vh);
  line-height: 1;
  padding: 0.18em 0 0.2em;
  perspective: 7em;
}

.parola {
  position: relative;
  display: flex;
  white-space: nowrap;
  font-optical-sizing: none;
}

.lettera {
  display: inline-block;
  position: relative;
  will-change: font-variation-settings;
}

/* the glyph itself: the script sets weight, softness and the wet halo on it */
.lettera__segno {
  display: inline-block;
  color: var(--inchiostro);
}

/* the shine on fresh ink: a thin highlight that slides across the wet letters */
.lettera__lucido {
  position: absolute;
  inset: 0;
  pointer-events: none;
  color: transparent;
  background: linear-gradient(100deg, transparent 38%, rgba(255, 255, 255, 0.55) 48%, transparent 58%) no-repeat;
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
}

.base {
  position: absolute;
  left: -0.12em;
  right: -0.12em;
  bottom: 0.2em;
  height: 0.3em;
  width: calc(100% + 0.24em);
  overflow: visible;
}

.base__linea {
  fill: none;
  stroke: var(--riga);
  stroke-width: 1.25;
  vector-effect: non-scaling-stroke;
}

.base__tacca {
  stroke: var(--tenue);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

/* the rocker blotter, seen from above: GSAP moves .tampone, the faces are drawn here */
.tampone {
  position: absolute;
  top: 0.06em;
  left: 0;
  width: 1.75em;
  height: 1.3em;
  transform-style: preserve-3d;
  will-change: transform;
}

.tampone__giro {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.tampone__faccia {
  position: absolute;
  inset: 0;
  border-radius: 0.07em;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.tampone__faccia--sopra {
  background: var(--tampone);
  border: 1.5px solid var(--inchiostro);
  box-shadow: var(--ombra, 0.02em 0.05em 0.12em rgba(20, 20, 20, 0.16));
}

/* the top plate, a little smaller, that slides as the blotter rocks */
.tampone__piastra {
  position: absolute;
  inset: 0.1em 0.14em;
  border: 1px solid rgba(20, 20, 20, 0.35);
  border-radius: 0.04em;
}

.tampone__pomo {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.36em;
  height: 0.36em;
  margin: -0.18em 0 0 -0.18em;
  border-radius: 50%;
  border: 1.5px solid var(--inchiostro);
  background: radial-gradient(circle at 35% 32%, #fff 0 18%, var(--tampone) 19% 100%);
}

.tampone__faccia--sotto {
  background: var(--assorbente);
  border: 1px solid rgba(20, 20, 20, 0.25);
  transform: rotateX(180deg);
  overflow: hidden;
}

/* a letter picked up by the blotter: mirrored, blue and soft */
.impronta {
  position: absolute;
  top: 50%;
  margin-top: -0.55em;
  line-height: 1;
  color: var(--accento);
  font-variation-settings: 'wght' 820, 'opsz' 144, 'SOFT' 100;
  filter: blur(0.01em);
  opacity: 0;
}

/* the second, fainter pass of the rocker: the same letter printed again a hair to the side */
.impronta::after {
  content: attr(data-segno);
  position: absolute;
  left: 0.06em;
  top: 0.02em;
  transform: scaleX(-1);
  opacity: 0.35;
}

.impronta__segno {
  display: inline-block;
  transform: scaleX(-1);
}

.coda {
  min-height: 70lvh;
  display: grid;
  place-content: center;
  gap: 18px;
  text-align: center;
  padding: 48px 16px;
}

.coda__testo {
  font-family: 'Fraunces Variable', Georgia, serif;
  font-variation-settings: 'opsz' 72, 'SOFT' 0;
  font-weight: 360;
  font-size: clamp(26px, 4.6vw, 52px);
  line-height: 1.1;
}

.piccolo {
  color: var(--tenue);
  font-size: 13px;
}

@media (hover: hover) {
  /* under the pointer the blotter lifts a hair off the paper and its knob catches the light */
  .tampone__faccia--sopra { transition: translate 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.35s; }
  .tampone:hover .tampone__faccia--sopra { translate: 0 -0.025em; filter: drop-shadow(0 0.04em 0.05em rgba(20, 20, 20, 0.12)); }
  .tampone:hover .tampone__pomo { background: radial-gradient(circle at 35% 32%, #fff 0 26%, var(--tampone) 27% 100%); }
}
