/* ============================================
   Om Sai Fabrication – Premium Gallery
   Mobile-first · Dynamic JSON · Lightbox
   ============================================ */

/* ---------- Page Hero ---------- */
.gallery-hero {
  position: relative;
  background: linear-gradient(135deg, var(--navy) 0%, #0f1b33 60%, #162240 100%);
  padding: 72px 0 56px;
  text-align: center;
  overflow: hidden;
  margin-top: 100px;
}

.gallery-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M54.627 0l.83.828-1.415 1.415L51.8 0h2.827zM5.373 0l-.83.828L5.96 2.243 8.2 0H5.374zM48.97 0l3.657 3.657-1.414 1.414L46.143 0h2.828zM11.03 0L7.372 3.657 8.787 5.07 13.857 0H11.03z' fill='%23ffffff' fill-opacity='0.03' fill-rule='evenodd'/%3E%3C/svg%3E");
  pointer-events: none;
}

.gallery-hero::after {
  content: '';
  position: absolute;
  right: -120px;
  top: -80px;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,107,53,0.18) 0%, transparent 70%);
  pointer-events: none;
}

.gallery-hero h1 {
  color: var(--white);
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.gallery-hero h1 span {
  color: var(--orange);
}

.gallery-hero p {
  color: #b0bbd0;
  font-size: clamp(15px, 2.5vw, 18px);
  max-width: 520px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ---------- Filter Bar ---------- */
.gallery-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 28px 0 8px;
  margin-bottom: 12px;
  position: sticky;
  top: 90px; /* below site header */
  z-index: 100;
  background: rgba(255,255,255,0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  transition: box-shadow 0.3s ease;
}

.gallery-filter-bar.scrolled {
  box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}

.filter-pill {
  padding: 10px 22px;
  border: 2px solid var(--border-color);
  border-radius: 50px;
  background: var(--white);
  color: var(--charcoal);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-primary);
  transition: all 0.28s cubic-bezier(.4,0,.2,1);
  min-height: 44px;
  position: relative;
  overflow: hidden;
  user-select: none;
}

.filter-pill::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--orange);
  border-radius: inherit;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.32s cubic-bezier(.4,0,.2,1);
  z-index: 0;
}

.filter-pill span {
  position: relative;
  z-index: 1;
  transition: color 0.28s ease;
}

.filter-pill:hover {
  border-color: var(--orange);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(255,107,53,0.12);
}

.filter-pill.active {
  border-color: var(--orange);
  color: var(--white);
}

.filter-pill.active::before {
  transform: scaleX(1);
}

.filter-pill .pill-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  background: rgba(0,0,0,0.07);
  border-radius: 50px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  padding: 0 6px;
  transition: background 0.25s ease, color 0.25s ease;
  position: relative;
  z-index: 1;
}

.filter-pill.active .pill-count {
  background: rgba(255,255,255,0.25);
  color: var(--white);
}

/* ---------- Gallery Stats ---------- */
.gallery-stats {
  text-align: center;
  padding: 16px 0 8px;
  font-size: 14px;
  color: var(--steel-grey);
  letter-spacing: 0.2px;
}

.gallery-stats strong {
  color: var(--navy);
  font-weight: 700;
}

/* ---------- Gallery Grid ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 0 40px;
  min-height: 200px;
}

/* ---------- Gallery Card ---------- */
.gallery-card {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  background: #eee;
  box-shadow: 0 2px 10px rgba(0,0,0,0.06);
  transition: transform 0.38s cubic-bezier(.4,0,.2,1),
              box-shadow 0.38s cubic-bezier(.4,0,.2,1);
  aspect-ratio: 4 / 5;
  opacity: 0;
  transform: translateY(24px);
  animation: cardReveal 0.5s cubic-bezier(.4,0,.2,1) forwards;
}

.gallery-card:hover {
  transform: translateY(-6px) scale(1.015);
  box-shadow: 0 16px 40px rgba(0,0,0,0.14);
}

/* Image fills card perfectly */
.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.5s cubic-bezier(.4,0,.2,1);
}

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

/* Gradient overlay — always visible on mobile, hover on desktop */
.gallery-card .card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(15,27,51,0.88) 0%,
    rgba(15,27,51,0.25) 40%,
    transparent 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 16px;
  transition: opacity 0.35s ease;
}

.card-overlay .card-title {
  color: var(--white);
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 6px;
  transform: translateY(6px);
  transition: transform 0.35s cubic-bezier(.4,0,.2,1),
              opacity 0.35s ease;
}

.card-overlay .card-category {
  display: inline-block;
  background: var(--orange);
  color: var(--white);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: fit-content;
  transform: translateY(6px);
  transition: transform 0.35s cubic-bezier(.4,0,.2,1) 0.04s,
              opacity 0.35s ease 0.04s;
}

/* Zoom icon */
.gallery-card .card-zoom {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.92);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-size: 13px;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  z-index: 2;
}

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

/* Hidden during filter */
.gallery-card.hidden {
  display: none !important;
}

