:root {
  color-scheme: dark;
}

html,
body {
  font-family: "Roboto", sans-serif;
  background: #000;
  color: #fff;
}

.avoid-break {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
}

/* Masonry grid with uniform spacing */
#grid {
  column-gap: 1rem;
  width: 100%;
}

#grid > * {
  margin-bottom: 1rem;
  display: inline-block;
  width: 100%;
  margin-left: 0;
  margin-right: 0;
  margin-top: 0;
  padding: 0;
}

#grid > *:last-child {
  margin-bottom: 0;
}

/* Ensure images and videos inside cards don't add extra spacing */
#grid > * img,
#grid > * video {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 0;
}

@keyframes marqueeX {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-33.333%);
  }
}

/* Faster marquee on mobile and tablet */
@media (max-width: 1023px) {
  #marquee {
    animation: marqueeX 15s linear infinite;
  }
}

@media (max-width: 767px) {
  #marquee {
    animation: marqueeX 12s linear infinite;
  }
}

.selected {
  background-color: white;
  color: black;
}

/* Make the YouTube iframe fit the screen while preserving 16:9 and the lightbox limits */
#lbIframe {
  width: min(92vw, calc(86vh * 16 / 9));
  height: min(86vh, calc(92vw * 9 / 16));
}

/* Ensure media in lightbox do not leave baseline gaps and keep black background */
#lbImg,
#lbVideo,
#lbIframe,
#lbStream {
  background: #000;
}

/* Make the stream iframe fit the screen */
#lbStream {
  width: min(92vw, calc(90vh * 16 / 9));
  height: min(90vh, calc(92vw * 9 / 16));
}

/* Prevent image selection and download */
img, video {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  pointer-events: auto;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

/* Prevent context menu on images and videos */
#grid img,
#grid video,
#lbImg,
#lbVideo,
figure img,
figure video {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
  pointer-events: auto;
}

/* Prevent text selection on image containers */
#grid > *,
figure {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Progressive image loading - shimmer effect (Windows and Safari) */
.image-loading-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    #0a0a0a 0%,
    #1a1a1a 25%,
    #2a2a2a 50%,
    #1a1a1a 75%,
    #0a0a0a 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
  z-index: 1;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* Progressive image reveal - top to bottom */
.image-progressive {
  position: relative;
  overflow: hidden;
}

.image-progressive img {
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
  will-change: opacity;
}

.image-progressive img.loaded {
  opacity: 1;
}

/* Progressive reveal overlay - reveals image from top to bottom */
.image-progressive .absolute.inset-0.bg-zinc-900 {
  background: #0a0a0a;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
  clip-path: inset(0 0 100% 0);
}

/* Ensure figure has relative positioning for absolute children */
#grid figure {
  position: relative;
  background: #0a0a0a;
  width: 100%;
  /* Aspect ratio will be set dynamically by JavaScript to prevent layout shift */
}

/* When figure has aspect-ratio, images should fill the container */
#grid figure[style*="aspect-ratio"] img {
  height: 100%;
  object-fit: cover;
}

/* Ensure VR badge and play badge are above images and placeholders */
#grid figure [class*="z-20"],
#grid figure .z-20 {
  z-index: 30 !important;
  position: absolute !important;
}

/* Ensure figcaption is above image but below badges */
#grid figure figcaption {
  z-index: 15 !important;
  position: absolute !important;
}

/* Safari compatibility: support padding-bottom technique for aspect ratio */
#grid figure[style*="padding-bottom"] {
  position: relative;
  width: 100%;
}

#grid figure[style*="padding-bottom"] img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Progressive reveal overlay for Safari */
#grid figure[style*="padding-bottom"] .absolute.inset-0.bg-zinc-900 {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #0a0a0a;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
  clip-path: inset(0 0 100% 0);
}
