/* =========================================================================
   Paint Events — Gallery
   Rewritten 2026-08-02. Single source of truth: the previous file had six
   generations of !important overrides stacked on each other, which is why the
   grid never aligned. Nothing here fights itself; !important appears only
   where page-theme-v3.css (loaded earlier) already uses it.
   ========================================================================= */

.gallery-page {
  --g-surface: #fbfaf6;
  --g-surface-2: #ffffff;
  --g-ink: #0d1b33;
  --g-muted: #5d6979;
  --g-line: rgba(11, 40, 84, .11);
  --g-navy: #0b376f;
  --g-green: #2f7a4b;
  --g-gap: clamp(10px, 1.05vw, 18px);
  --g-radius: 20px;
  --g-radius-sm: 14px;
  --g-ease: cubic-bezier(.22, .72, .18, 1);
  --g-ease-out: cubic-bezier(.16, 1, .3, 1);
  background: #fff;
  color: var(--g-ink);
}

.gallery-page .site-header {
  background: rgba(255, 253, 248, .78);
  border-bottom-color: rgba(7, 31, 74, .08);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.gallery-page .desktop-nav .is-current { color: var(--g-green); }

/* ---------------------------------------------------------------- hero --- */

.gallery-hero { position: relative; isolation: isolate; overflow: hidden; background: #071f4a; }
.gallery-hero-collage,
.collage-card { margin: 0; }
.gallery-hero-copy .eyebrow {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, .82);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.gallery-hero-copy h1 { margin: 0; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 14px; }
.gallery-scroll-link { align-items: center; gap: 10px; font-weight: 750; }
.gallery-scroll-link span { transition: transform .35s var(--g-ease); }
.gallery-scroll-link:hover span { transform: translateY(4px); }

/* ------------------------------------------------------------- browser --- */

.gallery-browser {
  position: relative;
  padding: clamp(4rem, 7vw, 6.5rem) 0 clamp(5rem, 9vw, 8rem);
  background: var(--g-surface);
}
.gallery-browser > .container { width: min(calc(100% - 48px), 1400px); }

.gallery-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: clamp(24px, 4vw, 64px);
  margin-bottom: clamp(1.6rem, 3vw, 2.4rem);
}
.gallery-heading__text { min-width: 0; }
.gallery-heading .eyebrow {
  margin: 0 0 12px;
  color: var(--g-green);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.gallery-heading h2 { margin: 0; }
.gallery-heading__blurb {
  max-width: 54ch;
  margin: 18px 0 0;
  color: var(--g-muted);
  font-size: 1.03rem;
  line-height: 1.7;
}
.gallery-heading__aside {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 14px;
  padding-bottom: 8px;
}
.gallery-count { margin: 0; color: var(--g-muted); font-size: .9rem; white-space: nowrap; }
.gallery-count strong {
  display: inline-block;
  min-width: 1.4ch;
  color: var(--g-navy);
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
}

/* Text swap between the index and a collection. */
.gallery-heading__text > *,
.gallery-count { transition: opacity .3s ease, transform .3s var(--g-ease); }
.gallery-heading.is-swapping .gallery-heading__text > *,
.gallery-heading.is-swapping .gallery-count { opacity: 0; transform: translateY(8px); }

.gallery-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px 0 16px;
  border: 1px solid var(--g-line);
  border-radius: 999px;
  background: var(--g-surface-2);
  color: var(--g-navy);
  font: 750 .84rem/1 inherit;
  cursor: pointer;
  transition: transform .3s var(--g-ease), box-shadow .3s ease, border-color .3s ease;
}
.gallery-back svg { transition: transform .3s var(--g-ease); }
.gallery-back:hover { border-color: rgba(11, 55, 111, .34); box-shadow: 0 10px 22px rgba(7, 31, 74, .1); }
.gallery-back:hover svg { transform: translateX(-3px); }
.gallery-back[hidden] { display: none; }

/* -------------------------------------------------------- filter rail --- */

.gallery-filterbar {
  position: sticky;
  z-index: 30;
  top: 92px;
  margin: 0 0 clamp(1.5rem, 2.6vw, 2.2rem);
  padding: 10px 0;
  background: rgba(251, 250, 246, .84);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border-bottom: 1px solid transparent;
  transition: box-shadow .3s ease, border-color .3s ease;
}
.gallery-filterbar.is-pinned {
  border-bottom-color: var(--g-line);
  box-shadow: 0 12px 28px -22px rgba(7, 31, 74, .55);
}
.gallery-filterbar > .container { width: min(calc(100% - 48px), 1400px); }

.filter-rail {
  position: relative;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.filter-rail::-webkit-scrollbar { display: none; }

.filter-rail__thumb {
  position: absolute;
  z-index: 0;
  top: 4px;
  left: 0;
  height: 46px;
  border-radius: 999px;
  background: var(--g-navy);
  box-shadow: 0 10px 24px -8px rgba(11, 55, 111, .6);
  opacity: 0;
  transition: transform .45s var(--g-ease-out), width .45s var(--g-ease-out), opacity .25s ease;
  pointer-events: none;
}

.filter-button {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--g-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .74);
  color: var(--g-ink);
  font: 750 .85rem/1 inherit;
  white-space: nowrap;
  cursor: pointer;
  scroll-snap-align: center;
  transition: color .3s ease, border-color .3s ease, background .3s ease, transform .3s var(--g-ease);
}
.filter-button:hover { transform: translateY(-2px); border-color: rgba(11, 55, 111, .3); }
.filter-button__n {
  color: var(--g-muted);
  font-size: .74rem;
  font-variant-numeric: tabular-nums;
  transition: color .3s ease;
}
.filter-button.is-active { color: #fff; border-color: transparent; background: transparent; }
.filter-button.is-active .filter-button__n { color: rgba(255, 255, 255, .66); }

/* --------------------------------------------------- collection index --- */

.gallery-view {
  position: relative;
  min-height: 40vh;
  transition: opacity .28s ease, transform .28s var(--g-ease);
}
.gallery-view.is-leaving { opacity: 0; transform: translateY(10px); }

.collection-index {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: clamp(122px, 10.6vw, 178px);
  gap: var(--g-gap);
}

/* Rhythm: 4·4·4 / 8·4 / 4·8 / 4·4·4 — ten slots that tile a twelve column
   grid exactly, so every row stays flush on both edges. */
.cat-card { grid-column: span 4; grid-row: span 2; }
.cat-card:nth-child(4),
.cat-card:nth-child(7) { grid-column: span 8; }

.cat-card {
  position: relative;
  display: block;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--g-radius);
  background: #0e2748;
  color: #fff;
  text-align: left;
  cursor: pointer;
  isolation: isolate;
  box-shadow: 0 14px 34px -18px rgba(7, 31, 74, .5);
  transition: transform .5s var(--g-ease), box-shadow .5s var(--g-ease);
}
.cat-card__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.04);
  transition: transform .8s var(--g-ease), opacity .7s ease, filter .5s ease;
}
.cat-card__img.is-loaded { opacity: 1; transform: scale(1); }
.cat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(178deg, rgba(4, 18, 40, .06) 30%, rgba(4, 18, 40, .58) 68%, rgba(3, 14, 33, .9) 100%);
  transition: opacity .45s ease;
}
.cat-card__meta {
  position: absolute;
  z-index: 2;
  inset: auto 0 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(16px, 1.7vw, 26px);
}
.cat-card__eyebrow {
  display: block;
  margin-bottom: 7px;
  color: rgba(255, 255, 255, .76);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .15em;
  text-transform: uppercase;
}
.cat-card__title {
  display: block;
  font-size: clamp(1.2rem, 1.72vw, 1.95rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.032em;
  text-shadow: 0 2px 18px rgba(3, 14, 33, .45);
}
.cat-card__count {
  display: block;
  margin-top: 6px;
  color: rgba(255, 255, 255, .66);
  font-size: .76rem;
  font-style: normal;
  font-variant-numeric: tabular-nums;
}
.cat-card__go {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateX(-8px) scale(.9);
  transition: opacity .35s ease, transform .45s var(--g-ease-out), background .3s ease;
}
.cat-card:hover { transform: translateY(-5px); box-shadow: 0 30px 60px -28px rgba(7, 31, 74, .7); }
.cat-card:hover .cat-card__img { transform: scale(1.07); filter: saturate(1.06); }
.cat-card:hover::after { opacity: .88; }
.cat-card:hover .cat-card__go,
.cat-card:focus-visible .cat-card__go { opacity: 1; transform: none; }
.cat-card:hover .cat-card__go { background: rgba(255, 255, 255, .26); }

/* ------------------------------------------------ justified photo grid --- */

.justified { display: flex; flex-direction: column; gap: var(--g-gap); }
.justified__row {
  display: flex;
  gap: var(--g-gap);
  content-visibility: auto;
  contain-intrinsic-size: auto 320px;
}
.tile {
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: var(--g-radius-sm);
  background: linear-gradient(135deg, #eaeee9, #e4ebf2);
  cursor: zoom-in;
  opacity: 0;
  transform: translateY(18px) scale(.985);
  transition: opacity .55s ease, transform .65s var(--g-ease-out), box-shadow .35s ease;
}
.tile.is-in { opacity: 1; transform: none; }
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .6s ease, transform .75s var(--g-ease);
}
.tile img.is-loaded { opacity: 1; }
.tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 55%, rgba(4, 18, 40, .34));
  opacity: 0;
  transition: opacity .4s ease;
  pointer-events: none;
}
.tile:hover { box-shadow: 0 20px 44px -20px rgba(7, 31, 74, .55); }
.tile:hover img { transform: scale(1.045); }
.tile:hover::after { opacity: 1; }
.tile__zoom {
  position: absolute;
  z-index: 2;
  right: 12px;
  bottom: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .9);
  color: var(--g-navy);
  opacity: 0;
  transform: translateY(6px) scale(.85);
  transition: opacity .3s ease, transform .4s var(--g-ease-out);
}
.tile:hover .tile__zoom,
.tile:focus-visible .tile__zoom { opacity: 1; transform: none; }

