/* ============ Liquid page transition ============ */

.page-transition {
  position: fixed;
  inset: 0;
  z-index: 5000;
  pointer-events: none;
  opacity: 1;
  background:
    radial-gradient(120% 90% at 50% 110%, rgba(204, 0, 17, 0.14), transparent 60%),
    rgba(5, 5, 7, 0.55);
  backdrop-filter: blur(36px) saturate(170%);
  -webkit-backdrop-filter: blur(36px) saturate(170%);
  transition:
    opacity 0.55s var(--ease-out),
    backdrop-filter 0.55s var(--ease-out),
    -webkit-backdrop-filter 0.55s var(--ease-out);
}

body.page-entered .page-transition {
  opacity: 0;
  backdrop-filter: blur(0px) saturate(100%);
  -webkit-backdrop-filter: blur(0px) saturate(100%);
}

body.page-leaving .page-transition {
  opacity: 1;
  backdrop-filter: blur(36px) saturate(170%);
  -webkit-backdrop-filter: blur(36px) saturate(170%);
  transition-duration: 0.45s;
}

/* page content gently sinks away as the glass floods in */
body > header,
body > main,
body > section,
body > .footer {
  transition:
    transform 0.5s var(--ease-out),
    opacity 0.5s ease,
    filter 0.5s ease;
}

body.page-leaving > header,
body.page-leaving > main,
body.page-leaving > section,
body.page-leaving > .footer {
  transform: scale(0.975) translateY(10px);
  opacity: 0.55;
}

/* arriving content rises softly out of the blur */
body.has-pt:not(.page-entered):not(.page-leaving) > header,
body.has-pt:not(.page-entered):not(.page-leaving) > main,
body.has-pt:not(.page-entered):not(.page-leaving) > section,
body.has-pt:not(.page-entered):not(.page-leaving) > .footer {
  transform: scale(0.985) translateY(14px);
  opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
  .page-transition {
    display: none;
  }
}

/* ============ Gallery button (home page, work section) ============ */

.work-gallery-cta {
  display: flex;
  justify-content: center;
  padding: 0 clamp(28px, 5vw, 64px) 96px;
  margin-top: -8px;
}

.gallery-btn {
  padding: 16px 34px;
  font-size: 16px;
  gap: 12px;
}

.gallery-btn svg {
  width: 19px;
  height: 19px;
  transition: transform 0.35s var(--ease-spring);
}

.gallery-btn .gallery-btn-arrow {
  width: 17px;
  height: 17px;
  transition: transform 0.3s var(--ease-out);
}

.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform 0.35s var(--ease-spring);
}

.btn-icon-lead:hover .btn-icon {
  transform: scale(1.15) rotate(-8deg);
}

.gallery-btn:hover svg {
  transform: rotate(90deg) scale(1.1);
}

.gallery-btn:hover .gallery-btn-arrow {
  transform: translateX(5px);
}

.gallery-btn::after {
  content: "";
  position: absolute;
  top: 0;
  left: -120%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.18) 45%,
    transparent 100%
  );
  transform: skewX(-18deg);
  pointer-events: none;
  transition: left 0.6s var(--ease-out);
}

.gallery-btn:hover::after {
  left: 130%;
}

.nav-gallery-link.is-current {
  color: var(--accent-bright);
}

/* ============ Gallery page ============ */

.gallery-page {
  min-height: 100vh;
  padding: calc(var(--nav-h) + clamp(48px, 8vw, 96px)) clamp(20px, 4vw, 56px) 40px;
  max-width: 1520px;
  margin: 0 auto;
}

.gallery-hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: clamp(48px, 6vw, 80px);
}

.gallery-badge {
  color: rgba(255, 255, 255, 0.9);
}

.gallery-headline {
  font-family: var(--font-display);
  font-size: clamp(3rem, 8vw, 5.5rem);
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: var(--white);
}

.gallery-headline em {
  font-style: italic;
  background: linear-gradient(120deg, #ff5866, var(--accent-bright) 45%, #ff8a94);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.gallery-sub {
  max-width: 560px;
  font-size: clamp(1rem, 1.4vw, 1.12rem);
  line-height: 1.65;
  color: var(--text-muted);
}

.gallery-count {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.gallery-count:empty {
  display: none;
}

/* ---- Grid ---- */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: clamp(16px, 2.2vw, 26px);
}

.gallery-card {
  position: relative;
  border-radius: var(--radius-lg);
  padding: 3px;
  aspect-ratio: 16 / 10;
  cursor: zoom-in;
  opacity: 0;
  transform: translateY(28px) scale(0.97);
  animation: gallery-card-in 0.7s var(--ease-out) forwards;
  animation-delay: calc(var(--stagger, 0) * 70ms);
  transition:
    transform 0.45s var(--ease-spring),
    box-shadow 0.45s ease;
  will-change: transform;
}

@keyframes gallery-card-in {
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.gallery-card img,
.gallery-card .placeholder-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--radius-lg) - 3px);
  transition: transform 0.6s var(--ease-out), filter 0.6s ease;
}

.gallery-card:hover,
.gallery-card:focus-visible {
  transform: translateY(-8px) scale(1.015);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 40px rgba(255, 42, 61, 0.12);
  z-index: 2;
}

.gallery-card:hover img {
  transform: scale(1.06);
  filter: brightness(1.06) saturate(1.06);
}

.gallery-card:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 3px;
}

/* liquid shine sweep on hover */
.gallery-card-shine {
  position: absolute;
  inset: 3px;
  border-radius: calc(var(--radius-lg) - 3px);
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.gallery-card-shine::before {
  content: "";
  position: absolute;
  top: -20%;
  left: -140%;
  width: 70%;
  height: 140%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.16) 45%,
    rgba(255, 255, 255, 0.05) 60%,
    transparent 100%
  );
  transform: skewX(-18deg);
  transition: left 0.75s var(--ease-out);
}

.gallery-card:hover .gallery-card-shine::before {
  left: 150%;
}

/* ---- Bottom actions ---- */

.gallery-back {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: clamp(56px, 7vw, 88px) 0 72px;
}

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

  .gallery-card {
    aspect-ratio: 16 / 10;
  }
}
