/**
 * Project Grid Block Styles
 */

.project-grid {
  margin: 3rem 0;
}

/* Category Filters */
.project-grid__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 3.5rem;

  @media (max-width: 768px) {
    gap: 0.5rem;
    padding-bottom: 1.5rem;
  }
}

.project-grid__filter-btn {
  padding: 0.625rem 1.25rem;
  font-size: 1.125rem;
  font-weight: bold;
  background: transparent;
  border: 1px solid #b1b1b4;
  border-radius: 2rem;
  color: var(--wp--preset--color--contrast, #010400);
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;

  &:hover {
    border: 1px solid var(--wp--preset--color--secondary, #C91F25);
    background: var(--wp--preset--color--secondary, #C91F25);
    color: white;
  }

  &.is-active {
    border: 1px solid var(--wp--preset--color--secondary, #C91F25);
    background: var(--wp--preset--color--secondary, #C91F25);
    color: white;
  }

  &:focus {
  }

  @media (max-width: 768px) {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
  }
}

.project-grid__container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;

  @media (max-width: 768px) {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  @media (max-width: 480px) {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Project Item */
.project-grid__item {
  overflow: hidden;
}

.project-grid__item.is-hidden {
  display: none;
}

/* Media Container */
.project-grid__media {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  overflow: hidden;
  background: var(--wp--preset--color--neutral, #E6E6EA);
}

.project-grid__video-trigger,
.project-grid__image-link {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.project-grid__video-trigger img,
.project-grid__image-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s ease-in-out;
}

.project-grid__item:hover .project-grid__video-trigger img,
.project-grid__item:hover .project-grid__image-link img {
  transform: scale(1.02);
}

/* Play Button Overlay */
.project-grid__play-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  opacity: 0.9;

  @media (max-width: 768px) {
    width: 50px;
    height: 50px;
  }
}

.project-grid__play-icon {
  width: 60px;
  height: 60px;
  color: white;

  @media (max-width: 768px) {
    width: 60px;
    height: 60px;
  }
}

.project-grid__video-trigger:hover .project-grid__play-overlay {
  background: var(--wp--preset--color--primary, #0068B3);
  transform: translate(-50%, -50%) scale(1.1);
}

/* Placeholder */
.project-grid__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--wp--preset--color--neutral, #E6E6EA);
  color: var(--wp--preset--color--contrast, #010400);
  text-decoration: none;
  font-style: italic;
  transition: background-color 0.3s ease;

  &:hover {
    background: #d6d6da;
  }
}

/* Project Info */
.project-grid__info {
  padding: 1rem 0 0;

  @media (max-width: 768px) {
    padding: 0.75rem 0 0;
  }
}

.project-grid__title {
  margin: 0;
  padding: 0;
  font-size: var(--wp--preset--font-size--large, 1.1rem);
  font-weight: 600;
  line-height: 1.3;

  @media (max-width: 768px) {
    font-size: var(--wp--preset--font-size--medium, 1.1rem);
  }
}

.project-grid__title a {
  color: var(--wp--preset--color--contrast, #010400);
  text-decoration: none;
  transition: color 0.3s ease;

  &:hover {
    color: var(--wp--preset--color--primary, #0068B3);
  }
}

.project-grid__location {
  color: #787878;
  font-size: var(--wp--preset--font-size--medium, 0.95rem);
  margin: 0;
  padding: 0;

  @media (max-width: 768px) {
  font-size: var(--wp--preset--font-size--medium, 0.85rem);
  }
}

/* Video Modal */
.vimeo-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  max-width: none !important;
  max-height: none !important;
  transform: none !important;

  &.is-open {
    opacity: 1;
    visibility: visible;
  }
}

.vimeo-modal__overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  cursor: pointer;
}

.vimeo-modal__container {
  position: relative;
  width: 90vw;
  border-radius: 0;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  margin: 0 !important;
  padding: 0 !important;
  max-width: none !important;
  max-height: none !important;
}

.vimeo-modal.is-open .vimeo-modal__container {
  transform: scale(1);
}

.vimeo-modal__close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.8);
  border: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.3s ease;
  color: white;
  z-index: 10;
  backdrop-filter: blur(10px);

  &:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
  }

  svg {
    width: 24px;
    height: 24px;
  }

  @media (max-width: 768px) {
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    
    svg {
      width: 20px;
      height: 20px;
    }
  }
}

.vimeo-modal__content {
  position: relative;
}

.vimeo-modal__video-container {
  position: relative;
  width: 100%;
  padding: 56.25% 0 0; /* 16:9 Aspect Ratio */

  iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
  }
}

/* Loading state */
.vimeo-modal__loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 1.1rem;
}

/* ACF Block Placeholder */
.acf-block-placeholder {
  padding: 2rem;
  text-align: center;
  background: #f9f9f9;
  border: 2px dashed #ddd;
  border-radius: 8px;
  color: #666;
}

/* Focus States for Accessibility */
.project-grid__video-trigger:focus,
.project-grid__image-link:focus,
.project-grid__title a:focus,
.vimeo-modal__close:focus {
  outline: 2px solid var(--wp--preset--color--primary, #0068B3);
  outline-offset: 2px;
}

/* Animation initial states (for theme animations) */
.project-grid__item {
  opacity: 1; /* Override theme fade-in for grid items */
}

/* =========================================================
   Gallery Trigger Button
   Replaces the <a> image link for non-video projects
   ========================================================= */

.project-grid__gallery-trigger {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.project-grid__gallery-trigger img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s ease-in-out;
}

.project-grid__item:hover .project-grid__gallery-trigger img {
  transform: scale(1.02);
}

/* Image count badge */
.project-grid__gallery-count {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 3px;
  backdrop-filter: blur(4px);
  pointer-events: none;
  opacity: 0;

  svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
  }
}

/* =========================================================
   Gallery Modal
   ========================================================= */

.gallery-modal {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 999999 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  margin: 0 !important;
  padding: 0 !important;

  &.is-open {
    opacity: 1;
    visibility: visible;
  }
}

.gallery-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}

/* Container — sits above the overlay */
.gallery-modal__container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90vw;
  max-width: 1100px;
  max-height: 90vh;
}

/* Close button */
.gallery-modal__close {
  position: absolute;
  top: -44px;
  right: 0;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s ease, transform 0.2s ease;
  color: #fff;
  z-index: 10;

  &:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
  }

  svg {
    width: 18px;
    height: 18px;
  }
}

