:root {
  --gallery-height: 70vh;
  --thumb-width: 100px;
  --thumb-height: 70px;
  --transition-duration: 0.5s;
}

.gallery-section {
  position: relative;
}

.gallery-header {
  text-align: center;
  margin: 0 auto 1rem;
}

.gallery-title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.2rem, 5vw, 3.8rem);
  font-weight: 300;
  letter-spacing: 0.14em;
  color: #1e3a5a;
  text-shadow: 0 2px 30px rgba(30, 58, 90, 0.15);
}

.gallery-title-ornament {
  width: 180px;
  height: 16px;
  margin: 0.8rem auto 0.45rem;
  color: #d4af7a;
}

.gallery-subtitle {
  margin: 0;
  font-family: "Great Vibes", cursive;
  font-size: 1.6rem;
  color: rgba(30, 58, 90, 0.55);
}

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin: 0 auto 1rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.48rem;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
  font-family: "Lato", sans-serif;
  font-size: 0.67rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 0.58rem 1.2rem;
  border-radius: 4px;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.pill:hover,
.pill:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(212, 175, 122, 0.6);
  background: rgba(255, 255, 255, 0.16);
}

.pill.is-active {
  background: rgba(212, 175, 122, 0.22);
  border-color: rgba(212, 175, 122, 0.55);
}

.pill-icon,
.pill-icon svg {
  width: 15px;
  height: 15px;
}

.gallery-upload {
  margin: 1rem auto 1.2rem;
  width: min(900px, 100%);
  border: 1px solid rgba(255, 247, 232, 0.46);
  border-radius: 12px;
  padding: 0.95rem 1rem;
  background: linear-gradient(145deg, rgba(185, 206, 227, 0.25), rgba(137, 171, 205, 0.2));
  box-shadow: 0 16px 40px rgba(39, 67, 99, 0.16);
}

.gallery-upload-head {
  margin-bottom: 0.7rem;
}

.gallery-upload-title {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.15rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(38, 66, 102, 0.88);
}

.gallery-upload-subtitle {
  margin: 0.15rem 0 0;
  font-family: "Lato", sans-serif;
  font-size: 0.86rem;
  color: rgba(43, 71, 106, 0.82);
}

.gallery-upload-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.gallery-upload-label {
  font-family: "Lato", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(41, 67, 98, 0.84);
}

.gallery-upload-select {
  min-width: 190px;
  padding: 0.52rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(171, 137, 77, 0.42);
  background: rgba(255, 252, 245, 0.95);
  color: #2b4668;
  font-family: "Lato", sans-serif;
  font-size: 0.86rem;
}

.gallery-upload-btn {
  border: 1px solid rgba(171, 137, 77, 0.56);
  background: linear-gradient(145deg, #f7ecd6, #ebd5a8);
  color: #795824;
  border-radius: 999px;
  padding: 0.52rem 0.9rem;
  font-family: "Lato", sans-serif;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.gallery-upload-btn.is-secondary {
  background: rgba(243, 249, 255, 0.92);
  color: #35557c;
  border-color: rgba(122, 154, 192, 0.5);
}

.gallery-upload-feedback {
  min-height: 1.3em;
  margin: 0.6rem 0 0;
  font-family: "Lato", sans-serif;
  font-size: 0.83rem;
  color: rgba(40, 67, 99, 0.88);
}

.gallery-grid {
  width: 100%;
}

.gallery-viewer {
  width: 100%;
}

.gallery-viewer.is-switching .gallery-main-media,
.gallery-viewer.is-switching .gallery-thumbs {
  opacity: 0;
  transform: scale(1.015);
}

.gallery-main-media {
  width: 100%;
  height: clamp(500px, var(--gallery-height), 800px);
  min-height: 500px;
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #1a2e42;
  box-shadow: 0 24px 80px rgba(15, 30, 50, 0.4);
  transition: opacity 0.4s ease, transform 0.5s ease;
}

.viewer-layers {
  position: absolute;
  inset: 0;
}

.viewer-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.04);
  transition: opacity var(--transition-duration) ease, transform var(--transition-duration) ease;
}

.viewer-layer.is-active {
  opacity: 1;
  transform: scale(1);
  z-index: 2;
}

.viewer-layer img,
.viewer-layer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: var(--media-position, center);
  filter: brightness(0.95) saturate(1.08) contrast(1.02);
  display: block;
}

.layer-video {
  display: none;
}

.viewer-layer.is-video .layer-image {
  display: block;
}

.viewer-layer.is-playing-video .layer-image {
  display: none;
}

.viewer-layer.is-playing-video .layer-video {
  display: block;
}

.viewer-gradient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent 50%, rgba(15, 30, 50, 0.6) 80%, rgba(15, 30, 50, 0.85) 100%);
  z-index: 3;
}

.viewer-info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 32px 40px;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
}

