.gallery-page {
  overflow-x: hidden;
  background: var(--color-secondary-cream);
}

.gallery-hero .page-hero__image {
  object-position: 50% 59%;
}

.gallery-hero .page-hero__overlay {
  background: rgba(0, 0, 0, 0.1);
}

.gallery {
  position: relative;
  width: calc(100% - (var(--page-gutter) * 2));
  max-width: 1240px;
  margin: 110px auto var(--section-footer-gap);
  padding-top: 145px;
}

.gallery__record {
  position: absolute;
  top: 0;
  left: 50%;
  z-index: var(--z-base);
  width: 300px;
  height: 300px;
  transform: translate3d(-50%, 0, 0);
  transform-origin: 50% 50%;
  pointer-events: none;
  will-change: transform;
}

.gallery__record img {
  position: absolute;
  display: block;
}

.gallery__record img:nth-child(1) {
  inset: 0;
  width: 100%;
  height: 100%;
}

.gallery__record img:nth-child(2),
.gallery__record img:nth-child(3) {
  /* Percentages keep the exported record layers registered while the record scales responsively. */
  top: 1.47%;
  left: 1.47%;
  width: 97.06%;
  height: 97.06%;
}

.gallery__record img:nth-child(4) {
  top: 27.83%;
  left: 27.83%;
  width: 44.33%;
  height: 44.33%;
}

.gallery__record img:nth-child(5) {
  top: 32.95%;
  left: 32.95%;
  width: 34.09%;
  height: 34.09%;
}

.gallery__record img:nth-child(6) {
  top: 38.92%;
  left: 38.92%;
  width: 22.16%;
  height: 22.16%;
}

.gallery__panel {
  position: relative;
  z-index: var(--z-content);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 76px 0 40px;
  border-radius: var(--page-radius);
  background: var(--color-secondary-cream);
  box-shadow: 0 -12px 32px rgba(26, 26, 26, 0.025);
}

.gallery__tabs {
  position: relative;
  z-index: var(--z-cta);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-bottom: 30px;
}

.gallery__tab {
  padding: 0;
  border: 0;
  color: var(--color-secondary-sage);
  background: transparent;
  font-family: var(--font-family-heading);
  font-size: var(--font-size-heading-5);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-heading-5);
  cursor: pointer;
  transition: color 220ms ease;
}

.gallery__tab[aria-selected="true"],
.gallery__tab:is(:hover, :focus-visible) {
  color: var(--color-secondary-ink);
}

.gallery__tab:focus-visible {
  outline: 2px solid var(--color-primary-orange);
  outline-offset: 5px;
}

.gallery__grid {
  position: relative;
  z-index: var(--z-cta);
  display: flex;
  flex-direction: column;
  width: 100%;
  gap: 16px;
}

.gallery__row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.gallery__column {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 16px;
}

.gallery__extras {
  display: none;
}

.gallery__item {
  position: relative;
  display: block;
  width: 100%;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: var(--color-secondary-sage);
  transform: translateZ(0);
}

.gallery__item--short {
  height: 188px;
}

.gallery__item--square {
  height: 303px;
}

.gallery__item--tall {
  height: 418px;
}

