/* =============================================================================
   Gallery page + home teaser — SW Mechanics
   Linked from Gallery/Index.cshtml and PageSection/Gallery.cshtml
   ============================================================================= */

.section-gallery-page,
.section-gallery-teaser {
  --gallery-gap: 1rem;
  --gallery-radius: var(--sp-radius-lg, 1.5rem);
  --gallery-zoom: 1.07;
  --gallery-ring: rgba(14, 165, 233, 0.42);
}

.section-gallery-page {
  padding: var(--sp-section-y, 5rem) 0 calc(var(--sp-section-y, 5rem) + 1.5rem);
}

.section-gallery-teaser {
  position: relative;
  overflow: hidden;
  color: var(--sp-text);
  background:
    radial-gradient(ellipse 70% 50% at 8% 0%, rgba(14, 165, 233, 0.1), transparent 55%),
    radial-gradient(ellipse 55% 45% at 96% 100%, rgba(245, 158, 11, 0.08), transparent 50%),
    transparent;
}

.section-gallery-teaser > .container {
  position: relative;
  z-index: 1;
}

.section-gallery-teaser .section-eyebrow {
  color: var(--sp-primary);
}

.section-gallery-teaser .section-title {
  color: var(--sp-dark);
}

.section-gallery-teaser .section-subtitle {
  color: var(--sp-text-muted);
  max-width: 40rem;
}

.section-gallery-teaser__actions {
  margin-top: 2.25rem;
  padding-bottom: 0.25rem;
}

.section-gallery-teaser__actions .btn-sp {
  text-decoration: none;
}

/* ── Page intro ──────────────────────────────────────────────────────────── */

.section-gallery-page .gallery-page-intro {
  max-width: 42rem;
  margin: 0 auto 2.5rem;
  padding-top: 0.25rem;
  text-align: center;
}

.section-gallery-page .gallery-page-intro__text {
  margin: 0;
  color: var(--sp-text-muted);
  font-size: 1.0625rem;
  line-height: 1.7;
}

.section-gallery-page .gallery-page-intro__text a {
  color: var(--sp-primary-dark, #0284c7);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(14, 165, 233, 0.35);
  text-underline-offset: 0.18em;
  transition: color var(--sp-transition-fast, 0.18s ease), text-decoration-color var(--sp-transition-fast, 0.18s ease);
}

.section-gallery-page .gallery-page-intro__text a:hover {
  color: var(--sp-primary);
  text-decoration-color: var(--sp-primary);
}

.section-gallery-page .gallery-page-empty {
  max-width: 36rem;
  margin: 0 auto;
  text-align: center;
  padding: 0.5rem 0 1rem;
}

.section-gallery-page .gallery-page-empty__text {
  margin: 0;
  color: var(--sp-text-muted);
  font-size: 1.0625rem;
  line-height: 1.7;
}

.section-gallery-page .gallery-page-empty__text a {
  color: var(--sp-primary-dark, #0284c7);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: rgba(14, 165, 233, 0.35);
  text-underline-offset: 0.18em;
}

/* ── Grids ───────────────────────────────────────────────────────────────── */

.section-gallery-page .gallery-page-grid,
.section-gallery-teaser .gallery-mosaic {
  display: grid;
  gap: var(--gallery-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.section-gallery-page .gallery-page-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-flow: dense;
}

.section-gallery-teaser .gallery-mosaic {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: dense;
}

.section-gallery-page .gallery-page-grid__item,
.section-gallery-teaser .gallery-mosaic__item {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: zoom-in;
  border-radius: var(--gallery-radius);
}

.section-gallery-page .gallery-page-grid__item--featured {
  grid-column: span 2;
  grid-row: span 2;
}

.section-gallery-teaser .gallery-mosaic__item--featured {
  grid-column: span 2;
  grid-row: span 2;
}

/* ── Media tiles ─────────────────────────────────────────────────────────── */

.section-gallery-page .gallery-mosaic__media,
.section-gallery-teaser .gallery-mosaic__media {
  position: relative;
  overflow: hidden;
  height: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--gallery-radius);
  background: var(--sp-surface-2, #e2e8f0);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: var(--sp-shadow-sm, 0 2px 8px rgba(15, 23, 42, 0.06));
  isolation: isolate;
  transition:
    transform var(--sp-transition, 0.35s ease),
    box-shadow var(--sp-transition, 0.35s ease),
    border-color var(--sp-transition, 0.35s ease);
}

.section-gallery-page .gallery-page-grid__item--featured .gallery-mosaic__media,
.section-gallery-teaser .gallery-mosaic__item--featured .gallery-mosaic__media {
  aspect-ratio: auto;
  min-height: 100%;
}

.section-gallery-page .gallery-mosaic__media::after,
.section-gallery-teaser .gallery-mosaic__media::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  z-index: 2;
}

.section-gallery-page .gallery-mosaic__media img,
.section-gallery-teaser .gallery-mosaic__media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.001);
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}

