/* =========================================
   HAPPY Media Gallery - Modern UI Styles
   ========================================= */

.mhmg { 
  --mhmg-col-min: 220px; 
  --mhmg-gap: 16px; 
  --mhmg-radius: 12px; 
  --mhmg-primary: #2563eb; /* Moderná modrá */
  --mhmg-bg-hover: #f3f4f6;
  --mhmg-text: #1f2937;
}

/* --- FILTRE --- */
.mhmg-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
}

.mhmg-filter {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background-color: var(--mhmg-bg-hover);
  color: #4b5563;
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  transition: all 0.2s ease;
  cursor: pointer;
}

.mhmg-filter:hover {
  background-color: #e5e7eb;
  color: #111;
  transform: translateY(-1px);
}

.mhmg-filter.is-active {
  background-color: var(--mhmg-primary);
  color: #fff;
  box-shadow: 0 4px 6px rgba(37, 99, 235, 0.25);
}

.mhmg-filter.is-pending {
  opacity: 0.7;
  cursor: wait;
}

/* --- GRID & ITEMS --- */
.mhmg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--mhmg-col-min), 1fr));
  gap: var(--mhmg-gap);
}

.mhmg-grid--masonry {
  display: block;
  position: relative;
  height: auto;
}

.mhmg-grid--masonry .mhmg-item {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  padding: 0;
  min-height: 0;
  height: auto;
  aspect-ratio: auto;
  overflow: hidden;
}

.mhmg-grid--masonry .mhmg-item:hover {
  transform: none;
}

.mhmg-grid--masonry .mhmg-item::before,
.mhmg-grid--masonry .mhmg-item::after {
  content: none;
  display: none;
}

.mhmg-grid--masonry .mhmg-item,
.mhmg-grid--masonry .mhmg-item a,
.mhmg-grid--masonry .mhmg-item img {
  min-height: 0;
  max-height: none;
}

.mhmg-grid--masonry .mhmg-item a {
  display: block;
  height: 100%;
  aspect-ratio: auto;
}

.mhmg-grid--masonry .mhmg-item img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
}

.mhmg-grid--justified {
  display: flex;
  flex-wrap: wrap;
  gap: var(--mhmg-gap);
}

.mhmg-grid--justified .mhmg-item {
  flex: 1 1 clamp(180px, 24vw, 340px);
  margin: 0;
}

.mhmg-grid--justified .mhmg-item img {
  width: 100%;
  height: clamp(180px, 18vw, 260px);
  object-fit: cover;
}

.mhmg-grid--metro {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-auto-rows: 90px;
  grid-auto-flow: dense;
}

.mhmg-grid--metro .mhmg-item {
  margin: 0;
  height: 100%;
}

.mhmg-grid--metro .mhmg-item img {
  width: 100%;
  height: 100%;
  min-height: 100%;
  object-fit: cover;
}

.mhmg-grid--metro .mhmg-item:nth-child(6n + 1) {
  grid-column: span 3;
  grid-row: span 3;
}

.mhmg-grid--metro .mhmg-item:nth-child(6n + 2) {
  grid-column: span 3;
  grid-row: span 2;
}

.mhmg-grid--metro .mhmg-item:nth-child(6n + 3) {
  grid-column: span 2;
  grid-row: span 2;
}

.mhmg-grid--metro .mhmg-item:nth-child(6n + 4) {
  grid-column: span 2;
  grid-row: span 2;
}

.mhmg-grid--metro .mhmg-item:nth-child(6n + 5) {
  grid-column: span 2;
  grid-row: span 3;
}

.mhmg-grid--metro .mhmg-item:nth-child(6n + 6) {
  grid-column: span 4;
  grid-row: span 2;
}