.gallery__item img {
  display: block;
  /* Images must completely fill their fixed Figma crop frames. */
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 650ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery__item--crop-high img {
  object-position: 50% 27%;
}

.gallery__item--crop-center img {
  object-position: 50% 52%;
}

.gallery__item--crop-mid img {
  object-position: 50% 43%;
}

.gallery__item--crop-top img {
  object-position: 50% 22%;
}

.gallery__item--crop-wide img {
  width: calc(100% + 16px);
  max-width: none;
  margin-left: -8px;
}

.gallery__grid--fluid {
  display: grid;
  grid-auto-flow: dense;
  grid-auto-rows: 1px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  column-gap: 16px;
  row-gap: 0;
}

.gallery__grid--fluid .gallery__row,
.gallery__grid--fluid .gallery__column,
.gallery__grid--fluid .gallery__extras {
  display: contents;
}

.gallery__grid--fluid .gallery__item {
  margin-bottom: 16px;
}

.gallery__grid--fluid .gallery__item--short {
  grid-row-end: span 204;
}

.gallery__grid--fluid .gallery__item--square {
  grid-row-end: span 319;
}

.gallery__grid--fluid .gallery__item--tall {
  grid-row-end: span 434;
}

.gallery__item:is(:hover, :focus-visible) img {
  transform: scale(1.035);
}

.gallery__item:focus-visible {
  outline: 3px solid var(--color-primary-orange);
  outline-offset: 4px;
}

.gallery__item[hidden] {
  display: none;
}

.gallery__load-more {
  margin-top: 24px;
  font-family: var(--font-family-body);
  font-size: var(--font-size-body-16);
  font-weight: var(--font-weight-medium);
}

.gallery__load-more[hidden] {
  display: none;
}

.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-loader) + 1);
  display: grid;
  place-items: center;
  padding: 72px 96px;
}

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

.gallery-lightbox__backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(26, 26, 26, 0.9);
  cursor: zoom-out;
}

.gallery-lightbox__dialog {
  position: relative;
  z-index: var(--z-content);
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  width: 100%;
  max-width: 1380px;
  align-items: center;
  gap: 24px;
}

.gallery-lightbox__figure {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin: 0;
}

.gallery-lightbox__image {
  display: block;
  max-width: 100%;
  /* Viewport-relative height keeps portrait and landscape media inside the modal. */
  max-height: calc(100dvh - 160px);
  border-radius: 10px;
  object-fit: contain;
}

.gallery-lightbox__caption {
  color: var(--color-secondary-cream);
  font-family: var(--font-family-body);
  font-size: var(--font-size-body-16);
  line-height: var(--line-height-body-16);
  text-align: center;
}

.gallery-lightbox__close,
.gallery-lightbox__control {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 0;
  border-radius: var(--button-radius);
  color: var(--color-secondary-ink);
  background: var(--color-secondary-cream);
  font-family: var(--font-family-body);
  font-size: var(--font-size-hoss-24);
  cursor: pointer;
}

.gallery-lightbox__control {
  position: relative;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border: 2px solid rgba(238, 236, 229, 0.58);
  color: var(--color-secondary-cream);
  background: var(--color-primary-orange);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  font-size: 0;
  transition:
    color 240ms ease,
    background-color 240ms ease,
    border-color 240ms ease,
    box-shadow 240ms ease,
    transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-lightbox__control::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M12 19l-7-7 7-7'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.25' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 12H5M12 19l-7-7 7-7'/%3E%3C/svg%3E") center / contain no-repeat;
}

.gallery-lightbox__control--next::before {
  transform: scaleX(-1);
}

.gallery-lightbox__control:is(:hover, :focus-visible) {
  color: var(--color-secondary-ink);
  border-color: var(--color-primary-lime);
  background: var(--color-primary-lime);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.34),
    0 0 0 4px rgba(203, 255, 47, 0.14);
  transform: scale(1.08);
}

.gallery-lightbox__control:active {
  transform: scale(0.96);
}

.gallery-lightbox__close {
  position: absolute;
  top: -56px;
  right: 0;
}

.gallery-lightbox__close:focus-visible,
.gallery-lightbox__control:focus-visible {
  outline: 3px solid var(--color-primary-lime);
  outline-offset: 3px;
}

.gallery-lightbox__control--previous {
  grid-column: 1;
}

.gallery-lightbox__figure {
  grid-column: 2;
}

.gallery-lightbox__control--next {
  grid-column: 3;
}

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

@media (max-width: 1366px) {
  .gallery {
    max-width: 1140px;
    margin-top: 100px;
    padding-top: 136px;
  }

  .gallery__record {
    width: 280px;
    height: 280px;
  }

  .gallery__panel {
    padding-top: 72px;
  }
}

