/* ============================================================
   PRIME MOTOR — Gallery Page Stylesheet (v2 — DB-driven)
   ============================================================ */

/* ---- TAB SWITCHER ---- */
.gallery-tabs {
  display: flex;
  gap: var(--sp-2);
  background: var(--clr-white);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-xl);
  padding: var(--sp-2);
  width: fit-content;
  margin: 0 auto var(--sp-10);
  box-shadow: var(--shadow-xs);
}

.gallery-tab-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6);
  border: none;
  border-radius: var(--r-lg);
  background: transparent;
  color: var(--clr-text-muted);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s;
}

.gallery-tab-btn:hover {
  background: var(--clr-bg);
  color: var(--clr-dark);
}

.gallery-tab-btn.active {
  background: var(--clr-primary);
  color: var(--clr-white);
  box-shadow: var(--shadow-green);
}

.gallery-tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 var(--sp-2);
  border-radius: var(--r-full);
  background: rgba(255,255,255,0.25);
  font-size: 0.7rem;
  font-weight: 700;
}

.gallery-tab-btn:not(.active) .gallery-tab-count {
  background: var(--clr-bg);
  color: var(--clr-text-muted);
}

/* ---- TAB PANELS ---- */
.gallery-tab-panel {
  display: none;
}

.gallery-tab-panel.active {
  display: block;
  animation: tabFadeIn 0.3s ease;
}

@keyframes tabFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- IMAGES GRID ---- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}

.gallery-item {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  aspect-ratio: 4/3;
  cursor: pointer;
  background: var(--clr-bg);
}

/* Give every 4th item a wide span for visual rhythm */
.gallery-item:nth-child(5n+1) {
  grid-column: span 2;
  aspect-ratio: 16/7;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
  display: block;
}

.gallery-item:hover img {
  transform: scale(1.06);
}

.gallery-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 40, 12, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s;
  z-index: 2;
}

.gallery-item:hover .gallery-overlay {
  background: rgba(10, 40, 12, 0.45);
}

/* ---- IMAGE CAPTION ---- */
.gallery-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2.5rem 1rem 0.875rem;
  background: linear-gradient(to top,
    rgba(5, 25, 8, 0.92) 0%,
    rgba(5, 25, 8, 0.55) 55%,
    transparent 100%);
  color: #fff;
  pointer-events: none;
  transition: padding 0.3s ease;
  z-index: 1;
}

.gallery-caption-title {
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.gallery-caption-desc {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

.gallery-item:hover .gallery-caption-desc {
  max-height: 2.75rem;
  opacity: 1;
  margin-top: 0.3rem;
}

.gallery-item:hover .gallery-caption {
  padding-bottom: 1.125rem;
}

.gallery-zoom {
  width: 52px;
  height: 52px;
  background: rgba(255, 255, 255, 0.95);
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  color: var(--clr-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.22s, transform 0.22s;
  box-shadow: var(--shadow-md);
}

.gallery-item:hover .gallery-zoom {
  opacity: 1;
  transform: scale(1);
}

/* ---- VIDEOS GRID ---- */
.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-6);
}

.video-card {
  background: var(--clr-white);
  border: 1px solid var(--clr-border);
  border-radius: var(--r-xl);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.25s, transform 0.25s;
}

.video-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

.video-thumb {
  position: relative;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--clr-dark);
}

.video-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease, opacity 0.25s;
}

.video-card:hover .video-thumb img {
  transform: scale(1.04);
  opacity: 0.75;
}

.video-play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.video-play-btn i {
  font-size: 4rem;
  color: #fff;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.5));
  transition: transform 0.25s, color 0.25s;
}

.video-card:hover .video-play-btn i {
  transform: scale(1.15);
  color: var(--clr-gold);
}

.video-card-body {
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
}

.video-card-title {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--clr-dark);
  line-height: 1.4;
  margin-bottom: var(--sp-2);
}

.video-card-desc {
  font-size: var(--text-sm);
  color: var(--clr-text-muted);
  line-height: 1.65;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0;
}

