.gallery-page {
  --gallery-bg: none;
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  padding: 0;
  background: #0e1918 var(--gallery-bg) center center / cover no-repeat;
  color: #ffffff;
  overflow: hidden;
  isolation: isolate;
}

.gallery-page::before,
.gallery-page::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.gallery-page::before {
  background: var(--gallery-bg) center center / cover no-repeat;
  filter: blur(1.5px);
  transform: scale(1.03);
  opacity: 0.86;
}

.gallery-page::after {
  z-index: -1;
  background:
    linear-gradient(180deg, rgba(4, 16, 17, 0.46) 0%, rgba(4, 16, 17, 0.24) 36%, rgba(4, 16, 17, 0.58) 100%),
    radial-gradient(circle at 50% 48%, rgba(4, 16, 17, 0.03) 0%, rgba(4, 16, 17, 0.48) 100%);
}

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

.project-gallery {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  width: 100%;
  display: flex;
  align-items: center;
  padding: clamp(105px, 12vh, 160px) 0 clamp(72px, 10vh, 125px);
  overflow: hidden;
}

.project-gallery__viewport {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: visible;
  scroll-behavior: smooth;
  -ms-overflow-style: none;
  scrollbar-width: none;
  padding: clamp(8px, 1.4vw, 18px) 0 clamp(44px, 5vw, 72px);
}

.project-gallery__viewport::-webkit-scrollbar {
  display: none;
}

.project-gallery__track {
  display: flex;
  align-items: flex-start;
  gap: clamp(18px, 2.15vw, 34px);
  min-width: max-content;
  padding: 0 max(clamp(56px, 12vw, 220px), calc((100vw - clamp(520px, 49vw, 820px)) / 2));
  will-change: transform;
}

.project-gallery.has-expanded-card .project-gallery__track {
  padding-left: max(clamp(56px, 12vw, 220px), calc((100vw - clamp(520px, 49vw, 820px)) / 2));
  padding-right: max(clamp(56px, 12vw, 220px), calc((100vw - clamp(520px, 49vw, 820px)) / 2));
}

.project-gallery-card {
  position: relative;
  flex: 0 0 clamp(205px, 22vw, 320px);
  background: transparent;
  color: #fff;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transform-origin: center center;
  transition:
    flex-basis 850ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 850ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 850ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 350ms ease;
  will-change: flex-basis, transform;
}

.project-gallery-card.is-expanded {
  flex-basis: clamp(520px, 49vw, 820px);
  z-index: 20;
  transform: translateY(-8px);
}

.project-gallery-card__media {
  position: relative;
  display: block;
  width: 100%;
  height: clamp(250px, 30vw, 430px);
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.18);
  transition:
    height 850ms cubic-bezier(0.22, 1, 0.36, 1),
    border-radius 850ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 850ms cubic-bezier(0.22, 1, 0.36, 1);
}

.project-gallery-card.is-expanded .project-gallery-card__media {
  height: clamp(280px, 33vw, 520px);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.28);
}

.project-gallery-card__media::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 46%;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.42) 100%);
  opacity: 0.82;
}

.project-gallery-card__media picture,
.project-gallery-card__media img,
.project-gallery-card__media video {
  display: block;
  width: 100%;
  height: 100%;
}

.project-gallery-card__media img,
.project-gallery-card__media video {
  object-fit: cover;
  transform: scale(1.02);
  transition: transform 1100ms cubic-bezier(0.22, 1, 0.36, 1), filter 1100ms cubic-bezier(0.22, 1, 0.36, 1);
  user-select: none;
  -webkit-user-drag: none;
}

.project-gallery-card:hover .project-gallery-card__media img,
.project-gallery-card:hover .project-gallery-card__media video,
.project-gallery-card.is-expanded .project-gallery-card__media img,
.project-gallery-card.is-expanded .project-gallery-card__media video {
  transform: scale(1.06);
}

