/**
 * Galleries page — museum wings.
 *
 * Each curated collection is a "wing" of the museum: an italic-serif
 * section title, a piece-count subtitle, a "View the full exhibition"
 * link, and a horizontal row of small framed thumbnails.
 *
 * Frames are thinner than on the pondering page (these are just sample
 * pieces, not the main display) and there are no individual placards —
 * the section header acts as the wing's signage.
 */

:root {
  --serif: "Newsreader", Georgia, "Iowan Old Style", "Source Serif 4", serif;
  --frame-wood: #3a2818;
  --frame-wood-light: #4a3522;
  --frame-wood-deep: #261a0e;
  --mat-white: #ece6d8;
  --mat-edge: rgba(58, 40, 24, 0.25);
  --mat-text: #3a2818;
  --mat-text-soft: #6e5536;
  --wall-top: #1c1814;
  --wall-bottom: #0d0a08;
  --accent-warm: #8b3a1a;
}

/* ============================================
   Page (gallery wall)
   ============================================ */
.galleries-page {
  padding: var(--space-5) var(--space-6);
  min-height: 100vh;
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, rgba(255, 230, 200, 0.04), transparent 70%),
    linear-gradient(180deg, var(--wall-top) 0%, var(--wall-bottom) 100%);
}

/* ============================================
   Page header — like an exhibition foyer sign
   ============================================ */
.galleries-header {
  text-align: center;
  background: transparent;
  border: none;
  padding: var(--space-6) var(--space-4) var(--space-3);
  margin-bottom: var(--space-8);
}
.galleries-header h1 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-3xl);
  color: var(--mat-white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  margin: 0 0 var(--space-3) 0;
  letter-spacing: -0.005em;
}
.galleries-header p {
  font-family: var(--serif);
  font-size: var(--font-base);
  color: rgba(236, 230, 216, 0.7);
  line-height: 1.55;
  max-width: 65ch;
  margin: 0 auto;
}

/* ============================================
   Gallery section ("wing")
   ============================================ */
.gallery-section {
  background: transparent;
  border: none;
  padding: 0;
  margin-bottom: var(--space-10);
}

.gallery-section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding: 0 var(--space-2) var(--space-3);
  border-bottom: 1px solid rgba(236, 230, 216, 0.12);
}

.gallery-section-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gallery-section-header h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-2xl);
  color: var(--mat-white);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  margin: 0;
  letter-spacing: -0.005em;
}

.gallery-count {
  font-family: var(--font-primary);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mat-text-soft);
  color: rgba(236, 230, 216, 0.55);
  margin-left: 0;
}

.see-more-btn {
  flex-shrink: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: var(--font-sm);
  color: var(--mat-white);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(236, 230, 216, 0.25);
  border-radius: 2px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}
.see-more-btn:hover {
  background: rgba(236, 230, 216, 0.06);
  border-color: var(--mat-white);
  color: #fff;
  text-decoration: none;
}

/* ============================================
   Gallery row — horizontal scroll of small framed thumbnails
   ============================================ */
.gallery-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  overflow-x: auto;
  overflow-y: hidden;
  padding: var(--space-2) var(--space-2) var(--space-4);
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(236, 230, 216, 0.2) transparent;
}
.gallery-row::-webkit-scrollbar { height: 8px; }
.gallery-row::-webkit-scrollbar-track { background: transparent; }
.gallery-row::-webkit-scrollbar-thumb {
  background: rgba(236, 230, 216, 0.18);
  border-radius: 4px;
}
.gallery-row::-webkit-scrollbar-thumb:hover {
  background: rgba(236, 230, 216, 0.35);
}

/* Each piece: thin walnut frame + small cream mat. Sized smaller than
   the pondering page since these are samples in a row, not the main
   display. */
.gallery-item {
  flex-shrink: 0;
  display: inline-block;
  background:
    linear-gradient(135deg, var(--frame-wood-light) 0%, var(--frame-wood) 50%, var(--frame-wood-deep) 100%);
  padding: 4px;
  cursor: pointer;
  box-shadow:
    0 3px 6px rgba(0, 0, 0, 0.5),
    0 8px 18px rgba(0, 0, 0, 0.4);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.gallery-mat {
  background: var(--mat-white);
  padding: 8px;
  display: block;
  font-size: 0;
}

.gallery-item img {
  display: block;
  max-height: 200px;
  max-width: 240px;
  width: auto;
  height: auto;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-3px);
  box-shadow:
    0 5px 10px rgba(0, 0, 0, 0.55),
    0 12px 26px rgba(0, 0, 0, 0.45);
}

