/* ==========================================================================
   Aqua Pure - Gallery Page Styles
   Loads AFTER style.css. Uses the same tokens (navy --bg-dark, blue --tan,
   6px radius) so the page matches index.html. The lightbox and the corner
   zoom icon are styled in style.css, so they are deliberately NOT redefined
   here (the old copies clashed with it: white caption text on a white card).
   ========================================================================== */

/* ── Page hero ──────────────────────────────────────────────────────────── */
.gallery-hero {
  position: relative;
  display: flex;
  align-items: center;
  min-height: min(85.5vh, 680px);
  padding: 5rem 0 5.5rem;
  text-align: center;
  overflow: hidden;
  isolation: isolate;
  background: var(--bg);
}

.gallery-hero-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  text-align: center;
}

.gallery-hero .gallery-hero-inner .chip {
  display: inline-flex;
  justify-content: center;
  max-width: 100%;
}

.gallery-hero .gallery-hero-inner .hero-title,
.gallery-hero .gallery-hero-inner .hero-sub {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}

/* Hero background: image / video toggle */
.hero-bg-image { display: block; }
.hero-bg-video { display: none; }
.hero-bg--video .hero-bg-image { display: none; }
.hero-bg--video .hero-bg-video { display: block; }

@media (max-width: 768px) {
  .gallery-hero {
    min-height: 0;
    padding: 3.5rem 0 4rem;
  }
}

@media (max-width: 600px) {
  .gallery-hero .cta-actions .btn {
    width: 100%;
    max-width: 20rem;
  }
}

/* ── Category filter bar ────────────────────────────────────────────────── */
.filter-bar-container {
  margin-top: 2.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.gal-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius) !important;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.gal-cat-btn:hover {
  color: var(--fg);
  border-color: var(--tan);
  background: var(--tan-light);
}

.gal-cat-btn.active {
  color: #FFFFFF;
  background: var(--bg-dark);
  border-color: var(--bg-dark);
}

.gal-cat-btn .count-badge {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px !important;
  background: var(--bg-3);
  color: var(--muted);
}

.gal-cat-btn.active .count-badge {
  background: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

/* Phones: tidy 2-column filter grid, "All Items" on its own row */
@media (max-width: 480px) {
  .filter-bar-container {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .gal-cat-btn {
    width: 100%;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 0.5rem;
    font-size: 0.74rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .gal-cat-btn[data-filter="all"] {
    grid-column: 1 / -1;
  }
}

/* ── Gallery grid: 3 columns, extras hidden until "Load More" ───────────── */
#mainGalleryGrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: auto; /* style.css fixes rows at 240px, which squashed the tiles */
  gap: 1.25rem;
  margin-top: 2.5rem;
}

#mainGalleryGrid .gal-item {
  grid-column: span 1;
  grid-row: span 1;
  aspect-ratio: 4 / 3;
  width: 100%;
  /* one transition for filter fades; also replaces .reveal's slower one */
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#mainGalleryGrid .gal-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Fade-out / fade-in state used by gallery.js when filtering */
#mainGalleryGrid .gal-item.is-leaving {
  opacity: 0;
  transform: scale(0.94);
}

#mainGalleryGrid .gal-item.is-hidden {
  display: none;
}

@media (max-width: 900px) {
  #mainGalleryGrid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  #mainGalleryGrid { grid-template-columns: 1fr; }
}

/* Touch screens have no hover, so keep captions and the zoom icon visible */
@media (hover: none) {
  .gal-overlay,
  .gal-zoom {
    opacity: 1;
  }
}

/* ── Load more ──────────────────────────────────────────────────────────── */
.load-more-container {
  margin-top: 3rem;
  display: flex;
  justify-content: center;
}

.btn-load-more {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1.8rem;
  border-radius: var(--radius) !important;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
  background: var(--bg-surface);
  border: 1px solid var(--fg);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.btn-load-more:hover:not(:disabled) {
  background: var(--tan);
  border-color: var(--tan);
  color: #FFFFFF;
}

.btn-load-more:disabled {
  opacity: 0.7;
  cursor: progress;
}

.btn-load-more i,
.btn-load-more svg {
  width: 1rem;
  height: 1rem;
  transition: transform 0.25s ease;
}

.btn-load-more .spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--border-2);
  border-top-color: var(--bg-dark);
  border-radius: 50%;
  animation: gal-spin 0.7s linear infinite;
}

@keyframes gal-spin {
  to { transform: rotate(360deg); }
}

/* ── Before / After slider ──────────────────────────────────────────────── */
.ba-section { background: var(--bg-2); }

.ba-slider-container {
  position: relative;
  max-width: 900px;
  margin: 3rem auto 0;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius) !important;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  cursor: ew-resize;
  user-select: none;
  touch-action: pan-y; /* horizontal drags move the slider, vertical drags still scroll */
}

.ba-image {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.ba-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
}

.ba-before { z-index: 1; }

/* Untreated look for the "before" photo - swap for a real photo when you have one */
.ba-before img {
  filter: sepia(0.85) saturate(1.1) brightness(0.8) contrast(1.05);
}

/* "After" is full width and clipped from the left by gallery.js, so the image
   never has to be resized to match the container. */
.ba-after {
  z-index: 2;
  clip-path: inset(0 0 0 50%);
}