/* ---------- Skeleton Loading ---------- */
.gallery-skeleton {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: #e8eaed;
  aspect-ratio: 4 / 5;
}

.gallery-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.5) 50%,
    transparent 100%
  );
  animation: shimmer 1.6s ease infinite;
}

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

/* ---------- Empty State ---------- */
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--steel-grey);
}

.gallery-empty i {
  font-size: 48px;
  color: var(--border-color);
  margin-bottom: 16px;
  display: block;
}

.gallery-empty p {
  font-size: 18px;
  font-weight: 500;
}

/* ---------- Error State ---------- */
.gallery-error {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
  color: var(--steel-grey);
}

/* ---------- Lightbox ---------- */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.lightbox-modal.active {
  opacity: 1;
  visibility: visible;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.lightbox-body {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
  max-height: 92vh;
}

.lightbox-body img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 12px 60px rgba(0,0,0,0.5);
  transition: transform 0.35s cubic-bezier(.4,0,.2,1),
              opacity 0.3s ease;
  transform: scale(0.92);
  opacity: 0;
}

.lightbox-modal.active .lightbox-body img {
  transform: scale(1);
  opacity: 1;
}

.lightbox-info {
  text-align: center;
  margin-top: 16px;
}

.lightbox-title {
  color: #eee;
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 4px;
}

.lightbox-counter {
  color: #888;
  font-size: 13px;
}

/* Lightbox controls */
.lb-close,
.lb-prev,
.lb-next {
  position: fixed;
  z-index: 3;
  background: rgba(255,255,255,0.1);
  color: var(--white);
  border: none;
  cursor: pointer;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: all 0.25s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.lb-close:hover,
.lb-prev:hover,
.lb-next:hover {
  background: var(--orange);
  transform: scale(1.1);
}

.lb-close {
  top: 20px;
  right: 20px;
}

.lb-prev {
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lb-next {
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.lb-prev:hover {
  transform: translateY(-50%) scale(1.1);
}

.lb-next:hover {
  transform: translateY(-50%) scale(1.1);
}

/* ---------- CTA Banner ---------- */
.gallery-cta {
  background: linear-gradient(135deg, var(--navy) 0%, #0f1b33 100%);
  padding: 64px 0;
  text-align: center;
}

.gallery-cta h2 {
  color: var(--white);
  font-size: clamp(24px, 4vw, 36px);
  margin-bottom: 12px;
}

.gallery-cta p {
  color: #b0bbd0;
  font-size: 17px;
  margin-bottom: 28px;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.gallery-cta .cta-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Animations ---------- */
@keyframes cardReveal {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ==========================================================
   RESPONSIVE — Mobile First → Tablet → Desktop
   ========================================================== */

/* Small phones (default — 2 columns already set above) */
@media (max-width: 480px) {
  .gallery-hero {
    padding: 48px 0 36px;
  }

  .gallery-filter-bar {
    gap: 6px;
    padding: 18px 8px 10px;
    top: 60px;
  }

  .filter-pill {
    padding: 8px 14px;
    font-size: 12px;
    min-height: 38px;
  }

  .gallery-grid {
    gap: 8px;
  }

  .gallery-card {
    border-radius: 10px;
    aspect-ratio: 3 / 4;
  }

  .card-overlay {
    padding: 10px !important;
  }

  .card-overlay .card-title {
    font-size: 12px;
  }

  .card-overlay .card-category {
    font-size: 9px;
    padding: 2px 8px;
  }

  .gallery-card .card-zoom {
    width: 28px;
    height: 28px;
    font-size: 11px;
    top: 8px;
    right: 8px;
  }

  .lb-prev { left: 8px; }
  .lb-next { right: 8px; }
  .lb-close { top: 12px; right: 12px; }
  .lb-close, .lb-prev, .lb-next { width: 40px; height: 40px; font-size: 16px; }
}

/* Tablets (3 columns) */
@media (min-width: 600px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }

  .gallery-card {
    border-radius: 16px;
    aspect-ratio: 4 / 5;
  }

  .filter-pill {
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* Desktop (3 columns wider, overlay on hover only) */
@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }

  .gallery-card {
    border-radius: 18px;
  }

  /* Hide overlay on desktop, show on hover */
  .gallery-card .card-overlay {
    opacity: 0;
  }

  .gallery-card:hover .card-overlay {
    opacity: 1;
  }

  .gallery-card:hover .card-title,
  .gallery-card:hover .card-category {
    transform: translateY(0);
  }
}

/* Large desktop (4 columns when many items) */
@media (min-width: 1280px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 22px;
  }

  .gallery-card .card-overlay {
    padding: 20px;
  }

  .card-overlay .card-title {
    font-size: 16px;
  }
}

/* Touch devices — always show overlay */
@media (hover: none) {
  .gallery-card .card-overlay {
    opacity: 1 !important;
  }

  .gallery-card .card-title,
  .gallery-card .card-category {
    transform: translateY(0) !important;
  }

  .gallery-card .card-zoom {
    opacity: 0.7 !important;
    transform: scale(1) !important;
  }
}
