/* Video Tiles Component
   Reusable tile gallery — drop a .scene-outer block in HTML,
   video-tiles.js auto-initialises it.
   Handles any aspect ratio. Supports videos and images. */

:root {
  --tile-radius: 32px;
}

/* ── SCENE OUTER ── */
.scene-outer {
  position: relative;
  width: 100vw;
  margin-left: calc(-50vw + 50%);
  max-width: none;
}

/* ── SCENE: horizontal scroll row ── */
.scene {
  display: flex;
  overflow-x: scroll;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 10px;
  padding: 0 24px 20px;
  scroll-snap-type: x mandatory;
  background: transparent;
}
.scene::-webkit-scrollbar {
  display: none;
}

/* ── TILE ── */
.tile {
  flex: 0 0 auto;
  height: min(82vw, 600px);
  display: flex;
  position: relative;
  border-radius: var(--tile-radius);
  overflow: hidden;
  cursor: pointer;
  z-index: 1;
  transition:
    filter 1s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s;
  background: transparent;
  border: 4px solid #fff;
  scroll-snap-align: center;
}
.tile:not(.active) {
  opacity: 0.65;
}

/* Loading state — grayscale with spinner until media is ready */
.tile-loading video,
.tile-loading > img {
  filter: grayscale(1) brightness(1.05);
}
.tile-loading.active::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin-top: -18px;
  margin-left: -18px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: #999;
  border-radius: 50%;
  animation: tile-spin 0.8s linear infinite, tile-spinner-fade-in 0.3s ease 1s both;
  z-index: 3;
  opacity: 0;
}
@keyframes tile-spin {
  to { transform: rotate(360deg); }
}
@keyframes tile-spinner-fade-in {
  to { opacity: 1; }
}

/* Content sizing — videos and images fill height, width follows aspect ratio */
.tile video,
.tile > img {
  height: 100%;
  width: auto;
  display: block;
  transition:
    filter 1s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.4s ease;
  background: #fcfcfc;
}
.tile.active video,
.tile.active > img {
  filter: grayscale(0) brightness(1);
}

/* Caption */
.tile-cap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 28px 20px 16px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.45));
  z-index: 5;
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.5s,
    transform 0.5s,
    padding 0.4s,
    background 0.4s;
  pointer-events: none;
  border-radius: 0 0 var(--tile-radius) var(--tile-radius);
  text-align: center;
}
.tile.active .tile-cap {
  opacity: 1;
  transform: translateY(0);
}
.tile.expanded .tile-cap {
  padding: 40px 20px 20px;
  background: linear-gradient(transparent 0%, rgba(0, 0, 0, 0.55) 30%);
}
.tile-cap span {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.85);
}
.tile-arrow {
  display: block;
  width: 8px;
  height: 8px;
  border-top: 1.5px solid rgba(255, 255, 255, 0.6);
  border-right: 1.5px solid rgba(255, 255, 255, 0.6);
  transform: rotate(-45deg);
  margin: 0 auto 6px;
  transition: transform 0.3s ease;
}
.tile.expanded .tile-arrow {
  transform: rotate(135deg);
}
.tile.active:hover .tile-arrow {
  transform: translateY(-3px) rotate(-45deg);
}
.tile.expanded.active:hover .tile-arrow {
  transform: translateY(3px) rotate(135deg);
}

/* Description inside tile */
.tile-desc {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.3s ease;
  font-size: 12px;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.75);
  line-height: 1.6;
  margin-top: 0;
  text-align: center;
}
.tile.expanded .tile-desc {
  max-height: 300px;
  opacity: 1;
  margin-top: 10px;
}

/* Progress bar */
.tile-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  z-index: 6;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.4s;
}
.tile.active .tile-progress {
  opacity: 1;
}
.tile-progress-bar {
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.85);
  transition: width 0.25s linear;
}

/* ── CHEVRONS ── */
.chevrons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 14px 0 8px;
}
.chev {
  border: none;
  background: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s;
}
.chev:hover {
  opacity: 0.4;
  box-shadow: none;
  background: none;
}
.chev:focus {
  outline: none;
}
.chev:focus-visible {
  outline: none;
}
.chev:active {
  outline: none;
}
.chev-icon {
  display: block;
  width: 10px;
  height: 10px;
  border-top: 2px solid var(--black, #150d0a);
  border-right: 2px solid var(--black, #150d0a);
}
.chev-prev .chev-icon {
  transform: rotate(-135deg);
}
.chev-next .chev-icon {
  transform: rotate(45deg);
}
.chev-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #999;
  min-width: 80px;
  text-align: center;
}

/* ── DESKTOP: grayscale on inactive tiles ── */
@media (min-width: 681px) {
  .tile:not(.active) video,
  .tile:not(.active) > img {
    filter: grayscale(1) brightness(1.05);
  }
}