.project-gallery-card__content {
  position: relative;
  z-index: 4;
  margin-top: 12px;
  padding: 0 2px;
  color: #ffffff;
  pointer-events: auto;
  text-shadow: 0 10px 28px rgba(0, 0, 0, 0.44);
}

.project-gallery-card__content h2 {
  margin: 0;
  font-family: 'PolySans-Median', 'Montserrat', Arial, sans-serif;
  font-weight: 700;
  font-style: normal;
  font-size: clamp(17px, 1.55vw, 25px);
  line-height: 1;
  letter-spacing: -0.045em;
}

.project-gallery-card__content p {
  margin: 5px 0 0;
  max-width: 440px;
  font-family: 'PolySans-Median', 'Montserrat', Arial, sans-serif;
  //font-weight: 700;
  font-size: clamp(11px, 0.95vw, 15px);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.project-gallery-card__close {
  position: absolute;
  top: 13px;
  right: 13px;
  z-index: 40;
  width: 38px;
  height: 38px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: rgba(18, 18, 18, 0.78);
  color: #fff;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
  transform: translateZ(0);
  transition: background 180ms ease, transform 180ms ease;
}

.project-gallery-card.is-expanded .project-gallery-card__close {
  display: flex;
}

.project-gallery-card__close:hover {
  background: rgba(18, 18, 18, 0.96);
  transform: scale(1.05);
}

.project-gallery__arrow {
  position: absolute;
  top: 50%;
  z-index: 50;
  width: clamp(58px, 7vw, 94px);
  height: clamp(90px, 11vw, 150px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #ffffff;
  cursor: pointer;
  transform: translateY(-50%);
  opacity: 0.92;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.project-gallery__arrow:hover {
  opacity: 1;
}

.project-gallery__arrow--left {
  left: clamp(10px, 2.5vw, 36px);
}

.project-gallery__arrow--right {
  right: clamp(10px, 2.5vw, 36px);
}

.project-gallery__arrow span {
  width: clamp(42px, 5vw, 72px);
  height: clamp(42px, 5vw, 72px);
  display: block;
  border-top: 4px solid currentColor;
  border-left: 4px solid currentColor;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.42));
}

.project-gallery__arrow--left span {
  transform: rotate(-45deg);
}

.project-gallery__arrow--right span {
  transform: rotate(135deg);
}

.project-gallery__arrow--left:hover {
  transform: translateY(-50%) translateX(-4px);
}

.project-gallery__arrow--right:hover {
  transform: translateY(-50%) translateX(4px);
}

.project-gallery--empty {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  align-items: center;
  font-family: 'PolySans-Median', 'Montserrat', Arial, sans-serif;
  color: #fff;
}

.project-gallery--empty p {
  padding: 28px 32px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.34);
}

@media (max-width: 1024px) {
  .project-gallery {
    padding-top: 105px;
    padding-bottom: 68px;
  }

  .project-gallery__track {
    gap: 18px;
    padding: 0 92px;
  }

  .project-gallery.has-expanded-card .project-gallery__track {
    padding-left: max(92px, calc((100vw - min(82vw, 620px)) / 2));
    padding-right: max(92px, calc((100vw - min(82vw, 620px)) / 2));
  }

  .project-gallery-card {
    flex-basis: min(58vw, 310px);
  }

  .project-gallery-card.is-expanded {
    flex-basis: min(82vw, 620px);
  }

  .project-gallery-card__media,
  .project-gallery-card.is-expanded .project-gallery-card__media {
    height: min(70vw, 520px);
  }

  .project-gallery__arrow {
    width: 58px;
  }

  .project-gallery__arrow span {
    width: 42px;
    height: 42px;
    border-width: 3px;
  }
}

