/* ── Gallery Overlay ────────────────────────────────── */

.gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.gallery-overlay[hidden] { display: none; }

/* Backdrop */
.gallery-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 1);
}

/* Close button */
.gallery-overlay__close {
  position: fixed;
  top: 40px;
  left: 40px;
  z-index: 10;
  width: 48px;
  height: 48px;
  padding: 0;
  justify-content: center;
}

/* X icon via mask — match burger menu close (14px, 1.5 round) */
.gallery-overlay__close span {
  display: block;
  width: 14px;
  height: 14px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M1 1L13 13M13 1L1 13' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") center/100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M1 1L13 13M13 1L1 13' stroke='black' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") center/100% no-repeat;
}

/* Right sidebar — company list + filmstrip stacked */
.gallery-overlay__sidebar {
  position: fixed;
  right: 24px;
  top: 48px;
  bottom: 0;
  width: 148px;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

/* Panel */
.gallery-overlay__panel {
  position: absolute;
  left: 100px;
  right: 196px; /* 148px sidebar + 24px right offset + 24px gap */
  top: 48px;
  bottom: 48px;
  z-index: 5;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

/* Main image + caption area */
.gallery-overlay__main {
  flex: 1;
  min-height: 0;
  padding: 0 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.gallery-overlay__media {
  display: grid;
  grid-template-rows: 1fr auto;
  width: 100%;
  flex: 1;
  min-height: 0;
}

.gallery-overlay__image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  justify-self: center;
  align-self: center;
}

.gallery-overlay__caption {
  font-family: var(--font-body);
  font-size: var(--size-body-md);
  color: var(--color-blue);
  opacity: 0.5;
  padding-top: var(--space-sm);
  max-width: 860px;
  text-align: left;
}

/* Filmstrip — clips only the top edge; bottom extends freely to viewport */
.gallery-overlay__filmstrip {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding-top: var(--space-xl);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 48px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 48px);
}

.gallery-overlay__filmstrip-track {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding-top: var(--space-xl);
  will-change: transform;
}

.gallery-overlay__filmstrip::-webkit-scrollbar { display: none; }

.gallery-overlay__divider {
  height: 1px;
  background: var(--color-blue);
  opacity: 0.4;
  margin: var(--space-xs) 0;
  flex-shrink: 0;
}

.gallery-overlay__thumb {
  flex-shrink: 0;
  overflow: hidden;
  opacity: 0.3;
  border: 2px solid transparent;
  transition: opacity 0.2s ease, border-color 0.2s ease;
}

.gallery-overlay__thumb img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.gallery-overlay__thumb.is-active {
  opacity: 0.5;
  border-color: var(--color-teal);
}

.gallery-overlay__thumb:hover:not(.is-active) {
  opacity: 0.6;
}

/* ── Responsive: mobile — horizontal strip on top ───── */

@media (max-width: 768px) {
  .gallery-overlay {
    display: flex;
    flex-direction: column;
  }

  /* Sidebar → full-width top bar */
  .gallery-overlay__sidebar {
    position: static;
    top: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    height: auto;
    order: -1;
    padding: var(--gutter) var(--gutter) 0;
  }

  /* Filmstrip → horizontal, native-scrollable, side fades */
  .gallery-overlay__filmstrip {
    flex: 0 0 auto;
    overflow-x: auto;
    overflow-y: hidden;
    padding-top: 0;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 24px, #000 calc(100% - 24px), transparent 100%);
  }

  .gallery-overlay__filmstrip-track {
    flex-direction: row;
    gap: var(--space-xs);
    padding-top: 0;
  }

  .gallery-overlay__thumb {
    width: 64px;
    flex: 0 0 auto;
  }

  /* Panel → fills below the strip */
  .gallery-overlay__panel {
    position: static;
    inset: auto;
    left: auto;
    right: auto;
    top: auto;
    bottom: auto;
    flex: 1;
    min-height: 0;
  }

  .gallery-overlay__main {
    padding: 0 var(--gutter) var(--gutter);
  }

  .gallery-overlay__close {
    top: 16px;
    left: 16px;
    z-index: 20;
  }
}
