/* Gallery page — mosaic grid, motion, lightbox */

.gallery-page {
  --gal-gold: #d4a853;
  --gal-gold-soft: #e8c882;
  --gal-teal: #2bb8a8;
  --gal-violet: #9b87f5;
  position: relative;
}

/* Hero */
.gallery-hero {
  position: relative;
  margin-bottom: clamp(1.35rem, 1rem + 2vw, 2.25rem);
  padding: clamp(1.35rem, 1rem + 2.5vw, 2.35rem);
  border-radius: var(--radius-xl);
  overflow: hidden;
  border: 1px solid transparent;
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
    linear-gradient(
      125deg,
      rgba(212, 168, 83, 0.45),
      rgba(43, 184, 168, 0.4),
      rgba(155, 135, 245, 0.35)
    )
    border-box;
  box-shadow: var(--shadow-md);
}

.gallery-hero__glow {
  position: absolute;
  inset: -40% -20% auto;
  height: 140%;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 35%, rgba(212, 168, 83, 0.22), transparent 48%),
    radial-gradient(circle at 80% 20%, rgba(43, 184, 168, 0.18), transparent 45%),
    radial-gradient(circle at 55% 95%, rgba(155, 135, 245, 0.14), transparent 50%);
  animation: gallery-hero-glow 18s ease-in-out infinite alternate;
}

@keyframes gallery-hero-glow {
  from {
    transform: translate3d(-2%, 0, 0) scale(1);
  }
  to {
    transform: translate3d(2%, 1.5%, 0) scale(1.04);
  }
}

.gallery-hero__eyebrow {
  position: relative;
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--gal-gold-soft);
}

.gallery-hero__title {
  position: relative;
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 1.35rem + 2.5vw, 2.75rem);
  line-height: 1.08;
  background: linear-gradient(105deg, var(--color-text), var(--gal-gold-soft), var(--gal-teal));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gallery-hero__lead {
  position: relative;
  margin: 0.85rem 0 0;
  max-width: 40rem;
  color: var(--color-text-muted);
  font-size: clamp(0.95rem, 0.9rem + 0.35vw, 1.08rem);
  line-height: 1.55;
}

.gallery-hero__count {
  position: relative;
  margin: 1rem 0 0;
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.gallery-hero__count-num {
  display: inline-block;
  min-width: 1.75rem;
  margin-right: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  text-align: center;
  color: var(--color-on-gold);
  background: linear-gradient(135deg, var(--gal-gold), var(--gal-teal));
}

/* Stage & ambient */
.gallery-stage {
  position: relative;
  margin-bottom: clamp(1.5rem, 1rem + 2vw, 2.5rem);
}

.gallery-stage__ambient {
  position: absolute;
  inset: -10% 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.gallery-stage__orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  animation: gallery-orb-float 22s ease-in-out infinite alternate;
}

.gallery-stage__orb--1 {
  width: min(280px, 50vw);
  height: min(280px, 50vw);
  top: 5%;
  left: -5%;
  background: rgba(212, 168, 83, 0.35);
}

.gallery-stage__orb--2 {
  width: min(220px, 45vw);
  height: min(220px, 45vw);
  top: 40%;
  right: -8%;
  background: rgba(43, 184, 168, 0.3);
  animation-delay: -6s;
}

.gallery-stage__orb--3 {
  width: min(180px, 40vw);
  height: min(180px, 40vw);
  bottom: 0;
  left: 35%;
  background: rgba(155, 135, 245, 0.25);
  animation-delay: -12s;
}

@keyframes gallery-orb-float {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(12px, -18px, 0);
  }
}

/* Mosaic grid */
.gallery-mosaic {
  position: relative;
  z-index: 1;
  display: grid;
  gap: clamp(0.65rem, 1.5vw, 1.15rem);
  grid-template-columns: minmax(0, 1fr);
  grid-auto-flow: dense;
  width: 100%;
  min-width: 0;
}

@media (min-width: 480px) {
  .gallery-mosaic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 768px) {
  .gallery-mosaic {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .gallery-tile--feature {
    grid-column: span 2;
    grid-row: span 2;
  }

  .gallery-tile--feature .gallery-tile__trigger {
    min-height: clamp(280px, 40vw, 420px);
  }

  .gallery-tile--feature .gallery-tile__trigger img {
    aspect-ratio: auto;
    height: 100%;
    min-height: inherit;
  }
}

@media (min-width: 1100px) {
  .gallery-mosaic {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* Tiles — visible immediately; image fades in once when loaded */
.gallery-tile {
  margin: 0;
  min-width: 0;
}

.gallery-tile.is-visible {
  opacity: 1;
}

.gallery-tile__trigger {
  position: relative;
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: zoom-in;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
  transition:
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.45s ease;
}

.gallery-tile__trigger:focus-visible {
  outline: 2px solid var(--gal-gold-soft);
  outline-offset: 3px;
}

.gallery-tile__trigger img,
.gallery-tile__img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  vertical-align: middle;
  background: var(--color-surface);
  transition:
    opacity 0.35s ease,
    transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-tile__img:not(.is-loaded) {
  opacity: 0;
}

.gallery-tile__img.is-loaded {
  opacity: 1;
}

.gallery-tile__frame {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: none;
}

.gallery-tile__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    125deg,
    transparent 35%,
    rgba(255, 255, 255, 0.12) 50%,
    transparent 65%
  );
  transform: translateX(-120%);
  transition: transform 0.85s ease;
  pointer-events: none;
}

.gallery-tile__zoom {
  position: absolute;
  right: 0.65rem;
  bottom: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(8, 12, 11, 0.55);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: scale(0.85);
  transition:
    opacity 0.35s ease,
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) and (pointer: fine) {
  .gallery-tile__trigger:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
  }

  .gallery-tile__trigger:hover img {
    transform: scale(1.06);
  }

  .gallery-tile__trigger:hover .gallery-tile__shine {
    transform: translateX(120%);
  }

  .gallery-tile__trigger:hover .gallery-tile__zoom {
    opacity: 1;
    transform: scale(1);
  }
}