.viewer-badge {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 2px;
  background: rgba(212, 175, 122, 0.2);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(212, 175, 122, 0.4);
  font-family: "Lato", sans-serif;
  font-size: 9px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #d4af7a;
}

.viewer-counter {
  margin: 0;
  justify-self: center;
  display: inline-flex;
  align-items: baseline;
  transform-style: preserve-3d;
  transition: transform 0.32s ease;
}

.viewer-counter.is-flipping {
  transform: rotateX(90deg);
}

.viewer-counter .current {
  font-family: "Cormorant Garamond", serif;
  font-size: 48px;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1;
}

.viewer-counter .slash {
  margin: 0 8px;
  font-family: "Lato", sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
}

.viewer-counter .total {
  font-family: "Cormorant Garamond", serif;
  font-size: 24px;
  color: rgba(255, 255, 255, 0.4);
}

.viewer-actions {
  justify-self: end;
  display: inline-flex;
  gap: 0.6rem;
}

.viewer-action {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.88);
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.viewer-action:hover,
.viewer-action:focus-visible {
  border-color: rgba(212, 175, 122, 0.62);
  background: rgba(212, 175, 122, 0.22);
  transform: translateY(-1px);
}

.viewer-action svg {
  width: 18px;
  height: 18px;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  color: #fff;
  display: grid;
  place-items: center;
  z-index: 5;
  transition: transform 0.25s ease, border-color 0.25s ease, background 0.25s ease;
}

.viewer-nav-prev {
  left: 24px;
}

.viewer-nav-next {
  right: 24px;
}

.viewer-nav svg {
  width: 20px;
  height: 20px;
}

.viewer-nav:hover,
.viewer-nav:focus-visible {
  background: rgba(212, 175, 122, 0.2);
  border-color: rgba(212, 175, 122, 0.5);
}

.viewer-nav-prev:hover,
.viewer-nav-prev:focus-visible {
  transform: translate(-2px, -50%);
}

.viewer-nav-next:hover,
.viewer-nav-next:focus-visible {
  transform: translate(2px, -50%);
}

.viewer-nav:active {
  transform: translateY(-50%) scale(0.92);
}

.viewer-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  color: #fff;
  z-index: 4;
  display: none;
  place-items: center;
  transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease;
  animation: playPulse 2.5s ease infinite;
}

.viewer-layer.is-video .viewer-play {
  display: grid;
}

.viewer-layer.is-video.is-playing-video .viewer-play {
  display: none;
}

.viewer-play svg {
  width: 28px;
  height: 28px;
  transform: translateX(3px);
}

.viewer-play:hover,
.viewer-play:focus-visible {
  transform: translate(-50%, -50%) scale(1.08);
  background: rgba(212, 175, 122, 0.3);
  border-color: rgba(212, 175, 122, 0.9);
}

.gallery-thumbs {
  width: 100%;
  margin-top: 16px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px;
  scroll-behavior: smooth;
  scrollbar-width: none;
  transition: opacity 0.3s ease;
}

.gallery-thumbs::-webkit-scrollbar {
  display: none;
}

.gallery-thumb {
  position: relative;
  width: var(--thumb-width);
  height: var(--thumb-height);
  border-radius: 4px;
  overflow: hidden;
  border: 2px solid transparent;
  opacity: 0.55;
  filter: brightness(0.8) saturate(0.7);
  cursor: pointer;
  flex: 0 0 auto;
  background: #243d59;
  transition: transform 0.3s ease, opacity 0.3s ease, filter 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

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

.gallery-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gallery-thumb.is-video::after {
  opacity: 1;
  background: rgba(8, 18, 30, 0.4);
}

.gallery-thumb-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 18px;
  height: 18px;
  color: #fff;
  z-index: 2;
}

.gallery-thumb-play svg {
  width: 100%;
  height: 100%;
}

.gallery-thumb:hover,
.gallery-thumb:focus-visible {
  opacity: 0.85;
  filter: brightness(1) saturate(1);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(15, 30, 50, 0.3);
}

.gallery-thumb.is-active {
  opacity: 1;
  filter: brightness(1) saturate(1.1);
  border-color: #d4af7a;
  box-shadow: 0 4px 16px rgba(212, 175, 122, 0.4);
  transform: translateY(-3px) scale(1.05);
}

.gallery-empty {
  width: 100%;
  min-height: 420px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 18, 30, 0.24);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 2rem;
  color: rgba(255, 255, 255, 0.45);
}

.gallery-empty.is-hidden {
  display: none;
}

.gallery-empty svg {
  width: 120px;
  color: rgba(255, 255, 255, 0.15);
}

.gallery-empty h3 {
  margin: 1rem 0 0.5rem;
  font-family: "Cormorant Garamond", serif;
  font-size: 28px;
  color: rgba(255, 255, 255, 0.4);
}

.gallery-empty p {
  margin: 0 0 1rem;
  font-family: "Lato", sans-serif;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.25);
}

