/* Travel journal gallery that frames the chosen photo: the gallery of Saltway, a made-up travel journal. Warm white
   paper, black ink, one terracotta accent for the lit thumbnail. Two layouts share the same stage: the tidy grid,
   and the open view with the chosen photo in the middle, its caption and arrows, and a thin row of thumbnails.
   The six photos move between the two with GSAP Flip. */
:root {
  --carta: #f7f3ec;        /* the warm white paper */
  --luce: #fffdf9;         /* the soft light on the paper */
  --inchiostro: #1c1915;   /* names, captions and buttons */
  --tenue: #8d8579;        /* months and small words */
  --filo: rgba(28, 25, 21, 0.1); /* thin lines */
  --accento: #c8642f;      /* terracotta: the lit thumbnail and the month */
  --ombra: 28, 22, 14;     /* the colour of the soft shadows */
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(110% 70% at 12% -10%, var(--luce) 0%, rgba(255, 253, 249, 0) 60%),
    radial-gradient(80% 60% at 100% 110%, rgba(200, 100, 47, 0.05), rgba(200, 100, 47, 0) 70%),
    var(--carta);
  color: var(--inchiostro);
  font-family: 'Mona Sans Variable', 'Mona Sans', 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

.palco {
  position: relative;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: clamp(10px, 3vh, 30px) clamp(14px, 4vw, 48px) clamp(12px, 3.4vh, 34px);
  overflow: hidden;
}

/* ------------------------------------------------------------ the bar at the top */
.testa {
  position: relative;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: clamp(34px, 7vh, 52px);
  border-bottom: 1px solid var(--filo);
  margin-bottom: clamp(10px, 3vh, 28px);
}

.marchio {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: clamp(14px, 1.3vw + 6px, 17px);
  font-weight: 680;
  font-variation-settings: 'wdth' 112;
  letter-spacing: -0.02em;
}

.marchio__segno {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--accento);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.testa__nota {
  margin: 0;
  font-size: clamp(11px, 0.6vw + 8px, 13px);
  color: var(--tenue);
  font-variation-settings: 'wdth' 96;
}

/* ------------------------------------------------------------ pill buttons */
.tasto {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: clamp(30px, 6vh, 38px);
  min-width: clamp(30px, 6vh, 38px);
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tasto__fondo {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #fff;
  box-shadow:
    0 0 0 1px rgba(28, 25, 21, 0.09),
    0 1px 2px rgba(var(--ombra), 0.08),
    0 6px 14px -6px rgba(var(--ombra), 0.18);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s;
}

.tasto svg {
  position: relative;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tasto__testo {
  position: relative;
  font-size: 13px;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tasto:active .tasto__fondo {
  transform: scale(0.92);
  transition-duration: 0.12s;
}

@media (hover: hover) {
  .tasto:hover .tasto__fondo {
    transform: scale(1.06);
    background-color: #fffaf3;
  }
  .tasto:hover .tasto__testo {
    font-variation-settings: 'wdth' 116;
  }
  .tasto--freccia[data-dopo]:hover svg {
    transform: translateX(2px);
  }
  .tasto--freccia[data-prima]:hover svg {
    transform: translateX(-2px);
  }
  .tasto--griglia:hover svg {
    transform: rotate(90deg);
  }
}

.tasto--griglia {
  position: absolute;
  right: 0;
  top: 50%;
  margin-top: calc(clamp(30px, 6vh, 38px) / -2);
  opacity: 0;
  visibility: hidden;
}

.tasto--griglia svg {
  stroke-width: 1.4;
}

/* ------------------------------------------------------------ the stage with its two layouts */
.scena {
  position: relative;
  flex: 1;
  min-height: 0;
}

.griglia,
.aperta {
  position: absolute;
  inset: 0;
}

.griglia {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-content: center;
  gap: clamp(10px, 2.4vh, 26px) clamp(8px, 1.8vw, 24px);
  width: min(100%, 1040px, calc((100vh - 200px) * 1.9));
  margin: 0 auto;
}

.cella {
  min-width: 0;
}

.presa {
  position: relative;
  aspect-ratio: 4 / 3;
}

.cella__nome {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  margin: clamp(5px, 1.2vh, 10px) 0 0;
  font-size: clamp(10.5px, 0.5vw + 8px, 13px);
  font-weight: 560;
  font-variation-settings: 'wdth' 104;
  white-space: nowrap;
  overflow: hidden;
}

.cella__nome span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.cella__nome em {
  font-style: normal;
  font-weight: 500;
  color: var(--tenue);
  font-size: 0.9em;
}

/* the open view */
.aperta {
  --larga: min(100%, 980px, calc((100vh - 170px - 15vh) * 1.6));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 2.2vh, 22px);
  visibility: hidden;
  pointer-events: none;
}

.palco.e-aperta .aperta {
  visibility: visible;
  pointer-events: auto;
}

.palco.e-aperta .griglia {
  pointer-events: none;
}

.vista-posto {
  position: relative;
  z-index: 3;
  width: var(--larga);
  aspect-ratio: 16 / 10;
  flex: none;
}

.vista {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: clamp(10px, 1.4vw, 16px);
  background: #2a241d;
  box-shadow:
    0 1px 2px rgba(var(--ombra), 0.1),
    0 12px 28px -12px rgba(var(--ombra), 0.32),
    0 40px 80px -40px rgba(var(--ombra), 0.4);
}

.binario {
  display: flex;
  width: 600%;
  height: 100%;
}

.lastra {
  flex: 0 0 calc(100% / 6);
  height: 100%;
  margin: 0;
  overflow: hidden;
}

.lastra img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* a breath of film grain over the big photo, tiled from a small canvas the script paints once */
.vista__grana,
.foto__dentro::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: var(--grana, none);
  background-size: 140px 140px;
  mix-blend-mode: overlay;
  opacity: calc(var(--grana-forza, 0.07) * 2.4);
  pointer-events: none;
}

/* the edge of the big photo catching the light from the top left */
.vista__bordo {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(150deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.08) 40%, rgba(255, 255, 255, 0) 60%, rgba(255, 255, 255, 0.22));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

.sotto {
  position: relative;
  z-index: 2;
  width: var(--larga);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex: none;
}

.didascalia {
  min-width: 0;
}

.riga {
  margin: 0;
  overflow: hidden;
  line-height: 1.28;
}

.riga--frase span {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.riga span {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.riga--luogo {
  font-size: clamp(16px, 1.6vw + 8px, 30px);
  font-weight: 650;
  font-variation-settings: 'wdth' 112;
  letter-spacing: -0.025em;
}

.riga--mese {
  margin-top: 2px;
  font-size: clamp(10.5px, 0.4vw + 8px, 13px);
  font-weight: 600;
  color: var(--accento);
  font-variation-settings: 'wdth' 96;
}

.riga--frase {
  margin-top: 2px;
  font-size: clamp(11.5px, 0.5vw + 8.5px, 15px);
  color: var(--tenue);
  font-variation-settings: 'wdth' 98;
}

.frecce {
  display: flex;
  gap: 6px;
  flex: none;
  padding-bottom: 2px;
}

.tasto--freccia {
  padding: 0;
}

/* the thin row of thumbnails */
.fila {
  position: relative;
  z-index: 1;
  display: flex;
  gap: clamp(5px, 0.8vw, 10px);
  flex: none;
}

.presa--fila {
  width: clamp(40px, 5.6vw, 74px);
}

.fila__luce {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 3;
  border-radius: 9px;
  border: 1.5px solid var(--accento);
  box-shadow: 0 0 0 3px rgba(200, 100, 47, 0.12);
  opacity: 0;
  pointer-events: none;
}

/* ------------------------------------------------------------ one photo (moved by Flip; its inside by the CSS) */
.foto {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: clamp(7px, 0.9vw, 12px);
  background: #d8cfc2;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow:
    0 1px 2px rgba(var(--ombra), 0.1),
    0 8px 20px -10px rgba(var(--ombra), 0.3);
}

.fila .foto {
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(var(--ombra), 0.12), 0 4px 10px -6px rgba(var(--ombra), 0.3);
}

.foto__dentro {
  position: absolute;
  inset: 0;
  display: block;
  overflow: hidden;
  border-radius: inherit;
  transition: transform 0.55s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.foto img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.02);
  transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1), filter 0.5s;
}

/* the edge that catches the light where the pointer is */
.foto::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
  padding: 1px;
  background:
    radial-gradient(140px circle at var(--lx, 30%) var(--ly, 0%), rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 70%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.05) 50%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: calc(var(--bordo, 0.6) * 0.6);
  transition: opacity 0.4s;
  pointer-events: none;
}

/* pressed, the photo gives a little and comes back on a spring */
.foto:active .foto__dentro,
.foto.premuta .foto__dentro {
  transform: scale(0.94);
  transition-duration: 0.12s;
}

.fila .foto img {
  filter: saturate(0.55) brightness(0.92);
}

.fila .foto.accesa img {
  filter: none;
}

@media (hover: hover) {
  .foto:hover::after {
    opacity: var(--bordo, 0.6);
  }
  .griglia .foto:hover img {
    transform: scale(1.06);
  }
  .fila .foto:hover img {
    filter: saturate(0.9) brightness(1);
  }
}

.foto:focus-visible,
.tasto:focus-visible {
  outline: 2px solid var(--accento);
  outline-offset: 3px;
}

/* ------------------------------------------------------------ the drawn pointer of the demo */
.puntatore {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 30;
  width: 22px;
  height: 22px;
  margin: -3px 0 0 -5px;
  fill: var(--inchiostro);
  stroke: #fff;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(var(--ombra), 0.3));
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 420px) {
  .palco.e-aperta .testa__nota {
    visibility: hidden;
  }
}
