/* ========================================
   ARCANE PINTEREST MASONRY GRID (V3)
   CSS Columns Implementation (Gap-Free)
   ======================================== */

/* === CONTAINER PRINCIPAL === */
.masonry-grid {
  /* Core Column Logic */
  column-count: 4; /* Default Desktop */
  column-gap: 24px;
  
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* === ITEMS DE LA GALERÍA (THE FRAME) === */
.masonry-item {
  /* Critical for Columns: Prevent splitting */
  break-inside: avoid; 
  -webkit-column-break-inside: avoid;
  margin-bottom: 24px; /* Vertical gap between items */
  display: block; /* Ensure block formatting */
  
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(5, 8, 22, 0.6); /* Dark Glass Base */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  
  /* Tech Border */
  border: 1px solid rgba(16, 185, 129, 0.15); /* Subtle Emerald */
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  
  transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  cursor: pointer;
  z-index: 1;
}

/* Double Border Effect via Pseudo-element */
.masonry-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    padding: 1px; /* Border width */
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0)); 
    -webkit-mask: 
       linear-gradient(#fff 0 0) content-box, 
       linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    z-index: 2;
    pointer-events: none;
    opacity: 0.5;
    transition: opacity 0.4s ease;
}

/* HOVER STATE (The Awakening) */
.masonry-item:hover {
  transform: translateY(-8px) scale(1.01);
  border-color: rgba(0, 217, 255, 0.4); /* Cyan Shift */
  box-shadow: 
    0 15px 40px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(0, 217, 255, 0.15); /* Cyan Glow */
  z-index: 10;
}

.masonry-item:hover::before {
    opacity: 1;
    background: linear-gradient(135deg, var(--arcane-gold), var(--arcane-emerald));
}

/* Imagen dentro del item */
.masonry-item img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  /* Cinematic Look */
  filter: brightness(0.85) contrast(1.1) saturate(0.9);
  transition: all 0.6s cubic-bezier(0.215, 0.610, 0.355, 1.000); /* Ease Out Cubic */
  will-change: transform, filter;
}

.masonry-item:hover img {
  filter: brightness(1.05) contrast(1.05) saturate(1.1);
  transform: scale(1.08); /* Cinematic Zoom */
}

/* === AUTO-FIT HEIGHT HELPERS (REMOVED) === */
/* CSS Columns handles this automatically */
/* .masonry-item[data-rows="1"]... Removed */

/* === OVERLAY INFO (Sliding Meta) === */
.masonry-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 24px 20px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.95) 0%, rgba(5, 8, 22, 0.8) 60%, transparent 100%);
  transform: translateY(105%); /* Hidden by default */
  transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 4px;
  backdrop-filter: blur(4px);
}

.masonry-item:hover .masonry-overlay {
  transform: translateY(0);
}

.masonry-overlay h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.4s 0.1s ease;
}

.masonry-overlay p {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--arcane-emerald);
  margin: 0;
  transform: translateY(10px);
  opacity: 0;
  transition: all 0.4s 0.2s ease;
}

.masonry-item:hover .masonry-overlay h3,
.masonry-item:hover .masonry-overlay p {
    transform: translateY(0);
    opacity: 1;
}

/* === CATEGORÍAS (Badges) === */
.masonry-category {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(5, 8, 22, 0.85); /* Darker backdrop */
  color: var(--arcane-gold);
  border: 1px solid rgba(255, 214, 10, 0.3);
  padding: 6px 14px;
  border-radius: 4px; /* Tech Sharpness */
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  z-index: 6;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.4s ease;
  backdrop-filter: blur(4px);
}

.masonry-item:hover .masonry-category {
    opacity: 1;
    transform: translateY(0);
}

/* === FILTERS (Sticky Header) === */
.masonry-filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 20px;
  margin-bottom: 20px;
  background: rgba(5, 8, 22, 0.7);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(16, 185, 129, 0.1);
  position: sticky;
  top: 70px; /* Below Navbar */
  z-index: 90;
}

.filter-btn {
  padding: 8px 20px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--arcane-emerald);
  color: #fff;
}

.filter-btn.active {
  background: var(--arcane-emerald); /* Solid Active */
  border-color: var(--arcane-emerald);
  color: #000;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.4);
}

/* Results Counter */
.results-count {
  width: 100%;
  text-align: center;
  padding-top: 5px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  letter-spacing: 1px;
}

/* === RESPONSIVE LAYOUT (CSS Columns) === */

/* Large Screens (1400px+) */
@media (min-width: 1600px) {
  .masonry-grid {
    column-count: 4;
  }
}

/* Standard Desktop */
@media (max-width: 1599px) {
  .masonry-grid {
    column-count: 3;
    column-gap: 20px;
  }
}

/* Tablets */
@media (max-width: 1024px) {
  .masonry-grid {
    column-count: 2;
    column-gap: 16px;
  }
}

/* Mobile */
@media (max-width: 550px) {
  .masonry-grid {
    column-count: 1; /* Single column for clarity */
    column-gap: 0;
  }
  
  .masonry-item {
      margin-bottom: 20px;
  }
}

/* === LIGHTBOX styles (moved here or integrated) === */
/* (Assuming lightbox styles are in gallery-enhancements or we add them here) */

