/* =========================================================
   CrystalShardGallery – style.css
   ========================================================= */

/* ── Scene wrapper ──────────────────────────────────────── */
.csg-scene-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 14px;
  background: #020818;           /* fallback; JS sets gradient */
  box-shadow:
    inset 0 0 0 1px rgba(168,216,255,0.08),
    0 32px 80px rgba(0,0,0,0.7);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  cursor: none;
}

/* ── Star field ─────────────────────────────────────────── */
.csg-stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

/* Individual stars injected by JS */
.csg-star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  animation: csg-twinkle var(--dur, 3s) ease-in-out infinite var(--delay, 0s);
  opacity: 0;
}

@keyframes csg-twinkle {
  0%, 100% { opacity: 0;   transform: scale(1); }
  50%       { opacity: 0.9; transform: scale(1.4); }
}

/* ── 3-D stage ──────────────────────────────────────────── */
.csg-stage {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  perspective: 900px;
  perspective-origin: 50% 50%;
}

.csg-world {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

/* ── Custom cursor dot ──────────────────────────────────── */
.csg-cursor {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(168,216,255,0.9) 0%, rgba(168,216,255,0) 70%);
  box-shadow: 0 0 12px 4px rgba(168,216,255,0.5);
  pointer-events: none;
  z-index: 50;
  transform: translate(-50%, -50%);
  transition: transform 0.08s ease, opacity 0.2s;
  opacity: 0;
}
.csg-scene-wrapper:hover .csg-cursor { opacity: 1; }

/* ── Individual shard ───────────────────────────────────── */
.csg-shard {
  position: absolute;
  transform-style: preserve-3d;
  will-change: transform;
  cursor: pointer;
}

/* Clip-path polygon faces */
.csg-face {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  backface-visibility: visible;
  overflow: hidden;
  transition: filter 0.25s ease;
}

.csg-shard:hover .csg-face {
  filter: brightness(1.35) saturate(1.3);
}

.csg-face img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-user-drag: none;
  opacity: 0.88;
}

/* Facet overlay for prismatic gloss */
.csg-face::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    rgba(255,255,255,0.22) 0%,
    rgba(255,255,255,0)    40%,
    rgba(0,0,0,0.15)       100%
  );
  pointer-events: none;
  mix-blend-mode: screen;
}

/* Decorative shards (no image) */
.csg-shard.is-deco .csg-face {
  background: linear-gradient(
    135deg,
    var(--tint-a, rgba(168,216,255,0.18)) 0%,
    var(--tint-b, rgba(232,196,255,0.08)) 100%
  );
}

/* Edge glow ring */
.csg-shard::after {
  content: '';
  position: absolute;
  inset: -3px;
  clip-path: inherit;
  background: transparent;
  box-shadow: 0 0 18px 4px var(--glow, rgba(136,204,255,0.35));
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.6;
  animation: csg-pulse var(--pulse-dur, 4s) ease-in-out infinite var(--pulse-delay, 0s);
}

@keyframes csg-pulse {
  0%, 100% { opacity: 0.45; }
  50%       { opacity: 0.9;  }
}

/* ── Click-burst ring ───────────────────────────────────── */
@keyframes csg-burst {
  0%   { transform: translate(-50%,-50%) scale(0.6); opacity: 0.9; }
  100% { transform: translate(-50%,-50%) scale(2.6); opacity: 0; }
}

.csg-burst {
  position: absolute;
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 2px solid rgba(168,216,255,0.8);
  pointer-events: none;
  animation: csg-burst 0.55s ease-out forwards;
  z-index: 40;
}

/* ── Lightbox ───────────────────────────────────────────── */
.csg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.38s ease;
}

.csg-lightbox.is-open {
  pointer-events: all;
  opacity: 1;
}

.csg-lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 24, 0.95);
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.csg-lb-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 92vw;
  max-height: 92vh;
  transform: scale(0.80) rotateX(12deg);
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.csg-lightbox.is-open .csg-lb-inner {
  transform: scale(1) rotateX(0deg);
}

.csg-lb-img {
  display: block;
  max-width: 100%;
  max-height: 76vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow:
    0 0 0 1px rgba(168,216,255,0.2),
    0 0 60px rgba(136,204,255,0.15),
    0 30px 80px rgba(0,0,0,0.75);
  -webkit-user-drag: none;
}

.csg-lb-caption {
  margin-top: 16px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #a8d8ff;
  text-align: center;
  max-width: 80vw;
  opacity: 0.75;
}

.csg-lb-close {
  position: absolute;
  top: -18px;
  right: -18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(168,216,255,0.3);
  background: rgba(136,204,255,0.1);
  color: #a8d8ff;
  font-size: 26px;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s, transform 0.3s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.csg-lb-close:hover {
  background: rgba(136,204,255,0.28);
  box-shadow: 0 0 22px rgba(136,204,255,0.5);
  transform: scale(1.12) rotate(90deg);
}

/* ── Empty state ────────────────────────────────────────── */
.csg-empty {
  padding: 40px;
  text-align: center;
  color: #667;
  font-size: 14px;
  border: 2px dashed #334;
  border-radius: 12px;
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .csg-lb-inner  { max-width: 96vw; }
  .csg-lb-img    { max-height: 64vh; border-radius: 4px; }
  .csg-lb-close  { top: -10px; right: -10px; width: 34px; height: 34px; font-size: 20px; }
}