/* ============================================
   Image viewer overlay — minimize chrome (image-first),
   matching the pondering-page treatment.
   ============================================ */
.image-viewer {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(8, 6, 4, 0.96);
  z-index: 2000;
  cursor: default;
}
.image-viewer.active {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

.image-viewer-content {
  position: relative;
  max-width: 92vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer-image-container {
  position: relative;
  max-width: 100%;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.image-viewer img {
  max-width: 92vw;
  max-height: 90vh;
  object-fit: contain;
  display: block;
  user-select: none;
}

.close-viewer,
.nav-arrow,
.like-button {
  opacity: 0.35;
  transition: opacity var(--transition-fast), background var(--transition-fast),
              border-color var(--transition-fast);
}
.close-viewer:hover,
.nav-arrow:hover,
.like-button:hover {
  opacity: 1;
}

.close-viewer {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--font-2xl);
  border-radius: 2px;
  cursor: pointer;
  z-index: 2001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.close-viewer:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
}

.nav-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 64px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255, 255, 255, 0.9);
  font-size: var(--font-2xl);
  cursor: pointer;
  z-index: 2001;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-arrow:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
}
.prev-arrow { left: var(--space-4); }
.next-arrow { right: var(--space-4); }

.like-button {
  position: fixed;
  top: var(--space-4);
  left: var(--space-4);
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 2px;
  cursor: pointer;
  z-index: 2001;
  display: flex;
  align-items: center;
  justify-content: center;
}
.like-button:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
}
.heart-icon {
  width: 22px;
  height: 22px;
  /* Force pure white regardless of source color so the outline reads
     against the dark viewer backdrop. */
  filter: brightness(0) invert(1);
  opacity: 0.85;
}

/* Viewer details — italic-serif at the bottom, gradient fade */
.viewer-details {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-5) var(--space-6) var(--space-4);
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.7) 70%);
  color: rgba(255, 255, 255, 0.95);
  z-index: 2001;
  pointer-events: none;
  transition: transform var(--transition-base), opacity var(--transition-base);
}
.viewer-details.minimized {
  transform: translateY(100%);
  opacity: 0;
}
.viewer-details-content {
  max-width: 720px;
  margin: 0 auto;
  text-align: center;
  font-family: var(--serif);
}
.viewer-details h2 {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: var(--font-2xl);
  color: rgba(255, 255, 255, 0.95);
  margin: 0 0 var(--space-2) 0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.viewer-details p {
  font-family: var(--serif);
  font-size: var(--font-sm);
  color: rgba(255, 255, 255, 0.85);
  margin: 0;
  line-height: 1.5;
  display: inline;
}
.viewer-details p::after {
  content: ' · ';
  color: rgba(255, 255, 255, 0.45);
}
.viewer-details p:last-child::after { content: ''; }
.viewer-details .artist-name {
  font-family: var(--font-primary);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.7rem;
  display: block;
  margin-bottom: var(--space-2);
}
.viewer-details .artist-name strong { display: none; }
.viewer-details .artist-link {
  color: rgba(255, 255, 255, 0.95);
  text-decoration: none;
  pointer-events: auto;
}
.viewer-details .artist-link:hover {
  color: var(--mat-white);
  text-decoration: underline;
}
.viewer-details strong {
  font-weight: 600;
  color: rgba(255, 255, 255, 0.6);
}

.viewer-details-toggle {
  position: absolute;
  bottom: 0;
  right: var(--space-4);
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
  z-index: 2002;
  border-radius: 2px;
  pointer-events: auto;
  opacity: 0.5;
  transition: opacity var(--transition-fast);
}
.viewer-details-toggle:hover { opacity: 1; }
.viewer-details-toggle::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid rgba(255, 255, 255, 0.85);
  border-bottom: 2px solid rgba(255, 255, 255, 0.85);
  /* Default = details VISIBLE → arrow points DOWN. */
  transform: translate(-50%, -65%) rotate(45deg);
}
.image-viewer.details-minimized .viewer-details-toggle::before {
  /* Minimized → arrow points UP. */
  transform: translate(-50%, -35%) rotate(-135deg);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
  .galleries-page {
    padding: var(--space-4) var(--space-3);
  }
  .galleries-header {
    padding: var(--space-4) var(--space-2) var(--space-2);
    margin-bottom: var(--space-6);
  }
  .gallery-section { margin-bottom: var(--space-8); }
  .gallery-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  .gallery-item img {
    max-height: 160px;
    max-width: 200px;
  }
  .nav-arrow {
    width: 40px;
    height: 56px;
  }
}
