.works-gallery {
  --gallery-gap: clamp(12px, 1.75vw, 26px);
  --gallery-edge: #becddd36;
  background: radial-gradient(ellipse at 20% 0%, #253d51, #172738 38%, #13202d 82%);
}

.works-gallery .section-head {
  margin-block-end: clamp(26px, 4vw, 58px);
  padding-block-end: clamp(17px, 2.2vw, 29px);
  border-block-end: 1px solid var(--gallery-edge);
}

.works-gallery .gallery-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gallery-gap);
  align-items: stretch;
}

.works-gallery .gallery-item,
.works-gallery .gallery-video {
  position: relative;
  min-width: 0;
  overflow: hidden;
  isolation: isolate;
  border: 1px solid var(--gallery-edge);
  border-radius: clamp(10px, 1.25vw, 18px);
  background: radial-gradient(ellipse at 50% 20%, #344e63, #162433 70%);
  box-shadow: 0 12px 32px #08142340;
}

.works-gallery .gallery-item {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 5;
  width: 100%;
  transition: border-color .25s ease, box-shadow .25s ease, translate .25s ease;
}

.works-gallery .gallery-item:first-child {
  grid-column: span 2;
  grid-row: span 2;
  aspect-ratio: auto;
}

.works-gallery .gallery-item img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.works-gallery .gallery-item::after { content: none; }

.gallery-expand {
  position: absolute;
  display: grid;
  place-items: center;
  inset: auto 12px 12px auto;
  width: 37px;
  height: 37px;
  border: 1px solid #e1eef37d;
  border-radius: 50%;
  color: #f2f7fc;
  background: #172637e6;
  box-shadow: 0 3px 15px #101c2b8a;
  transition: background-color .2s ease, opacity .2s ease;
  pointer-events: none;
}

.gallery-expand svg { width: 18px; height: 18px; }

.works-gallery .gallery-item:focus-visible {
  border-color: #dceef8;
  outline: 2px solid #dceef8;
  outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
  .gallery-expand { opacity: 0; }
  .gallery-item:first-child .gallery-expand { opacity: 1; }
  .works-gallery .gallery-item:is(:hover, :focus-visible) {
    translate: 0 -3px;
    border-color: #b7cad8;
    box-shadow: 0 16px 34px #060d1880;
  }
  .gallery-item:is(:hover, :focus-visible) .gallery-expand {
    opacity: 1;
    background-color: #293f56;
  }
}

.works-gallery .video-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: var(--gallery-gap);
  margin-block-end: clamp(38px, 6vw, 95px);
}

.works-gallery .gallery-video { aspect-ratio: 9 / 16; }

.works-gallery .gallery-video:first-child {
  grid-column: 1 / -1;
  aspect-ratio: 848 / 386;
}

.works-gallery .gallery-video video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
  background: #0c1723;
}

.lightbox[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: clamp(8px, 1.4vh, 16px);
  width: 100%;
  height: 100%;
  margin: 0;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at 50% 0%, #203447, #0b141f 74%);
  overflow: hidden;
  overscroll-behavior: contain;
}

.lightbox-toolbar,
.lightbox-navigation {
  display: grid;
  align-items: center;
  gap: clamp(7px, 1.1vw, 14px);
  width: min(100%, 980px);
  margin-inline: auto;
}

.lightbox-toolbar {
  display: flex;
  justify-content: space-between;
}

.lightbox-count {
  padding: 3px 8px;
  color: #e9f3fb;
  font: 600 .84rem/1.5 var(--body);
  font-variant-numeric: tabular-nums;
  letter-spacing: .08em;
}

.lightbox .lightbox-inner {
  display: block;
  min-height: 0;
  padding: 0;
  touch-action: pan-y pinch-zoom;
}

.lightbox .lightbox-inner figure {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 6px;
  width: min(100%, 1320px);
  margin-inline: auto;
}

.lightbox-image {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 8px;
}

.lightbox .lightbox-image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  user-select: none;
}

.lightbox figcaption {
  max-height: 4em;
  padding: 3px 0;
  overflow: auto;
  color: #d4e0ec;
  font-size: clamp(.75rem, 1.6vw, .875rem);
  line-height: 1.45;
  text-align: center;
  overflow-wrap: anywhere;
}

.lightbox-navigation { grid-template-columns: 44px minmax(0, 1fr) 44px; }

.lightbox .icon-button {
  position: static;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #aabbcc60;
  border-radius: 50%;
  background: #1c2d3c;
  color: #f0f6fe;
}

.lightbox .icon-button:is(:hover, :focus-visible) { border-color: #e2f0ff; background: #304c65; }
.lightbox .prev svg { rotate: 180deg; }

.lightbox-thumbs {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: #6c8299 transparent;
  touch-action: pan-x pinch-zoom;
}

.lightbox-thumb {
  flex: none;
  width: clamp(44px, 5.4vw, 58px);
  aspect-ratio: 4 / 5;
  padding: 0;
  overflow: hidden;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #213349;
  opacity: .76;
}

.lightbox-thumb[aria-current="true"],
.lightbox-thumb:is(:hover, :focus-visible) { opacity: 1; border-color: #d9eaf8; }

.lightbox-thumbs .lightbox-thumb img { width: 100%; height: 100%; max-height: none; object-fit: contain; }

@media (max-width: 960px) {
  .works-gallery .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .works-gallery .gallery-item:first-child {
    grid-column: 1 / -1;
    grid-row: auto;
    height: min(64svh, 490px);
  }
}

@media (max-width: 650px) {
  .works-gallery .gallery-item:first-child { height: auto; aspect-ratio: 4 / 5; }
  .gallery-expand { inset: auto 7px 7px auto; width: 29px; height: 29px; }
  .gallery-expand svg { width: 15px; height: 15px; }
  .works-gallery .video-grid { grid-template-columns: minmax(0, 1fr); }
  .works-gallery .gallery-video { width: 100%; max-width: 370px; margin-inline: auto; }
  .works-gallery .gallery-video:first-child { max-width: none; }
}

@media (orientation: landscape) and (max-height: 480px) {
  .lightbox-thumb { width: 44px; height: 44px; aspect-ratio: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .works-gallery .gallery-item, .gallery-expand { transition: none; }
  .works-gallery .gallery-item:is(:hover, :focus-visible) { translate: none; }
}

.sailing-paused .works-gallery .gallery-item,
.sailing-paused .gallery-expand { transition: none; }
.sailing-paused .works-gallery .gallery-item:is(:hover, :focus-visible) { translate: none; }
