/* ============================================
   GALLERY PAGE - Grid, Filters, Lightbox
   ============================================ */

/* -------------------- Gallery Layout -------------------- */

.gallery-page {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-8);
  padding-top: var(--space-8);
}

.gallery-main {
  min-width: 0;
}

/* -------------------- Gallery Header -------------------- */

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.gallery-title {
  font-size: var(--text-3xl);
}

.gallery-count {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.gallery-view-toggle {
  display: flex;
  gap: var(--space-2);
}

.view-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--color-warm-gray);
  transition: all var(--transition-fast);
}

.view-btn:hover,
.view-btn.active {
  background-color: var(--color-parchment);
  color: var(--color-charcoal);
}

/* -------------------- Gallery Grid -------------------- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-6);
}

/* Masonry-style layout with CSS columns */
.gallery-grid--masonry {
  display: block;
  column-count: 3;
  column-gap: var(--space-6);
}

.gallery-grid--masonry .artwork-card {
  break-inside: avoid;
  margin-bottom: var(--space-6);
}

/* List view */
.gallery-grid--list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.gallery-grid--list .artwork-card {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--space-4);
}

.gallery-grid--list .artwork-card__image {
  aspect-ratio: 1;
}

.gallery-grid--list .artwork-card__content {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* -------------------- Filter Sidebar -------------------- */

.gallery-sidebar {
  position: sticky;
  top: calc(var(--header-height) + var(--space-8));
  height: fit-content;
  max-height: calc(100vh - var(--header-height) - var(--space-16));
  overflow-y: auto;
  padding: var(--space-6);
  background-color: var(--color-warm-white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.clear-filters {
  font-size: var(--text-sm);
  color: var(--color-terracotta);
  transition: opacity var(--transition-fast);
}

.clear-filters:hover {
  opacity: 0.7;
}

/* Active Filters */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.active-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  background-color: var(--color-terracotta);
  color: white;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
}

.active-filter button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: var(--space-1);
  color: white;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.active-filter button:hover {
  opacity: 1;
}

/* Filter Group */
.filter-group {
  margin-bottom: var(--space-5);
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) 0;
  cursor: pointer;
}

.filter-group__title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--color-charcoal);
}

.filter-group__toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-warm-gray);
  transition: transform var(--transition-fast);
}

.filter-group.collapsed .filter-group__toggle {
  transform: rotate(-90deg);
}

.filter-group__content {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-top: var(--space-3);
}

.filter-group.collapsed .filter-group__content {
  display: none;
}

/* Filter Buttons */
.filter-btn {
  padding: var(--space-2) var(--space-3);
  background-color: var(--color-parchment);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  color: var(--color-warm-gray);
  transition: all var(--transition-fast);
}

.filter-btn:hover {
  background-color: var(--color-border);
  color: var(--color-charcoal);
}

.filter-btn.active {
  background-color: var(--color-terracotta);
  color: white;
}

.filter-btn__count {
  margin-left: var(--space-1);
  font-size: var(--text-xs);
  opacity: 0.7;
}

/* Color Filter */
.filter-color {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.filter-color:hover {
  transform: scale(1.1);
}

.filter-color.active {
  border-color: var(--color-charcoal);
  box-shadow: 0 0 0 2px white;
}

/* -------------------- No Results -------------------- */

.gallery-empty {
  text-align: center;
  padding: var(--space-16) var(--space-4);
}

.gallery-empty__icon {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--space-6);
  color: var(--color-border);
}

.gallery-empty__title {
  font-size: var(--text-xl);
  margin-bottom: var(--space-2);
}

.gallery-empty__text {
  color: var(--color-muted);
  margin-bottom: var(--space-6);
}

/* -------------------- Mobile Filter Toggle -------------------- */

.filter-toggle-btn {
  display: none;
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-sticky);
  padding: var(--space-3) var(--space-5);
  background-color: var(--color-terracotta);
  color: white;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
}

.filter-toggle-btn svg {
  width: 20px;
  height: 20px;
  margin-right: var(--space-2);
}

/* -------------------- Responsive Gallery -------------------- */

@media (max-width: 1200px) {
  .gallery-grid--masonry {
    column-count: 2;
  }
}

@media (max-width: 1024px) {
  .gallery-page {
    grid-template-columns: 1fr;
  }

  .gallery-sidebar {
    position: fixed;
    top: var(--header-height-mobile);
    right: 0;
    bottom: 0;
    width: 300px;
    max-height: none;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--color-border);
    transform: translateX(100%);
    transition: transform var(--transition-normal) var(--ease-out-expo);
    z-index: var(--z-fixed);
  }

  .gallery-sidebar.active {
    transform: translateX(0);
  }

  .filter-toggle-btn {
    display: flex;
    align-items: center;
  }

  .sidebar-close {
    display: block;
  }
}

