/* ── CubeGallery ─────────────────────────────────────────────────────────── */

.cg-root {
  display: flex;
  width: 100%;
  min-height: 720px;
  background: transparent;
  border: none;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0;
  box-sizing: border-box;
}

@media (min-width: 1024px) {
  .cg-root { min-height: min(80vh, 900px); }
}

@media (min-width: 1440px) {
  .cg-root { min-height: min(85vh, 1100px); }
}

/* ── List panel ─────────────────────────────────────────────────────────── */

.cg-list-panel {
  width: 210px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.cg-list-panel::-webkit-scrollbar { width: 3px; }
.cg-list-panel::-webkit-scrollbar-track { background: transparent; }
.cg-list-panel::-webkit-scrollbar-thumb { background: #1a2d4a; border-radius: 2px; }

.cg-list-title {
  padding: 28px 16px 10px;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #8aaed8;
  flex-shrink: 0;
}

.cg-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 16px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  flex-shrink: 0;
}

.cg-list-item:hover {
  background: #0c1929;
}

.cg-list-item.cg-active {
  background: #091627;
  border-left: 3px solid #4d8cff;
  padding-left: 13px;
}

.cg-list-item-dot {
  display: none;
}

.cg-list-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 500;
  color: #8aaed8;
  transition: color 0.15s;
}

.cg-list-item:hover .cg-list-item-label {
  color: #b0cce8;
}

.cg-list-item.cg-active .cg-list-item-label {
  color: #c8d8f0;
}

/* ── 3D stage ───────────────────────────────────────────────────────────── */

.cg-stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  min-width: 0;
  padding: 16px 32px 32px;
  background: transparent;
  gap: 16px;
}

/* ── Cube stage (flat 2D container — no perspective here) ──────────────── */

.cg-cube-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Perspective lives here, one level below cubeStage, so the shared control
   bar (a sibling of this element) stays in a flat 2D stacking context. */
.cg-perspective-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* ── Cube wrapper ───────────────────────────────────────────────────────── */

.cg-cube-wrapper {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
  /* --cg-size and --cg-half set by JS via ResizeObserver */
  --cg-size: 300px;
  --cg-half: 150px;
}

/* ── Faces ──────────────────────────────────────────────────────────────── */

.cg-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  border-radius: 6px;
  border: 1px solid #1a2d4a;
  background-color: #0a1522;
  background-image:
    radial-gradient(circle, rgba(77, 140, 255, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: center center;
  box-shadow: inset 0 0 0 1px rgba(77, 140, 255, 0.06);
}

.cg-face-front  { transform: translateZ(var(--cg-half)); }
.cg-face-back   { transform: rotateY(180deg)  translateZ(var(--cg-half)); }
.cg-face-right  { transform: rotateY(90deg)   translateZ(var(--cg-half)); }
.cg-face-left   { transform: rotateY(-90deg)  translateZ(var(--cg-half)); }
.cg-face-top    { transform: rotateX(-90deg)  translateZ(var(--cg-half)); }
.cg-face-bottom { transform: rotateX(90deg)   translateZ(var(--cg-half)); }

/* ── Face media ─────────────────────────────────────────────────────────── */

.cg-face-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.cg-caption {
  color: #8aaed8;
  font-size: 15px;
  line-height: 1.55;
  text-align: center;
  max-width: 560px;
  padding: 0 8px;
}

/* ── Video controls (flat 2D overlay, outside the 3D tree) ─────────────── */

.cg-video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 22px 10px 9px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  border-radius: 0 0 6px 6px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

.cg-video-controls.cg-video-controls--visible {
  opacity: 1;
  pointer-events: all;
  touch-action: none;
}

.cg-video-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
}

.cg-video-btn:hover { opacity: 1; }

.cg-video-progress {
  flex: 1;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  touch-action: none;
  transition: height 0.15s;
  /* Invisible padding enlarges the click/grab target without visual change */
  padding: 14px 0;
  margin: -14px 0;
  background-clip: content-box;
}

.cg-video-progress:hover { height: 5px; }

.cg-video-progress-fill {
  height: 3px;
  width: 0%;
  background: #2dd4bf;
  border-radius: 2px;
  pointer-events: none;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}

.cg-video-progress-fill::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #2dd4bf;
  box-shadow: 0 0 3px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 950px) {
  .cg-root {
    flex-direction: column;
    min-height: unset;
  }

  .cg-list-panel {
    width: 100%;
    flex-direction: row;
    border-right: none;
    border-bottom: none;
    overflow-x: auto;
    overflow-y: hidden;
    margin-bottom: clamp(8px, 3vw, 30px);
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-mask-image: linear-gradient(to right, black 75%, transparent 100%);
    mask-image: linear-gradient(to right, black 75%, transparent 100%);
  }
  .cg-list-panel::-webkit-scrollbar { display: none; }

  .cg-list-title {
    display: none;
  }

  .cg-list-item {
    padding: 10px 10px;
    white-space: nowrap;
  }

  .cg-list-item.cg-active {
    background: transparent;
    border-left: none;
    border-bottom: 3px solid #4d8cff;
    padding-left: 16px;
    padding-bottom: 7px;
  }

  .cg-stage {
    min-height: 300px;
    padding: 32px 0 16px;
    gap: 8px;
  }
}
