/* ── Screenshot Gallery ── */
.screenshot-gallery.screenshot-gallery {
  position: relative;
  z-index: 2;
  background: var(--bg);
}

.gallery-stage.gallery-stage {
  position: relative;
}

.gallery-viewport.gallery-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
  padding: 1rem 0;
}

.gallery-theme-segment {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  border-radius: 100px;
  overflow: hidden;
  border: 1px solid var(--surface-border);
  z-index: 4;
}

.gallery-segment-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text-muted);
  background: transparent;
  border: none;
  padding: 0.55em 1.4em !important;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.gallery-segment-btn + .gallery-segment-btn {
  border-left: 1px solid var(--surface-border);
}

.gallery-segment-btn.active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-weight: 700;
}

.gallery-segment-btn:hover:not(.active) {
  color: var(--text);
}

.gallery-viewport {
  position: relative;
  width: 100%;
  overflow: hidden;
  mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
  -webkit-mask-image: linear-gradient(to right, transparent 0%, black 3%, black 97%, transparent 100%);
  padding: 0.75rem 0;
}

.gallery-track.gallery-track {
  display: flex;
  gap: clamp(1rem, 2.5vw, 2rem);
  padding: clamp(2rem, 6vh, 3.5rem) clamp(1.25rem, 5vw, 4rem);
  width: max-content;
  will-change: transform;
}

@keyframes gallery-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.gallery-track.scrolling {
  animation: gallery-scroll var(--gallery-speed, 55s) linear infinite;
}

.gallery-track.paused {
  animation-play-state: paused;
}

.gallery-item {
  position: relative;
  flex-shrink: 0;
  min-width: 0;
  cursor: pointer;
  transform: rotate(var(--rotation, 0deg)) translateY(var(--y-offset, 0px));
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              filter 0.4s ease;
}

.gallery-item:hover {
  transform: rotate(var(--rotation, 0deg)) translateY(var(--y-offset, 0px)) scale(1.06);
  z-index: 5;
}

.gallery-image {
  display: block;
  width: calc(60vw - 2rem);
  height: auto;
  min-width: 0;
  border-radius: 14px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  transition: filter 0.4s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.gallery-item:hover .gallery-image {
  filter: drop-shadow(0 14px 36px rgba(0, 0, 0, 0.65));
}

.gallery-bubble {
  position: absolute;
  padding: 0.4em 0.85em;
  border-radius: 14px;
  corner-shape: superellipse;
  background: rgba(0, 0, 0, 0.78);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.72rem;
  font-weight: 400;
  white-space: nowrap;
  pointer-events: none;
  opacity: 1;
  transform: translateY(0) rotate(calc(var(--rotation, 0deg) * -1));
  transition: opacity 0.3s ease, transform 0.3s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  z-index: 6;
}

.gallery-item:hover .gallery-image {
  filter: drop-shadow(0 14px 36px rgba(0, 0, 0, 0.65));
}

.gallery-bottom-mask {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 42%;
  background: linear-gradient(to top, var(--bg) 0%, var(--bg) 40%, transparent 100%);
  pointer-events: none;
  z-index: 3;
}

.gallery-scroll-controls {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 2rem);
  pointer-events: none;
  z-index: 4;
}

.gallery-scroll-btn.gallery-scroll-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--icon);
  font-size: 1.1rem;
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
  margin: 1em;
}

.gallery-scroll-btn:hover {
  background: var(--surface-hover);
  border-color: var(--card-border-hover);
  color: var(--decoration-hover);
}

.gallery-scroll-btn:focus-visible {
  outline: 2px solid var(--focus-outline);
  outline-offset: 3px;
}

/* ── Gallery Lightbox ── */
.gallery-lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
  padding: clamp(1rem, 4vw, 3rem);
}

.gallery-lightbox-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.gallery-lightbox-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  max-width: min(90vw, 500px);
  width: 100%;
  transform: scale(0.92) translateY(20px);
  transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.gallery-lightbox-overlay.active .gallery-lightbox-inner {
  transform: scale(1) translateY(0);
}

.gallery-lightbox-image-wrap {
  position: relative;
  width: 100%;
  max-width: min(90vw, 500px);
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 18px;
}

.gallery-lightbox-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 16px 48px rgba(0, 0, 0, 0.6));
}

.gallery-lightbox-mask {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 10%;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.85) 0%,
    rgba(0, 0, 0, 0.4) 50%,
    transparent 100%
  );
  pointer-events: none;
}

.gallery-lightbox-info {
  text-align: center;
  max-width: min(90vw, 440px);
}

.gallery-lightbox-title {
  font-size: 1.25rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.92);
  margin: 0 0 0.4rem;
}

.gallery-lightbox-desc {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.6);
  line-height: 1.55;
}

.gallery-lightbox-close {
  position: absolute;
  top: clamp(1rem, 3vw, 1.5rem);
  right: clamp(1rem, 3vw, 1.75rem);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
  font-size: 1.5rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, border-color 0.2s ease;
  line-height: 1;
  z-index: 1;
}

.gallery-lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Light theme overrides */
@media (prefers-color-scheme: light) {
  .gallery-bubble {
    background: rgba(255, 255, 255, 0.85);
    color: rgba(0, 0, 0, 0.8);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  }

  .gallery-image {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
  }

  .gallery-item:hover .gallery-image {
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.35));
  }

  .gallery-segment-btn.active {
    background: rgba(0, 0, 0, 0.1);
  }
}

@media (min-width: 640px) {
  .gallery-image {
    width: calc(45vw - 2rem);
  }
}

@media (min-width: 1024px) {
  .gallery-image {
    width: calc(30vw - 3rem);
  }
}

@media (max-width: 640px) {
  .gallery-scroll-btn {
    width: 36px;
    height: 36px;
    font-size: 1rem;
  }
}