@media (max-width: 640px) {
  .gallery-page {
    overflow-y: auto;
  }

  .project-gallery {
    min-height: 100svh;
    padding-top: 96px;
    padding-bottom: 54px;
  }

  .project-gallery__viewport {
    padding-bottom: 48px;
  }

  .project-gallery__track {
    gap: 16px;
    padding: 0 70px;
  }

  .project-gallery-card,
  .project-gallery-card.is-expanded {
    flex-basis: 72vw;
  }

  .project-gallery-card__media,
  .project-gallery-card.is-expanded .project-gallery-card__media {
    height: 92vw;
    max-height: 560px;
  }

  .project-gallery-card.is-expanded {
    transform: translateY(-4px);
  }

  .project-gallery-card__content h2 {
    font-size: 19px;
  }

  .project-gallery-card__content p {
    font-size: 12px;
  }

  .project-gallery__arrow {
    width: 46px;
    height: 90px;
  }

  .project-gallery__arrow--left {
    left: 8px;
  }

  .project-gallery__arrow--right {
    right: 8px;
  }

  .project-gallery__arrow span {
    width: 34px;
    height: 34px;
    border-width: 3px;
  }
}

/* Mobile layout matching the Leapmotor reference */
.gallery-page {
  --gallery-bg-mobile: var(--gallery-bg);
}

@media (max-width: 640px) {
  .gallery-page {
    min-height: 100vh;
    min-height: 100svh;
    overflow: hidden;
    background: #0e1918 var(--gallery-bg-mobile) center top / cover no-repeat;
  }

  .gallery-page::before {
    background: var(--gallery-bg-mobile) center top / cover no-repeat;
    filter: none;
    transform: scale(1.015);
    opacity: 0.92;
  }

  .gallery-page::after {
    background:
      linear-gradient(180deg, rgba(5, 31, 35, 0.26) 0%, rgba(5, 31, 35, 0.36) 43%, rgba(5, 31, 35, 0.64) 100%),
      radial-gradient(circle at 50% 50%, rgba(3, 18, 20, 0.02) 0%, rgba(3, 18, 20, 0.38) 100%);
  }

  .project-gallery {
    min-height: 100vh;
    min-height: 100svh;
    align-items: center;
    padding: 0;
    overflow: hidden;
  }

  .project-gallery__viewport {
    padding: 0 0 54px;
    overflow-x: auto;
    overflow-y: visible;
  }

  .project-gallery__track {
    gap: 16px;
    padding: 0 22vw;
    align-items: flex-start;
  }

  .project-gallery.has-expanded-card .project-gallery__track {
    padding-left: 24px;
    padding-right: 24px;
  }

  .project-gallery-card {
    flex-basis: min(59vw, 360px);
    border-radius: 10px;
    transform: none;
  }

  .project-gallery-card.is-expanded {
    flex-basis: calc(100vw - 48px);
    max-width: 560px;
    transform: translateY(-2px);
    z-index: 30;
  }

  .project-gallery-card__media {
    height: min(68vw, 410px);
    border-radius: 10px;
    box-shadow: 0 22px 70px rgba(0, 0, 0, 0.22);
  }

  .project-gallery-card.is-expanded .project-gallery-card__media {
    height: min(69vw, 420px);
    border-radius: 10px;
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.24);
  }

  .project-gallery-card__media::after {
    height: 42%;
    opacity: 0.74;
  }

  .project-gallery-card__content {
    margin-top: 10px;
    padding: 0 0 0 1px;
    text-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  }

  .project-gallery-card__content h2 {
    font-size: clamp(18px, 4.7vw, 22px);
    line-height: 1.02;
    letter-spacing: -0.035em;
  }

  .project-gallery-card__content p {
    margin-top: 4px;
    font-size: clamp(11px, 3vw, 13px);
    line-height: 1.08;
  }

  .project-gallery-card__close {
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    font-size: 22px;
  }

  .project-gallery__arrow {
    display: none;
  }
}

@media (max-width: 420px) {
  .project-gallery__track {
    gap: 14px;
    padding: 0 20vw;
  }

  .project-gallery.has-expanded-card .project-gallery__track {
    padding-left: 16px;
    padding-right: 16px;
  }

  .project-gallery-card {
    flex-basis: 62vw;
  }

  .project-gallery-card.is-expanded {
    flex-basis: calc(100vw - 32px);
  }

  .project-gallery-card__media {
    height: 72vw;
  }

  .project-gallery-card.is-expanded .project-gallery-card__media {
    height: 72vw;
  }
}

