/* ============================================================
   THE TREE — Gallery page
   ============================================================ */

html,
body,
button,
input,
select,
textarea {
  font-family: "Assistant", Arial, sans-serif !important;
}

body[data-page="gallery"] {
  overflow-x: hidden;
  background: #faf7f0;
}

/* Hero */
body[data-page="gallery"] .page-hero {
  min-height: 360px;
}

body[data-page="gallery"] .page-hero img {
  transform: scale(1.015);
  filter: saturate(0.92) contrast(1.02);
}

body[data-page="gallery"] .page-hero .container-tree {
  padding-bottom: clamp(2.5rem, 6vw, 5rem);
}

body[data-page="gallery"] .page-hero h1 {
  font-family: "Assistant", Arial, sans-serif !important;
  font-size: clamp(3.3rem, 7vw, 6.6rem);
  font-weight: 700;
  letter-spacing: -0.05em;
}

/* Gallery section */
.gallery-section {
  position: relative;
  padding: clamp(4rem, 8vw, 7.5rem) 0;
  background:
    radial-gradient(circle at 88% 8%, rgba(221, 201, 163, 0.18), transparent 28rem),
    #faf7f0;
}

.gallery-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(17rem, 0.65fr);
  gap: 3rem;
  align-items: end;
  margin-bottom: clamp(2rem, 5vw, 3.75rem);
}

.gallery-intro .eyebrow {
  margin-bottom: 0.8rem;
}

.gallery-intro h2 {
  margin: 0;
  color: #221f1b;
  font-family: "Assistant", Arial, sans-serif !important;
  font-size: clamp(2.3rem, 5vw, 4.6rem);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.gallery-intro > p {
  margin: 0;
  color: rgba(34, 31, 27, 0.58);
  font-size: 1.04rem;
  line-height: 1.8;
}

.gallery-toolbar {
  position: sticky;
  top: 80px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin: 0 0 2rem;
  border: 1px solid rgba(34, 31, 27, 0.09);
  border-radius: 1rem;
  background: rgba(250, 247, 240, 0.93);
  padding: 0.8rem;
  box-shadow: 0 16px 36px -30px rgba(14, 32, 40, 0.45);
  backdrop-filter: blur(14px);
}

.gallery-filters {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.gallery-filter-button {
  min-height: 2.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(34, 31, 27, 0.13);
  border-radius: 999px;
  background: transparent;
  padding: 0.62rem 1.05rem;
  color: rgba(34, 31, 27, 0.68);
  font-size: 0.9rem;
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background-color 180ms ease,
    color 180ms ease;
}

.gallery-filter-button:hover {
  border-color: rgba(22, 48, 61, 0.45);
  color: #16303d;
  transform: translateY(-1px);
}

.gallery-filter-button.is-active,
.gallery-filter-button[aria-pressed="true"] {
  border-color: #16303d;
  background: #16303d;
  color: #faf7f0;
}

.gallery-filter-button:focus-visible {
  outline: 2px solid #16303d;
  outline-offset: 3px;
}

.gallery-results-status {
  flex: 0 0 auto;
  margin: 0;
  color: rgba(34, 31, 27, 0.48);
  font-size: 0.84rem;
  white-space: nowrap;
}

/* Masonry gallery */
.gallery-grid {
  columns: 3 18rem;
  column-gap: 1.15rem;
}

.gallery-card {
  width: 100%;
  display: inline-block;
  break-inside: avoid;
  margin: 0 0 1.15rem;
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity 650ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 650ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-card.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.gallery-card-button {
  position: relative;
  width: 100%;
  display: block;
  overflow: hidden;
  border: 0;
  border-radius: 1rem;
  background: #e9e1d3;
  padding: 0;
  cursor: zoom-in;
  box-shadow: 0 15px 40px -32px rgba(14, 32, 40, 0.6);
}

.gallery-card-button::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: inherit;
  pointer-events: none;
}

.gallery-card-media {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #e9e1d3;
}

.gallery-card-media img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.025);
  transition:
    opacity 420ms ease,
    transform 850ms cubic-bezier(0.22, 1, 0.36, 1);
}

.gallery-card-media img.is-loaded {
  opacity: 1;
}

.gallery-card-button:hover .gallery-card-media img {
  transform: scale(1.06);
}

.gallery-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(to top, rgba(8, 24, 30, 0.76), rgba(8, 24, 30, 0.03) 58%);
  padding: 1.25rem;
  opacity: 0;
  transition: opacity 300ms ease;
}

