.gallery-hero {
  padding-block: clamp(2.2rem, 5vw, 4.65rem);
  border-bottom: 1px solid var(--line);
  background: radial-gradient(ellipse at 90% 10%, var(--blue-light), transparent 62%), var(--white);
}

.gallery-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr);
  align-items: center;
  gap: clamp(1.8rem, 5vw, 4.75rem);
}

.gallery-intro::before {
  content: '';
  display: block;
  width: 3.2rem;
  height: .28rem;
  margin-bottom: 1.15rem;
  border-radius: 1rem;
  background: var(--gold-gradient);
}

.gallery-intro h1 { max-width: none; }
.gallery-intro p { max-width: 27rem; margin: 1rem 0 1.45rem; color: var(--muted); font-size: clamp(.96rem, 1.5vw, 1.12rem); }

.gallery-feature {
  display: grid;
  position: relative;
  min-width: 0;
  padding: .45rem;
  border: 1px solid var(--line);
  border-radius: 1.35rem;
  background: var(--white);
  box-shadow: 0 1.1rem 2.6rem #15396e16;
}

.gallery-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  gap: .45rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: thin;
  border-radius: .95rem;
}

.gallery-track:has(+ .gallery-controls:not([hidden])) { scrollbar-width: none; }
.gallery-slide { min-width: 0; scroll-snap-align: start; }
.gallery-photo { display: block; position: relative; overflow: hidden; background: var(--pale); }
.gallery-photo img { width: 100%; object-fit: cover; object-position: center 43%; }
.gallery-slide .gallery-photo { border-radius: .9rem; }
.gallery-slide .gallery-photo:focus-visible { outline-offset: -4px; }
.gallery-slide img { aspect-ratio: 16 / 10; }
.gallery-slide figcaption {
  position: static;
  padding: .75rem .7rem .5rem;
  color: var(--navy);
  background: transparent;
  font: 700 1.08rem/1.3 var(--heading);
}

.gallery-track:has(+ .gallery-controls:not([hidden])) figcaption {
  display: grid;
  align-content: center;
  min-height: 3.5rem;
  padding: .55rem 9.4rem .35rem .7rem;
}

.gallery-expand {
  position: absolute;
  right: .55rem;
  bottom: .55rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-weight: 700;
}

.gallery-controls:not([hidden]), .gallery-dialog-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .45rem;
  padding: .3rem .55rem .45rem;
}

.gallery-controls:not([hidden]) { position: absolute; right: .55rem; bottom: .65rem; padding: 0; }

.gallery-count { margin-inline: .4rem; color: var(--muted); font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.gallery-control {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  padding: 0 0 .13em;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--white);
  color: var(--blue-deep);
  font: 600 1.65rem/1 var(--body);
  cursor: pointer;
}

.gallery-control:enabled:hover { border-color: var(--blue); background: var(--pale); }
.gallery-control:disabled { opacity: .46; cursor: default; }
.gallery-collection .section-heading p { margin-top: .5rem; }
.gallery-collection + .gallery-collection { padding-top: 0; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(.8rem, 2vw, 1.35rem);
  margin-top: 1.75rem;
}

.gallery-clients-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.gallery-tile {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: .85rem;
  background: var(--white);
  box-shadow: 0 .38rem 1.2rem #15396e0b;
}

.gallery-tile:focus-within { border-color: var(--blue); }
.gallery-tile .gallery-photo { border-radius: .8rem .8rem 0 0; }
.gallery-tile img { aspect-ratio: 4 / 3; }
.gallery-tile h3 { padding: .76rem .82rem .88rem; font-size: clamp(1rem, 1.45vw, 1.2rem); line-height: 1.2; overflow-wrap: anywhere; }

.gallery-client-tile { display: grid; grid-template-rows: subgrid; grid-row: span 3; row-gap: 0; scroll-margin-top: 6.25rem; }
.gallery-client-tile:target { outline: 3px solid var(--gold-deep); outline-offset: 3px; }
.gallery-client-tile img { aspect-ratio: 1; object-fit: contain; }
.gallery-client-tile h3 { padding-bottom: .32rem; }
.gallery-client-tile p { padding: 0 .82rem .85rem; color: var(--muted); font-size: .89rem; line-height: 1.4; overflow-wrap: anywhere; }

.gallery-dialog {
  width: min(52rem, calc(100% - 1.5rem));
  max-height: calc(100dvh - 1.5rem);
  padding: .55rem;
  border: 1px solid var(--line);
  border-radius: .9rem;
  background: var(--white);
  box-shadow: 0 .8rem 3rem #0005;
}

.gallery-dialog::backdrop { background: #081429db; }
html:has(.gallery-dialog[open]) { overflow: hidden; }
.gallery-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 0 .25rem .5rem; }
.gallery-dialog-header p { color: var(--navy); font: 700 1.22rem/1.25 var(--heading); }
.gallery-dialog-header button { flex: 0 0 2.8rem; }
.gallery-dialog-stage { display: grid; place-items: center; height: min(65dvh, 40rem); border-radius: .45rem; overflow: hidden; background: #0b1930; }
.gallery-dialog-stage img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.gallery-dialog-controls { justify-content: center; gap: .75rem; padding: .55rem 0 0; }

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .gallery-tile img { transition: transform .25s ease; }
  .gallery-tile .gallery-photo:hover img { transform: scale(1.04); }
}

@media (max-width: 55rem) {
  .gallery-hero-grid { grid-template-columns: minmax(0, 1fr); }
  .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 38rem) {
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery-client-tile { scroll-margin-top: 5rem; }
  .gallery-feature { border-radius: 1rem; }
  .gallery-intro p { margin-bottom: 1.1rem; }
}

@media (min-width: 74rem) {
  .gallery-clients-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .gallery-client-tile { scroll-margin-top: 13rem; }
}
