/* ============================================================
   GALLERY PAGE — event sections, image grid, lightbox
   Reuses design tokens (colors, type, spacing) from css/style.css.
   ============================================================ */

/* ---------------- Event sections ---------------- */

.event-section {
  padding: var(--space-xl) 0;
  border-bottom: 1px solid var(--color-border-soft);
}

.event-section:last-of-type {
  border-bottom: none;
}

.event-header {
  max-width: 100ch;
}

.event-date {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: var(--fs-tiny);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-green);
}

.event-date::before {
  content: "";
  width: 22px;
  height: 1px;
  background: var(--color-green);
}

.event-title {
  margin-top: var(--space-xs);
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.event-description {
  margin-top: var(--space-sm);
  font-size: var(--fs-lead);
  line-height: 1.6;
  color: var(--color-text-soft);
}

.event-divider {
  margin: var(--space-lg) 0;
  height: 1px;
  background: var(--color-border);
}

/* ---------------- Gallery grid ---------------- */

.event-gallery-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-sm);
}

.event-gallery-item {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg-tertiary);
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11, 13, 12, 0.04);
  transition: box-shadow 0.4s var(--ease-out);
}

.event-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.6s var(--ease-out);
}

.event-gallery-item-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(10, 31, 23, 0) 45%, rgba(10, 31, 23, 0.55) 100%);
  opacity: 0;
  transition: opacity 0.4s var(--ease-out);
}

.event-gallery-item-overlay svg {
  width: 22px;
  height: 22px;
  color: var(--color-white);
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}

.event-gallery-item:hover img,
.event-gallery-item:focus-visible img {
  transform: scale(1.07);
}

.event-gallery-item:hover .event-gallery-item-overlay,
.event-gallery-item:focus-visible .event-gallery-item-overlay {
  opacity: 1;
}

.event-gallery-item:hover .event-gallery-item-overlay svg,
.event-gallery-item:focus-visible .event-gallery-item-overlay svg {
  opacity: 1;
  transform: scale(1);
}

.event-gallery-item:hover,
.event-gallery-item:focus-visible {
  box-shadow: 0 20px 40px -18px rgba(11, 13, 12, 0.35);
}

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

/* ---------------- Lightbox ---------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.3s var(--ease-out), visibility 0s linear 0.3s;
}

.lightbox.is-open {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.3s var(--ease-out), visibility 0s linear 0s;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 8, 0.92);
}

.lightbox-dialog {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  height: 100%;
  padding: var(--space-md) var(--space-2xl);
  /* Only the controls/image below should catch clicks — everywhere
     else in this full-size wrapper must pass through to the backdrop
     so clicking outside the image closes the lightbox. */
  pointer-events: none;
}

.lightbox-dialog > * {
  pointer-events: auto;
}

.lightbox-figure {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  max-width: min(1400px, 84vw);
  max-height: 85vh;
  margin: 0;
  transform: scale(0.96);
  opacity: 0;
  transition: transform 0.35s var(--ease-out), opacity 0.35s var(--ease-out);
}

.lightbox.is-open .lightbox-figure {
  transform: scale(1);
  opacity: 1;
}

.lightbox-img {
  display: block;
  max-width: 100%;
  max-height: 78vh;
  width: auto;
  height: auto;
  border-radius: var(--radius-sm);
  object-fit: contain;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.6);
}

.lightbox-counter {
  font-family: var(--font-display);
  font-size: var(--fs-small);
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.7);
}

.lightbox-close,
.lightbox-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-white);
  cursor: pointer;
  transition: background 0.25s var(--ease-out), transform 0.25s var(--ease-out), border-color 0.25s var(--ease-out);
}

.lightbox-close svg,
.lightbox-nav svg {
  width: 20px;
  height: 20px;
}

.lightbox-close:hover,
.lightbox-nav:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.4);
}

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

.lightbox-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 2;
  width: 44px;
  height: 44px;
}

.lightbox-nav {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
}

.lightbox-nav:active {
  transform: scale(0.92);
}

/* Scroll lock while the lightbox is open */
html.gallery-lightbox-open,
body.gallery-lightbox-open {
  overflow: hidden;
}

/* ---------------- Responsive ---------------- */

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

  .lightbox-dialog {
    padding: var(--space-md) var(--space-lg);
  }
}

@media (max-width: 640px) {
  .event-section {
    padding: var(--space-lg) 0;
  }

  .event-divider {
    margin: var(--space-md) 0;
  }

  .event-gallery-grid {
    grid-template-columns: 1fr;
    gap: var(--space-xs);
  }

  .lightbox-dialog {
    padding: var(--space-2xs) var(--space-2xs);
    gap: var(--space-3xs);
  }

  .lightbox-figure {
    max-width: 78vw;
  }

  .lightbox-nav {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .lightbox-nav svg {
    width: 16px;
    height: 16px;
  }

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

  .lightbox-close svg {
    width: 16px;
    height: 16px;
  }

  .lightbox-img {
    max-height: 68vh;
  }
}

@media (prefers-reduced-motion: reduce) {

  .event-gallery-item img,
  .event-gallery-item-overlay,
  .event-gallery-item-overlay svg,
  .lightbox,
  .lightbox-figure {
    transition: none !important;
  }
}
