/* The halftone that melts away: the work page of a made-up CGI studio, four renders in a grid. In every card the
   render is a canvas painted by the script, and on top of it a second canvas holds the halftone: a flat field of
   colour with a black dot on every cell where the picture underneath is dark. */
:root {
  --fondo: #0b0b10;        /* the page */
  --campo: #2f3bff;        /* the field of colour over each render */
  --punti: #050507;        /* the dots */
  --testo: #eef0ff;        /* names */
  --tenue: #8d91b8;        /* the small text */
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
}

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

.pagina {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: clamp(14px, 2.2vh, 28px);
  min-height: 100vh;
  padding: clamp(16px, 2.6vw, 40px);
}

.testa {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 16px;
}

.testa__marchio,
.testa__nota,
.carta__dove {
  margin: 0;
  color: var(--tenue);
  font-family: 'JetBrains Mono Variable', ui-monospace, Menlo, monospace;
  font-size: clamp(11px, 0.85vw, 13px);
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.testa__nota {
  text-align: right;
}

.testa__titolo {
  margin: 0;
  font-size: clamp(26px, 3.4vw, 54px);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* ---------------------------------------------------------------- the cards */
.griglia {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(14px, 1.6vw, 26px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.carta {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: 1fr auto;
  gap: 8px 12px;
  height: 100%;
  color: inherit;
  text-decoration: none;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.carta__quadro {
  position: relative;
  grid-column: 1 / -1;
  min-height: 0;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 14px;
  background: var(--campo);
}

.carta:focus-visible .carta__quadro {
  outline: 2px solid var(--testo);
  outline-offset: 3px;
}

.carta__render,
.carta__retino {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.carta__nome {
  font-size: clamp(16px, 1.25vw, 20px);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.carta__dove {
  align-self: center;
  text-align: right;
}

/* on a desktop screen the four cards fit in the window; on a phone they stack and the page scrolls */
@media (min-width: 761px) and (min-aspect-ratio: 4 / 3) {
  .griglia {
    height: calc(100vh - clamp(16px, 2.6vw, 40px) * 2 - clamp(26px, 3.4vw, 54px) - clamp(14px, 2.2vh, 28px));
    grid-template-rows: 1fr 1fr;
  }

  .carta__quadro {
    aspect-ratio: auto;
  }
}

@media (max-width: 760px) {
  .testa {
    grid-template-columns: 1fr 1fr;
  }

  .testa__titolo {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .griglia {
    grid-template-columns: 1fr;
  }
}

/* sul telefono con lo schermo basso (la casella dell'anteprima, 341 per 410) le quattro carte stanno in due per due e
   riempiono la finestra come sul computer, invece di andare in colonna sotto il bordo */
@media (max-width: 760px) and (max-height: 520px) {
  .pagina {
    gap: 12px;
    height: 100vh;
    min-height: 0;
  }

  .testa {
    row-gap: 6px;
  }

  .testa__titolo {
    font-size: 24px;
  }

  .griglia {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 12px 10px;
    min-height: 0;
  }

  .griglia > li {
    min-height: 0;
  }

  .carta {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto auto;
    gap: 4px;
  }

  .carta__quadro {
    aspect-ratio: auto;
    border-radius: 10px;
  }

  .carta__nome {
    font-size: 15px;
    line-height: 1.1;
  }

  .carta__dove {
    align-self: start;
    text-align: left;
    font-size: 10px;
  }
}
