.gallery-page-hero {
  align-items: center;
  gap: clamp(2rem, 4vw, 4.25rem);
}

.gallery-page-hero .hero-copy {
  max-width: 34rem;
}

.gallery-hero-strip {
  justify-self: stretch;
  min-width: 0;
}

.gallery-hero-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.gallery-hero-label span {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 700;
}

.gallery-hero-label strong {
  color: var(--ink);
  font-weight: 600;
}

.gallery-hero-window {
  position: relative;
  overflow: hidden;
  padding: 1rem;
  border-radius: calc(var(--radius) + 10px);
  border: 1px solid rgba(255, 255, 255, 0.38);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 251, 245, 0.2)),
    linear-gradient(135deg, rgba(184, 132, 69, 0.16), rgba(32, 55, 47, 0.08));
  box-shadow:
    0 28px 90px rgba(16, 20, 17, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  isolation: isolate;
}

.gallery-hero-window::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(239, 230, 216, 0.96), transparent 14%, transparent 86%, rgba(239, 230, 216, 0.96)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 40%);
  pointer-events: none;
  z-index: 1;
}

.gallery-hero-track {
  --gallery-track-gap: 1rem;
  position: relative;
  z-index: 0;
  display: flex;
  gap: var(--gallery-track-gap);
  width: max-content;
  animation: gallery-runway 58s linear infinite;
  will-change: transform;
}

.gallery-hero-track:hover,
.gallery-hero-track:focus-within {
  animation-play-state: paused;
}

.gallery-hero-track-group {
  display: flex;
  gap: var(--gallery-track-gap);
}

.gallery-hero-track-group[aria-hidden="true"] {
  pointer-events: none;
}

.gallery-hero-card,
.gallery-tile {
  position: relative;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: calc(var(--radius) - 8px);
  background: rgba(255, 255, 255, 0.24);
  cursor: pointer;
}

.gallery-hero-card {
  flex: 0 0 auto;
  width: clamp(180px, 19vw, 250px);
  aspect-ratio: 0.76;
  box-shadow:
    0 18px 42px rgba(16, 20, 17, 0.16),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
  transition:
    transform 220ms ease,
    box-shadow 220ms ease,
    filter 220ms ease;
}

.gallery-hero-card:nth-child(odd) {
  animation: gallery-float 7s ease-in-out infinite alternate;
}

.gallery-hero-card:nth-child(even) {
  animation: gallery-float 9s ease-in-out infinite alternate-reverse;
}

.gallery-hero-card:hover,
.gallery-hero-card:focus-visible,
.gallery-tile:hover,
.gallery-tile:focus-visible {
  transform: translateY(-4px);
  box-shadow:
    0 26px 58px rgba(16, 20, 17, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.36);
}

.gallery-hero-card::after,
.gallery-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), transparent 28%, rgba(16, 20, 17, 0.12)),
    linear-gradient(120deg, rgba(255, 255, 255, 0.16), transparent 34%);
  pointer-events: none;
}

.gallery-hero-card img,
.gallery-tile img,
.gallery-detail-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-hero-card[data-orientation="portrait"] img,
.gallery-tile[data-orientation="portrait"] img,
.gallery-detail-media[data-orientation="portrait"] img {
  object-position: center 28%;
}

.gallery-hero-card[data-orientation="landscape"] img,
.gallery-tile[data-orientation="landscape"] img,
.gallery-detail-media[data-orientation="landscape"] img {
  object-position: center center;
}

.gallery-stage {
  width: min(1280px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 1.5rem) 0 clamp(4rem, 8vw, 6rem);
}

.gallery-inline {
  display: grid;
  gap: 1.15rem;
  margin-top: 2rem;
}

.gallery-hero-window-inline {
  padding: 0.9rem;
}

.gallery-mosaic {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
}

.gallery-tile {
  grid-column: span 3;
  aspect-ratio: 0.78;
  box-shadow:
    0 20px 46px rgba(16, 20, 17, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transition:
    transform 220ms ease,
    box-shadow 220ms ease,
    outline-color 220ms ease;
  outline: 1px solid rgba(255, 255, 255, 0.2);
  outline-offset: -1px;
}

.gallery-tile[data-orientation="landscape"] {
  grid-column: span 4;
  aspect-ratio: 1.18;
}

.gallery-tile[data-featured="true"] {
  grid-column: span 4;
  aspect-ratio: 0.9;
}

.gallery-tile.is-active {
  outline: 2px solid rgba(184, 132, 69, 0.52);
  outline-offset: -2px;
  box-shadow:
    0 28px 64px rgba(16, 20, 17, 0.16),
    0 0 0 1px rgba(184, 132, 69, 0.22);
}

.gallery-empty {
  grid-column: 1 / -1;
  padding: 2rem;
  border-radius: calc(var(--radius) - 6px);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(16, 20, 17, 0.08);
}

.gallery-empty h3 {
  margin: 0 0 0.7rem;
  font-size: 1.4rem;
}

.gallery-empty p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.gallery-detail {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  align-items: stretch;
  justify-items: end;
  padding: 1rem;
}

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

.gallery-detail-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(184, 132, 69, 0.18), transparent 24%),
    linear-gradient(180deg, rgba(9, 10, 9, 0.54), rgba(9, 10, 9, 0.7));
  backdrop-filter: blur(14px) saturate(120%);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  opacity: 0;
  transition: opacity 220ms ease;
}

