/* The weightless objects: a pink page with a ticker of giant words across the middle. The cubes are plain CSS 3D:
   six faces in a box that turns on its own; the script only moves and turns the box that holds each cube, like the
   site moves its pictures. Some cubes sit behind the words and some in front. */
:root {
  --fondo: #ff4f9a;         /* the page */
  --testo: #fff4e8;         /* the words */
  --inchiostro: #24112b;    /* the small print */
  --vetro: rgba(150, 225, 255, 0.34);   /* the glass cubes */
  --gomma: #b6f03a;         /* the rubber cube */
  --caramella: #ffd23f;     /* the candy cube */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--fondo);
  color: var(--testo);
  font-family: 'Schibsted Grotesk Variable', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.pagina {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
}

.testa,
.piede {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: clamp(14px, 2vw, 24px) clamp(16px, 2.4vw, 32px);
  font-size: clamp(12px, 1vw, 15px);
  font-weight: 800;
  text-transform: uppercase;
  position: relative;
  z-index: 3;
}

.testa__voci {
  display: flex;
  gap: clamp(14px, 2vw, 28px);
}

.testa a,
.piede a {
  color: inherit;
  text-decoration: none;
}

.testa a:focus-visible,
.piede a:focus-visible {
  outline: 2px solid var(--testo);
  outline-offset: 4px;
}

/* ---------------------------------------------------------------- the sky the cubes float in */
.cielo {
  position: relative;
  overflow: hidden;
  display: grid;
  align-items: center;
}

.nastro {
  position: relative;
  z-index: 1;
  display: flex;
  overflow: hidden;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.nastro__fila {
  display: flex;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  will-change: transform;
}

.nastro__voce {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  font-size: clamp(64px, 9.2vw, 132px);
  font-weight: 850;
  line-height: 0.91;
  letter-spacing: -0.027em;
  text-transform: uppercase;
  white-space: nowrap;
}

.nastro__segno {
  width: 0.6em;
  height: 0.6em;
  margin: 0 0.3em;
  fill: var(--testo);
  flex-shrink: 0;
}

.nastro__voce:nth-child(2n) .nastro__segno {
  transform: rotate(45deg);
}

/* ---------------------------------------------------------------- a cube */
.oggetto {
  --lato: 75px;
  position: absolute;
  top: 0;
  left: 0;
  width: var(--lato);
  height: var(--lato);
  z-index: 0;
  pointer-events: none;
  will-change: transform;
}

.oggetto[data-livello='davanti'] {
  z-index: 2;
}

.oggetto[data-taglia='medium'] {
  --lato: 125px;
}

.oggetto[data-taglia='large'] {
  --lato: 175px;
}

@media (min-width: 900px) {
  .oggetto {
    --lato: 120px;
  }

  .oggetto[data-taglia='medium'] {
    --lato: 190px;
  }

  .oggetto[data-taglia='large'] {
    --lato: 260px;
  }
}

/* the cube shows up with a little pop once it has its place */
.oggetto__scena {
  position: absolute;
  inset: 18%;
  perspective: 900px;
  transform: scale(0);
  transition: transform 0.5s cubic-bezier(0.26, 1, 0.48, 1);
}

.oggetto[data-pronto='true'] .oggetto__scena {
  transform: scale(1);
}

.cubo {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  animation: gira var(--giro, 12s) linear infinite;
  animation-delay: var(--ritardo, 0s);
}

@keyframes gira {
  from {
    transform: rotate3d(1, 0.85, 0.3, 0deg);
  }

  to {
    transform: rotate3d(1, 0.85, 0.3, 360deg);
  }
}

.faccia {
  position: absolute;
  inset: 0;
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
}

.faccia:nth-child(1) { transform: translateZ(calc(var(--lato) * 0.32)); }
.faccia:nth-child(2) { transform: rotateY(180deg) translateZ(calc(var(--lato) * 0.32)); }
.faccia:nth-child(3) { transform: rotateY(90deg) translateZ(calc(var(--lato) * 0.32)); }
.faccia:nth-child(4) { transform: rotateY(-90deg) translateZ(calc(var(--lato) * 0.32)); }
.faccia:nth-child(5) { transform: rotateX(90deg) translateZ(calc(var(--lato) * 0.32)); }
.faccia:nth-child(6) { transform: rotateX(-90deg) translateZ(calc(var(--lato) * 0.32)); }

/* a fixed light from the top left: each face a little lighter or darker */
.faccia:nth-child(2),
.faccia:nth-child(4) { filter: brightness(0.82); }
.faccia:nth-child(6) { filter: brightness(0.7); }
.faccia:nth-child(5) { filter: brightness(1.12); }

/* glass: tinted, see-through, with a bright rim and a shine */
[data-materiale='glass'] .faccia {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.65) 0%, rgba(255, 255, 255, 0) 38%),
    var(--vetro);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.7), inset 0 0 22px rgba(255, 255, 255, 0.35);
  border-radius: 6%;
}

/* a die: cream with dark pips */
[data-materiale='dice'] .faccia {
  border-radius: 16%;
  background-color: #fff6e6;
  box-shadow: inset 0 0 0 3px rgba(36, 17, 43, 0.08);
}

[data-materiale='dice'] .faccia:nth-child(odd) {
  background-image:
    radial-gradient(circle at 28% 28%, #24112b 0 9%, transparent 10%),
    radial-gradient(circle at 50% 50%, #24112b 0 9%, transparent 10%),
    radial-gradient(circle at 72% 72%, #24112b 0 9%, transparent 10%);
}

[data-materiale='dice'] .faccia:nth-child(even) {
  background-image:
    radial-gradient(circle at 30% 30%, #24112b 0 9%, transparent 10%),
    radial-gradient(circle at 70% 30%, #24112b 0 9%, transparent 10%),
    radial-gradient(circle at 30% 70%, #24112b 0 9%, transparent 10%),
    radial-gradient(circle at 70% 70%, #24112b 0 9%, transparent 10%);
}

/* sugar: white and grainy */
[data-materiale='sugar'] .faccia {
  border-radius: 4%;
  background-color: #ffffff;
  background-image:
    radial-gradient(rgba(36, 17, 43, 0.12) 1px, transparent 1.6px),
    radial-gradient(rgba(36, 17, 43, 0.08) 1px, transparent 1.8px);
  background-size: 7px 7px, 11px 11px;
  background-position: 0 0, 3px 5px;
}

/* candy: stripes */
[data-materiale='candy'] .faccia {
  border-radius: 10%;
  background: repeating-linear-gradient(45deg, var(--caramella) 0 12%, #4fa8ff 12% 24%);
}

/* rubber: flat and soft */
[data-materiale='rubber'] .faccia {
  border-radius: 22%;
  background: var(--gomma);
  box-shadow: inset 0 -8px 16px rgba(0, 0, 0, 0.12);
}

/* chrome: a mirror of sky and floor */
[data-materiale='chrome'] .faccia {
  border-radius: 8%;
  background: linear-gradient(180deg, #f6f7fb 0%, #9aa2b8 46%, #2b2f3d 50%, #c9cfdd 100%);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .cubo {
    animation: none;
    transform: rotate3d(1, 0.85, 0.3, 32deg);
  }

  .oggetto__scena {
    transition: opacity 0.4s ease;
    transform: none;
    opacity: 0;
  }

  .oggetto[data-pronto='true'] .oggetto__scena {
    transform: none;
    opacity: 1;
  }
}