/* Final interaction layer: keeps arrows, wheel, drag and image expand clickable */
.project-gallery {
  pointer-events: auto !important;
}

.project-gallery__viewport {
  position: relative !important;
  overflow-x: auto !important;
  overflow-y: visible !important;
  scroll-behavior: auto !important;
  cursor: grab !important;
  touch-action: pan-y !important;
  overscroll-behavior: contain !important;
  z-index: 2 !important;
}

.project-gallery__viewport.is-dragging {
  cursor: grabbing !important;
}

.project-gallery__track {
  pointer-events: auto !important;
}

.project-gallery-card {
  pointer-events: auto !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
}

.project-gallery-card__media,
.project-gallery-card__media img,
.project-gallery-card__media picture,
.project-gallery-card__media video,
.project-gallery-card__content {
  pointer-events: none !important;
}

.project-gallery-card__close {
  pointer-events: auto !important;
  z-index: 999 !important;
  touch-action: manipulation !important;
}

.project-gallery__arrow {
  pointer-events: auto !important;
  z-index: 999 !important;
  touch-action: manipulation !important;
}

.project-gallery__arrow span {
  pointer-events: none !important;
}

.project-gallery-card.is-expanded {
  z-index: 60 !important;
}

@media (min-width: 641px) {
  .project-gallery__arrow {
    display: flex !important;
  }
}

@media (max-width: 640px) {
  .project-gallery-card__media,
  .project-gallery-card.is-expanded .project-gallery-card__media {
    pointer-events: none !important;
  }
}
/* Instagram link: keep the content layer clickable in every card state. */
.project-gallery-card__content {
  pointer-events: auto !important;
  position: relative !important;
  z-index: 80 !important;
}

.project-gallery-card__content a[href] {
  display: inline-block !important;
  position: relative !important;
  z-index: 90 !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
  user-select: auto !important;
  -webkit-user-select: auto !important;
}

.project-gallery-card.is-expanded .project-gallery-card__content,
.project-gallery-card.is-expanded .project-gallery-card__content a[href] {
  pointer-events: auto !important;
}


/* FINAL: separa completamente a zona que expande o card da zona do link. */
.project-gallery-card,
.project-gallery-card.is-expanded {
  cursor: default !important;
}

.project-gallery-card__media {
  position: relative !important;
  z-index: 1 !important;
  cursor: pointer !important;
  pointer-events: auto !important;
  touch-action: pan-y !important;
}

.project-gallery-card__content,
.project-gallery-card.is-expanded .project-gallery-card__content,
.project-gallery-card__content p {
  position: relative !important;
  z-index: 1000 !important;
  pointer-events: auto !important;
  cursor: default !important;
}

.project-gallery-card__instagram-link,
.project-gallery-card.is-expanded .project-gallery-card__instagram-link {
  position: relative !important;
  z-index: 1100 !important;
  display: inline-block !important;
  pointer-events: auto !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
  padding: 2px 0 6px !important;
}

.project-gallery-card__instagram-link::before {
  content: "";
  position: absolute;
  inset: -6px -10px;
  z-index: -1;
}

@media (max-width: 640px) {
  .project-gallery-card__media,
  .project-gallery-card.is-expanded .project-gallery-card__media {
    pointer-events: auto !important;
  }
}

/*
 * FIX: the fixed footer sits above the gallery (z-index: 9999) and its
 * transparent full-width box was intercepting clicks on card text when an
 * expanded card reaches the bottom of the viewport. Let clicks pass through
 * empty footer space while keeping the footer's own links clickable.
 */
.gallery-page ~ .site-footer {
  pointer-events: none !important;
}

.gallery-page ~ .site-footer a,
.gallery-page ~ .site-footer button {
  pointer-events: auto !important;
}
