/* cube.css */

:root {
  /* Brand Accent Palette */
  --evx-blue: #0054B1;
  --evx-blue-glow: rgba(0, 84, 177, 0.45);
  --evx-green: #007700;
  --evx-green-glow: rgba(0, 119, 0, 0.35);

  /* Dark Theme Default Surfaces */
  --cube-bg-dark: rgba(15, 20, 30, 0.65);
  --cube-border-dark: rgba(255, 255, 255, 0.12);
  --cube-text-main-dark: #f8fafc;
  --cube-text-sub-dark: #94a3b8;
  --cube-glass-blur: 24px;
  --cube-shadow-dark: 0 30px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.2);

  /* Light Theme Surfaces */
  --cube-bg-light: rgba(255, 255, 255, 0.75);
  --cube-border-light: rgba(0, 0, 0, 0.08);
  --cube-text-main-light: #0f172a;
  --cube-text-sub-light: #475569;
  --cube-shadow-light: 0 25px 50px rgba(0, 84, 177, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Host mount: pin to viewport so JS stage position (%) stays stable during page scroll */
.demo-container,
#cubeMount {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  max-width: none;
  margin: 0;
  z-index: 1;
  overflow: visible;
  pointer-events: none;
  box-sizing: border-box;
}

#cubeMount .evx-cube-wrapper,
.demo-container .evx-cube-wrapper {
  pointer-events: auto;
}

/* Outer Viewport Perspective Wrapper */
.evx-cube-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  perspective: 1200px;
  perspective-origin: 50% 50%;
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  touch-action: none;
  cursor: grab;
  box-sizing: border-box;
}

.evx-cube-wrapper:active {
  cursor: grabbing;
}

/* 3D Scene Root — keep square; JS may set equal px when size is % */
.evx-cube-stage {
  width: var(--cube-size, 300px);
  height: var(--cube-size, 300px);
  max-width: var(--cube-max-size, none);
  max-height: var(--cube-max-size, none);
  aspect-ratio: 1 / 1;
  box-sizing: border-box;
  position: absolute; /* JS handles top/left transforms */
  transform-style: preserve-3d;
  will-change: transform, left, top;
  transition: left 0.4s ease, top 0.4s ease, transform 0.4s ease, width 0.35s ease, height 0.35s ease;
}

/* Inner Rotating Assembly */
.evx-cube-3d {
  width: 100%;
  height: 100%;
  position: absolute;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.1s linear;
}

/* Individual Face Component */
.evx-cube-face {
  position: absolute;
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  box-sizing: border-box;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backface-visibility: visible;
  backdrop-filter: blur(var(--cube-glass-blur));
  -webkit-backdrop-filter: blur(var(--cube-glass-blur));
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.5s cubic-bezier(0.16, 1, 0.3, 1),
              border-color 0.5s ease,
              background 0.5s ease;
  will-change: transform, box-shadow;
}

/* Dark / Light Theme Styles */
.evx-cube-wrapper[data-theme="dark"] .evx-cube-face {
  background: var(--cube-bg-dark);
  border: 1px solid var(--cube-border-dark);
  box-shadow: var(--cube-shadow-dark);
  color: var(--cube-text-main-dark);
}

.evx-cube-wrapper[data-theme="light"] .evx-cube-face {
  background: var(--cube-bg-light);
  border: 1px solid var(--cube-border-light);
  box-shadow: var(--cube-shadow-light);
  color: var(--cube-text-main-light);
}

/* Face Dynamic Content Layout */
.evx-face-media {
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background: rgba(0, 0, 0, 0.2);
}

.evx-face-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.evx-face-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 2;
}

.evx-face-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.evx-face-desc {
  font-size: 0.825rem;
  line-height: 1.45;
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: opacity 0.3s ease;
}

.evx-cube-wrapper[data-theme="dark"] .evx-face-desc { color: var(--cube-text-sub-dark); }
.evx-cube-wrapper[data-theme="light"] .evx-face-desc { color: var(--cube-text-sub-light); }

/* Premium CTA Button Row */
.evx-face-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  z-index: 3;
}

.evx-btn-pill {
  flex: 1;
  padding: 0.5rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: center;
  border: none;
  cursor: pointer;
  outline: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.evx-btn-primary {
  background: linear-gradient(135deg, var(--evx-blue), #003a7c);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 84, 177, 0.3);
}

.evx-btn-primary:hover {
  background: linear-gradient(135deg, #0066d6, var(--evx-blue));
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 84, 177, 0.5);
}

.evx-btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: inherit;
  backdrop-filter: blur(8px);
}

.evx-cube-wrapper[data-theme="light"] .evx-btn-secondary {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.12);
}

.evx-btn-secondary:hover {
  background: rgba(0, 119, 0, 0.15);
  border-color: var(--evx-green);
  color: #008800;
  transform: translateY(-2px);
}

.evx-cube-wrapper[data-theme="dark"] .evx-btn-secondary:hover {
  color: #33bb33;
}

.evx-cube-face:hover {
  border-color: var(--evx-blue);
  box-shadow: 0 20px 50px var(--evx-blue-glow),
              0 0 30px var(--evx-green-glow),
              inset 0 0 15px rgba(255, 255, 255, 0.15);
}

.evx-cube-face:hover .evx-face-media img {
  transform: scale(1.08);
}

.evx-cube-face.is-hovered {
  z-index: 10;
}

.evx-cube-shadow-floor {
  position: absolute;
  width: 120%;
  height: 40px;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%) rotateX(90deg);
  background: radial-gradient(ellipse at center, rgba(0, 84, 177, 0.35) 0%, rgba(0, 119, 0, 0.15) 40%, rgba(0,0,0,0) 70%);
  filter: blur(14px);
  pointer-events: none;
  border-radius: 50%;
}

@media (max-width: 600px) {
  .evx-cube-stage {
    --cube-size: 250px !important;
  }
  .evx-face-title {
    font-size: 1.1rem;
  }
  .evx-face-desc {
    font-size: 0.75rem;
  }
}