/* ============================================
   GALLERY PAGE STYLES
   Gallery Grid, Filters, and Lightbox
   ============================================ */


.gallery-section {
  background: #f5f5f5;
  overflow-x: hidden;
}

/* Gallery Header */
.gallery-header {
  text-align: center;
  padding-bottom: var(--space-6);
}

@media (min-width: 768px) {
  .gallery-header {
    padding-top: 15vh;
  }
}

@media (min-width: 1024px) {
  .gallery-header {
    padding-top: calc(var(--section-padding-y) * 1.3);
  }
}

@media (max-width: 767px) {
  .gallery-header {
    padding-top: calc(var(--section-padding-y) * 2);
  }
}

/* ============================================
   GALLERY FILTERS
   ============================================ */
.gallery-filters {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--color-border);
}

.filter-bar {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  max-width: var(--container-max-width);
  margin: 0 auto;
  padding: var(--space-5) var(--section-padding-x);
  background: transparent;
  /* INTENTIONAL: border-bottom removed — .gallery-filters
     already provides the section separator. Two borders
     created a visually thick or doubled line.
     Do not add border-bottom back to this rule. */
}

.filter-label {
  display: block;
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
  text-align: left;
}

.filter-controls {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.filter-btn {
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  background: transparent;
  border: none;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.filter-btn:hover {
  color: var(--color-text-primary);
  background: transparent;
  border-bottom-color: var(--color-brass);
}

.filter-btn.active {
  color: var(--color-text-primary);
  font-weight: var(--weight-semibold);
  background: transparent;
  border-bottom-color: var(--color-brass);
}

.filter-select-wrapper {
  display: none;
}

/* INTENTIONAL: force all four filter buttons onto one line
   at mobile. flex-wrap: nowrap is required — without it
   buttons spill to a second row. Reduced padding and gap
   create sufficient room on a 375px screen.
   Do not change flex-wrap: nowrap to wrap.
   Do not increase padding or gap values at mobile. */
@media (max-width: 767px) {
  .filter-bar {
    padding: var(--space-4) var(--space-2);
  }

  .filter-controls {
    flex-wrap: nowrap;
    gap: var(--space-1);
    width: 100%;
  }

  .filter-btn {
    padding: var(--space-2);
    letter-spacing: 0.06em;
    white-space: nowrap;
  }
}

@media (min-width: 768px) {
  .filter-select-wrapper {
    display: none;
  }

  .filter-controls {
    gap: var(--space-3);
  }

  .filter-btn {
    padding: var(--space-2) var(--space-4);
  }
}

/* ============================================
   GALLERY GRID - COMPACT SALON LAYOUT
   Three aspect ratios at curator-appropriate scale
   ============================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: clamp(3rem, 6vw, 5rem);
  justify-items: center;
  padding: var(--space-8) var(--section-padding-x);
  max-width: 1400px;
  margin: 0 auto;
}

/* Base gallery item */
.gallery-item {
  position: relative;
  width: 100%;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity 1.5s ease, transform 1.5s ease;
}

.gallery-item.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

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

/* Aspect ratio-specific max-widths */
.gallery-item[data-aspect="landscape"] {
  max-width: 400px;
}

.gallery-item[data-aspect="square"] {
  max-width: 327px;
}

/* INTENTIONAL: 267px at mobile/base, increased to 285px
   at desktop where grid cells are ~345px wide. Portrait
   pieces at 267px in 345px cells leave excessive gaps.
   285px fills the cell more appropriately while keeping
   portrait pieces visibly narrower than landscape. */
.gallery-item[data-aspect="portrait"] {
  max-width: 267px;
}

@media (min-width: 1024px) {
  .gallery-item[data-aspect="portrait"] {
    max-width: 285px;
  }
}

/* Mobile: collapse inherited double-padding, use flexbox for centering.
   gallery-section carries section-padded AND section-container padding,
   leaving only ~294px on a 390px phone — too narrow for visible centering.
   Zeroing both here and controlling all spacing at the grid level. */
@media (max-width: 767px) {
  .gallery-section.section-padded {
    padding-inline: 0;
  }

  .gallery-section .section-container {
    padding-inline: 0;
  }

  .gallery-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-inline: var(--section-padding-x);
    gap: clamp(3rem, 7vw, 4.5rem);
  }

  .gallery-item[data-aspect="landscape"],
  .gallery-item[data-aspect="square"],
  .gallery-item[data-aspect="portrait"] {
    width: 100%;
    max-width: 300px;
  }

  .gallery-item[data-aspect="landscape"] .gallery-item-media,
  .gallery-item[data-aspect="square"] .gallery-item-media,
  .gallery-item[data-aspect="portrait"] .gallery-item-media {
    aspect-ratio: unset;
    height: 260px;
  }
}

/* Tablet: transition to multi-column */
@media (min-width: 768px) and (max-width: 1023px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    padding-top: calc(var(--space-8) * 0.9);
  }
}