@media (max-width: 1024px) {
  .mhmg-grid--metro {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 80px;
  }

  .mhmg-grid--metro .mhmg-item:nth-child(6n + 1),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 2),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 6) {
    grid-column: span 2;
  }

  .mhmg-grid--metro .mhmg-item:nth-child(6n + 3),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 4),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 5) {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .mhmg-grid--justified {
    gap: calc(var(--mhmg-gap) * 0.75);
  }

  .mhmg-grid--justified .mhmg-item {
    flex-basis: 100%;
  }

  .mhmg-grid--justified .mhmg-item img {
    height: auto;
  }

  .mhmg-grid--metro {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: 90px;
  }

  .mhmg-grid--metro .mhmg-item:nth-child(6n + 1),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 2),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 3),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 4),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 5),
  .mhmg-grid--metro .mhmg-item:nth-child(6n + 6) {
    grid-column: span 1;
    grid-row: span 2;
  }
}

.mhmg-item {
  margin: 0;
  border-radius: var(--mhmg-radius);
  overflow: hidden;
  position: relative;
  background: #fff;
  /* Card Lift Effect */
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), box-shadow 0.3s ease;
  backface-visibility: hidden; /* Fix pre ostré hrany v Chrome */
}

.mhmg-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.12);
  z-index: 2;
}

.mhmg-item img {
  width: 100%;
  height: auto;
  display: block;
  /* Smooth loading transition */
  transition: opacity 0.3s ease;
}

/* --- PAGINÁCIA & LOAD MORE --- */
.mhmg-pagination {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.mhmg-pagination a {
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  background: #fff;
  color: var(--mhmg-text);
  border: 1px solid #e5e7eb;
  transition: all 0.2s;
  font-size: 14px;
}

.mhmg-pagination a:hover {
  border-color: var(--mhmg-primary);
  color: var(--mhmg-primary);
}

.mhmg-pagination a.is-active {
  background: var(--mhmg-primary);
  color: #fff;
  border-color: var(--mhmg-primary);
}

.mhmg-loadmore {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

.mhmg-loadmore-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 24px;
  background: #fff;
  color: var(--mhmg-text);
  border: 1px solid #d1d5db;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s;
  min-width: 160px;
}

.mhmg-loadmore-btn:hover {
  border-color: var(--mhmg-primary);
  color: var(--mhmg-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.mhmg-loadmore-btn[aria-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
  cursor: wait;
}

.mhmg-empty {
  padding: 20px;
  text-align: center;
  color: #6b7280;
  background: #f9fafb;
  border-radius: var(--mhmg-radius);
  margin: 0;
}

/* --- HUB REŽIM (Karty kategórií) --- */
.mhmg-hub {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(max(var(--mhmg-col-min), 240px), 1fr));
  gap: var(--mhmg-gap);
}

.mhmg-card {
  display: block;
  text-decoration: none;
  border: 1px solid #e5e7eb;
  border-radius: var(--mhmg-radius);
  overflow: hidden;
  background: #fff;
  transition: all 0.3s ease;
}

.mhmg-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 20px rgba(0,0,0,0.1);
  border-color: #d1d5db;
}

.mhmg-card.is-active {
  border-color: var(--mhmg-primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.2) inset;
}

.mhmg-card-media {
  display: block;
  aspect-ratio: 4 / 3;
  background: #f3f4f6;
  position: relative;
  overflow: hidden;
}

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

.mhmg-card:hover .mhmg-card-media img {
  transform: scale(1.05);
}

.mhmg-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid #f3f4f6;
}

.mhmg-card-title {
  font-weight: 600;
  color: #111;
  font-size: 15px;
}

.mhmg-card-count {
  font-size: 12px;
  background: #f3f4f6;
  padding: 2px 8px;
  border-radius: 10px;
  color: #6b7280;
}

/* --- LOADING ANIMATION (Pulse) --- */
@keyframes mhmg-pulse {
  0% { opacity: 0.6; filter: grayscale(0.5); }
  50% { opacity: 0.3; filter: grayscale(1); }
  100% { opacity: 0.6; filter: grayscale(0.5); }
}