@media (max-width: 1280px) {
  .gallery {
    max-width: 1060px;
  }
}

@media (max-width: 1166px) {
  .gallery {
    margin-top: 90px;
    padding-top: 122px;
  }

  .gallery__record {
    width: 250px;
    height: 250px;
  }

  .gallery__panel {
    padding-top: 66px;
  }

  .gallery__grid {
    display: grid;
    grid-auto-flow: dense;
    grid-auto-rows: 1px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 14px;
    row-gap: 0;
  }

  .gallery__row,
  .gallery__column,
  .gallery__extras {
    display: contents;
  }

  .gallery__item {
    margin-bottom: 14px;
  }

  .gallery__item--short {
    height: 174px;
    grid-row-end: span 188;
  }

  .gallery__item--square {
    height: 272px;
    grid-row-end: span 286;
  }

  .gallery__item--tall {
    height: 370px;
    grid-row-end: span 384;
  }
}

@media (max-width: 768px) {
  .gallery {
    margin-top: 76px;
    padding-top: 103px;
  }

  .gallery__record {
    width: 212px;
    height: 212px;
  }

  .gallery__panel {
    padding: 58px 14px 30px;
    border-radius: 12px;
  }

  .gallery__tabs {
    gap: 22px;
    margin-bottom: 24px;
  }

  .gallery__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 12px;
  }

  .gallery__item {
    margin-bottom: 12px;
  }

  .gallery__item--short {
    height: 158px;
    grid-row-end: span 170;
  }

  .gallery__item--square {
    height: 238px;
    grid-row-end: span 250;
  }

  .gallery__item--tall {
    height: 318px;
    grid-row-end: span 330;
  }

  .gallery-lightbox {
    padding: 68px 20px 24px;
  }

  .gallery-lightbox__dialog {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    gap: 10px;
  }

  .gallery-lightbox__close {
    width: 42px;
    height: 42px;
  }

  .gallery-lightbox__control {
    width: 50px;
    height: 50px;
  }

  .gallery-lightbox__control::before {
    width: 21px;
    height: 21px;
  }

  .gallery-lightbox__close {
    top: -52px;
  }
}