.gallery-tile__caption {
  margin: 0;
  padding: 0.65rem 0.15rem 0;
  font-size: clamp(0.78rem, 0.72rem + 0.25vw, 0.92rem);
  line-height: 1.4;
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
}

/* Empty state */
.gallery-empty {
  text-align: center;
  padding: clamp(2rem, 1.5rem + 3vw, 3.5rem) clamp(1rem, 0.5rem + 2vw, 2rem);
  border-radius: var(--radius-xl);
  border: 1px dashed var(--color-border-subtle);
  background: var(--color-surface);
  margin-bottom: clamp(1.5rem, 1rem + 2vw, 2rem);
}

.gallery-empty__icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  animation: gallery-empty-pulse 3s ease-in-out infinite;
}

@keyframes gallery-empty-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

.gallery-empty__title {
  margin: 0 0 0.5rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 1.1rem + 1vw, 1.75rem);
}

.gallery-empty__text {
  margin: 0 0 1.25rem;
  max-width: 28rem;
  margin-inline: auto;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.55;
}

.gallery-actions {
  margin-top: clamp(0.5rem, 0.25rem + 1vw, 1rem);
}

.gallery-actions .btn {
  width: 100%;
}

@media (min-width: 480px) {
  .gallery-actions .btn {
    width: auto;
  }
}

/* Lightbox */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0.75rem, 2vw, 1.5rem);
}

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

.gallery-lightbox.is-open {
  animation: gallery-lightbox-in 0.35s ease both;
}

@keyframes gallery-lightbox-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.gallery-lightbox__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 7, 0.88);
  backdrop-filter: blur(12px);
}

.gallery-lightbox__panel {
  position: relative;
  z-index: 1;
  width: min(960px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: gallery-panel-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes gallery-panel-in {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.gallery-lightbox__figure {
  margin: 0;
  width: 100%;
  max-height: calc(92vh - 4rem);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gallery-lightbox__img {
  display: block;
  max-width: 100%;
  max-height: calc(92vh - 5.5rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.gallery-lightbox__caption {
  margin: 0.85rem 0 0;
  max-width: 36rem;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.82);
}

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

.gallery-lightbox__counter {
  margin: 0.65rem 0 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

.gallery-lightbox__close {
  position: absolute;
  top: -0.25rem;
  right: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border: none;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.2s ease;
}

@media (min-width: 640px) {
  .gallery-lightbox__close {
    top: -3rem;
    right: 0;
  }
}

.gallery-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.22);
}

.gallery-lightbox__close:focus-visible {
  outline: 2px solid var(--gal-gold-soft);
  outline-offset: 2px;
}

.gallery-lightbox__nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-top: -1.375rem;
  border: none;
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}

.gallery-lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.05);
}

.gallery-lightbox__nav--prev {
  left: 0;
}

.gallery-lightbox__nav--next {
  right: 0;
}

@media (max-width: 639px) {
  .gallery-lightbox__nav {
    top: auto;
    bottom: -3.25rem;
    margin-top: 0;
  }

  .gallery-lightbox__nav--prev {
    left: calc(50% - 3.25rem);
  }

  .gallery-lightbox__nav--next {
    right: calc(50% - 3.25rem);
  }

  .gallery-lightbox__panel {
    padding-bottom: 3.5rem;
  }
}

[data-gallery-reveal]:not(.is-visible) {
  opacity: 0;
  transform: translate3d(0, 14px, 0);
}

[data-gallery-reveal].is-visible {
  animation: gallery-reveal-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes gallery-reveal-in {
  from {
    opacity: 0;
    transform: translate3d(0, 14px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* Light theme */
html[data-theme="light"] .gallery-hero__title {
  background: linear-gradient(105deg, #1a2824, #8a6b2a, #1a7a6e);
  -webkit-background-clip: text;
  background-clip: text;
}

html[data-theme="light"] .gallery-tile__trigger {
  border: 1px solid var(--color-border-subtle);
}

html[data-theme="light"] .gallery-lightbox__backdrop {
  background: rgba(232, 237, 235, 0.92);
}

html[data-theme="light"] .gallery-lightbox__caption,
html[data-theme="light"] .gallery-lightbox__counter {
  color: var(--color-text-muted);
}

html[data-theme="light"] .gallery-lightbox__close,
html[data-theme="light"] .gallery-lightbox__nav {
  color: var(--color-text);
  background: rgba(10, 16, 14, 0.08);
}

@media (prefers-reduced-motion: reduce) {
  .gallery-hero__glow,
  .gallery-stage__orb,
  .gallery-empty__icon {
    animation: none;
  }

  .gallery-tile__img {
    opacity: 1 !important;
    transition: none;
  }

  .gallery-tile__trigger img,
  .gallery-tile__shine,
  .gallery-tile__zoom,
  .gallery-tile__trigger {
    transition: none;
  }

  [data-gallery-reveal] {
    opacity: 1;
    transform: none;
    animation: none !important;
  }

  .gallery-lightbox.is-open,
  .gallery-lightbox__panel {
    animation: none;
  }
}