.collection__more { display: flex; justify-content: center; padding: clamp(2rem, 4vw, 3.2rem) 0 0; }
.collection__more[hidden] { display: none; }
.collection__more button {
  min-height: 52px;
  padding: 0 30px;
  border: 1px solid var(--g-line);
  border-radius: 999px;
  background: var(--g-surface-2);
  color: var(--g-navy);
  font: 750 .9rem/1 inherit;
  cursor: pointer;
  transition: transform .3s var(--g-ease), box-shadow .3s ease;
}
.collection__more button:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -14px rgba(7, 31, 74, .6); }

.collection__empty { padding: 4rem 0; color: var(--g-muted); text-align: center; }

/* ------------------------------------------------------------ lightbox --- */

.gallery-lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: transparent;
}
.gallery-lightbox::backdrop {
  background: rgba(4, 12, 26, .88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: lb-fade .3s ease both;
}
.gallery-lightbox[open] { display: block; }
/* inset:0 gives the stage a definite box, so the image's percentage max-height
   actually resolves — inside an auto-sized grid row it never would. */
.lightbox-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(56px, 8vh, 92px) clamp(16px, 7vw, 110px);
}
.lightbox-stage img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 40px 100px rgba(0, 0, 0, .55);
  animation: lb-in .42s var(--g-ease-out) both;
}
.gallery-lightbox.is-swapping .lightbox-stage img { animation: none; opacity: .35; }
@keyframes lb-in { from { opacity: 0; transform: scale(.965) } to { opacity: 1; transform: none } }
@keyframes lb-fade { from { opacity: 0 } to { opacity: 1 } }

