/* ══════════════════════════════════════════════════
   CLICK-TO-PLAY VIDEO THUMBNAILS  — video-lazy.css
   Handles both 9:16 vertical and 16:9 horizontal
   grids. Drop alongside subpage.css / index CSS.
══════════════════════════════════════════════════ */

/* ─── Aspect-ratio shells ──────────────────────── */

/* 9:16 vertical wrapper (Shorts / product / AI) */
.vertical-video-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 177.78%; /* 9:16 */
  overflow: hidden;
  background: var(--bg2, #1c1c1c);
  border-radius: 6px;
}

/* project-video-wrap lives in index.html (9:16) */
.project-video-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 177.78%;
  overflow: hidden;
  background: var(--bg2, #1c1c1c);
  border-radius: 6px;
}

/* Bootstrap .ratio.ratio-16x9 already sets
   position:relative + padding-bottom:56.25%.
   We just make sure overflow is clipped nicely. */
.ratio {
  overflow: hidden;
  border-radius: 6px;
  background: var(--bg2, #1c1c1c);
}

/* ─── Grids ────────────────────────────────────── */

/* 16:9 grid — featured.html & music.html */
.video-grid-16x9 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  gap: 1.5rem;
  width: 100%;
  padding: 0 0 2rem;
  box-sizing: border-box;
}

/* 9:16 grid — ai.html, product.html */
.video-grid-9x16 {
  display: grid;
  /* 3 columns on wide screens, scales down gracefully */
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  gap: 1.25rem;
  width: 100%;
  padding: 0 0 2rem;
  box-sizing: border-box;
}

.video-item {
  width: 100%;
  min-width: 0; /* prevent grid blowout */
}

/* ─── Thumbnail button ─────────────────────────── */

.video-thumb {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  overflow: hidden;
  background: var(--bg2, #1c1c1c);
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              filter  0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.video-thumb:hover img,
.video-thumb:focus-visible img {
  transform: scale(1.05);
  filter: brightness(0.65);
}

/* ─── Play icon ────────────────────────────────── */

.video-thumb .play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  transform: translate(-50%, -50%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.video-thumb .play-icon circle {
  fill: rgba(8, 8, 8, 0.55);
  transition: fill 0.3s ease;
}

.video-thumb .play-icon path {
  fill: var(--white, #fafafa);
}

.video-thumb:hover .play-icon,
.video-thumb:focus-visible .play-icon {
  transform: translate(-50%, -50%) scale(1.12);
}

.video-thumb:hover .play-icon circle,
.video-thumb:focus-visible .play-icon circle {
  fill: var(--red, #c0392b);
}

.video-thumb:focus-visible {
  outline: 2px solid var(--red, #c0392b);
  outline-offset: 3px;
}

/* ─── Loading state ────────────────────────────── */

.video-thumb.is-loading img {
  filter: brightness(0.45);
}

.video-thumb.is-loading .play-icon {
  display: none;
}

.video-thumb.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--red, #c0392b);
  border-radius: 50%;
  animation: video-thumb-spin 0.8s linear infinite;
}

@keyframes video-thumb-spin {
  to { transform: rotate(360deg); }
}

/* ─── Live iframe (replaces thumbnail on click) ─ */

.video-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ─── Responsive breakpoints ───────────────────── */

/* Tablet */
@media (max-width: 900px) {
  .video-grid-16x9 {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 1.25rem;
  }
  .video-grid-9x16 {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
    gap: 1rem;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .video-grid-16x9 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .video-grid-9x16 {
    /* 2-column shorts on mobile — nice and compact */
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  .video-thumb .play-icon {
    width: 44px;
    height: 44px;
  }
}

/* Very small phones */
@media (max-width: 360px) {
  .video-grid-9x16 {
    grid-template-columns: 1fr;
  }
}

/* ─── Page content wrapper safety ─────────────── */
/* Prevents grids from ever escaping viewport */
.page-content {
  box-sizing: border-box;
  overflow-x: hidden;
}

.video-grid-16x9,
.video-grid-9x16 {
  box-sizing: border-box;
  max-width: 100%;
}

/* Make sure .vertical-video-wrap inside .video-item
   doesn't inherit any conflicting height */
.video-item > .vertical-video-wrap,
.video-item > .ratio {
  display: block;
}
