/* =============================================================================
   OPC Gallery Manager — front-end gallery grid and lightbox
   Enqueued site-wide by OPC_Gallery_Shortcode::enqueue_frontend_assets()
   Matches the OPC theme's industrial aesthetic: no border-radius, red/blue accent.
============================================================================= */

/* ── Design tokens (from OPC theme style.css) ──────────────────────────────── */
:root {
  --opc-red:         #E31E24;
  --opc-red-dark:    #b81519;
  --opc-blue:        #1B4F9B;
  --opc-yellow:      #F5C518;
  --opc-green:       #2E8B57;
  --opc-dark:        #1a1a1a;
  --opc-dark-2:      #2d2d2d;
  --opc-light:       #f5f4f2;
  --opc-white:       #ffffff;
  --opc-text:        #9a9a9a;
  --opc-border:      rgba(255, 255, 255, 0.08);
  --opc-red-glow:    rgba(227, 30, 36, 0.15);
  --opc-blue-glow:   rgba(27, 79, 155, 0.15);
  --opc-font-head:   'Barlow Condensed', sans-serif;
  --opc-font-body:   'Barlow', sans-serif;
  --opc-radius:      0;
  --opc-transition:  0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ── Gallery grid ───────────────────────────────────────────────────────────── */
.opc-gallery-grid {
  display: grid;
  gap: 1rem;
  margin: 2rem 0;
}
.opc-gallery-grid--cols-1 { grid-template-columns: 1fr; }
.opc-gallery-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.opc-gallery-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.opc-gallery-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Gallery item ───────────────────────────────────────────────────────────── */
.opc-gallery-item {
  margin: 0;
  position: relative;
  overflow: hidden;
  background-color: var(--opc-dark-2);
  border-radius: var(--opc-radius);
}
.opc-gallery-item--featured {
  border: 2px solid var(--opc-red);
}
.opc-gallery-item__link {
  display: block;
  overflow: hidden;
}
.opc-gallery-item__img {
  width: 100%;
  display: block;
  object-fit: cover;
  aspect-ratio: 4 / 3;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.opc-gallery-item__link:hover .opc-gallery-item__img,
.opc-gallery-item__link:focus .opc-gallery-item__img {
  transform: scale(1.05);
}
/* Focus ring for keyboard navigation */
.opc-gallery-item__link:focus-visible {
  outline: 2px solid var(--opc-red);
  outline-offset: 2px;
}

/* ── Caption ────────────────────────────────────────────────────────────────── */
.opc-gallery-item__caption {
  background-color: rgba(26, 26, 26, 0.9);
  padding: 0.6rem 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.opc-gallery-item__caption-title {
  display: block;
  font-family: var(--opc-font-head);
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--opc-white);
  margin-bottom: 0.2rem;
}
.opc-gallery-item__caption-desc {
  display: block;
  font-family: var(--opc-font-body);
  font-size: 0.78rem;
  color: rgba(245, 244, 242, 0.6);
  line-height: 1.4;
}

/* ── Lightbox container ─────────────────────────────────────────────────────── */
.opc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.opc-lightbox-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.92);
  cursor: pointer;
}
.opc-lightbox-box {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 1100px);
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ── Lightbox close button ──────────────────────────────────────────────────── */
.opc-lightbox-close {
  position: absolute;
  top: -2.75rem;
  right: 0;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--opc-transition);
  line-height: 1;
}
.opc-lightbox-close:hover {
  color: var(--opc-red);
}
.opc-lightbox-close:focus-visible {
  outline: 2px solid var(--opc-red);
  outline-offset: 2px;
}

/* ── Lightbox prev / next ───────────────────────────────────────────────────── */
.opc-lightbox-prev,
.opc-lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: var(--opc-white);
  font-size: 2rem;
  cursor: pointer;
  padding: 0.5rem 0.85rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--opc-transition);
  z-index: 2;
  line-height: 1;
}
.opc-lightbox-prev { left: -3.5rem; }
.opc-lightbox-next { right: -3.5rem; }
.opc-lightbox-prev:hover,
.opc-lightbox-next:hover {
  background-color: var(--opc-red);
}
.opc-lightbox-prev:focus-visible,
.opc-lightbox-next:focus-visible {
  outline: 2px solid var(--opc-red);
  outline-offset: 2px;
}

/* ── Lightbox image ─────────────────────────────────────────────────────────── */
.opc-lightbox-img {
  width: 100%;
  height: auto;
  max-height: 80vh;
  object-fit: contain;
  display: block;
  border-radius: var(--opc-radius);
}

/* ── Lightbox caption ───────────────────────────────────────────────────────── */
.opc-lightbox-caption {
  margin-top: 0.75rem;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
  font-family: var(--opc-font-body);
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 600px;
}
.opc-lightbox-caption strong {
  font-family: var(--opc-font-head);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: block;
  margin-bottom: 0.2rem;
  color: var(--opc-white);
}

/* ── Responsive grid breakpoints ────────────────────────────────────────────── */
@media (max-width: 900px) {
  .opc-gallery-grid--cols-4 {
    grid-template-columns: repeat(3, 1fr);
  }
}
@media (max-width: 680px) {
  .opc-gallery-grid--cols-3,
  .opc-gallery-grid--cols-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Pull nav arrows inward on small screens */
  .opc-lightbox-prev { left: 0; }
  .opc-lightbox-next { right: 0; }
}
@media (max-width: 420px) {
  .opc-gallery-grid--cols-2,
  .opc-gallery-grid--cols-3,
  .opc-gallery-grid--cols-4 {
    grid-template-columns: 1fr;
  }
}

/* ── Reduced motion ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .opc-gallery-item__img {
    transition: none;
  }
}