.gallery-empty-cta {
  border: 1px solid rgba(212, 175, 122, 0.8);
  background: rgba(212, 175, 122, 0.25);
  color: #f6ddbc;
  border-radius: 999px;
  padding: 0.6rem 1rem;
  font-family: "Lato", sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.upload-fab {
  display: none;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 18, 30, 0.97);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.4s ease;
}

.lightbox.is-open {
  display: flex;
  opacity: 1;
}

.lightbox-figure {
  position: relative;
  max-width: 90vw;
  max-height: 88vh;
  display: grid;
  gap: 0.7rem;
}

#lightbox-image {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7);
  animation: lightboxIn 0.4s ease;
}

.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.lightbox-nav.prev {
  left: calc(50% - min(45vw, 630px) - 82px);
}

.lightbox-nav.next {
  right: calc(50% - min(45vw, 630px) - 82px);
}

.lightbox-nav:hover,
.lightbox-nav:focus-visible {
  background: rgba(212, 175, 122, 0.2);
  border-color: rgba(212, 175, 122, 0.8);
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  display: grid;
  place-items: center;
  transition: transform 0.3s ease, background 0.3s ease;
}

.lightbox-close:hover,
.lightbox-close:focus-visible {
  transform: rotate(90deg);
  background: rgba(212, 175, 122, 0.2);
}

.lightbox-meta {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 16px 32px;
  background: rgba(8, 18, 30, 0.8);
  backdrop-filter: blur(10px);
  border-radius: 4px;
}

.lightbox-meta-left,
.lightbox-meta-right {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.lightbox-category-badge {
  font-family: "Lato", sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  padding: 0.28rem 0.6rem;
  border-radius: 2px;
  border: 1px solid rgba(212, 175, 122, 0.5);
  background: rgba(212, 175, 122, 0.15);
  color: rgba(212, 175, 122, 0.95);
}

.lightbox-counter {
  margin: 0;
  font-family: "Lato", sans-serif;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.85);
}

.lightbox-title {
  margin: 0;
  text-align: center;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.1rem;
  color: rgba(255, 255, 255, 0.78);
}

.lightbox-download,
.lightbox-close-inline {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  display: grid;
  place-items: center;
}

.lightbox-download:hover,
.lightbox-close-inline:hover,
.lightbox-download:focus-visible,
.lightbox-close-inline:focus-visible {
  background: rgba(212, 175, 122, 0.2);
  border-color: rgba(212, 175, 122, 0.7);
  color: #fff;
}

.lightbox-close-inline svg,
.lightbox-download svg,
.lightbox-close svg,
.lightbox-nav svg {
  width: 18px;
  height: 18px;
}

@keyframes playPulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(212, 175, 122, 0);
  }
  50% {
    box-shadow: 0 0 20px rgba(212, 175, 122, 0.55);
  }
}

@keyframes lightboxIn {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 1024px) {
  :root {
    --gallery-height: 55vh;
    --thumb-width: 80px;
    --thumb-height: 56px;
  }

  .viewer-nav {
    width: 48px;
    height: 48px;
  }
}

@media (max-width: 600px) {
  :root {
    --thumb-width: 64px;
    --thumb-height: 44px;
  }

  .gallery-main-media {
    height: min(50vw, 420px);
    min-height: 280px;
  }

  .gallery-title {
    font-size: 44px;
    letter-spacing: 6px;
  }

  .filter-pills {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 6px;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

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

  .pill {
    flex-shrink: 0;
    scroll-snap-align: start;
  }

  .viewer-nav {
    width: 40px;
    height: 40px;
  }

  .viewer-nav-prev {
    left: 12px;
  }

  .viewer-nav-next {
    right: 12px;
  }

  .viewer-info {
    padding: 20px 14px;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.5rem;
  }

  .viewer-badge,
  .viewer-actions {
    justify-self: center;
  }

  .viewer-counter .current {
    font-size: 34px;
  }

  .viewer-counter .total {
    font-size: 18px;
  }

  .gallery-upload {
    margin-bottom: 5.2rem;
  }

  .upload-fab {
    position: fixed;
    right: 16px;
    bottom: 18px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: 0;
    background: #d4af7a;
    color: #fff;
    box-shadow: 0 6px 24px rgba(212, 175, 122, 0.5);
    display: grid;
    place-items: center;
    z-index: 60;
  }

  .upload-fab svg {
    width: 22px;
    height: 22px;
  }

  .lightbox {
    padding: 0.6rem;
  }

  .lightbox-nav {
    width: 44px;
    height: 44px;
  }

  .lightbox-nav.prev,
  .lightbox-nav.next {
    position: static;
    transform: none;
  }

  .lightbox {
    flex-direction: column;
    gap: 0.7rem;
  }

  .lightbox-meta {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 12px 14px;
  }

  .lightbox-meta-left,
  .lightbox-meta-right {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  .viewer-layer,
  .viewer-nav,
  .viewer-counter,
  .gallery-thumb,
  .gallery-main-media,
  .gallery-thumbs {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
