:root {
  --carta: #f2efe7;        /* the paper of the page */
  --carta-chiara: #faf8f3; /* the light paper of the captions and of one car of the train */
  --pietra: #8e887a;       /* the stone grey of the small type and of one car */
  --sabbia: #e3dccb;       /* the sand of the bar track and of one car */
  --inchiostro: #1c1b18;   /* the ink of the type and of the last colour car */
  --accento: #ff5a1f;      /* the one accent: the bar, the caption blocks and the first car */
  --u: min(26vw, 27vh);    /* the width of a photo frame, measured on both sides of the screen */
}

* { 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;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.palco {
  position: relative;
  height: 100vh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: clamp(14px, 3.4vh, 34px) clamp(14px, 4vw, 48px);
  overflow: hidden;
}

/* the header */
.testa {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: clamp(11px, min(1.25vw, 2vh), 14px);
  font-weight: 560;
  letter-spacing: -0.005em;
}
.marca { display: flex; align-items: center; gap: 0.55em; }
.marca svg { width: 1.35em; height: 1.35em; fill: var(--inchiostro); }
.marca svg rect:last-child { fill: var(--accento); }
.luogo { display: flex; gap: 0.9em; align-items: baseline; }
.luogo__date {
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 0.86em;
  font-weight: 500;
  color: var(--pietra);
}

/* the staircase of frames */
.scala {
  align-self: center;
  justify-self: center;
  display: grid;
  grid-template-columns: repeat(3, var(--u));
  gap: calc(var(--u) * 0.09);
  align-items: start;
}
.riquadro { position: relative; width: var(--u); }
.riquadro:nth-child(2) { margin-top: calc(var(--u) * 0.5); }
.riquadro:nth-child(3) { margin-top: calc(var(--u) * 1); }

/* the lifting layer, moved only by CSS (GSAP moves the photo and the caption inside it) */
.riquadro__su {
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), filter 0.6s ease;
}
@media (hover: hover) {
  .riquadro:hover .riquadro__su { transform: translateY(-4px); }
  .riquadro:hover .riquadro__foto { box-shadow: 0 1px 1px rgb(28 27 24 / 0.06), 0 10px 20px -8px rgb(28 27 24 / 0.28), 0 28px 50px -24px rgb(28 27 24 / 0.32); }
}

.riquadro__foto {
  position: relative;
  aspect-ratio: 4 / 5;
  overflow: hidden;
  background: var(--sabbia);
  box-shadow: 0 1px 1px rgb(28 27 24 / 0.05), 0 6px 14px -8px rgb(28 27 24 / 0.22), 0 18px 34px -22px rgb(28 27 24 / 0.22);
  transition: box-shadow 0.6s ease;
}
/* the film: a light version of the filter the site lays over its photos, on the photo and on the train alike */
.riquadro__foto img,
.riquadro__foto canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: contrast(1.03) saturate(0.95) brightness(1.01) sepia(0.06) hue-rotate(-4deg);
  user-select: none;
}
.riquadro__foto::after {
  content: '';
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.14);
  pointer-events: none;
  z-index: 3;
}
.riquadro__grana {
  position: absolute;
  inset: -50%;
  z-index: 2;
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: overlay;
  background-size: 128px 128px;
}

/* the captions: a name and a time, with a block of colour that slides across when they change */
.didascalia,
.giorno {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
}
.didascalia {
  height: calc(var(--u) * 0.15);
  min-height: 22px;
  margin-top: calc(var(--u) * 0.035);
  padding: 0 0.7em;
  background: var(--carta-chiara);
  font-size: clamp(10px, calc(var(--u) * 0.068), 14px);
  box-shadow: 0 1px 0 rgb(28 27 24 / 0.06);
}
.didascalia__testo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6em;
  white-space: nowrap;
  min-width: 0;
}
.didascalia__nome {
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: clip;
}
.didascalia__ora {
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-weight: 500;
  font-size: 0.86em;
  color: var(--pietra);
}
.didascalia__blocco {
  position: absolute;
  inset: 0;
  background: var(--accento);
  transform: scaleX(0);
  transform-origin: 0 50%;
  pointer-events: none;
}

/* the foot: the day, the hairline bar and the next button */
.piede {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(10px, 1.6vw, 22px);
  width: min(100%, calc(var(--u) * 3.18 + 64px));
  justify-self: center;
}
.giorno {
  height: clamp(20px, 3.4vh, 28px);
  padding: 0 0.15em;
  font-size: clamp(11px, min(1.3vw, 2.1vh), 15px);
  font-weight: 620;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.giorno__testo { display: block; }
.barra {
  position: relative;
  height: 2px;
  background: var(--sabbia);
  border-radius: 2px;
  overflow: hidden;
}
.barra::after {
  content: '';
  position: absolute;
  inset: -1px 0 auto;
  height: 1px;
  background: rgb(255 255 255 / 0.6);
}
.barra__pieno {
  position: absolute;
  inset: 0;
  background: var(--accento);
  transform: scaleX(0);
  transform-origin: 0 50%;
}
.avanti {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(28px, 4.6vh, 38px);
  height: clamp(28px, 4.6vh, 38px);
  border: 1px solid rgb(28 27 24 / 0.16);
  border-radius: 50%;
  background: var(--carta-chiara);
  color: var(--inchiostro);
  cursor: pointer;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}
.avanti svg {
  width: 44%;
  height: 44%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@media (hover: hover) {
  .avanti:hover { background: var(--inchiostro); border-color: var(--inchiostro); color: var(--carta-chiara); }
  .avanti:hover svg { transform: translateX(1.5px); }
}
.avanti:active { transform: scale(0.92); }
.avanti:focus-visible { outline: 2px solid var(--accento); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .riquadro__su, .riquadro__foto, .avanti, .avanti svg { transition: none; }
  .riquadro:hover .riquadro__su { transform: none; }
}

/* small frames: the caption keeps only the name */
@media (max-width: 560px) {
  .didascalia { padding: 0 0.5em; font-size: clamp(9px, calc(var(--u) * 0.11), 12px); }
  .didascalia__ora { display: none; }
}
