/* ==========================================================
   SOWAYA | gallery.css
   Gallery page only. Load after base.css and page.css.

   Layout: "justified rows". Every photo keeps its real proportions
   (set per photo as --ar = width / height). A photo's share of its
   row is proportional to --ar, so wide, landscape, square and portrait
   photos line up in even rows with no cropping and no gaps.
   Featured photos are marked with a badge, not resized, so rows stay even.
   ========================================================== */

.gallery {
  --row-h: 240px;
  --gap: 12px;
}

/* ----- filter ----- */
.gfilter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}
.gfilter__chip {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--green-ink);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  transition:
    background-color 0.2s,
    color 0.2s,
    border-color 0.2s;
}
.gfilter__chip span {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--sand);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted);
  transition:
    background-color 0.2s,
    color 0.2s;
}
.gfilter__chip:hover {
  border-color: var(--green);
}
.gfilter__chip.is-active {
  border-color: var(--green);
  background: var(--green);
  color: var(--cream);
}
.gfilter__chip.is-active span {
  background: var(--gold);
  color: var(--green-ink);
}

/* ----- groups ----- */
.ggroup {
  margin-bottom: clamp(3.5rem, 7vw, 6rem);
}
.ggroup:last-child {
  margin-bottom: 0;
}
.ggroup[hidden] {
  display: none;
}
.ggroup__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}
.ggroup__head h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
}
.ggroup__head p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
}

/* ----- justified rows ----- */
.jgrid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
}
.jgrid::after {
  content: "";
  flex-grow: 1000000;
} /* keeps the last row from stretching */

.jitem {
  --boost: 1;
  --w: calc(var(--ar) * var(--boost));
  position: relative;
  display: block;
  overflow: hidden;
  flex: calc(var(--w) * 100) 1 calc(var(--w) * var(--row-h));
  aspect-ratio: var(--ar);
  align-self: flex-start;
  border-radius: 14px;
  background: var(--sand);
}
.jitem img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.jitem:hover img,
.jitem:focus-visible img {
  transform: scale(1.04);
}
.jitem:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

/* flat caption bar (no gradient) */
.jitem__cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0.85rem 1rem;
  background: rgba(15, 51, 34, 0.8);
  color: var(--cream);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.3;
  transform: translateY(101%);
  transition: transform 0.3s ease;
}
.jitem:hover .jitem__cap,
.jitem:focus-visible .jitem__cap {
  transform: none;
}
.jitem__flag {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--green-ink);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ----- empty ----- */
.gempty {
  max-width: 34rem;
  margin-inline: auto;
  padding-block: 3rem;
  text-align: center;
}
.gempty p {
  color: var(--muted);
}
.gempty a {
  color: var(--green);
}

/* ----- responsive ----- */
@media (max-width: 1024px) {
  .gallery {
    --row-h: 200px;
  }
}
@media (max-width: 640px) {
  .gallery {
    --row-h: 150px;
    --gap: 8px;
  }
  .jitem {
    border-radius: 10px;
  }
  .jitem__cap {
    display: none;
  } /* captions live in the lightbox on touch screens */
  .gfilter {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-inline: calc(var(--gutter) * -1);
    padding-inline: var(--gutter);
    padding-bottom: 0.5rem;
    scrollbar-width: none;
  }
  .gfilter::-webkit-scrollbar {
    display: none;
  }
  .gfilter__chip {
    flex-shrink: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .jitem img,
  .jitem__cap {
    transition: none;
  }
}