.section-gallery-page .gallery-mosaic__overlay,
.section-gallery-teaser .gallery-mosaic__overlay {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  gap: 0.3rem;
  padding: 1.1rem 1.15rem 1.05rem;
  background:
    linear-gradient(180deg, transparent 28%, rgba(2, 6, 23, 0.55) 72%, rgba(2, 6, 23, 0.88) 100%);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.35s var(--sp-ease-out, cubic-bezier(0.16, 1, 0.3, 1)),
    transform 0.35s var(--sp-ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.section-gallery-page .gallery-mosaic__zoom,
.section-gallery-teaser .gallery-mosaic__zoom {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.18);
  transform: scale(0.88);
  transition: transform 0.35s var(--sp-ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.section-gallery-page .gallery-mosaic__title,
.section-gallery-teaser .gallery-mosaic__title {
  color: #fff;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.section-gallery-page .gallery-mosaic__tag,
.section-gallery-teaser .gallery-mosaic__tag {
  display: inline-flex;
  align-items: center;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Hover / focus ───────────────────────────────────────────────────────── */

.section-gallery-page .gallery-page-grid__item:hover .gallery-mosaic__media,
.section-gallery-teaser .gallery-mosaic__item:hover .gallery-mosaic__media,
.section-gallery-page .gallery-page-grid__item:focus-visible .gallery-mosaic__media,
.section-gallery-teaser .gallery-mosaic__item:focus-visible .gallery-mosaic__media {
  transform: translateY(-4px);
  border-color: var(--gallery-ring);
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.16),
    0 0 0 1px rgba(14, 165, 233, 0.22);
}

.section-gallery-page .gallery-page-grid__item:hover .gallery-mosaic__media img,
.section-gallery-teaser .gallery-mosaic__item:hover .gallery-mosaic__media img,
.section-gallery-page .gallery-page-grid__item:focus-visible .gallery-mosaic__media img,
.section-gallery-teaser .gallery-mosaic__item:focus-visible .gallery-mosaic__media img {
  transform: scale(var(--gallery-zoom));
}

.section-gallery-page .gallery-page-grid__item:hover .gallery-mosaic__overlay,
.section-gallery-teaser .gallery-mosaic__item:hover .gallery-mosaic__overlay,
.section-gallery-page .gallery-page-grid__item:focus-visible .gallery-mosaic__overlay,
.section-gallery-teaser .gallery-mosaic__item:focus-visible .gallery-mosaic__overlay {
  opacity: 1;
  transform: translateY(0);
}

.section-gallery-page .gallery-page-grid__item:hover .gallery-mosaic__zoom,
.section-gallery-teaser .gallery-mosaic__item:hover .gallery-mosaic__zoom,
.section-gallery-page .gallery-page-grid__item:focus-visible .gallery-mosaic__zoom,
.section-gallery-teaser .gallery-mosaic__item:focus-visible .gallery-mosaic__zoom {
  transform: scale(1);
}

.section-gallery-page .gallery-page-grid__item:focus-visible,
.section-gallery-teaser .gallery-mosaic__item:focus-visible {
  outline: none;
}

.section-gallery-page .gallery-page-grid__item:focus-visible .gallery-mosaic__media,
.section-gallery-teaser .gallery-mosaic__item:focus-visible .gallery-mosaic__media {
  box-shadow: var(--sp-focus-ring, 0 0 0 3px rgba(14, 165, 233, 0.28)), 0 18px 40px rgba(15, 23, 42, 0.16);
}

/* ── Lightbox polish (existing markup) ───────────────────────────────────── */

.gallery-lightbox {
  background: rgba(2, 6, 23, 0.94);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.gallery-lightbox__image {
  border-radius: var(--gallery-radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.gallery-lightbox__caption {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.95rem;
}

.gallery-lightbox__close,
.gallery-lightbox__nav {
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.gallery-lightbox__close:hover,
.gallery-lightbox__close:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.28);
  transform: scale(1.06);
}

.gallery-lightbox__nav:hover,
.gallery-lightbox__nav:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-50%) scale(1.04);
}

.gallery-lightbox__close:focus-visible,
.gallery-lightbox__nav:focus-visible {
  outline: 2px solid var(--sp-primary, #0ea5e9);
  outline-offset: 3px;
}

/* ── Dark theme ──────────────────────────────────────────────────────────── */

html[data-site-theme="dark"] .section-gallery-page,
html[data-site-theme="dark"] .section-gallery-teaser {
  --gallery-ring: rgba(56, 189, 248, 0.5);
}

html[data-site-theme="dark"] .section-gallery-teaser {
  background:
    radial-gradient(ellipse 75% 55% at 12% 0%, rgba(56, 189, 248, 0.12), transparent 55%),
    radial-gradient(ellipse 50% 40% at 90% 100%, rgba(251, 191, 36, 0.08), transparent 48%),
    transparent;
}

html[data-site-theme="dark"] .section-gallery-teaser .section-title {
  color: var(--sp-text);
}

html[data-site-theme="dark"] .section-gallery-teaser .section-subtitle,
html[data-site-theme="dark"] .section-gallery-page .gallery-page-intro__text,
html[data-site-theme="dark"] .section-gallery-page .gallery-page-empty__text {
  color: var(--sp-text-muted);
}

html[data-site-theme="dark"] .section-gallery-page .gallery-page-intro__text a,
html[data-site-theme="dark"] .section-gallery-page .gallery-page-empty__text a {
  color: var(--sp-primary);
  text-decoration-color: rgba(56, 189, 248, 0.4);
}

html[data-site-theme="dark"] .section-gallery-page .gallery-mosaic__media,
html[data-site-theme="dark"] .section-gallery-teaser .gallery-mosaic__media {
  background: rgba(15, 23, 42, 0.65);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

html[data-site-theme="dark"] .section-gallery-page .gallery-mosaic__media::after,
html[data-site-theme="dark"] .section-gallery-teaser .gallery-mosaic__media::after {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

html[data-site-theme="dark"] .section-gallery-page .gallery-page-grid__item:hover .gallery-mosaic__media,
html[data-site-theme="dark"] .section-gallery-teaser .gallery-mosaic__item:hover .gallery-mosaic__media,
html[data-site-theme="dark"] .section-gallery-page .gallery-page-grid__item:focus-visible .gallery-mosaic__media,
html[data-site-theme="dark"] .section-gallery-teaser .gallery-mosaic__item:focus-visible .gallery-mosaic__media {
  border-color: rgba(56, 189, 248, 0.45);
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(56, 189, 248, 0.28);
}

html[data-site-theme="dark"] .section-gallery-page .gallery-mosaic__zoom,
html[data-site-theme="dark"] .section-gallery-teaser .gallery-mosaic__zoom {
  background: rgba(15, 23, 42, 0.78);
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28);
}

html[data-site-theme="dark"] .section-gallery-teaser__actions .btn-sp-primary {
  color: #fff;
}

/* ── Breakpoints ─────────────────────────────────────────────────────────── */

@media (max-width: 1199.98px) {
  .section-gallery-page .gallery-page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .section-gallery-teaser .gallery-mosaic {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 991.98px) {
  .section-gallery-page .gallery-page-grid,
  .section-gallery-teaser .gallery-mosaic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
  }

  .section-gallery-page .gallery-page-grid__item--featured,
  .section-gallery-teaser .gallery-mosaic__item--featured {
    grid-column: span 2;
    grid-row: span 1;
  }

  .section-gallery-page .gallery-page-grid__item--featured .gallery-mosaic__media,
  .section-gallery-teaser .gallery-mosaic__item--featured .gallery-mosaic__media {
    aspect-ratio: 16 / 9;
  }
}

@media (max-width: 575.98px) {
  .section-gallery-page .gallery-page-grid,
  .section-gallery-teaser .gallery-mosaic {
    grid-template-columns: 1fr;
  }

  .section-gallery-page .gallery-page-grid__item--featured,
  .section-gallery-teaser .gallery-mosaic__item--featured {
    grid-column: span 1;
    grid-row: span 1;
  }

  .section-gallery-page .gallery-page-grid__item--featured .gallery-mosaic__media,
  .section-gallery-teaser .gallery-mosaic__item--featured .gallery-mosaic__media {
    aspect-ratio: 4 / 3;
  }

  .section-gallery-page .gallery-page-intro {
    margin-bottom: 1.75rem;
  }
}

@media (hover: none) {
  .section-gallery-page .gallery-mosaic__overlay,
  .section-gallery-teaser .gallery-mosaic__overlay {
    opacity: 1;
    transform: none;
    background: linear-gradient(180deg, transparent 42%, rgba(2, 6, 23, 0.82) 100%);
  }

  .section-gallery-page .gallery-mosaic__zoom,
  .section-gallery-teaser .gallery-mosaic__zoom {
    transform: none;
    width: 2.1rem;
    height: 2.1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .section-gallery-page .gallery-mosaic__media,
  .section-gallery-teaser .gallery-mosaic__media,
  .section-gallery-page .gallery-mosaic__media img,
  .section-gallery-teaser .gallery-mosaic__media img,
  .section-gallery-page .gallery-mosaic__overlay,
  .section-gallery-teaser .gallery-mosaic__overlay,
  .section-gallery-page .gallery-mosaic__zoom,
  .section-gallery-teaser .gallery-mosaic__zoom,
  .gallery-lightbox__close,
  .gallery-lightbox__nav {
    transition: none;
  }

  .section-gallery-page .gallery-page-grid__item:hover .gallery-mosaic__media,
  .section-gallery-teaser .gallery-mosaic__item:hover .gallery-mosaic__media,
  .section-gallery-page .gallery-page-grid__item:hover .gallery-mosaic__media img,
  .section-gallery-teaser .gallery-mosaic__item:hover .gallery-mosaic__media img {
    transform: none;
  }
}