/* Desktop: full scale */
@media (min-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  }
}

/* Gallery Item Link */
.gallery-item-link {
  display: block;
  position: relative;
  width: 100%;
  color: inherit;
  text-decoration: none;
  cursor: default;
}

@media (min-width: 1024px) {
  .gallery-item-link {
    cursor: pointer;
  }
}

/* Gallery Item Media Container */
.gallery-item-media {
  position: relative;
  width: 100%;
  overflow: visible;
  background: transparent;
  transition: transform var(--transition-slow);
}

/* Aspect ratios applied to media container */
.gallery-item[data-aspect="landscape"] .gallery-item-media {
  aspect-ratio: 3 / 2;
}

.gallery-item[data-aspect="square"] .gallery-item-media {
  aspect-ratio: 1 / 1;
}

.gallery-item[data-aspect="portrait"] .gallery-item-media {
  aspect-ratio: 2 / 3;
}

.gallery-item-link:hover .gallery-item-media {
  transform: translateY(-4px);
}

/* Gallery Item Image */
.gallery-item-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: filter var(--transition-slow);
}

/* Gallery Item Overlay */
.gallery-item-overlay {
  position: static;
  padding: var(--space-3) 0 0;
  background: none;
  text-align: center;
  transform: none;
  transition: none;
}

/* Gallery Item Typography */
.gallery-item-title {
  font-family: var(--font-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
  color: var(--color-graphite);
  margin: 0 0 var(--space-1);
  letter-spacing: 0.01em;
}

.gallery-item-meta {
  font-family: var(--font-secondary);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin: 0;
  text-transform: none;
  opacity: 0.7;
}

/* ============================================
   LIGHTBOX MODAL
   ============================================ */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(18, 18, 18, 0.97);
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.lightbox.active {
  display: flex;
  opacity: 1;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4);
}

.lightbox-image {
  max-width: 100%;
  max-height: 60vh;
  object-fit: contain;
  border: 1px solid var(--color-border);
}

.lightbox-info {
  padding: var(--space-3) 0;
  color: var(--color-text-inverse);
}

@media (min-width: 768px) {
  .lightbox-content {
    padding: 0;
  }

  .lightbox-image {
    max-height: 80vh;
  }

  .lightbox-info {
    padding: var(--space-4);
  }
}

@media (min-width: 1024px) {
  .lightbox-content {
    grid-template-columns: 2fr 1fr;
    gap: var(--space-6);
    max-width: 1200px;
  }
}

.lightbox-title {
  font-family: var(--font-primary);
  font-size: var(--text-xl);
  font-weight: var(--weight-regular);
  margin: 0 0 var(--space-2);
  color: var(--color-text-inverse);
}

.lightbox-meta {
  font-family: var(--font-secondary);
  font-size: var(--text-sm);
  color: var(--color-brass);
  margin: 0 0 var(--space-3);
  text-transform: lowercase;
  letter-spacing: 0.05em;
}

.lightbox-description {
  font-family: var(--font-secondary);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-text-inverse);
  opacity: 0.9;
  margin: 0;
}

/* Lightbox Controls */
.lightbox-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  width: 50px;
  height: 50px;
  background: rgba(247, 246, 243, 0.1);
  border: 1px solid var(--color-border);
  color: var(--color-text-inverse);
  font-size: 32px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.lightbox-close:hover {
  background: var(--color-brass);
  border-color: var(--color-brass);
  color: var(--color-charcoal);
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(247, 246, 243, 0.1);
  border: 1px solid var(--color-border);
  color: var(--color-text-inverse);
  font-size: 36px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10001;
}

.lightbox-nav:hover {
  background: var(--color-brass);
  border-color: var(--color-brass);
  color: var(--color-charcoal);
}

.lightbox-nav--prev {
  left: var(--space-2);
}

.lightbox-nav--next {
  right: var(--space-2);
}

.nav-arrow {
  display: block;
  line-height: 1;
}

/* Desktop lightbox nav enhancements */
@media (min-width: 768px) {
  .lightbox-nav {
    width: 60px;
    height: 60px;
    font-size: 48px;
  }

  .lightbox-nav--prev {
    left: var(--space-4);
  }

  .lightbox-nav--next {
    right: var(--space-4);
  }
}
