.gallery-page {
  --gallery-surface: #001f3f;
  --gallery-surface-soft: #052b55;
  --gallery-accent: #ffd700;
  --gallery-radius: clamp(16px, 2vw, 28px);
  color: var(--font-color-2, #fff);
  background: var(--gallery-surface);
  touch-action: manipulation;
}

.gallery-hero,
.gallery-sections,
.gallery-section {
  touch-action: manipulation;
}

.gallery-hero .bg,
.gallery-hero .bg img {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.gallery-content-anchor {
  scroll-margin-top: var(--header-height, 90px);
}

.gallery-section {
  padding-block: clamp(72px, 9vw, 150px);
  position: relative;
  scroll-margin-top: calc(var(--header-height, 80px) + 70px);
  overflow: clip;
}

.gallery-section + .gallery-section {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.gallery-section:nth-child(even) {
  background: var(--gallery-surface-soft);
}

.gallery-section::before {
  position: absolute;
  top: -14vw;
  right: -12vw;
  width: 36vw;
  aspect-ratio: 1;
  content: "";
  pointer-events: none;
  background: radial-gradient(circle, rgba(111, 174, 230, 0.2), transparent 66%);
}

.gallery-section__header {
  margin-block-end: clamp(34px, 6vw, 72px);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(260px, 0.55fr);
  align-items: end;
  gap: 18px clamp(22px, 4vw, 64px);
}

.gallery-page .gallery-section__index {
  color: var(--gallery-accent);
  font-family: var(--font-family-2, inherit);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.gallery-page .gallery-section__eyebrow {
  margin-block-end: 10px;
  color: var(--gallery-accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.gallery-section__heading h2 {
  margin: 0;
  max-width: 12ch;
  color: inherit;
  font-family: var(--font-family-2, inherit);
  font-size: clamp(2.35rem, 6vw, 6.25rem);
  font-weight: 750;
  line-height: 0.92;
  letter-spacing: -0.045em;
}

.gallery-section__description {
  color: rgba(255, 255, 255, 0.7);
  font-size: clamp(0.95rem, 1.3vw, 1.1rem);
  line-height: 1.55;
}

.gallery-section__description > :first-child {
  margin-block-start: 0;
}

.gallery-section__description > :last-child {
  margin-block-end: 0;
}

.gallery-image-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-flow: dense;
  grid-auto-rows: clamp(88px, 8.5vw, 150px);
  gap: clamp(10px, 1.35vw, 22px);
}

.gallery-image-card {
  margin: 0;
  min-height: 0;
  grid-column: span 4;
  grid-row: span 2;
}

.gallery-image-card:nth-child(8n + 1),
.gallery-image-card:nth-child(8n + 6) {
  grid-column: span 7;
  grid-row: span 3;
}

.gallery-image-card:nth-child(8n + 2),
.gallery-image-card:nth-child(8n + 5) {
  grid-column: span 5;
  grid-row: span 2;
}

.gallery-image-card:nth-child(8n + 3),
.gallery-image-card:nth-child(8n + 4) {
  grid-column: span 5;
  grid-row: span 1;
}

.gallery-image-card:nth-child(8n + 7),
.gallery-image-card:nth-child(8n + 8) {
  grid-column: span 5;
}

.gallery-image-card__button {
  margin: 0;
  padding: 0;
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: block;
  overflow: hidden;
  color: #fff;
  background: #06325f;
  border: 0;
  border-radius: var(--gallery-radius);
  cursor: zoom-in;
  touch-action: pan-y;
}

.gallery-image-card__button > img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
  transition: transform 650ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.gallery-image-card__overlay {
  padding: clamp(16px, 2.2vw, 30px);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 20px;
  pointer-events: none;
  text-align: left;
  background: linear-gradient(180deg, transparent 35%, rgba(1, 14, 10, 0.82) 100%);
  opacity: 0;
  transition: opacity 260ms ease;
}

.gallery-image-card__expand {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  color: var(--gallery-surface);
  background: var(--gallery-accent);
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
}

.gallery-image-card__button:hover > img,
.gallery-image-card__button:focus-visible > img {
  transform: scale(1.045);
}

.gallery-image-card__button:hover .gallery-image-card__overlay,
.gallery-image-card__button:focus-visible .gallery-image-card__overlay {
  opacity: 1;
}

.gallery-section--construction .gallery-image-card {
  grid-column: span 6;
  grid-row: span 3;
}

.gallery-section--construction .gallery-image-card:nth-child(3n + 1) {
  grid-column: span 12;
  grid-row: span 4;
}

.gallery-video-carousel {
  position: relative;
  min-width: 0;
}

.gallery-video-carousel__controls {
  margin-block-end: 18px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.gallery-video-carousel__controls button {
  margin: 0;
  padding: 0;
  width: 48px;
  height: 48px;
  min-height: 0;
  display: grid;
  place-items: center;
  color: var(--gallery-surface);
  background: var(--gallery-accent);
  border: 1px solid var(--gallery-accent);
  border-radius: 50%;
  box-shadow: none;
  cursor: pointer;
  transition: color 180ms ease, background-color 180ms ease, opacity 180ms ease, transform 180ms ease;
}

.gallery-video-carousel__controls button:hover,
.gallery-video-carousel__controls button:focus-visible {
  color: var(--gallery-surface);
  background: #fff;
  border-color: #fff;
  transform: translateY(-2px);
}

.gallery-video-carousel__controls button:disabled {
  opacity: 0.28;
  pointer-events: none;
}

.gallery-video-carousel__controls span {
  font-size: 22px;
  line-height: 1;
}

.gallery-video-grid {
  padding: 6px 2px 30px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(220px, 21vw, 300px);
  gap: clamp(16px, 2vw, 30px);
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-behavior: smooth;
  scroll-padding-inline: 2px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  touch-action: pan-x pan-y;
}

.gallery-video-grid::-webkit-scrollbar {
  display: none;
}

.gallery-video-card {
  margin: 0;
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: normal;
}

.gallery-video-card__button {
  margin: 0;
  padding: 0;
  width: 100%;
  display: block;
  color: inherit;
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.gallery-video-card__media {
  position: relative;
  aspect-ratio: 9 / 16;
  display: block;
  overflow: hidden;
  background: linear-gradient(145deg, #0b4f8a, #001f3f 72%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: clamp(20px, 2vw, 30px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  transition: border-color 220ms ease, box-shadow 220ms ease, transform 220ms ease;
}

.gallery-video-card__media > img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 600ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.gallery-video-card__placeholder {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 72% 22%, rgba(255, 215, 0, 0.2), transparent 28%),
    linear-gradient(145deg, #0b4f8a, #001f3f 72%);
}

.gallery-video-card__shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.58), transparent 34%, rgba(0, 0, 0, 0.48));
}

.gallery-video-card__title {
  position: absolute;
  z-index: 1;
  top: clamp(18px, 2vw, 24px);
  right: clamp(18px, 2vw, 24px);
  left: clamp(18px, 2vw, 24px);
  overflow: hidden;
  color: #fff;
  font-family: var(--font-family-2, inherit);
  font-size: clamp(1rem, 1.35vw, 1.2rem);
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}

.gallery-video-card__number {
  position: absolute;
  z-index: 1;
  bottom: clamp(18px, 2vw, 24px);
  left: clamp(18px, 2vw, 24px);
  color: var(--gallery-accent);
  font-family: var(--font-family-2, inherit);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.gallery-video-card__play {
  position: absolute;
  top: 50%;
  left: 50%;
  width: clamp(64px, 6vw, 84px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  color: var(--gallery-surface);
  background: var(--gallery-accent);
  border-radius: 50%;
  box-shadow: 0 12px 42px rgba(0, 0, 0, 0.28);
  transform: translate(-50%, -50%);
  transition: transform 220ms ease, background-color 220ms ease;
}

.gallery-video-card__play span {
  margin-inline-start: 5px;
  width: 0;
  height: 0;
  border-block: 9px solid transparent;
  border-inline-start: 15px solid var(--gallery-surface);
}

.gallery-video-card__button:hover .gallery-video-card__media > img,
.gallery-video-card__button:focus-visible .gallery-video-card__media > img {
  transform: scale(1.04);
}

.gallery-video-card__button:hover .gallery-video-card__media,
.gallery-video-card__button:focus-visible .gallery-video-card__media {
  border-color: var(--gallery-accent);
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.34);
  transform: translateY(-3px);
}

.gallery-video-card__button:hover .gallery-video-card__play,
.gallery-video-card__button:focus-visible .gallery-video-card__play {
  background: #fff;
  transform: translate(-50%, -50%) scale(1.08);
}

.gallery-empty-state {
  margin: 0;
  padding: 24px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  border-radius: var(--gallery-radius);
}

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

.gallery-lightbox,
.gallery-video-dialog {
  margin: auto;
  padding: 0;
  color: #fff;
  background: rgba(0, 15, 30, 0.97);
  border: 0;
  outline: 0;
}

.gallery-lightbox:not([open]),
.gallery-video-dialog:not([open]) {
  display: none;
}

.gallery-lightbox::backdrop,
.gallery-video-dialog::backdrop {
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(12px);
}

.gallery-lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
}

.gallery-lightbox figure {
  margin: 0;
  padding: clamp(70px, 8vw, 100px) clamp(22px, 8vw, 140px) 30px;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
  gap: 20px;
}

.gallery-lightbox figure img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
}

.gallery-lightbox figcaption {
  display: flex;
  justify-content: center;
  text-align: center;
}

.gallery-lightbox figcaption [data-gallery-dialog-counter] {
  color: var(--gallery-accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.gallery-dialog-close,
.gallery-dialog-arrow {
  margin: 0;
  padding: 0;
  position: absolute;
  z-index: 3;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  cursor: pointer;
}

.gallery-dialog-close {
  top: 22px;
  right: 22px;
  width: 48px;
  height: 48px;
  font-size: 30px;
}

.gallery-dialog-arrow {
  top: 50%;
  width: 52px;
  height: 52px;
  transform: translateY(-50%);
}

.gallery-dialog-arrow--prev {
  left: 22px;
}

.gallery-dialog-arrow--next {
  right: 22px;
}

.gallery-dialog-close:hover,
.gallery-dialog-close:focus-visible,
.gallery-dialog-arrow:hover,
.gallery-dialog-arrow:focus-visible {
  color: var(--gallery-surface);
  background: var(--gallery-accent);
}

.gallery-video-dialog,
.gallery-video-dialog:modal {
  width: min(520px, calc((100dvh - 60px) * 9 / 16), calc(100vw - 30px));
  height: auto;
  inline-size: min(520px, calc((100dvh - 60px) * 9 / 16), calc(100vw - 30px));
  block-size: auto;
  max-width: none;
  max-inline-size: none;
  max-height: calc(100dvh - 60px);
  max-block-size: calc(100dvh - 60px);
  border-radius: 28px;
  overflow: visible;
}

.gallery-video-dialog__frame {
  width: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background: #000;
  border-radius: 28px;
}

.gallery-video-dialog__frame video,
.gallery-video-dialog__frame iframe {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  border: 0;
}

.gallery-video-dialog .gallery-dialog-close {
  top: -18px;
  right: -18px;
  background: var(--gallery-accent);
  color: var(--gallery-surface);
}

@media (max-width: 991px) {
  .gallery-section__header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .gallery-section__description {
    grid-column: 2;
    max-width: 620px;
  }

  .gallery-video-grid {
    grid-auto-columns: clamp(220px, 32vw, 280px);
  }
}

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

  .gallery-section__index {
    display: none;
  }

  .gallery-section__description {
    grid-column: auto;
  }

  .gallery-image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: clamp(130px, 38vw, 200px);
  }

  .gallery-image-card,
  .gallery-image-card:nth-child(n) {
    grid-column: span 1;
    grid-row: span 1;
  }

  .gallery-image-card:nth-child(5n + 1) {
    grid-column: span 2;
    grid-row: span 2;
  }

  .gallery-section--construction .gallery-image-card,
  .gallery-section--construction .gallery-image-card:nth-child(n) {
    grid-column: span 2;
    grid-row: span 2;
  }

  .gallery-image-card__overlay {
    opacity: 1;
    background: linear-gradient(180deg, transparent 50%, rgba(1, 14, 10, 0.78));
  }

  .gallery-image-card__expand {
    width: 36px;
    height: 36px;
  }

  .gallery-video-carousel__controls {
    display: none;
  }

  .gallery-video-grid {
    margin-inline: calc(var(--grid-gap) / -2);
    padding: 6px calc(var(--grid-gap) / 2) 34px;
    grid-auto-columns: min(78vw, 310px);
    gap: 14px;
    scroll-padding-inline: calc(var(--grid-gap) / 2);
  }

  .gallery-dialog-arrow {
    top: auto;
    bottom: 24px;
    transform: none;
  }

  .gallery-lightbox figure {
    padding: 76px 18px 94px;
  }

  .gallery-video-dialog .gallery-dialog-close {
    position: fixed;
    z-index: 3;
    top: max(12px, env(safe-area-inset-top));
    right: max(12px, env(safe-area-inset-right));
  }

  .gallery-video-dialog[open],
  .gallery-video-dialog:modal {
    width: 100vw;
    height: 100dvh;
    inline-size: 100vw;
    block-size: 100dvh;
    max-width: none;
    max-height: none;
    max-inline-size: none;
    max-block-size: none;
    display: grid;
    place-items: center;
    background: #000;
    border-radius: 0;
    overflow: hidden;
  }

  .gallery-video-dialog__frame {
    width: min(100vw, calc(100dvh * 9 / 16));
    height: min(100dvh, calc(100vw * 16 / 9));
    aspect-ratio: 9 / 16;
    border-radius: 0;
  }

}

@media (prefers-reduced-motion: reduce) {
  .gallery-page *,
  .gallery-page *::before,
  .gallery-page *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
