/* ============================================================
   PROJECT GALLERY - STANDALONE STYLES
   Loaded on gallery pages
   CSS Flexbox layout (replaced Isotope.js)
   3 columns on desktop, 50px column gap, 40px row gap
   ============================================================ */

/* ===== GRID LAYOUT ===== */

/* Container base - flexbox with gap-based spacing */
/* Gallery visible immediately - no opacity gate */
.thumbs.gallery-grid-container {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 40px 50px;
}

/* All cards use uniform 1-column width */
.thumbs.gallery-grid-container .project.small {
  flex: 0 0 calc((100% - 100px) / 3); /* 3 columns: (100% - 2×50px gaps) / 3 */
  margin-bottom: 0; /* Gap handles vertical spacing */
  box-sizing: border-box;
}

/* ===== CARD BASE STYLES ===== */

/* Base card: no geometry here; container rules control width & spacing */
.ssck-gallery .project.small {
  height: auto;
  margin-top: 0;
  margin-left: 0;
  padding-bottom: 0;
  cursor: pointer;
}

/* ===== CARD STRUCTURE (flexbox equal-height rows) ===== */

/* Card link - flex column for title-below-image layout */
.ssck-gallery .project.small a.card-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
  /* Removed: justify-content: flex-end - media area now centers images */
}

/* Media container - flex center for constrained portrait images */
.ssck-gallery .project.small .card-media {
  container-type: inline-size; /* Enable cqi units for max-height constraint */
  position: relative;
  overflow: hidden;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner wrapper - shrinks to fit primary image dimensions, centered */
.ssck-gallery .project.small .card-media-inner {
  position: relative;
  display: inline-block; /* Shrinks to fit content (primary image) */
  align-self: center;
}

/* Primary image - max 1:1 aspect ratio, defines wrapper size */
.ssck-gallery .project.small .card-media img.thumb {
  display: block;
  max-width: 100%;
  max-height: 80cqi; /* Constrain to container width  */
  width: auto;
  height: auto;
}

/* ===== REVEAL IMAGE STYLES ===== */

/* Revealed image - absolute within inner wrapper, exactly covers primary */
.ssck-gallery .project.small .card-media img.thumb-revealed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  pointer-events: none;
  z-index: 10;
}

/* Hover reveals image - trigger on card hover (also works for mobile touch via :hover) */
.ssck-gallery .project.small:hover .card-media img.thumb-revealed {
  opacity: 1;
}

/* ===== TITLE STYLES ===== */

/* Title - always visible, centered below image */
.ssck-gallery .project.small h3.card-title,
.ssck-gallery .project.small h3.card-dimensions {
  display: block;
  margin: 0;
  padding: 12px 0 0 0;
  font-size: 16px;
  font-weight: normal;
  line-height: 1.3;
  text-align: center;
  color: var(--ssck-grey);
  transition: color 0.5s ease-in-out;
  flex-shrink: 0; /* Ensure title doesn't compress */
}

.ssck-gallery .project.small h3.card-dimensions {
  padding-top: 0;
  font-size: 13px;
  letter-spacing: 1px;
}

/* Hover changes title color (same trigger as revealed image) */
.ssck-gallery .project.small:hover h3.card-title,
.ssck-gallery .project.small:hover h3.card-dimensions {
  color: var(--ssck-darkest-grey);
}

/* ===== PLAY ICON FOR VIDEO CONTENT ===== */

/* Play icon base - positioned within card-media-inner */
.ssck-gallery .project.small .card-media-inner .play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: clamp(36px, 30%, 216px);
  height: clamp(36px, 30%, 216px);
  background: center / contain no-repeat url("../images/play-icon.png");
  opacity: 0.85;
  pointer-events: none;
  transition: opacity 0.5s ease-in-out;
}

/* Primary play icon - always visible */
.ssck-gallery .project.small .card-media-inner .play-icon-primary {
  z-index: 5;
}

/* Revealed play icon - hidden by default */
.ssck-gallery .project.small .card-media-inner .play-icon-revealed {
  z-index: 20;
  opacity: 0;
}

/* Show revealed play icon on hover (also works for mobile touch via :hover) */
.ssck-gallery .project.small:hover .card-media-inner .play-icon-revealed {
  opacity: 0.85;
}

/* ===== GSAP SCROLL ANIMATION ===== */

/* Initial state - cards start hidden, GSAP handles all animation */
.ssck-gallery .project.small .card-link {
  opacity: 0;
  transform: translateY(24px);
  /* NO transition - GSAP is sole animator */
}