/* Prev / Next navigation */
.gallery-modal__prev,
.gallery-modal__next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.12);
  border: none;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s ease, transform 0.2s ease;
  color: #fff;
  z-index: 10;

  &:hover {
    background: rgba(255, 255, 255, 0.28);
    transform: translateY(-50%) scale(1.08);
  }

  svg {
    width: 22px;
    height: 22px;
  }

  @media (max-width: 600px) {
    width: 36px;
    height: 36px;

    svg {
      width: 18px;
      height: 18px;
    }
  }

  @media (max-width: 768px) {
    background: rgba(0, 0, 0, 0.5);
  }
}

.gallery-modal__prev {
  left: -58px;

  @media (max-width: 768px) {
    left: 8px;
  }
}

.gallery-modal__next {
  right: -58px;

  @media (max-width: 768px) {
    right: 8px;
  }
}

/* Slide track */
.gallery-modal__track {
  position: relative;
  width: 100%;
}

/* Individual slides */
.gallery-modal__slide {
  display: none;
  flex-direction: column;
  align-items: center;

  &.is-active {
    display: flex;
    animation: gallery-fade-in 0.3s ease;
  }
}

@keyframes gallery-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Image wrapper */
.gallery-modal__image-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 70vh;
  overflow: hidden;

  img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
  }
}

/* Caption */
.gallery-modal__caption {
  margin: 0.75rem 0 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.875rem;
  text-align: center;
  line-height: 1.4;
  max-width: 70ch;
}

/* Footer: counter + dots */
.gallery-modal__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1rem;
}

.gallery-modal__counter {
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  letter-spacing: 0.05em;
}

.gallery-modal__dots {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.gallery-modal__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s ease, transform 0.2s ease;

  &.is-active {
    background: #fff;
    transform: scale(1.3);
  }

  &:hover:not(.is-active) {
    background: rgba(255, 255, 255, 0.6);
  }
}

/* Focus states */
.project-grid__gallery-trigger:focus,
.gallery-modal__close:focus,
.gallery-modal__prev:focus,
.gallery-modal__next:focus,
.gallery-modal__dot:focus {
  outline: 2px solid var(--wp--preset--color--primary, #0068B3);
  outline-offset: 2px;
}