/* ==========================================================================
   RM.Synergy — Gallery Page
   ========================================================================== */

/* ---------- Intro ---------- */
.gallery-hero {
  padding: 36px 0 28px;
}

.gallery-hero-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 40px;
  align-items: end;
}

.gallery-title {
  margin-top: 12px;
  font-size: clamp(36px, 5vw, 60px);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.04em;
  color: var(--ink);
  text-wrap: balance;
}

.gallery-hero-desc {
  max-width: 460px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--muted);
  text-wrap: pretty;
}

.gallery-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.gallery-meta-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 9px 15px;
  border-radius: 14px;
  background: #ffffff;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.gallery-meta-chip strong {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink-stat);
}

/* ---------- Collection Cards ---------- */
.gallery-collections {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 34px;
}

.collection-card {
  position: relative;
  display: flex;
  align-items: flex-end;
  min-height: 150px;
  padding: 18px;
  border-radius: 20px;
  overflow: hidden;
  border: 0;
  cursor: pointer;
  text-align: left;
  color: #ffffff;
  font: inherit;
  background: #12142a;
  isolation: isolate;
  transition: transform 0.25s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.25s ease;
}

.collection-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: -2;
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.collection-card::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(10, 12, 32, 0.1) 0%, rgba(10, 12, 32, 0.55) 45%, rgba(10, 12, 32, 0.9) 100%);
}

.collection-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 16px 34px rgba(40, 36, 120, 0.22);
}

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

.collection-card.is-active {
  box-shadow: 0 0 0 3px #ffffff, 0 0 0 5px var(--primary), 0 16px 34px rgba(40, 36, 120, 0.22);
}

.collection-card:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.collection-card-tag {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c7d2fe;
}

.collection-card-title {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.collection-card-count {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.75);
}

/* ---------- Toolbar ---------- */
.gallery-toolbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 14px 0;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.gallery-toolbar.is-stuck {
  border-bottom-color: #eceef8;
}

.gallery-toolbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.gallery-toolbar .pillar-filter-tabs {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.gallery-toolbar .pillar-filter-tabs::-webkit-scrollbar {
  display: none;
}

.gallery-toolbar .filter-tab {
  font-size: 12.5px;
  padding: 7px 15px;
}

.filter-tab-count {
  margin-left: 4px;
  opacity: 0.6;
  font-weight: 500;
}

.gallery-result-count {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted-light);
  white-space: nowrap;
}

/* ---------- Masonry Grid ---------- */
.gallery-section {
  padding: 22px 0 64px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
  gap: 16px;
}

.gallery-item {
  margin: 0;
  aspect-ratio: 4 / 5;
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background: #eef0fa;
  cursor: zoom-in;
  box-shadow: 0 2px 10px rgba(30, 35, 90, 0.06);
  animation: galleryIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.gallery-item.is-hidden {
  display: none;
}

.gallery-item:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.gallery-item.is-wide {
  grid-column: span 2;
  aspect-ratio: auto;
  min-height: 100%;
}

.gallery-item.is-wide img {
  position: absolute;
  inset: 0;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.55s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease;
  opacity: 0;
}

.gallery-item img.is-loaded {
  opacity: 1;
}

.gallery-item-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(10, 12, 32, 0) 50%, rgba(10, 12, 32, 0.72) 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gallery-item-label {
  min-width: 0;
  color: #ffffff;
}

.gallery-item-tag {
  display: block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c7d2fe;
}

.gallery-item-title {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
}

.gallery-item-zoom {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.95);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.gallery-item-zoom svg {
  width: 16px;
  height: 16px;
}

.gallery-item:hover img,
.gallery-item:focus-visible img {
  transform: scale(1.04);
}

.gallery-item:hover .gallery-item-overlay,
.gallery-item:focus-visible .gallery-item-overlay {
  opacity: 1;
}

@keyframes galleryIn {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Lightbox ---------- */
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgba(8, 9, 22, 0.94);
  color: #ffffff;
  overflow: hidden;
}

.lightbox::backdrop {
  background: rgba(8, 9, 22, 0.6);
}

.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: lightboxIn 0.25s ease both;
}

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

.lightbox-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 3vw, 28px);
}

.lightbox-caption {
  min-width: 0;
}

.lightbox-caption-tag {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a5b4fc;
}

.lightbox-caption-title {
  display: block;
  margin-top: 2px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lightbox-counter {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  font-variant-numeric: tabular-nums;
}

.lightbox-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.lightbox-btn:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 2px;
}

.lightbox-btn svg {
  width: 18px;
  height: 18px;
}

.lightbox-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(12px, 7vw, 96px);
  min-height: 0;
  touch-action: pan-y;
}

.lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s ease;
}

.lightbox-img.is-loading {
  opacity: 0.35;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.lightbox-nav:hover {
  transform: translateY(-50%) scale(1.06);
}

.lightbox-prev {
  left: clamp(12px, 2vw, 28px);
}

.lightbox-next {
  right: clamp(12px, 2vw, 28px);
}

.lightbox-thumbs {
  display: flex;
  gap: 8px;
  padding: 14px clamp(16px, 3vw, 28px) 18px;
  overflow-x: auto;
  scrollbar-width: none;
}

.lightbox-thumbs::-webkit-scrollbar {
  display: none;
}

.lightbox-thumb {
  flex: 0 0 auto;
  width: 46px;
  height: 58px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: #1c1e36;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.lightbox-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.lightbox-thumb:hover {
  opacity: 0.8;
}

.lightbox-thumb.is-active {
  opacity: 1;
  border-color: #a5b4fc;
}

/* ---------- Responsive ---------- */
@media (max-width: 1140px) {
  .gallery-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .gallery-hero-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .gallery-collections {
    grid-template-columns: 1fr 1fr;
  }

  .gallery-collections .collection-card:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .gallery-hero {
    padding-top: 20px;
  }

  .gallery-collections {
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 24px;
  }

  .collection-card {
    min-height: 120px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .gallery-item {
    border-radius: 12px;
  }

  .gallery-item-overlay {
    display: none;
  }

  .gallery-result-count {
    display: none;
  }

  .lightbox-nav {
    display: none;
  }

  .lightbox-stage {
    padding: 0 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-item,
  .lightbox[open] {
    animation: none;
  }

  .gallery-item img,
  .collection-card img {
    transition: none;
  }
}