/* GSAP completion state */
.ssck-gallery .project.small .card-link.is-bottom-faded-up {
  opacity: 1;
  transform: translateY(0);
}

/* ===== NO-JS FALLBACK ===== */

/* Show cards without animation if JS disabled */
.no-js .ssck-gallery .project.small .card-link {
  opacity: 1;
  transform: none;
}

/* ===== YEAR HEADINGS (Exhibition Galleries) ===== */

/* Year heading for exhibition galleries - full width flex item */
.thumbs.gallery-grid-container .ssck-gallery-year-heading {
  flex: 0 0 100%;
  width: 100%;
  margin-top: 12px;
  margin-bottom: -10px;
  padding: 0;
  font-family: var(--heading-font, "Bellefair", serif);
  font-size: 28px;
  font-weight: 400;
  text-align: center;
  color: var(--ssck-dark-grey, #555555);
  border: none;
  background: none;
}

.thumbs.gallery-grid-container .ssck-gallery-year-heading:first-child {
  margin-top: 0;
}

/* ===== LOAD MORE BUTTON ===== */

#project-load-more-container,
.ssck-gallery-load-more-container {
  text-align: center;
  padding: 20px 0;
  clear: both;
}

#project-load-more-button,
.ssck-gallery-load-more-button {
  padding: 10px 20px;
  cursor: pointer;
}

#project-loading-indicator,
.ssck-gallery-loading-indicator {
  display: inline-block;
  margin-left: 10px;
  padding: 10px;
  color: #555;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Tablet <= 1024px: 2 cols, 30px gutter */
@media (max-width: 1024px) {
  .thumbs.gallery-grid-container {
    gap: 32px;
  }
  .thumbs.gallery-grid-container .project.small {
    /* 2 columns => subtract 1 gutter */
    flex: 0 0 calc((100% - 32px) / 2);
  }
  .thumbs.gallery-grid-container .ssck-gallery-year-heading {
    font-size: 24px;
    margin: 32px 0 16px;
  }
}

/* Mobile <= 640px: 1 col, no horizontal gutter */
@media (max-width: 640px) {
  .thumbs.gallery-grid-container {
    gap: 32px 0;
  }
  .thumbs.gallery-grid-container .project.small {
    flex: 0 0 100%;
  }
  .thumbs.gallery-grid-container .ssck-gallery-year-heading {
    font-size: 22px;
    margin: 28px 0 14px;
  }
}

/* ==========================================================================
   EXHIBITION CARD STYLES
   ========================================================================== */

/**
 * Exhibition cards reuse project card styling but need special handling
 * for the no-poster case where we show title only.
 */

/* Exhibition card - no poster image */
.ssck-gallery .project.small.exhibition-card.no-poster .card-link {
  justify-content: center;
  min-height: 120px;
  padding: 24px 16px;
  background-color: var(--ssck-lightest-grey, #f5f5f5);
  border-radius: 4px;
}

.ssck-gallery .project.small.exhibition-card.no-poster h3.card-title {
  padding: 0;
  margin: 0;
}

/* Ensure exhibition cards have consistent hover behavior */
.ssck-gallery .project.small.exhibition-card.no-poster:hover .card-link {
  background-color: var(--ssck-light-grey, #ebebeb);
}

/* Exhibition card hover tint overlay - transparent by default */
.ssck-gallery .project.small.exhibition-card .card-media-inner::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0);
  transition: background-color 0.5s ease-in-out;
  pointer-events: none;
  z-index: 1;
}

/* Hover reveals dark tint overlay */
.ssck-gallery .project.small.exhibition-card:hover .card-media-inner::after {
  background-color: rgba(0, 0, 0, 0.08);
}

/* Responsive: Mobile adjustments for no-poster cards */
@media (max-width: 640px) {
  .ssck-gallery .project.small.exhibition-card.no-poster .card-link {
    min-height: 100px;
    padding: 20px 12px;
  }
}

/* Exhibition card poster - 4:3 aspect ratio with cover cropping */
.ssck-gallery .project.small.exhibition-card .card-media-inner.exhibition-poster {
  aspect-ratio: 4 / 3;
  width: 100%;
}

.ssck-gallery .project.small.exhibition-card .card-media-inner.exhibition-poster .exhibition-poster-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Disable cqi constraint for exhibition cards */
.ssck-gallery .project.small.exhibition-card .card-media {
  container-type: normal;
}