.ba-label {
  position: absolute;
  bottom: 1rem;
  padding: 0.4rem 0.9rem;
  border-radius: var(--radius) !important;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #FFFFFF;
  background: rgba(13, 27, 42, 0.72);
  backdrop-filter: blur(4px);
}

.before-label { left: 1rem; }
.after-label { right: 1rem; }

.ba-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  z-index: 3;
  width: 3px;
  background: #FFFFFF;
  transform: translateX(-50%);
  pointer-events: none;
}

.ba-handle-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 2.6rem;
  height: 2.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50% !important;
  background: var(--bg-dark);
  border: 2px solid #FFFFFF;
  color: #FFFFFF;
  font-size: 1rem;
  box-shadow: var(--shadow-hover);
  pointer-events: auto;
}

@media (max-width: 600px) {
  .ba-slider-container {
    aspect-ratio: 4 / 3;
    margin-top: 2rem;
  }

  .ba-label {
    bottom: 0.6rem;
    padding: 0.3rem 0.6rem;
    font-size: 0.62rem;
    letter-spacing: 0.04em;
    white-space: nowrap;
  }

  .before-label { left: 0.6rem; }
  .after-label { right: 0.6rem; }

  .ba-handle-button {
    width: 2.2rem;
    height: 2.2rem;
    font-size: 0.9rem;
  }
}

/* ── Featured project ───────────────────────────────────────────────────── */
.featured-project {
  margin-top: 3rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  border-radius: var(--radius) !important;
  overflow: hidden;
  max-width: 100%;
}

.featured-img-wrap {
  position: relative;
  min-height: 320px;
  min-width: 0;
}

.featured-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.featured-badge-top {
  position: absolute;
  top: 1.2rem;
  left: 1.2rem;
  padding: 0.4rem 0.9rem;
  border-radius: 4px !important;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #FFFFFF;
  background: var(--bg-dark);
}

.featured-content {
  padding: 2.5rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}

.featured-content .eyebrow { margin-bottom: 0; }

.featured-content h2 {
  margin: 0;
  font-size: clamp(1.7rem, 3vw, 2.2rem);
}

.featured-content h2,
.featured-content p {
  overflow-wrap: break-word;
  word-break: break-word;
}

.featured-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  margin: 0.5rem 0;
}

.f-stat-v {
  font-size: 1.8rem;
  color: var(--bg-dark);
}

.f-stat-l {
  margin-top: 0.2rem;
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.featured-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

@media (max-width: 860px) {
  .featured-project { grid-template-columns: minmax(0, 1fr); }
  .featured-img-wrap { min-height: 220px; }
}

@media (max-width: 480px) {
  .featured-content { padding: 1.5rem; gap: 0.75rem; }
  .featured-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
  }
  .f-stat { text-align: center; }
  .f-stat-v { font-size: 1.2rem; }
  .f-stat-l { font-size: 0.62rem; letter-spacing: 0.03em; }
  .featured-actions { flex-direction: column; }
  .featured-actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 360px) {
  .featured-content { padding: 1.25rem 1rem; }
  .f-stat-v { font-size: 1.05rem; }
  .f-stat-l { font-size: 0.58rem; letter-spacing: 0.02em; }
}

/* ── Video showcase ─────────────────────────────────────────────────────── */
.video-grid {
  margin-top: 3rem;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.video-card {
  border-radius: var(--radius) !important;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.25s;
}

.video-card:hover {
  border-color: var(--tan);
  box-shadow: var(--shadow-hover);
  transform: translateY(-3px);
}

.video-thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-3);
}

.video-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.video-card:hover .video-thumb img { transform: scale(1.06); }

.video-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3.2rem;
  height: 3.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.94);
  color: var(--bg-dark);
  box-shadow: var(--shadow-hover);
  transition: background 0.2s, color 0.2s;
}

.video-card:hover .video-play-btn,
.video-card:focus-visible .video-play-btn {
  background: var(--tan);
  color: #FFFFFF;
}

.video-play-btn i { width: 1.3rem; height: 1.3rem; }

.video-info { padding: 1.25rem; }
.video-info h3 { font-size: 1.05rem; margin-top: 0; }
.video-info p {
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .video-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .video-grid { grid-template-columns: 1fr; }
}

/* ── Video modal (hidden until JS adds .open) ───────────────────────────── */
.video-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000; /* above the sticky header (1000) and cart drawer (1200) */
  align-items: center;
  justify-content: center;
  background: rgba(13, 27, 42, 0.9);
  backdrop-filter: blur(4px);
  padding: 2rem;
}

.video-modal.open { display: flex; }

.video-modal-inner {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow-deep);
}

.video-modal-inner iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: var(--radius);
}

.video-modal-close {
  position: absolute;
  top: -2.8rem;
  right: 0;
  width: 2.2rem;
  height: 2.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50% !important;
  background: #FFFFFF;
  color: #000000;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
  transition: background 0.2s ease;
}

.video-modal-close:hover { background: #E5E5E5; }

@media (max-width: 480px) {
  .video-modal { padding: 1rem; }
  .video-modal-close { top: -2.6rem; }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #mainGalleryGrid .gal-item,
  .video-card,
  .video-thumb img,
  .btn-load-more svg {
    transition: none;
  }

  .video-card:hover { transform: none; }
  .btn-load-more .spinner { animation-duration: 1.6s; }
}