.gallery-hero {
  padding-bottom: clamp(1.5rem, 4vw, 3rem);
}

.gallery-section {
  padding-top: 0;
}

.gallery-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}

.gallery-filter-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .65rem;
}

.gallery-filter {
  min-height: 42px;
  padding: .7rem 1rem;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}

.gallery-filter:hover,
.gallery-filter:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, .5);
}

.gallery-filter.active {
  background: linear-gradient(135deg, rgba(169, 111, 255, .95), rgba(86, 178, 255, .9));
  border-color: transparent;
  color: #fff;
}

.gallery-status,
.gallery-empty {
  text-align: center;
}

.gallery-status.error {
  color: #ffb4b4;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: clamp(.85rem, 2vw, 1.35rem);
}

.gallery-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .14);
  border-radius: 18px;
  background: rgba(255, 255, 255, .055);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

.gallery-card-button {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.gallery-card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(155, 110, 255, .4), transparent 45%),
    linear-gradient(135deg, #181126, #090b16);
}

.gallery-card-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .35s ease, filter .35s ease;
}

.gallery-card-button:hover img,
.gallery-card-button:focus-visible img {
  transform: scale(1.045);
  filter: brightness(1.08);
}

.gallery-card-overlay {
    position: absolute;
    inset: auto 0 0;
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: .75rem;
    min-height: 50%;
    padding: 1rem;
    background: linear-gradient(
      to top,
      rgba(35, 30, 72, .72) 0%,
      rgba(67, 54, 122, .42) 48%,
      transparent 100%
    );
}

.gallery-card-title {
  margin: 0;
  color: #fff;
  font-size: 1rem;
  line-height: 1.25;
}

.gallery-card-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem .65rem;
  border-radius: 999px;
  background: rgba(10, 11, 20, .78);
  color: #fff;
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.gallery-card-copy {
    padding: 1rem 1.1rem 1.15rem;
    background: linear-gradient(
    180deg,
    rgba(28, 33, 58, .96),
    rgba(18, 22, 42, .98)
    );
    border-top: 1px solid rgba(132, 170, 255, .18);
}

.gallery-card-meta {
  margin: 0;
  color: #e9edff !important;
  opacity: 1 !important;
  font-size: .85rem;
  font-weight: 500;
  text-shadow: 0 1px 2px rgba(3, 4, 12, .55);
}

.gallery-viewer[hidden] {
  display: none;
}

.gallery-viewer {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: clamp(.5rem, 2vw, 1.5rem);
}

.gallery-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 2, 8, .92);
  backdrop-filter: blur(12px);
}

.gallery-viewer-dialog {
  position: relative;
  z-index: 1;
  width: min(1200px, 100%);
  max-height: calc(100vh - 1rem);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: 20px;
  background: #090b13;
  box-shadow: 0 30px 100px rgba(0, 0, 0, .62);
}

.gallery-viewer-media {
  display: grid;
  place-items: center;
  min-height: min(70vh, 760px);
  background: #020309;
}

.gallery-viewer-media img,
.gallery-viewer-media video,
.gallery-viewer-media iframe {
  display: block;
  max-width: 100%;
  width: auto;
  max-height: min(78vh, 900px);
  border: 0;
}

.gallery-viewer-media img {
  height: auto;
  object-fit: contain;
}

.gallery-viewer-media video {
  width: min(100%, 1100px);
}

.gallery-viewer-media iframe {
  width: min(100%, 1100px);
  aspect-ratio: 16 / 9;
}

.gallery-viewer-copy {
    padding: 1rem clamp(1rem, 4vw, 2rem) 1.5rem;
    color: #ffffff;
}

.gallery-viewer-copy h2 {
  margin: .25rem 0 .45rem;
}

.gallery-viewer-copy p {
  margin-top: 0;
  color: rgba(235, 241, 255, 0.9);
}

.gallery-viewer-meta {
    color: #b8c9ff;
    opacity: 1;
    font-size: .85rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.gallery-viewer-close,
.gallery-viewer-nav {
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(4, 5, 12, .78);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.gallery-viewer-close {
  top: .75rem;
  right: .75rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 2rem;
  line-height: 1;
}

.gallery-viewer-nav {
  top: 50%;
  width: 48px;
  height: 64px;
  border-radius: 14px;
  transform: translateY(-50%);
  font-size: 2.5rem;
}

.gallery-viewer-previous {
  left: .75rem;
}

.gallery-viewer-next {
  right: .75rem;
}

body.viewer-open {
  overflow: hidden;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 700px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .7rem;
  }

  .gallery-card-copy {
    display: none;
  }

  .gallery-card-overlay {
    padding: .75rem;
  }

  .gallery-card-title {
    font-size: .9rem;
  }

  .gallery-card-badge {
    padding: .35rem .5rem;
    font-size: .68rem;
  }

  .gallery-viewer {
    padding: 0;
  }

  .gallery-viewer-dialog {
    max-height: 100vh;
    border-radius: 0;
  }

  .gallery-viewer-media {
    min-height: 58vh;
  }

  .gallery-viewer-nav {
    top: 46%;
    width: 42px;
    height: 54px;
  }
}

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

/* Caption colour repair: keep gallery text bright across loaded themes. */
.gallery-card .gallery-card-title {
  color: #ffffff !important;
  opacity: 1 !important;
  text-shadow: 0 2px 8px rgba(3, 4, 12, .72);
}

.gallery-card .gallery-card-badge {
  background: rgba(45, 35, 88, .72) !important;
  color: #f7f4ff !important;
  border: 1px solid rgba(220, 211, 255, .28);
}

.gallery-viewer .gallery-viewer-copy,
.gallery-viewer .gallery-viewer-copy h2,
.gallery-viewer #viewerTitle {
  color: #ffffff !important;
  opacity: 1 !important;
}

.gallery-viewer .gallery-viewer-copy p,
.gallery-viewer #viewerDescription {
  color: #e9edff !important;
  opacity: 1 !important;
}

.gallery-viewer .gallery-viewer-meta,
.gallery-viewer #viewerMeta {
  color: #c9c5ff !important;
  opacity: 1 !important;
}

