.cinematic-gallery {
  --cg-accent: #30d9ff;
  position: fixed;
  z-index: 160;
  inset: 0;
  overflow: hidden;
  color: #f4f8ff;
  isolation: isolate;
}

.cg-backdrop {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  background:
    radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--cg-accent) 13%, transparent), transparent 44%),
    rgba(1, 5, 11, 0.97);
  backdrop-filter: blur(24px) saturate(0.72);
  cursor: default;
}

.cg-view {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  place-items: center;
  padding: clamp(70px, 8vh, 96px) clamp(82px, 8vw, 140px) clamp(108px, 12vh, 138px);
  pointer-events: none;
}

.cg-figure {
  position: relative;
  display: grid;
  width: max-content;
  max-width: 92vw;
  justify-items: stretch;
  margin: 0;
  touch-action: pan-y;
  pointer-events: none;
}

.cg-frame {
  position: relative;
  width: min(82vw, 1280px);
  height: min(70vh, 720px);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--cg-accent) 28%, transparent);
  border-radius: 2px;
  background: #010409;
  box-shadow:
    0 48px 130px rgba(0, 0, 0, 0.8),
    0 0 80px color-mix(in srgb, var(--cg-accent) 8%, transparent);
  pointer-events: auto;
  touch-action: pan-y;
  will-change: width, height;
}

.cg-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #010409;
  will-change: clip-path;
}

.cg-layer--current {
  z-index: 1;
}

.cg-layer--incoming {
  z-index: 2;
}

.cg-layer--incoming[aria-hidden="true"] {
  visibility: hidden;
}

.cg-layer img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scale(1.025);
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  will-change: transform;
}

.cg-caption {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.75fr);
  gap: 24px;
  align-items: start;
  width: 100%;
  padding: 16px 2px 0;
  pointer-events: none;
}

.cg-caption strong {
  color: rgba(242, 248, 255, 0.94);
  font-size: clamp(18px, 1.7vw, 26px);
  font-weight: 680;
  line-height: 1.2;
}

.cg-caption p {
  margin: 1px 0 0;
  color: rgba(186, 207, 222, 0.68);
  font-size: 13px;
  line-height: 1.65;
}

.cg-nav {
  position: absolute;
  z-index: 4;
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 15px;
  border: 1px solid rgba(137, 202, 237, 0.22);
  border-radius: 999px;
  color: rgba(227, 241, 250, 0.82);
  background: rgba(3, 13, 23, 0.74);
  font-size: 13px;
  cursor: pointer;
  pointer-events: auto;
  transform: translateY(-50%);
  transition: border-color 180ms ease, color 180ms ease, background 180ms ease, transform 220ms ease;
}

.cg-nav:hover,
.cg-nav:focus-visible {
  border-color: var(--cg-accent);
  color: white;
  background: rgba(5, 35, 54, 0.9);
  transform: translateY(-50%) scale(1.04);
}

.cg-nav--previous {
  left: clamp(18px, 3vw, 48px);
}

.cg-nav--next {
  right: clamp(18px, 3vw, 48px);
}

.cg-progress {
  position: absolute;
  z-index: 3;
  right: clamp(22px, 4vw, 60px);
  bottom: max(34px, env(safe-area-inset-bottom));
  left: clamp(22px, 4vw, 60px);
  display: grid;
  grid-template-columns: repeat(var(--cg-count, 1), 1fr);
  gap: 5px;
  height: 8px;
  align-items: center;
  pointer-events: none;
}

.cg-progress i {
  height: 1px;
  background: rgba(128, 181, 211, 0.2);
  transition: height 220ms ease, background 220ms ease, box-shadow 220ms ease;
}

.cg-progress i.is-active {
  height: 3px;
  background: var(--cg-accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--cg-accent) 70%, transparent);
}

.cg-help {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: max(53px, calc(env(safe-area-inset-bottom) + 18px));
  width: max-content;
  max-width: 72vw;
  margin: 0;
  color: rgba(177, 204, 221, 0.56);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.cg-close {
  position: fixed;
  z-index: 6;
  top: max(18px, env(safe-area-inset-top));
  right: max(18px, env(safe-area-inset-right));
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(155, 212, 241, 0.26);
  border-radius: 50%;
  color: rgba(230, 242, 250, 0.78);
  background: rgba(1, 7, 13, 0.76);
  font-size: 25px;
  font-weight: 300;
  cursor: pointer;
  pointer-events: auto;
  transition: color 180ms ease, border-color 180ms ease, transform 220ms ease;
}

.cg-close:hover,
.cg-close:focus-visible {
  border-color: var(--cg-accent);
  color: white;
  transform: rotate(90deg);
}

.cg-flight-image {
  position: fixed;
  z-index: 10000;
  max-width: none;
  object-fit: cover;
  overflow: hidden;
  box-shadow: 0 36px 100px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  will-change: left, top, width, height, border-radius;
}

.is-cg-origin {
  opacity: 0 !important;
}

body.has-cinematic-gallery .theme-content {
  overflow: hidden;
}

@media (max-width: 820px) {
  .cg-view {
    padding: 70px 12px 154px;
  }

  .cg-figure {
    max-width: 94vw;
  }

  .cg-caption {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 12px 2px 0;
  }

  .cg-caption strong {
    font-size: 18px;
  }

  .cg-caption p {
    font-size: 12px;
  }

  .cg-nav {
    top: auto;
    bottom: max(24px, env(safe-area-inset-bottom));
    min-height: 46px;
    transform: none;
  }

  .cg-nav:hover,
  .cg-nav:focus-visible {
    transform: scale(1.03);
  }

  .cg-nav--previous {
    left: calc(50% - 126px);
  }

  .cg-nav--next {
    right: calc(50% - 126px);
  }

  .cg-progress {
    right: 18px;
    bottom: max(98px, calc(env(safe-area-inset-bottom) + 76px));
    left: 18px;
    gap: 3px;
  }

  .cg-help {
    bottom: max(116px, calc(env(safe-area-inset-bottom) + 94px));
    max-width: 86vw;
    font-size: 11px;
  }

  .cg-close {
    top: max(14px, env(safe-area-inset-top));
    right: max(14px, env(safe-area-inset-right));
  }
}

@media (prefers-reduced-motion: reduce) {
  .cg-frame,
  .cg-layer,
  .cg-layer img,
  .cg-flight-image {
    transform: none !important;
    transition: none !important;
  }
}
