/* Projects with elastic lines: a studio's list of five products on a pale sage page. Every name is two halves that
   part to make room for a small picture of the product; between the names run thin lines drawn by the script, each in
   an SVG as tall as a row and centred on the border, so that the line can bend up or down inside it. */
:root {
  --fondo: #e9f3e4;        /* the page */
  --inchiostro: #14261c;   /* the names */
  --filo: #6f8174;         /* the lines between the names */
  --tenue: #4d6153;        /* the small text */
  --durata: 0.5s;          /* how long the halves take to part: the script writes it from SPLIT */
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: 'DM Mono', ui-monospace, Menlo, monospace;
  -webkit-font-smoothing: antialiased;
}

.pagina {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
  padding: clamp(16px, 2.6vw, 34px) clamp(16px, 5.5vw, 96px);
}

.testa {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--tenue);
  font-size: clamp(11px, 0.9vw, 14px);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- the list */
.elenco {
  align-self: center;
  margin: 0;
  padding: 0;
  list-style: none;
  /* on a touch screen a finger on the list bends the lines instead of moving the page */
  touch-action: none;
  --corpo: clamp(40px, min(9.4vw, 11.4vh), 136px);
}

.voce {
  position: relative;
}

.riga {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(var(--corpo) * 1.3);
  padding: calc(var(--corpo) * 0.12) 0;
  color: inherit;
  text-decoration: none;
  outline-offset: -6px;
  -webkit-tap-highlight-color: transparent;
}

.riga:focus-visible {
  outline: 2px solid var(--inchiostro);
  border-radius: 14px;
}

.parola {
  display: block;
  font-family: 'DynaPuff Variable', 'Arial Rounded MT Bold', sans-serif;
  font-size: var(--corpo);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.01em;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}

/* the two halves: the script measures how far each must go so the picture fits between them */
.meta {
  display: inline-block;
  transition: transform var(--durata) cubic-bezier(0, 0, 0.2, 1);
}

.riga[data-aperta='true'] .meta--sx {
  transform: translateX(calc(var(--sx, 0px) * -1));
}

.riga[data-aperta='true'] .meta--dx {
  transform: translateX(var(--dx, 0px));
}

/* the picture of the product, in the middle of the row, a touch smaller until it shows */
.anteprima {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--corpo) * 1.5);
  aspect-ratio: 2 / 1;
  translate: -50% -50%;
  opacity: 0;
  scale: 0.95;
  pointer-events: none;
  transition: opacity var(--durata) cubic-bezier(0, 0, 0.2, 1), scale var(--durata) cubic-bezier(0, 0, 0.2, 1);
}

.anteprima svg {
  display: block;
  width: 100%;
  height: 100%;
}

.anteprima text {
  font-family: 'DM Mono', ui-monospace, monospace;
  font-size: 15px;
  font-weight: 500;
}

.riga[data-aperta='true'] .anteprima {
  opacity: 1;
  scale: 1;
}

/* ---------------------------------------------------------------- the lines */
.filo {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: calc(var(--corpo) * 1.3);
  translate: 0 -50%;
  overflow: visible;
  pointer-events: none;
}

.filo path {
  fill: none;
  stroke: var(--filo);
  stroke-width: 1.5;
  stroke-linecap: round;
}

/* less motion: the halves jump apart at once, the picture fades in, the lines stay straight */
@media (prefers-reduced-motion: reduce) {
  .meta {
    transition: none;
  }

  .anteprima {
    scale: 1;
    transition: opacity 0.3s linear;
  }
}