@media (max-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

  .gallery-grid--masonry {
    column-count: 2;
    column-gap: var(--space-4);
  }

  .gallery-grid--masonry .artwork-card {
    margin-bottom: var(--space-4);
  }

  .gallery-grid--list .artwork-card {
    grid-template-columns: 120px 1fr;
  }

  .gallery-sidebar {
    width: 100%;
    max-width: none;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: 1fr;
  }

  .gallery-grid--masonry {
    column-count: 1;
  }
}

/* -------------------- Lightbox Enhancements -------------------- */

.lightbox__title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  margin-bottom: var(--space-2);
}

.lightbox__description {
  color: var(--color-warm-gray);
  margin-bottom: var(--space-6);
  line-height: var(--leading-relaxed);
}

.lightbox__meta {
  margin-bottom: var(--space-6);
}

.lightbox__meta dt {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-bottom: var(--space-1);
}

.lightbox__meta dd {
  font-size: var(--text-base);
  color: var(--color-charcoal);
  margin-bottom: var(--space-4);
}

.lightbox__price {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  color: var(--color-terracotta);
  margin-bottom: var(--space-6);
}

.lightbox__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.lightbox__colors {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.lightbox__colors .color-dot {
  width: 24px;
  height: 24px;
}

/* -------------------- Card Enhancements -------------------- */

.artwork-card__image {
  position: relative;
}

.artwork-card__badge {
  position: absolute;
  top: var(--space-3);
  left: var(--space-3);
  padding: var(--space-1) var(--space-2);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  font-size: var(--text-xs);
  text-transform: capitalize;
  border-radius: var(--radius-sm);
  z-index: 2;
}

.artwork-card__description {
  font-size: var(--text-sm);
  color: var(--color-warm-gray);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* -------------------- Gallery Modal -------------------- */

.gallery-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-modal);
  background-color: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-normal);
}

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

.gallery-modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  color: white;
  transition: all var(--transition-fast);
  z-index: 10;
}

.gallery-modal__close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.gallery-modal__inner {
  display: grid;
  grid-template-columns: 1fr 380px;
  max-width: 1200px;
  max-height: 90vh;
  width: 100%;
  background-color: var(--color-warm-white);
  border-radius: var(--radius-xl);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.gallery-modal.active .gallery-modal__inner {
  transform: scale(1);
}

.gallery-modal__image {
  background-color: var(--color-charcoal);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gallery-modal__image img {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
}

.gallery-modal__details {
  padding: var(--space-6);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.gallery-modal__title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  color: var(--color-charcoal);
  margin-bottom: var(--space-4);
}

.gallery-modal__section {
  margin-bottom: var(--space-4);
}

.gallery-modal__section h4 {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-muted);
  margin-bottom: var(--space-2);
}

.gallery-modal__description {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  color: var(--color-charcoal);
}

.gallery-modal__metadata {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background-color: var(--color-cream);
  border-radius: var(--radius-lg);
}

.gallery-modal__metadata .metadata-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.gallery-modal__metadata .metadata-label {
  font-size: var(--text-xs);
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.gallery-modal__metadata .metadata-value {
  font-size: var(--text-sm);
  color: var(--color-charcoal);
  text-transform: capitalize;
  font-weight: var(--font-medium);
}

.gallery-modal__metadata .metadata-value:empty::after {
  content: '—';
  color: var(--color-muted);
}

.gallery-modal__colors {
  margin-bottom: var(--space-4);
}

.gallery-modal__colors h4 {
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-bottom: var(--space-2);
  font-weight: 500;
}

.gallery-modal__colors .color-palette {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.gallery-modal__colors .color-swatch,
.gallery-modal__colors .color-dot {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.gallery-modal__colors .color-swatch:hover,
.gallery-modal__colors .color-dot:hover {
  transform: scale(1.1);
}

.gallery-modal__price {
  font-family: var(--font-heading);
  font-size: var(--text-xl);
  color: var(--color-terracotta);
  margin-bottom: var(--space-4);
}

.gallery-modal__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: auto;
}

/* Gallery Modal Responsive */
@media (max-width: 1024px) {
  .gallery-modal__inner {
    grid-template-columns: 1fr;
    grid-template-rows: 60vh auto;
    max-height: 95vh;
  }

  .gallery-modal__image {
    max-height: 60vh;
  }

  .gallery-modal__details {
    max-height: 40vh;
  }
}

@media (max-width: 640px) {
  .gallery-modal {
    padding: 0;
  }

  .gallery-modal__inner {
    border-radius: 0;
    max-height: 100vh;
    grid-template-rows: 50vh auto;
  }

  .gallery-modal__image {
    max-height: 50vh;
  }

  .gallery-modal__details {
    max-height: 50vh;
    padding: var(--space-4);
  }

  .gallery-modal__title {
    font-size: var(--text-xl);
  }

  .gallery-modal__actions {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .gallery-modal__actions .btn {
    flex: 1;
    min-width: calc(50% - var(--space-2));
  }
}
