:root {
  --carta: #f6f3ee;          /* the warm white of the page */
  --inchiostro: #1b1a18;     /* the ink of the text and of the pill */
  --grigio: #8c877f;         /* the quiet grey of the notes */
  --binario: rgba(20, 22, 26, 0.22); /* the track of the loading line, dark enough to read on snow */
  --accento: #fbf8f2;        /* the single accent: the light of the loading line */
  --raggio: 6px;             /* the corners of a frame while it loads */
}

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

html, body { height: 100%; }

body {
  background: var(--carta);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", system-ui, sans-serif;
  display: grid;
  place-items: center;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.pagina {
  width: min(820px, 90vw, 132vh);
  display: grid;
  gap: clamp(12px, 3.4vh, 30px);
}

/* the head: brand, title, state on the left, Reload on the right */
.testa {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
}
.testa__sx { display: grid; gap: clamp(3px, 0.9vh, 8px); min-width: 0; }

.marca {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: "JetBrains Mono Variable", ui-monospace, monospace;
  font-size: clamp(9px, 1.6vh, 12px);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--grigio);
}
.marca svg { width: 16px; height: 16px; flex: none; }

.titolo {
  font-size: clamp(22px, 6.6vh, 56px);
  font-weight: 560;
  font-stretch: 112%;
  letter-spacing: -0.03em;
  line-height: 0.95;
}

.nota {
  font-size: clamp(10px, 1.8vh, 13px);
  color: var(--grigio);
  height: 1.3em;
  overflow: hidden;
  position: relative;
}
.nota__riga { display: block; white-space: nowrap; }

/* the elastic pill: the background swells, the word widens */
.pillola {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(32px, 5.6vh, 42px);
  padding: 0 clamp(14px, 2.2vh, 18px);
  border: 0;
  background: none;
  color: var(--carta);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pillola__fondo {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--inchiostro);
}
.pillola__dentro {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: clamp(11px, 1.9vh, 14px);
  font-weight: 520;
  font-stretch: 100%;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
  transition: font-stretch 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pillola__icona { width: 15px; height: 15px; flex: none; display: block; }
.pillola:focus-visible { outline: 2px solid var(--inchiostro); outline-offset: 3px; border-radius: 999px; }
@media (hover: hover) {
  .pillola:hover .pillola__dentro { font-stretch: 118%; }
}

/* the grid of six frames */
.griglia {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vh, 16px) clamp(6px, 1.4vh, 12px);
}

.riquadro { display: grid; gap: clamp(4px, 0.9vh, 8px); min-width: 0; }

.cornice {
  position: relative;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  border-radius: var(--raggio);
  background: var(--medio);
  isolation: isolate;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.piccola,
.nitida {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* the tiny copy, blown up and blurred: its scale lives in CSS, GSAP only fades it */
.piccola {
  filter: blur(12px) saturate(1.15);
  transform: scale(1.18);
  opacity: 0;
}

/* a light grain over the placeholder, so the blur reads as film and not as an error */
.grana {
  position: absolute;
  inset: -10%;
  opacity: 0;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='g'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0 0.5 0 0 0 0.9 0'/></filter><rect width='100%' height='100%' filter='url(%23g)'/></svg>");
  pointer-events: none;
}

.nitida { opacity: 0; }

/* the thin loading line at the bottom of each frame */
.barra {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: clamp(6px, 1.4vh, 10px);
  height: 2px;
  border-radius: 2px;
  background: var(--binario);
  overflow: hidden;
}
.barra__pieno {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: var(--accento);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.5);
  transform-origin: left center;
  transform: scaleX(0);
}

.dida {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  font-size: clamp(9px, 1.7vh, 13px);
  opacity: 0;
}
.dida__nome { font-weight: 520; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dida__meta {
  font-family: "JetBrains Mono Variable", ui-monospace, monospace;
  font-size: 0.86em;
  color: var(--grigio);
  white-space: nowrap;
}

@media (max-width: 520px) {
  .dida__meta { display: none; }
  .marca svg { width: 13px; height: 13px; }
}