@media (max-width: 480px) {
  .gallery {
    margin-top: 64px;
    padding-top: 84px;
  }

  .gallery__record {
    width: 174px;
    height: 174px;
  }

  .gallery__panel {
    padding: 50px 12px 26px;
  }

  .gallery__tabs {
    gap: 18px;
    margin-bottom: 20px;
  }

  .gallery__grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .gallery__item--short {
    height: 178px;
    grid-row-end: span 190;
  }

  .gallery__item--square {
    height: 268px;
    grid-row-end: span 280;
  }

  .gallery__item--tall {
    height: 358px;
    grid-row-end: span 370;
  }

  .gallery__load-more {
    margin-top: 18px;
  }

  .gallery-lightbox__dialog {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .gallery-lightbox__figure {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .gallery-lightbox__control--previous,
  .gallery-lightbox__control--next {
    grid-row: 2;
    justify-self: center;
  }

  .gallery-lightbox__control--previous {
    grid-column: 1;
  }

  .gallery-lightbox__control--next {
    grid-column: 2;
  }

  .gallery-lightbox__image {
    /* Viewport-relative height keeps the modal image within the visible dialog. */
    max-height: calc(100dvh - 190px);
  }
}

@media (max-width: 360px) {
  .gallery__tabs {
    gap: 14px;
  }

  .gallery__item--short {
    height: 158px;
    grid-row-end: span 170;
  }

  .gallery__item--square {
    height: 238px;
    grid-row-end: span 250;
  }

  .gallery__item--tall {
    height: 318px;
    grid-row-end: span 330;
  }
}

@media (min-width: 769px) and (max-height: 620px) {
  .gallery {
    margin-top: 70px;
  }
}

/* Keep responsive masonry spans authoritative when filters switch the grid to fluid mode. */
@media (max-width: 768px) {
  .gallery__grid--fluid .gallery__item--short {
    grid-row-end: span 170;
  }

  .gallery__grid--fluid .gallery__item--square {
    grid-row-end: span 250;
  }

  .gallery__grid--fluid .gallery__item--tall {
    grid-row-end: span 330;
  }
}

@media (max-width: 480px) {
  .gallery__grid--fluid .gallery__item--short {
    grid-row-end: span 190;
  }

  .gallery__grid--fluid .gallery__item--square {
    grid-row-end: span 280;
  }

  .gallery__grid--fluid .gallery__item--tall {
    grid-row-end: span 370;
  }
}

@media (max-width: 360px) {
  .gallery__grid--fluid .gallery__item--short {
    grid-row-end: span 170;
  }

  .gallery__grid--fluid .gallery__item--square {
    grid-row-end: span 250;
  }

  .gallery__grid--fluid .gallery__item--tall {
    grid-row-end: span 330;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery__record {
    will-change: auto;
  }

  .gallery__item img,
  .gallery__tab,
  .gallery-lightbox__control {
    transition: none;
  }

  .gallery__item:is(:hover, :focus-visible) img {
    transform: none;
  }

  .gallery-lightbox__control:is(:hover, :focus-visible, :active) {
    transform: none;
  }
}

/* Gallery lightbox record-arrow controls. */
.gallery-lightbox__control {
  width: 66px;
  height: 66px;
  overflow: visible;
  isolation: isolate;
  border: 2px solid var(--color-secondary-cream);
  border-radius: 50%;
  color: var(--color-secondary-cream);
  background: var(--color-primary-orange);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.34),
    inset 0 0 0 4px rgba(32, 59, 49, 0.14);
  transition:
    color 260ms ease,
    background-color 260ms ease,
    border-color 260ms ease,
    box-shadow 260ms ease,
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-lightbox__control::before,
.gallery-lightbox__control::after {
  content: none;
}

.gallery-lightbox__control-art,
.gallery-lightbox__control-art svg {
  display: block;
  width: 46px;
  height: 46px;
}

.gallery-lightbox__control-art {
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-lightbox__control--next .gallery-lightbox__control-art {
  transform: scaleX(-1);
}

.gallery-lightbox__control-groove {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  opacity: 0.22;
}

.gallery-lightbox__control-groove--inner {
  opacity: 0.12;
}

.gallery-lightbox__control-arrow {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gallery-lightbox__control-accent {
  fill: var(--color-primary-lime);
  stroke: var(--color-secondary-ink);
  stroke-width: 1;
}

.gallery-lightbox__control--previous:is(:hover, :focus-visible) {
  transform: translateX(-5px) scale(1.06);
}

.gallery-lightbox__control--next:is(:hover, :focus-visible) {
  transform: translateX(5px) scale(1.06);
}

.gallery-lightbox__control:is(:hover, :focus-visible) {
  color: var(--color-secondary-ink);
  border-color: var(--color-primary-lime);
  background: var(--color-primary-lime);
  box-shadow:
    0 16px 38px rgba(0, 0, 0, 0.38),
    0 0 0 5px rgba(203, 255, 47, 0.16),
    inset 0 0 0 4px rgba(255, 107, 26, 0.1);
}

.gallery-lightbox__control:is(:hover, :focus-visible) .gallery-lightbox__control-accent {
  fill: var(--color-primary-orange);
}

.gallery-lightbox__control--previous:is(:hover, :focus-visible) .gallery-lightbox__control-art {
  transform: translateX(-2px);
}

.gallery-lightbox__control--next:is(:hover, :focus-visible) .gallery-lightbox__control-art {
  transform: scaleX(-1) translateX(-2px);
}

.gallery-lightbox__control:active {
  transform: scale(0.96);
}

@media (max-width: 768px) {
  .gallery-lightbox__control {
    width: 56px;
    height: 56px;
  }

  .gallery-lightbox__control-art,
  .gallery-lightbox__control-art svg {
    width: 40px;
    height: 40px;
  }
}
