@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@500&family=Playfair+Display:wght@600&display=swap");

/* =========================================
   1. Core Variables
   ========================================= */
:root {
  --hex-width: 220px;
  --hex-gap: 16px;
  --sqrt3: 1.73205;
  --hex-height: calc(var(--hex-width) * 2 / var(--sqrt3));
  --hover-scale: 1.15;
}

/* =========================================
   2. Gallery Layout (6,5,6,5 Grid)
   ========================================= */
.gallery-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  perspective: 1000px;
  overflow: hidden;
  padding: 40px 0;
}

.hex-grid {
  display: grid;
  grid-template-columns: repeat(11, calc((var(--hex-width) + var(--hex-gap)) / 2));
  grid-auto-rows: calc(var(--hex-height) * 0.75 + var(--hex-gap));
  justify-content: center;
  gap: 0;
  margin: 0 auto;
  padding-bottom: 40px;
}

.hex {
  width: var(--hex-width);
  height: var(--hex-height);
  margin: calc(var(--hex-gap) / 2);
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4));
  transform: translateY(0);
  transition:
    filter 0.5s cubic-bezier(0.25, 1, 0.5, 1),
    transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  outline: none;
}

/* 6,5,6,5 pattern */
.hex:nth-child(11n + 1) { grid-column: 1 / span 2; }
.hex:nth-child(11n + 2) { grid-column: 3 / span 2; }
.hex:nth-child(11n + 3) { grid-column: 5 / span 2; }
.hex:nth-child(11n + 4) { grid-column: 7 / span 2; }
.hex:nth-child(11n + 5) { grid-column: 9 / span 2; }
.hex:nth-child(11n + 6) { grid-column: 11 / span 2; }

.hex:nth-child(11n + 7) { grid-column: 2 / span 2; }
.hex:nth-child(11n + 8) { grid-column: 4 / span 2; }
.hex:nth-child(11n + 9) { grid-column: 6 / span 2; }
.hex:nth-child(11n + 10) { grid-column: 8 / span 2; }
.hex:nth-child(11n + 11) { grid-column: 10 / span 2; }

.hex-shape {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  clip-path: polygon(
    50% 0%,
    100% 25%,
    100% 75%,
    50% 100%,
    0% 75%,
    0% 25%
  );
  background-color: #1e2025;
}

.hex-shape::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 50% 50%,
    transparent 40%,
    rgba(0, 0, 0, 0.6) 120%
  );
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.5s ease;
}

.hex:hover,
.hex:focus-within {
  z-index: 10;
  transform: translateY(-6px);
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.6));
}

.hex:hover .hex-shape::after,
.hex:focus-within .hex-shape::after {
  opacity: 0;
}

.hex img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scale(1.02);
  backface-visibility: hidden;
  will-change: transform;
  transition:
    transform 0.6s cubic-bezier(0.25, 1, 0.5, 1),
    filter 0.6s ease;
}

.hex-grid.no-grayscale .hex img {
  filter: none !important;
}

.hex:hover img,
.hex:focus-visible img {
  transform: scale(var(--hover-scale));
  filter: grayscale(0%) brightness(1.05) contrast(1.05) !important;
}

/* =========================================
   3. Caption Overlay
   ========================================= */
.hex-caption {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.95) 0%,
    rgba(0, 0, 0, 0.4) 50%,
    rgba(0, 0, 0, 0) 100%
  );
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 0 20px 70px 20px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.hex-caption h3 {
  font-family: "Playfair Display", serif;
  color: #fff;
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 6px;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
  transform: translateY(15px);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.hex-caption p {
  font-family: "Montserrat", sans-serif;
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 3px;
  margin: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  transform: translateY(15px);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
}

.hex:hover .hex-caption,
.hex:focus-visible .hex-caption {
  opacity: 1;
}

.hex:hover .hex-caption h3,
.hex:focus-visible .hex-caption h3,
.hex:hover .hex-caption p,
.hex:focus-visible .hex-caption p {
  transform: translateY(0);
}

/* =========================================
   4. Lightbox
   ========================================= */
.hex-lightbox-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 999999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.5s cubic-bezier(0.25, 1, 0.5, 1),
    visibility 0.5s;
  backdrop-filter: blur(8px);
}

.hex-lightbox-overlay.active {
  opacity: 1;
  visibility: visible;
}

.hex-lightbox-container {
  position: relative;
  width: 90%;
  max-width: 1200px;
  height: 90%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transform: scale(0.8);
  transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

.hex-lightbox-overlay.active .hex-lightbox-container {
  transform: scale(1);
}

.hex-lightbox-image-wrapper {
  position: relative;
  flex-grow: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

.hex-lightbox-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.hex-lightbox-overlay.active .hex-lightbox-image {
  opacity: 1;
}

.hex-lightbox-info {
  width: 100%;
  padding: 20px 0;
  text-align: center;
  color: #fff;
  opacity: 0;
  transform: translateY(20px);
  transition:
    opacity 0.5s ease 0.2s,
    transform 0.5s ease 0.2s;
}

.hex-lightbox-overlay.active .hex-lightbox-info {
  opacity: 1;
  transform: translateY(0);
}

.hex-lightbox-title {
  font-family: "Playfair Display", serif;
  font-size: 2rem;
  margin: 0 0 10px;
  font-weight: 600;
}

.hex-lightbox-desc {
  font-family: "Montserrat", sans-serif;
  font-size: 1rem;
  color: #ccc;
  margin: 0;
}

.hex-lightbox-close {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  padding: 10px;
  line-height: 1;
}

.hex-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  font-size: 40px;
  padding: 20px 15px;
  cursor: pointer;
  z-index: 10;
}

.hex-lightbox-prev {
  left: -60px;
}

.hex-lightbox-next {
  right: -60px;
}

@media (max-width: 1200px) {
  .hex-lightbox-prev { left: 0; }
  .hex-lightbox-next { right: 0; }
}

@media (max-width: 768px) {
  .hex-lightbox-title {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  :root {
    --hex-width: 160px;
    --hex-gap: 10px;
  }
}