.gallery-detail-panel {
  position: relative;
  width: min(620px, calc(100vw - 1rem));
  height: calc(100dvh - 2rem);
  border-radius: calc(var(--radius) + 6px);
  border: 1px solid rgba(255, 255, 255, 0.42);
  background:
    linear-gradient(180deg, rgba(255, 252, 247, 0.96), rgba(245, 236, 224, 0.92)),
    linear-gradient(135deg, rgba(184, 132, 69, 0.12), rgba(32, 55, 47, 0.06));
  box-shadow:
    0 36px 110px rgba(16, 20, 17, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.82);
  transform: translate3d(1.3rem, 0, 0);
  opacity: 0;
  transition:
    transform 260ms ease,
    opacity 220ms ease;
  overflow: hidden;
}

.gallery-detail.is-open .gallery-detail-backdrop {
  opacity: 1;
}

.gallery-detail.is-open .gallery-detail-panel {
  transform: translate3d(0, 0, 0);
  opacity: 1;
}

body.gallery-detail-open {
  overflow: hidden;
}

.gallery-detail-close {
  position: absolute;
  top: 0.9rem;
  right: 0.9rem;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid rgba(16, 20, 17, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background-color 180ms ease,
    border-color 180ms ease;
}

.gallery-detail-close:hover,
.gallery-detail-close:focus-visible {
  transform: translateY(-1px);
  background: #fffaf3;
  border-color: rgba(16, 20, 17, 0.2);
}

.gallery-detail-scroll {
  height: 100%;
  overflow: auto;
  padding: 1rem;
  scrollbar-gutter: stable;
}

.gallery-detail-stack {
  display: grid;
  gap: 1.1rem;
  padding-top: 2.8rem;
}

.gallery-detail-header {
  display: grid;
  gap: 0.65rem;
}

.gallery-detail-kicker {
  margin: 0;
  color: var(--accent-deep);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 0.74rem;
  font-weight: 700;
}

.gallery-detail-title {
  margin: 0;
  max-width: 11ch;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(2.2rem, 4.4vw, 3.5rem);
  line-height: 0.94;
  letter-spacing: -0.04em;
}

.gallery-detail-lead {
  margin: 0;
  max-width: 34rem;
  color: var(--muted);
  line-height: 1.65;
}

.gallery-detail-media {
  position: relative;
  border-radius: calc(var(--radius) - 6px);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.4);
  box-shadow: 0 20px 56px rgba(16, 20, 17, 0.12);
}

.gallery-detail-media img {
  aspect-ratio: 0.96;
}

.gallery-detail-copy {
  display: grid;
  gap: 1rem;
}

.gallery-detail-empty {
  min-height: 100%;
  display: grid;
  place-content: center start;
  gap: 1rem;
  padding: 3rem 0.35rem 2rem;
}

.gallery-detail-empty h2 {
  margin: 0;
  max-width: 10ch;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  font-size: clamp(2rem, 4vw, 3.15rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.gallery-detail-empty p {
  margin: 0;
  max-width: 28rem;
  color: var(--muted);
  line-height: 1.65;
}

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

@keyframes gallery-runway {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(calc(-50% - 0.5rem), 0, 0);
  }
}

@keyframes gallery-float {
  from {
    transform: translate3d(0, 0, 0);
  }

  to {
    transform: translate3d(0, -8px, 0);
  }
}

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

  .gallery-hero-strip {
    justify-self: stretch;
  }

  .gallery-mosaic {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .gallery-tile {
    grid-column: span 4;
  }

  .gallery-tile[data-orientation="landscape"],
  .gallery-tile[data-featured="true"] {
    grid-column: span 8;
  }
}

@media (max-width: 820px) {
  .gallery-page-hero {
    min-height: auto;
    padding-top: 5.75rem;
  }

  .gallery-hero-label {
    flex-direction: column;
    align-items: flex-start;
  }

  .gallery-hero-window {
    overflow: hidden;
    padding: 0.85rem;
  }

  .gallery-hero-window::before {
    display: none;
  }

  .gallery-hero-track {
    animation: gallery-runway 72s linear infinite;
  }

  .gallery-hero-track-group[aria-hidden="true"] {
    display: flex;
  }

  .gallery-hero-card {
    width: clamp(156px, 44vw, 220px);
  }

  .gallery-hero-card:nth-child(odd),
  .gallery-hero-card:nth-child(even) {
    animation: none;
  }

  .gallery-stage {
    width: min(100vw - 0.85rem, 1280px);
  }

  .gallery-mosaic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .gallery-tile,
  .gallery-tile[data-orientation="landscape"],
  .gallery-tile[data-featured="true"] {
    grid-column: span 1;
    aspect-ratio: 0.78;
  }

  .gallery-detail {
    padding: 0.45rem;
    align-items: end;
    justify-items: stretch;
  }

  .gallery-detail-panel {
    width: 100%;
    height: min(88dvh, 54rem);
    border-radius: 28px 28px 20px 20px;
    transform: translate3d(0, 1rem, 0);
  }

  .gallery-detail-backdrop {
    background:
      radial-gradient(circle at 18% 16%, rgba(184, 132, 69, 0.24), transparent 24%),
      linear-gradient(180deg, rgba(9, 10, 9, 0.66), rgba(9, 10, 9, 0.78));
  }

  .gallery-detail-scroll {
    padding: 0.9rem;
  }

  .gallery-detail-stack {
    padding-top: 2.6rem;
  }

  .gallery-detail-title,
  .gallery-detail-empty h2 {
    max-width: 12ch;
    font-size: clamp(1.9rem, 9vw, 2.6rem);
  }

  .gallery-detail-lead,
  .gallery-detail-empty p {
    font-size: 0.97rem;
    line-height: 1.58;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-hero-track,
  .gallery-hero-card:nth-child(odd),
  .gallery-hero-card:nth-child(even) {
    animation: none;
  }
}
