/* ============================================================
   EXPEDITION BRAZILIAN JIU-JITSU — Gallery Page Styles
   ============================================================ */

/* --- Breadcrumb Section ---------------------------------- */
.breadcrumb-section {
  background-color: var(--color-bg-raised);
  border-bottom: 1px solid var(--color-border);
}

/* --- Filter Bar ------------------------------------------ */
.filter-section {
  background-color: var(--color-bg-raised);
  padding-block: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: var(--nav-height);
  z-index: calc(var(--z-nav) - 1);
  transition: top var(--duration-normal) var(--ease-smooth);
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 2px; /* prevent clipping of focus rings */
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  font-family: var(--font-body);
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
  color: var(--color-text-secondary);
  background-color: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-lg);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-smooth);
}

.filter-btn:hover {
  color: var(--color-text-primary);
  border-color: var(--color-border-light);
  background-color: var(--color-bg-card);
}

.filter-btn.active {
  color: var(--color-bg);
  background-color: var(--color-accent);
  border-color: var(--color-accent);
}

.filter-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Gallery Grid ---------------------------------------- */
.gallery-section {
  background-color: var(--color-bg);
  padding-block: var(--section-pad-y);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 220px;
  gap: var(--space-md);
}

/* Row span variations for masonry effect */
.gallery-item--tall {
  grid-row: span 2;
}

.gallery-item--wide {
  grid-column: span 2;
}

/* --- Gallery Item ---------------------------------------- */
.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-md);
  background-color: var(--color-bg-card);
  cursor: pointer;
  border: 1px solid var(--color-border);
  transition: border-color var(--duration-normal) var(--ease-smooth),
              box-shadow var(--duration-normal) var(--ease-smooth);
}

.gallery-item:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-lg);
}

.gallery-item:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-smooth);
  display: block;
}

.gallery-item:hover img {
  transform: scale(1.06);
}

/* Hover overlay */
.gallery-item-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(10, 10, 10, 0.85) 0%,
    rgba(10, 10, 10, 0.2) 50%,
    transparent 100%
  );
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-smooth);
  display: flex;
  align-items: flex-end;
  padding: var(--space-md);
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

.gallery-item-label {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--color-accent);
  background-color: rgba(10, 10, 10, 0.6);
  padding: 4px var(--space-sm);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(200, 150, 46, 0.3);
}

/* Expand icon on hover */
.gallery-item-expand {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 32px;
  height: 32px;
  background-color: rgba(10, 10, 10, 0.7);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-smooth);
  backdrop-filter: blur(4px);
}

.gallery-item:hover .gallery-item-expand {
  opacity: 1;
}

.gallery-item-expand svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-text-primary);
  fill: none;
  stroke-width: 2;
}

/* --- Placeholder items ----------------------------------- */
.gallery-placeholder {
  width: 100%;
  height: 100%;
  background-color: var(--color-bg-surface);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  color: var(--color-text-muted);
  font-size: var(--fs-small);
  font-style: italic;
  text-align: center;
  padding: var(--space-lg);
  pointer-events: none;
}

.gallery-placeholder svg {
  width: 32px;
  height: 32px;
  stroke: var(--color-border-light);
  fill: none;
  stroke-width: 1.5;
  flex-shrink: 0;
}

.gallery-placeholder span {
  font-size: var(--fs-xs);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

/* Hidden state for filter */
.gallery-item.hidden {
  display: none;
}

/* Animate in on filter change */
.gallery-item.fade-in {
  animation: galleryFadeIn 0.3s var(--ease-smooth) forwards;
}

@keyframes galleryFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* --- Gallery Count ---------------------------------------- */
.gallery-count {
  font-size: var(--fs-small);
  color: var(--color-text-muted);
  margin-bottom: var(--space-xl);
  font-style: italic;
}

.gallery-count strong {
  color: var(--color-accent);
  font-style: normal;
}

/* --- Video Section --------------------------------------- */
.video-section {
  background-color: var(--color-bg-raised);
  padding-block: var(--section-pad-y);
  border-top: 1px solid var(--color-border);
}

.video-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-xl);
  margin-top: var(--space-3xl);
}

.video-placeholder {
  position: relative;
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 9;
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-smooth);
}

.video-placeholder:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-lg);
}

.video-placeholder-inner {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--color-bg-surface) 0%, var(--color-bg-card) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
}

.video-play-btn {
  width: 64px;
  height: 64px;
  background-color: var(--color-accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--duration-normal) var(--ease-smooth),
              box-shadow var(--duration-normal) var(--ease-smooth);
  flex-shrink: 0;
}

.video-placeholder:hover .video-play-btn {
  transform: scale(1.1);
  box-shadow: var(--shadow-glow);
}

.video-play-btn svg {
  width: 28px;
  height: 28px;
  fill: var(--color-bg);
  margin-left: 4px; /* optical centering for play triangle */
}

.video-placeholder-label {
  font-family: var(--font-heading);
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
  color: var(--color-text-muted);
  text-align: center;
}

.video-placeholder-sublabel {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  opacity: 0.7;
  font-style: italic;
}

.video-section-footer {
  margin-top: var(--space-3xl);
  text-align: center;
}

.youtube-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  color: var(--color-text-secondary);
  transition: color var(--duration-fast);
}

.youtube-link:hover {
  color: var(--color-accent);
}

.youtube-link svg {
  width: 20px;
  height: 20px;
  fill: #FF0000;
  flex-shrink: 0;
}