.gallery-card-button:hover .gallery-card-overlay,
.gallery-card-button:focus-visible .gallery-card-overlay {
  opacity: 1;
}

.gallery-card-copy {
  min-width: 0;
  text-align: right;
}

.gallery-card-copy strong {
  display: block;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.gallery-card-copy span {
  display: block;
  margin-top: 0.18rem;
  color: rgba(255, 255, 255, 0.66);
  font-size: 0.78rem;
}

.gallery-card-open {
  width: 2.65rem;
  height: 2.65rem;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  color: #fff;
  backdrop-filter: blur(10px);
}

.gallery-card-open svg {
  width: 1rem;
  height: 1rem;
}

/* Lightbox */
.gallery-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 280ms ease, visibility 280ms ease;
}

.gallery-lightbox.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.gallery-lightbox-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(5, 17, 21, 0.94);
  backdrop-filter: blur(12px);
}

.gallery-lightbox-dialog {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 4rem minmax(0, 1fr) 4rem;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0.75rem;
  align-items: center;
  padding: 1.25rem;
}

.gallery-lightbox-top {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: rgba(250, 247, 240, 0.62);
}

.gallery-lightbox-top p {
  margin: 0;
  font-size: 0.88rem;
}

.gallery-lightbox-close {
  position: relative;
  width: 2.8rem;
  height: 2.8rem;
  border: 1px solid rgba(250, 247, 240, 0.24);
  border-radius: 50%;
  background: rgba(250, 247, 240, 0.04);
  color: #fff;
  cursor: pointer;
}

.gallery-lightbox-close span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.1rem;
  height: 1px;
  background: currentColor;
}

.gallery-lightbox-close span:first-child {
  transform: translate(-50%, -50%) rotate(45deg);
}

.gallery-lightbox-close span:last-child {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.gallery-lightbox-figure {
  grid-column: 2;
  min-width: 0;
  max-width: 100%;
  max-height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.gallery-lightbox-figure img {
  max-width: 100%;
  max-height: min(76vh, 900px);
  display: block;
  object-fit: contain;
  border-radius: 0.7rem;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
}

.gallery-lightbox-figure figcaption {
  margin-top: 0.9rem;
  color: rgba(250, 247, 240, 0.72);
  font-size: 0.92rem;
  text-align: center;
}

.gallery-lightbox-arrow {
  width: 3.25rem;
  height: 3.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(250, 247, 240, 0.2);
  border-radius: 50%;
  background: rgba(250, 247, 240, 0.04);
  color: #fff;
  cursor: pointer;
  transition: background-color 180ms ease, transform 180ms ease;
}

.gallery-lightbox-arrow:hover {
  background: rgba(250, 247, 240, 0.1);
  transform: scale(1.04);
}

.gallery-lightbox-arrow svg {
  width: 1.5rem;
  height: 1.5rem;
}

.gallery-lightbox-prev {
  grid-column: 1;
}

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

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

@media (max-width: 900px) {
  .gallery-intro {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .gallery-toolbar {
    top: 80px;
    align-items: flex-start;
    flex-direction: column;
  }

  .gallery-results-status {
    white-space: normal;
  }

  .gallery-grid {
    columns: 2 15rem;
  }
}

@media (max-width: 560px) {
  body[data-page="gallery"] .page-hero {
    min-height: 300px;
  }

  .gallery-section {
    padding: 3.5rem 0 5rem;
  }

  .gallery-toolbar {
    position: relative;
    top: auto;
    border-radius: 0.85rem;
  }

  .gallery-filters {
    width: 100%;
  }

  .gallery-filter-button {
    flex: 1 1 calc(50% - 0.55rem);
    white-space: normal;
  }

  .gallery-grid {
    columns: 1;
  }

  .gallery-card {
    margin-bottom: 0.9rem;
  }

  .gallery-card-overlay {
    opacity: 1;
    padding: 1rem;
  }

  .gallery-lightbox-dialog {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding: 0.85rem;
  }

  .gallery-lightbox-top {
    grid-column: 1 / -1;
  }

  .gallery-lightbox-figure {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .gallery-lightbox-prev,
  .gallery-lightbox-next {
    grid-row: 3;
    justify-self: center;
  }

  .gallery-lightbox-prev {
    grid-column: 1;
  }

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

  .gallery-lightbox-figure img {
    max-height: 67vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-card,
  .gallery-card-media img,
  .gallery-card-overlay,
  .gallery-lightbox,
  .gallery-lightbox-arrow {
    transition: none;
  }

  .gallery-card {
    opacity: 1;
    transform: none;
  }
}