* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  min-height: 100vh;
}

body {
  font-family: Arial, sans-serif;
  color: white;
  text-align: center;

  background:
    linear-gradient(rgba(0,0,0,0.20), rgba(0,0,0,0.40)),
    url("./img/Sfondo-per-il-Sito.png");

  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  background-attachment: fixed;

  min-height: 100vh;
  padding: 14px;
  overflow-x: hidden;
}

.bg-video {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  z-index: -3;
}

.bg-video-mobile {
  display: none;
}

.video-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -2;
  background: linear-gradient(rgba(3, 13, 35, 0.24), rgba(3, 13, 35, 0.58));
}

.gallery-page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 6px 40px;
}

.gallery-title {
  font-size: 32px;
  margin: 18px 0 24px;
  color: white;
  text-shadow: 0 0 14px rgba(255,255,255,0.70);
}

.back-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 10px 20px;
  border-radius: 999px;

  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);

  color: white;
  font-size: 15px;
  font-weight: 700;
  text-decoration: none;

  box-shadow: 0 0 14px rgba(255,255,255,0.25);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.category-card {
  position: relative;
  display: block;

  aspect-ratio: 1 / 1;
  overflow: hidden;

  border-radius: 16px;
  text-decoration: none;

  background: rgba(0,0,0,0.35);
  box-shadow:
    0 0 12px rgba(255,255,255,0.20),
    inset 0 0 10px rgba(255,255,255,0.08);
}

.category-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;

  transition: transform 0.25s ease;
}

.category-card:hover img {
  transform: scale(1.06);
}

.category-overlay {
  position: absolute;
  inset: 0;

  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;

  padding: 10px 6px;

  background:
    linear-gradient(
      rgba(0,0,0,0.05),
      rgba(0,0,0,0.78)
    );
}

.category-overlay span {
  color: white;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.1;
  text-shadow: 0 0 8px rgba(0,0,0,0.9);
}

.category-overlay small {
  margin-top: 3px;
  color: rgba(255,255,255,0.88);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.1;
  text-shadow: 0 0 8px rgba(0,0,0,0.9);
}

.slow-gallery {
  width: 100vw;
  margin: 34px calc(50% - 50vw) 0;
  padding: 18px 0 12px;
  overflow: hidden;

  background: linear-gradient(
    90deg,
    rgba(6, 28, 70, 0.18),
    rgba(255, 255, 255, 0.16),
    rgba(6, 28, 70, 0.18)
  );
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);

  border-top: 1px solid rgba(255,255,255,0.34);
  border-bottom: 1px solid rgba(255,255,255,0.26);
  box-shadow:
    inset 0 0 22px rgba(255,255,255,0.10),
    0 0 22px rgba(0,0,0,0.18);
}

.slow-gallery-track {
  display: flex;
  gap: 22px;
  width: max-content;
  animation: slowGalleryScroll 55s linear infinite;
  will-change: transform;
}

.slow-gallery-track img {
  flex: 0 0 auto;
  width: 190px;
  height: 245px;
  object-fit: cover;
  border-radius: 18px;
  display: block;
  border: 1px solid rgba(255,255,255,0.36);
  box-shadow:
    0 12px 26px rgba(0,0,0,0.28),
    0 0 14px rgba(255,255,255,0.12);
}

.slow-gallery:hover .slow-gallery-track {
  animation-play-state: paused;
}

@keyframes slowGalleryScroll {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-50%);
  }
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.photo-card {
  display: block;
  overflow: hidden;
  border-radius: 16px;

  background: rgba(0,0,0,0.35);
  box-shadow: 0 0 12px rgba(255,255,255,0.18);
}

.photo-card img {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 600px) {
  body {
    padding: 10px;
    background-attachment: scroll;
  }

  .bg-video-desktop {
    display: none;
  }

  .bg-video-mobile {
    display: block;
  }

  .gallery-page {
    padding: 18px 4px 32px;
  }

  .gallery-title {
    font-size: 26px;
    margin: 16px 0 20px;
  }

  .category-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .category-card {
    border-radius: 11px;
  }

  .category-overlay {
    padding: 7px 4px;
  }

  .category-overlay span {
    font-size: 12px;
  }

  .category-overlay small {
    font-size: 9px;
  }

  .slow-gallery {
    margin-top: 24px;
    padding: 14px 0 9px;
  }

  .slow-gallery-track {
    gap: 14px;
    animation-duration: 42s;
  }

  .slow-gallery-track img {
    width: 135px;
    height: 185px;
    border-radius: 15px;
  }

  .photo-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .back-button {
    font-size: 14px;
    padding: 9px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slow-gallery-track {
    animation: none;
    overflow-x: auto;
  }
}