.mhmg.is-loading .mhmg-body {
  pointer-events: none;
  animation: mhmg-pulse 1.2s infinite ease-in-out;
}

/* --- CAPTIONS (Miniatúry) --- */
.mhmg-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  color: #fff;
  background: linear-gradient(to top, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
  z-index: 10;
  pointer-events: none;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
}

/* Slide up efekt */
.mhmg--cap-thumb-hover .mhmg-caption {
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.mhmg--cap-thumb-hover .mhmg-item:hover .mhmg-caption {
  transform: translateY(0);
}

.mhmg--cap-thumb-always .mhmg-caption {
  transform: translateY(0);
}

/* --- HOVER EFEKTY --- */
.mhmg-item a { display: block; }

.mhmg--fx-zoom_in .mhmg-item img,
.mhmg--fx-zoom_out .mhmg-item img,
.mhmg--fx-gray .mhmg-item img,
.mhmg--fx-blur .mhmg-item img {
  transition: transform var(--mhmg-fx-duration, 220ms) ease, filter var(--mhmg-fx-duration, 220ms) ease;
  will-change: transform, filter;
}

.mhmg--fx-zoom_in .mhmg-item:hover img { transform: scale(1.08); }
.mhmg--fx-zoom_out .mhmg-item img { transform: scale(1.08); }
.mhmg--fx-zoom_out .mhmg-item:hover img { transform: scale(1.0); }
.mhmg--fx-gray .mhmg-item img { filter: grayscale(0); }
.mhmg--fx-gray .mhmg-item:hover img { filter: grayscale(1); }
.mhmg--fx-blur .mhmg-item img { filter: blur(0); }
.mhmg--fx-blur .mhmg-item:hover img { filter: blur(3px); }


/* --- LIGHTBOX (Modern Frosted Glass) --- */
html.mhmg-lb-open,
html.mhmg-lb-open body {
  overflow: hidden;
}

.mhmg-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 999999;
}

.mhmg-lightbox.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mhmg-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px); /* Frosted Glass efekt */
  -webkit-backdrop-filter: blur(8px);
}

.mhmg-lightbox__figure {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.mhmg-lightbox__img {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  object-fit: contain;
  user-select: none;
}

/* Lightbox Controls - Glassy Buttons */
.mhmg-lightbox__close,
.mhmg-lightbox__nav {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  backdrop-filter: blur(4px);
  transition: all 0.2s;
  z-index: 20;
}

.mhmg-lightbox__close:hover,
.mhmg-lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.mhmg-lightbox__close {
  top: -20px;
  right: -20px;
  font-size: 28px;
}

.mhmg-lightbox__prev { left: -60px; top: 50%; transform: translateY(-50%); }
.mhmg-lightbox__next { right: -60px; top: 50%; transform: translateY(-50%); }

.mhmg-lightbox__prev:hover { transform: translateY(-50%) scale(1.1); }
.mhmg-lightbox__next:hover { transform: translateY(-50%) scale(1.1); }

/* Mobilné úpravy lightboxu */
@media (max-width: 768px) {
  .mhmg-lightbox__close { top: 10px; right: 10px; background: rgba(0,0,0,0.5); border-color: transparent; }
  .mhmg-lightbox__prev { left: 10px; background: rgba(0,0,0,0.5); border-color: transparent; }
  .mhmg-lightbox__next { right: 10px; background: rgba(0,0,0,0.5); border-color: transparent; }
  .mhmg-lightbox__figure { max-width: 100%; max-height: 100%; }
  .mhmg-lightbox__img { max-height: 100vh; border-radius: 0; }
}

.mhmg-lightbox__caption {
  margin-top: 16px;
  color: rgba(255, 255, 255, 0.9);
  text-align: center;
  font-size: 14px;
  font-weight: 400;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
  max-width: 600px;
}