.lightbox-bar {
  position: absolute;
  z-index: 3;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(14px, 2.4vw, 26px);
  color: #fff;
}
.lightbox-caption { margin: 0; font-size: .9rem; font-weight: 700; }
.lightbox-caption span { color: rgba(255, 255, 255, .58); font-weight: 600; font-variant-numeric: tabular-nums; }

.lightbox-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, .26);
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: background .25s ease, transform .3s var(--g-ease), opacity .25s ease;
}
.lightbox-btn:hover { background: rgba(255, 255, 255, .22); transform: scale(1.07); }
.lightbox-btn:disabled { opacity: .28; cursor: default; transform: none; }
.lightbox-nav { position: absolute; z-index: 3; top: 50%; transform: translateY(-50%); }
.lightbox-nav--prev { left: clamp(10px, 2vw, 26px); }
.lightbox-nav--next { right: clamp(10px, 2vw, 26px); }

/* ----------------------------------------------------------------- cta --- */

.gallery-cta {
  position: relative;
  isolation: isolate;
  display: grid;
  align-items: center;
  overflow: hidden;
  min-height: 480px;
  background: var(--navy-900, #071f4a);
  color: #fff;
}
.gallery-cta-paint {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(10, 39, 83, .96) 0%, rgba(10, 39, 83, .82) 46%, rgba(10, 39, 83, .28) 100%),
    url("assets/images/paint-texture-green-navy.jpg") center / cover no-repeat;
}
.gallery-cta-inner { padding: clamp(72px, 9vw, 110px) 0; text-align: center; }
.gallery-cta .eyebrow.light {
  margin: 0 0 18px;
  color: rgba(255, 255, 255, .74);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.gallery-cta h2 { margin: 0 0 34px; }
.gallery-cta .button-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }

.gallery-page .site-footer { background: var(--navy-900, #071f4a); }

/* --------------------------------------------------------- responsive --- */

@media (max-width: 1180px) {
  .collection-index { grid-auto-rows: clamp(112px, 12vw, 150px); }
}

@media (max-width: 900px) {
  .gallery-browser > .container,
  .gallery-filterbar > .container { width: min(calc(100% - 32px), 1400px); }
  .gallery-filterbar { top: 76px; }
  .gallery-heading { flex-direction: column; align-items: flex-start; }
  .gallery-heading__aside { padding-bottom: 0; }
  .collection-index {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: clamp(130px, 22vw, 190px);
  }
  .cat-card,
  .cat-card:nth-child(4),
  .cat-card:nth-child(7) { grid-column: span 1; }
}

@media (max-width: 560px) {
  .collection-index { grid-template-columns: 1fr; grid-auto-rows: clamp(160px, 42vw, 220px); }
  .cat-card__count { display: none; }
  .lightbox-nav { top: auto; bottom: clamp(14px, 4vh, 30px); transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .gallery-page *,
  .gallery-page *::before,
  .gallery-page *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .tile { opacity: 1; transform: none; }
  .cat-card__img,
  .tile img { opacity: 1; }
}
