/* The crew that glitches: a night radio's crew page in lime on near black. The stage holds five frames over the same
   portrait, one large and four close-ups around it; each frame is a box the mouse moves a little (the outer element),
   with an SVG outline that draws itself and a canvas inside (made by the script). */
:root {
  --fondo: #0a0b08;        /* the page */
  --luce: #d4ff3a;         /* the light of the portraits and the outlines */
  --buio: #0b0d08;         /* the dark of the portraits */
  --testo: #e9ffb0;        /* names */
  --tenue: #7f8f52;        /* the small text */
}

* {
  box-sizing: border-box;
}

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

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

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

.pagina {
  position: relative;
  display: grid;
  grid-template-columns: minmax(180px, 22vw) 1fr;
  grid-template-rows: auto 1fr;
  gap: 18px 3vw;
  height: 100%;
  padding: clamp(16px, 2.4vw, 36px);
}

.testa__marchio {
  margin: 0 0 10px;
  color: var(--tenue);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.testa__titolo {
  margin: 0;
  font-size: clamp(24px, 2.6vw, 40px);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------- the names */
.nomi {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  align-self: end;
  gap: 4px;
  grid-row: 2;
}

.nomi button {
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--testo);
  font: inherit;
  font-size: clamp(18px, 1.5vw, 24px);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.35s cubic-bezier(0.34, 1.6, 0.5, 1);
  -webkit-tap-highlight-color: transparent;
}

.nomi button span {
  color: var(--tenue);
  font-size: 0.6em;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: color 0.25s ease;
}

/* the name on air is printed on a lime pill */
.nomi button[aria-checked='true'] {
  background: var(--luce);
  color: var(--buio);
}

.nomi button[aria-checked='true'] span {
  color: var(--buio);
}

.nomi button:focus-visible {
  outline: 2px solid var(--luce);
  outline-offset: 3px;
}

@media (hover: hover) {
  .nomi button:hover {
    transform: translateX(6px);
  }
}

/* ---------------------------------------------------------------- the frames */
.palco {
  position: relative;
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 0;
}

.cornice {
  position: absolute;
  transition: transform 0.3s ease-out;
}

.cornice--grande { left: 26%; top: 8%; width: 42%; height: 84%; }
.cornice--alto { left: 58%; top: 0; width: 18%; height: 30%; }
.cornice--sinistra { left: 8%; top: 40%; width: 26%; height: 18%; }
.cornice--basso { left: 4%; top: 70%; width: 14%; height: 18%; }
.cornice--destra { left: 62%; top: 62%; width: 24%; height: 30%; }

/* inside a frame: the picture, the glitch over it, the outline over both */
.cornice__dentro {
  position: absolute;
  inset: 0;
  overflow: hidden;
  scale: 0;
  transition: scale 0.6s cubic-bezier(0.33, 1, 0.32, 1);
}

.cornice[data-pronta='true'] .cornice__dentro {
  scale: 1;
}

.cornice canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.cornice__guasto {
  opacity: 0;
  pointer-events: none;
}

.cornice__linea {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  overflow: visible;
  pointer-events: none;
}

.cornice__linea rect {
  fill: none;
  stroke: var(--luce);
  stroke-width: 1.5;
}

.cornice__linea .angolo {
  fill: var(--luce);
  stroke: none;
}

/* on a phone the names line up at the bottom and the frames take the rest */
@media (max-width: 760px) {
  .pagina {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }

  .palco {
    grid-column: 1;
    grid-row: 2;
  }

  .nomi {
    grid-row: 3;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 2px;
  }

  .nomi button {
    font-size: 17px;
  }

  .nomi button span {
    display: none;
  }

  .cornice--grande { left: 18%; top: 4%; width: 64%; height: 82%; }
  .cornice--alto { left: 66%; top: 0; width: 30%; height: 24%; }
  .cornice--sinistra { left: 0; top: 34%; width: 36%; height: 16%; }
  .cornice--basso { left: 2%; top: 70%; width: 24%; height: 18%; }
  .cornice--destra { left: 60%; top: 66%; width: 38%; height: 26%; }
}

/* less motion: no pop, no mouse, the frames simply fade in and the faces cross-fade */
@media (prefers-reduced-motion: reduce) {
  .cornice {
    transition: none;
  }

  .cornice__dentro {
    scale: 1;
    opacity: 0;
    transition: opacity 0.5s linear;
  }

  .cornice[data-pronta='true'] .cornice__dentro {
    opacity: 1;
  }

  .nomi button {
    transition: background-color 0.25s ease, color 0.25s ease;
  }
}
