/*
  css/gallery.css
  Stylesheet for the Main Gallery Page (collections/index.html)
  Author: Jules
*/

/* ------------------- */
/* --- Page Layout --- */
/* ------------------- */
.page-title {
  /* Center-aligns the main title of the page. */
  text-align: center;
  /* Increases the font size for a strong visual hierarchy. */
  font-size: 2.5rem;
}

.page-intro {
  /* The introductory paragraph below the title. */
  text-align: center;
  /* Sets a maximum width for better readability. */
  max-width: 650px;
  /* Centers the paragraph block. */
  margin: 0 auto var(--spacing-large);
  /* Slightly larger font size for emphasis. */
  font-size: 1.1rem;
}

/* ------------------- */
/* --- Gallery Grid --- */
/* ------------------- */
.gallery-grid {
  /* Uses CSS Grid for a flexible and responsive layout. */
  display: grid;
  /* Creates three equal-width columns for the collection sections. */
  grid-template-columns: repeat(3, 1fr);
  /* Adds a gap between the grid items. */
  gap: var(--spacing-large);
}

.gallery-item {
  /* This is the container for each series link. */
  position: relative; /* Establishes a positioning context for the overlay. */
  overflow: hidden; /* Hides parts of the overlay that are outside the item's bounds. */
  display: block; /* Ensures the anchor tag behaves like a block-level element. */
  border: 2px solid var(--secondary-accent-color); /* Adds a border. */
  color: var(--secondary-text-color); /* Sets the default text color inside the link to white. */
  aspect-ratio: 1 / 1; /* Forces a 1:1 square aspect ratio */
}

.gallery-item img {
  /* Ensures the image fills its container. */
  width: 100%;
  height: 100%;
  /* Ensures the image maintains its aspect ratio while filling the container. */
  object-fit: cover;
  /* A smooth transition for the hover effect. */
  transition: transform 0.5s ease;
}

.gallery-item:hover, .gallery-item:focus {
  color: var(--secondary-text-color); /* Keeps text white on hover. */
  text-decoration: none; /* Removes underline on hover. */
}

.gallery-item:hover img, .gallery-item:focus img {
  /* Creates a subtle zoom and slight rotation effect on hover. */
  transform: scale(1.05) rotate(1deg);
}

.gallery-item-overlay {
  /* Positions the overlay on top of the image. */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Flexbox to perfectly center the text content. */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  /* Adds padding inside the overlay. */
  padding: var(--spacing-medium);
  /* A dark, semi-transparent background to ensure text is readable. */
  background-color: rgba(4, 26, 47, 0.7);
  /* Starts with the overlay being fully transparent. */
  opacity: 0;
  /* A smooth transition for the fade-in effect. */
  transition: opacity 0.5s ease;
}

.gallery-item-label {
  /* Positions the always-visible label at the center of the gallery item. */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  /* Always visible by default */
  opacity: 1;
  /* Smooth transition for fade-out on hover */
  transition: opacity 0.3s ease;
}

.gallery-item-label span {
  /* Style for the label text */
  display: inline-block;
  background-color: rgba(4, 26, 47, 0.8);
  color: var(--primary-text-color); /* Orange color */
  padding: var(--spacing-small) var(--spacing-medium);
  border-radius: 4px;
  font-family: var(--heading-font);
  font-weight: 700;
  font-size: 2.24rem; /* Increased by 60% from 1.4rem */
  /* Ensures the background only surrounds the text */
  white-space: nowrap;
}

.gallery-item-label-multiline {
  /* Special styling for multi-line labels */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.gallery-item-label-multiline span {
  /* Individual lines in multi-line label */
  display: block;
  margin: 0;
  line-height: 1.1;
}

.gallery-item:hover .gallery-item-label,
.gallery-item:focus .gallery-item-label {
  /* Hide the label when the item is hovered or focused */
  opacity: 0;
}

.gallery-item-title {
  /* Positions the always-visible title centered in the gallery item. */
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  /* Flexbox to perfectly center the text content. */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  /* Adds padding inside the title area. */
  padding: var(--spacing-medium);
  /* No background - let the image show through */
  background-color: transparent;
  /* Always visible */
  opacity: 1;
}

.gallery-item-title h2 {
  /* The always-visible title styling to match across all boxes. */
  color: var(--primary-text-color); /* Uses orange for the title. */
  margin-bottom: var(--spacing-small);
  /* Set consistent font-size for all always-visible titles */
  font-size: 1.8rem;
  font-weight: 700;
  /* Match the font family used in overlays */
  font-family: 'Montserrat', sans-serif;
}

.gallery-item:hover .gallery-item-overlay,
.gallery-item:focus .gallery-item-overlay {
  /* Fades the overlay in when the item is hovered or focused. */
  opacity: 1;
}

.gallery-item-overlay h2 {
  /* The title of the series. */
  color: var(--primary-text-color); /* Uses orange for the title. */
  margin-bottom: var(--spacing-small);
  transform: translateY(10px); /* Starts the text slightly lower. */
  transition: transform 0.4s ease 0.1s; /* Adds a delayed slide-in effect. */
}

.gallery-item-overlay p {
  /* The description of the series. */
  margin-bottom: 0;
  transform: translateY(10px); /* Starts the text slightly lower. */
  transition: transform 0.4s ease 0.2s; /* Adds a more delayed slide-in effect. */
}

.gallery-item:hover .gallery-item-overlay h2,
.gallery-item:hover .gallery-item-overlay p {
  /* Moves the text to its final position on hover. */
  transform: translateY(0);
}

/* ------------------- */
/* --- Series Header --- */
/* ------------------- */
.series-header {
  /* Defines the layout for the top part of individual collection pages. */
  text-align: center; /* Centers the title and description. */
  margin-bottom: var(--spacing-large); /* Adds space below the header. */
  padding-bottom: var(--spacing-large); /* Adds padding below the content. */
  border-bottom: 1px solid var(--primary-accent-color); /* A line to separate header from grid. */
}

.series-header h1 {
  /* The main title of the series. */
  text-align: center;
  font-size: 3.3rem; /* 10% larger than original 3rem */
}

.series-description {
  /* The paragraph describing the series. */
  text-align: center;
  max-width: 750px; /* Constrains the width for readability. */
  margin: 0 auto var(--spacing-large); /* Centers the paragraph and adds space below it. */
  font-size: 1.21rem; /* 10% larger than original 1.1rem */
  color: var(--secondary-accent-color);
}

.back-to-gallery-btn {
  /* The link to return to the main gallery page. */
  display: inline-block; /* Allows for padding and margin. */
  font-family: var(--heading-font);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary-text-color);
  border: 1px solid var(--primary-text-color);
  padding: var(--spacing-small) var(--spacing-medium);
  transition: background-color 0.3s ease, color 0.3s ease;
  text-decoration: none;
  margin-top: var(--spacing-small);
}

.back-to-gallery-btn:hover,
.back-to-gallery-btn:focus {
  background-color: var(--primary-text-color);
  color: var(--background-color);
}

/* ------------------- */
/* --- Media Queries --- */
/* ------------------- */
@media (max-width: 900px) {
  .gallery-grid {
    /* Switches to a two-column layout on smaller tablets. */
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .gallery-grid {
    /* Switches to a single-column layout on mobile devices. */
    grid-template-columns: 1fr;
  }
}
