/* ------------------------------------------
   CB Simple Gallery - Metroid Database Theme
   Colors:
     Blue:   #46a9ef
     Orange: #ffb022
-------------------------------------------*/

/* GRID / THUMBNAILS */
.cbg-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.cbg-gallery .cbg-item {
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}

.cbg-gallery .cbg-item img {
  width: 100%;
  height: auto;
  display: block;
  border: 2px solid #0f172a;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

/* Thumb hover: subtle lift + blue glow */
.cbg-gallery .cbg-item:hover img {
  transform: translateY(-2px);
  border-color: #46a9ef;
  box-shadow: 0 0 14px rgba(70,169,239,0.7);
}

/* ------------------------------------------
   OVERLAY BACKDROP
-------------------------------------------*/

.cbg-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(70,169,239,0.18), rgba(0,0,0,0.96));
  z-index: 99999;
  display: none;
}

/* LIGHTBOX WINDOW */
.cbg-overlay-inner {
  position: relative;
  max-width: 1200px;
  margin: 40px auto;
  padding: 18px 20px 16px;
  background: #070b12;
  border: 2px solid #1a2639;
  box-shadow: 0 0 40px rgba(0,0,0,0.9);
  border-radius: 4px;
  box-sizing: border-box;
  font-family: inherit;
}

/* MAIN IMAGE PANEL */
.cbg-main {
  position: relative; /* needed for loader overlay */
  text-align: center;
  margin-bottom: 12px;
  background: #000;
  padding: 12px;
  border: 1px solid #101827;
  border-radius: 4px;
}

.cbg-main img {
  max-width: 100%;
  max-height: 70vh;
  height: auto;
  display: block;
  opacity: 1;
  transition: opacity 0.2s ease;
}

/* ------------------------------------------
   LOADING STATE (uses custom GIF)
-------------------------------------------*/

/* Dim image when loading */
.cbg-overlay.cbg-loading .cbg-main img {
  opacity: 0.4;
}

/* Darken area behind the loader */
.cbg-overlay.cbg-loading .cbg-main::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 5;
}

/* Centered GIF loader */
.cbg-overlay.cbg-loading .cbg-main::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 72px;   /* adjust if needed */
  height: 72px;  /* adjust if needed */
  transform: translate(-50%, -50%);
  background-image: url("https://metroiddatabase.com/wp-content/uploads/2025/12/tumblr_nkz54yoaUS1qashpbo1_1280.gif");
  background-size: contain;
  background-repeat: no-repeat;
  z-index: 10;
  pointer-events: none;
}

/* ------------------------------------------
   BUTTONS (CLOSE + ARROWS)
-------------------------------------------*/

.cbg-close,
.cbg-prev,
.cbg-next {
  position: absolute;
  background: rgba(8,12,20,0.88);
  border: 1px solid #46a9ef;
  color: #e5e7eb;
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  border-radius: 50%;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100; /* Make sure arrows are on top */
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.15s ease,
    color 0.15s ease;
}

/* Close button in top-right */
.cbg-close {
  top: 10px;
  right: 10px;
  font-size: 20px;
}

/* Nav arrows mid-left/right */
.cbg-prev,
.cbg-next {
  top: 50%;
  transform: translateY(-50%);
  font-size: 30px;
}

.cbg-prev { left: 12px; }
.cbg-next { right: 12px; }

/* Hover: blue filled, orange edge, strong glow */
.cbg-close:hover,
.cbg-prev:hover,
.cbg-next:hover {
  background: #46a9ef;
  color: #000;
  border-color: #ffb022;
  box-shadow: 0 0 16px rgba(255,176,34,0.9);
  transform: translateY(-50%) scale(1.08);
}

/* Fix close hover transform (no translateY) */
.cbg-close:hover {
  transform: scale(1.08);
}

/* ------------------------------------------
   FILMSTRIP
-------------------------------------------*/

.cbg-filmstrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-top: 10px;
  margin-top: 6px;
  border-top: 1px solid #121a27;
  position: relative;
  z-index: 1; /* Keep filmstrip below arrows */
}

.cbg-filmstrip::-webkit-scrollbar {
  height: 6px;
}

.cbg-filmstrip::-webkit-scrollbar-track {
  background: #0b1019;
}

.cbg-filmstrip::-webkit-scrollbar-thumb {
  background: #1a2535;
}

/* Filmstrip thumbs */
.cbg-filmstrip .cbg-thumb {
  border: 2px solid transparent;
  padding: 0;
  background: none;
  cursor: pointer;
  flex: 0 0 auto;
  border-radius: 4px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.15s ease;
}

.cbg-filmstrip .cbg-thumb img {
  height: 60px;
  width: auto;
  display: block;
  border-radius: 2px;
}

/* Hover: blue glow */
.cbg-filmstrip .cbg-thumb:hover {
  border-color: #46a9ef;
  box-shadow: 0 0 10px rgba(70,169,239,0.85);
  transform: translateY(-1px);
}

/* Active thumb: orange highlight + stronger glow */
.cbg-filmstrip .cbg-thumb.cbg-active {
  border-color: #ffb022;
  box-shadow:
    0 0 18px rgba(255,176,34,0.9),
    0 0 2px #000 inset;
}

/* ------------------------------------------
   RESPONSIVE TWEAKS
-------------------------------------------*/

@media (max-width: 768px) {
  .cbg-overlay-inner {
    margin: 20px 10px;
    padding: 14px;
  }

  .cbg-prev,
  .cbg-next {
    font-size: 24px;
  }

  .cbg-filmstrip .cbg-thumb img {
    height: 48px;
  }

  /* Force 2-column layout on mobile */
  .cbg-gallery {
    grid-template-columns: repeat(2, 1fr);
  }
}