/* --- Bottom CTA ------------------------------------------ */
.gallery-cta {
  background-color: var(--color-bg);
  border-top: 1px solid var(--color-border);
  padding-block: var(--section-pad-y);
  text-align: center;
}

.gallery-cta h2 {
  margin-bottom: var(--space-md);
}

.gallery-cta p {
  color: var(--color-text-secondary);
  font-size: var(--fs-body-lg);
  max-width: 500px;
  margin-inline: auto;
  margin-bottom: var(--space-2xl);
}

/* --- Lightbox -------------------------------------------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--duration-normal) var(--ease-smooth),
              visibility var(--duration-normal) var(--ease-smooth);
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(5, 5, 5, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
}

.lightbox-container {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  padding: var(--space-xl);
  padding-top: calc(var(--space-xl) + 60px);
  padding-bottom: calc(var(--space-xl) + 60px);
  pointer-events: none;
}

.lightbox-image-wrap {
  position: relative;
  max-width: min(90vw, 1100px);
  max-height: 80vh;
  pointer-events: auto;
  transition: transform var(--duration-normal) var(--ease-smooth),
              opacity var(--duration-fast) var(--ease-smooth);
}

.lightbox-image-wrap.transitioning {
  opacity: 0;
  transform: scale(0.97);
}

.lightbox-image-wrap img {
  display: block;
  max-width: 100%;
  max-height: 80vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
}

/* Lightbox caption */
.lightbox-caption {
  position: absolute;
  bottom: calc(-1 * var(--space-2xl));
  left: 0;
  right: 0;
  text-align: center;
  font-size: var(--fs-small);
  color: var(--color-text-muted);
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

/* Lightbox close button */
.lightbox-close {
  position: fixed;
  top: var(--space-xl);
  right: var(--space-xl);
  width: 48px;
  height: 48px;
  background-color: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background-color var(--duration-fast) var(--ease-smooth),
              transform var(--duration-fast) var(--ease-smooth);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.lightbox-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.lightbox-close:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.lightbox-close svg {
  width: 20px;
  height: 20px;
  stroke: var(--color-text-primary);
  fill: none;
  stroke-width: 2;
}

/* Lightbox nav arrows */
.lightbox-prev,
.lightbox-next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background-color var(--duration-fast) var(--ease-smooth),
              transform var(--duration-fast) var(--ease-smooth);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.lightbox-prev {
  left: var(--space-xl);
}

.lightbox-next {
  right: var(--space-xl);
}

.lightbox-prev:hover,
.lightbox-next:hover {
  background-color: rgba(255, 255, 255, 0.18);
}

.lightbox-prev:hover {
  transform: translateY(-50%) translateX(-2px);
}

.lightbox-next:hover {
  transform: translateY(-50%) translateX(2px);
}

.lightbox-prev:focus-visible,
.lightbox-next:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.lightbox-prev svg,
.lightbox-next svg {
  width: 22px;
  height: 22px;
  stroke: var(--color-text-primary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Counter */
.lightbox-counter {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  z-index: 2;
  background-color: rgba(10, 10, 10, 0.6);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
}

/* Body scroll lock */
body.lightbox-open {
  overflow: hidden;
}

/* --- Responsive ------------------------------------------ */
@media (max-width: 1024px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 200px;
  }

  .gallery-item--wide {
    grid-column: span 1;
  }

  .video-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .lightbox-prev {
    left: var(--space-md);
  }

  .lightbox-next {
    right: var(--space-md);
  }
}

@media (max-width: 768px) {
  .filter-section {
    top: 0;
  }

  /* Fade hint to indicate the filter bar scrolls horizontally */
  .filter-bar {
    -webkit-mask-image: linear-gradient(to right, black 85%, transparent 100%);
    mask-image: linear-gradient(to right, black 85%, transparent 100%);
    padding-right: var(--space-xl);
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-auto-rows: 160px;
    gap: var(--space-sm);
  }

  .gallery-item--tall {
    grid-row: span 2;
  }

  .video-grid {
    grid-template-columns: 1fr;
    gap: var(--space-lg);
  }

  .lightbox-prev,
  .lightbox-next {
    width: 44px;
    height: 44px;
  }

  .lightbox-prev {
    left: var(--space-sm);
  }

  .lightbox-next {
    right: var(--space-sm);
  }

  .lightbox-close {
    top: var(--space-md);
    right: var(--space-md);
    width: 44px;
    height: 44px;
  }

  .lightbox-image-wrap img {
    max-height: 70vh;
  }
}

@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: 240px;
    gap: var(--space-sm);
  }

  .gallery-item--tall {
    grid-row: span 1;
  }

  .gallery-item--wide {
    grid-column: span 1;
  }

  /* Touch target fix: min 44px height for filter buttons */
  .filter-btn {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--fs-xs);
    min-height: 44px;
  }

  /* Lightbox: tighter padding so image fills more of screen */
  .lightbox-container {
    padding: var(--space-md);
    padding-top: calc(var(--space-md) + 60px);
    padding-bottom: calc(var(--space-md) + 50px);
  }

  /* Lightbox nav: larger touch targets, pushed to edges */
  .lightbox-prev,
  .lightbox-next {
    width: 48px;
    height: 48px;
  }

  .lightbox-prev {
    left: var(--space-xs);
  }

  .lightbox-next {
    right: var(--space-xs);
  }

  /* More readable gallery category labels */
  .gallery-item-label {
    font-size: var(--fs-xs);
    padding: 5px var(--space-sm);
    background-color: rgba(10, 10, 10, 0.8);
  }
}