/* ---- EMPTY STATE ---- */
.gallery-empty {
  text-align: center;
  padding: var(--sp-20) var(--sp-8);
  color: var(--clr-text-muted);
}

.gallery-empty i {
  font-size: 3.5rem;
  margin-bottom: var(--sp-5);
  display: block;
  opacity: 0.25;
}

.gallery-empty h3 {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--clr-dark);
  margin-bottom: var(--sp-3);
}

.gallery-empty p {
  font-size: var(--text-base);
  max-width: 420px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ---- IMAGE LIGHTBOX ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.lightbox-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: min(90vw, calc(100% - 2rem));
  max-height: 90vh;
}

.lightbox-img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border-radius: var(--r-md);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  display: block;
}

.lightbox-caption {
  margin-top: var(--sp-4);
  text-align: center;
  color: rgba(255, 255, 255, 0.9);
  max-width: 600px;
}

.lightbox-caption h4 {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--sp-1);
}

.lightbox-caption p {
  font-size: var(--text-sm);
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.6;
  margin: 0;
}

.lightbox-close {
  position: absolute;
  top: 1.25rem;
  right: 1.25rem;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 1;
}

.lightbox-close:hover { background: rgba(255, 255, 255, 0.22); }

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.lightbox-nav:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-prev { left: 1.25rem; }
.lightbox-next { right: 1.25rem; }

/* ---- VIDEO MODAL ---- */
.video-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  padding: var(--sp-4);
}

.video-modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.video-modal {
  background: var(--clr-white);
  border-radius: var(--r-xl);
  overflow: hidden;
  width: 100%;
  max-width: 860px;
  position: relative;
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform 0.25s;
}

.video-modal-overlay.open .video-modal {
  transform: scale(1);
}

.video-modal-close {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  width: 36px;
  height: 36px;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  border-radius: 50%;
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.2s;
}

.video-modal-close:hover { background: rgba(0, 0, 0, 0.8); }

.video-modal-frame {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
}

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

.video-modal-body {
  padding: var(--sp-5) var(--sp-6);
}

.video-modal-body h3 {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--clr-dark);
  margin-bottom: var(--sp-2);
}

.video-modal-body p {
  font-size: var(--text-sm);
  color: var(--clr-text-muted);
  line-height: 1.7;
  margin: 0;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 1024px) {
  .video-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-item:nth-child(5n+1) { grid-column: span 1; aspect-ratio: 4/3; }
  .video-grid { grid-template-columns: repeat(2, 1fr); }
  .lightbox-nav { display: none; }
  .gallery-tabs { width: 100%; }
  .gallery-tab-btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
  .gallery-grid { grid-template-columns: 1fr; }
  .gallery-item:nth-child(n) { grid-column: span 1; aspect-ratio: 4/3; }
  .video-grid { grid-template-columns: 1fr; }
}

/* ---- PHONES ≤ 430px ---- */
@media (max-width: 430px) {
  .gallery-tabs        { flex-wrap: wrap; gap: var(--sp-1); width: 100%; }
  .gallery-tab-btn     { flex: 1; padding: var(--sp-2) var(--sp-3); font-size: 0.7rem; }
  .gallery-tab-count   { min-width: 18px; height: 18px; font-size: 0.6rem; }
  .gallery-item        { aspect-ratio: 3/2; }
  .video-card-body     { padding: var(--sp-4); }
  .video-card-title    { font-size: 0.82rem; }
  .video-card-desc     { font-size: 0.7rem; }
  .video-modal-body    { padding: var(--sp-4) var(--sp-4); }
  .video-modal-body h3 { font-size: var(--text-sm); }
}

/* ---- PHONES ≤ 375px ---- */
@media (max-width: 375px) {
  .gallery-tab-btn  { font-size: 0.65rem; padding: var(--sp-2); }
  .gallery-item     { aspect-ratio: 1/1; }
  .lightbox-close   { top: 0.75rem; right: 0.75rem; width: 36px; height: 36px; }
}
