/* ============================================
   3D Marketing Analytics Cube - Dedicated Styles
   ============================================ */

/* 3D Cube Stage - Responsive Design */
.hero-3d-stage {
    perspective: clamp(1000px, 20vw, 1400px); /* Responsive perspective */
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(450px, 55vh, 550px); /* Increased height to prevent cutting */
    position: relative;
    filter: drop-shadow(0 60px 120px rgba(0, 0, 0, 0.5));
    overflow: visible; /* Allow cube to be fully visible */
    --cube-size: clamp(280px, 30vw, 340px); /* Slightly smaller cube to fit better */
    --cube-half: calc(var(--cube-size) / 2); /* Half of cube size for transforms */
    padding: 20px; /* Add padding to ensure cube fits */
}

.marketing-cube {
    position: relative;
    width: var(--cube-size); /* Use custom property */
    height: var(--cube-size); /* Use custom property */
    transform-style: preserve-3d;
    animation: rotateCube 18s linear infinite;
    max-width: 90vw; /* Prevent overflow on small screens */
    max-height: 90vh; /* Prevent overflow on small screens */
}

@keyframes rotateCube {
    0% { transform: rotateX(-18deg) rotateY(30deg); }
    25% { transform: rotateX(-22deg) rotateY(120deg); }
    50% { transform: rotateX(-18deg) rotateY(210deg); }
    75% { transform: rotateX(-22deg) rotateY(300deg); }
    100% { transform: rotateX(-18deg) rotateY(390deg); }
}

/* Cube Faces - Responsive */
.hero-section .cube-face {
    position: absolute;
    width: var(--cube-size); /* Use custom property */
    height: var(--cube-size); /* Use custom property */
    background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
    background-color: #11162e !important;
    background-image: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
    border: 1px solid #2a2f59;
    border-radius: clamp(8px, 1.5vw, 12px); /* Responsive border radius */
    padding: clamp(16px, 3vw, 24px); /* Responsive padding */
    display: flex;
    flex-direction: column;
    box-shadow: 
        inset 0 0 0 1px rgba(255, 255, 255, 0.02),
        0 0 40px rgba(42, 193, 174, 0.25),
        0 0 80px rgba(139, 92, 246, 0.15);
    backdrop-filter: blur(15px);
    overflow: hidden;
    isolation: isolate;
}

/* Protect all cube content from external styles */
.hero-section .cube-face *,
.hero-section .cube-face *::before,
.hero-section .cube-face *::after {
    background-attachment: scroll !important;
}

.hero-section .marketing-cube *:not(svg):not(path):not(circle):not(rect) {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
}

/* Face positioning - Responsive using CSS custom properties */
.hero-section .cube-face.front { 
    transform: translateZ(var(--cube-half)); 
    background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
}

.hero-section .cube-face.back { 
    transform: rotateY(180deg) translateZ(var(--cube-half)); 
    background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
}

.hero-section .cube-face.right { 
    transform: rotateY(90deg) translateZ(var(--cube-half)); 
    background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
}

.hero-section .cube-face.left { 
    transform: rotateY(-90deg) translateZ(var(--cube-half)); 
    background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
}

.hero-section .cube-face.top { 
    transform: rotateX(90deg) translateZ(var(--cube-half)); 
    background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
}

.hero-section .cube-face.bottom { 
    transform: rotateX(-90deg) translateZ(var(--cube-half)); 
    background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
}

/* Face content styling */
.face-badge {
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 11px;
    padding: 6px 12px;
    border-radius: 20px;
    background: rgba(42, 193, 174, 0.15);
    border: 1px solid rgba(42, 193, 174, 0.3);
    color: #2BC7B4;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-weight: 600;
}

.hero-section .face-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-top: 40px;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
}

/* Chart containers */
.hero-section .cube-face .chart-container {
    flex: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    min-height: 120px !important;
    width: 100% !important;
    height: 100% !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
}

.hero-section .performance-chart {
    width: 100%;
    height: 120px;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
}

.chart-line {
    fill: none;
    stroke: url(#lineGradient);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    animation: drawLine 3s ease-out forwards;
}

@keyframes drawLine {
    to {
        stroke-dashoffset: 0;
    }
}

.chart-dots circle {
    fill: #2BC7B4;
    r: 0;
    animation: growDot 0.5s ease-out forwards;
}

.chart-dots circle:nth-child(1) { animation-delay: 1s; }
.chart-dots circle:nth-child(2) { animation-delay: 1.5s; }
.chart-dots circle:nth-child(3) { animation-delay: 2s; }
.chart-dots circle:nth-child(4) { animation-delay: 2.5s; }
.chart-dots circle:nth-child(5) { animation-delay: 3s; }

@keyframes growDot {
    to { r: 4; }
}

/* Bar Chart */
.hero-section .cube-face .bar-chart {
    display: flex !important;
    align-items: end !important;
    justify-content: space-around !important;
    height: 140px !important;
    width: 100% !important;
    gap: 8px !important;
    padding: 10px 15px !important;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: visible !important;
    border: 1px solid rgba(42, 193, 174, 0.1) !important;
    border-radius: 8px !important;
}

.hero-section .cube-face .bar {
    background: linear-gradient(180deg, #2BC7B4 0%, #8B5CF6 100%) !important;
    width: 28px !important;
    border-radius: 8px 8px 0 0 !important;
    height: var(--bar-height) !important;
    position: relative !important;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
    box-shadow: 0 4px 8px rgba(42, 193, 174, 0.3) !important;
    transition: all 0.3s ease !important;
}

.hero-section .cube-face .bar:nth-child(1) { animation-delay: 0.5s; }
.hero-section .cube-face .bar:nth-child(2) { animation-delay: 1s; }
.hero-section .cube-face .bar:nth-child(3) { animation-delay: 1.5s; }
.hero-section .cube-face .bar:nth-child(4) { animation-delay: 2s; }

@keyframes growBar {
    to { height: var(--bar-height); }
}

/* Heatmap */
.hero-section .heatmap {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    height: 140px;
    padding: 20px;
    align-content: center;
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
}

.heat-cell {
    aspect-ratio: 1;
    background: linear-gradient(135deg, #2BC7B4, #8B5CF6);
    border-radius: 4px;
    opacity: 0;
    animation: fadeInCell 0.3s ease-out forwards;
}

.heat-cell:nth-child(n) {
    animation-delay: calc(var(--cell-index) * 0.05s);
}

@keyframes fadeInCell {
    to { opacity: var(--cell-opacity); }
}

/* Metrics */
.metrics {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
}

.metric {
    text-align: center;
    flex: 1;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #2a2f59;
    border-radius: 8px;
    padding: 12px 8px;
}

.metric .value {
    display: block;
    color: #2BC7B4;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    opacity: 0;
    animation: countUp 2s ease-out forwards;
}

.metric .label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 10px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Service Cards (for back face) */
.service-cards {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    height: 100%;
}

.service-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid #2a2f59;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.service-card .title {
    color: #ffffff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.service-card .value {
    color: #2BC7B4;
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 4px;
}

.service-card .desc {
    color: rgba(255, 255, 255, 0.6);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Hover effects */
.marketing-cube:hover {
    animation-play-state: paused;
}

.cube-face::after {
    content: '';
    position: absolute;
    inset: -30% -30%;
    background: 
        radial-gradient(800px 300px at 80% 10%, rgba(42, 193, 174, 0.08), transparent 60%),
        radial-gradient(700px 400px at 20% 80%, rgba(139, 92, 246, 0.08), transparent 60%);
    pointer-events: none;
    opacity: 0.6;
}

/* Responsive Design */
@media (max-width: 992px) {
    .hero-3d-stage {
        height: 400px;
    }
    
    .marketing-cube {
        width: 300px;
        height: 300px;
    }
    
    .hero-section .cube-face {
        width: 300px;
        height: 300px;
        padding: 20px;
        background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
    }
    
    .hero-section .cube-face.front { transform: translateZ(150px); }
    .hero-section .cube-face.back { transform: rotateY(180deg) translateZ(150px); }
    .hero-section .cube-face.right { transform: rotateY(90deg) translateZ(150px); }
    .hero-section .cube-face.left { transform: rotateY(-90deg) translateZ(150px); }
    .hero-section .cube-face.top { transform: rotateX(90deg) translateZ(150px); }
    .hero-section .cube-face.bottom { transform: rotateX(-90deg) translateZ(150px); }
}

@media (max-width: 768px) {
    .hero-3d-stage {
        height: 400px;
        margin-bottom: 30px;
    }
    
    .marketing-cube {
        width: 280px;
        height: 280px;
    }
    
    .hero-section .cube-face {
        width: 280px;
        height: 280px;
        padding: 18px;
        background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
    }
    
    .hero-section .cube-face.front { transform: translateZ(140px); }
    .hero-section .cube-face.back { transform: rotateY(180deg) translateZ(140px); }
    .hero-section .cube-face.right { transform: rotateY(90deg) translateZ(140px); }
    .hero-section .cube-face.left { transform: rotateY(-90deg) translateZ(140px); }
    .hero-section .cube-face.top { transform: rotateX(90deg) translateZ(140px); }
    .hero-section .cube-face.bottom { transform: rotateX(-90deg) translateZ(140px); }
    
    .metric .value {
        font-size: 17px;
    }
    
    .face-badge {
        font-size: 10px;
        padding: 5px 10px;
    }
    
    .service-card .value {
        font-size: 26px;
    }
}

@media (max-width: 576px) {
    .hero-3d-stage {
        height: 400px;
        margin-bottom: 40px;
        overflow: visible;
    }
    
    .marketing-cube {
        width: 280px;
        height: 280px;
    }
    
    .hero-section .cube-face {
        width: 280px;
        height: 280px;
        padding: 16px;
        background: linear-gradient(180deg, #11162e 0%, #0e1330 100%) !important;
    }
    
    .hero-section .cube-face.front { transform: translateZ(140px); }
    .hero-section .cube-face.back { transform: rotateY(180deg) translateZ(140px); }
    .hero-section .cube-face.right { transform: rotateY(90deg) translateZ(140px); }
    .hero-section .cube-face.left { transform: rotateY(-90deg) translateZ(140px); }
    .hero-section .cube-face.top { transform: rotateX(90deg) translateZ(140px); }
    .hero-section .cube-face.bottom { transform: rotateX(-90deg) translateZ(140px); }
    
    .hero-section .face-content {
        padding-top: 35px;
        gap: 12px;
    }
    
    .hero-section .cube-face .bar-chart {
        height: 100px !important;
        padding: 8px 12px !important;
    }
    
    .hero-section .cube-face .bar {
        width: 24px !important;
    }
    
    .hero-section .heatmap {
        height: 100px;
        padding: 15px;
        grid-template-columns: repeat(6, 1fr);
        gap: 4px;
    }
    
    .hero-section .performance-chart {
        height: 100px;
    }
    
    .metrics {
        gap: 8px;
        margin-top: 10px;
    }
    
    .metric {
        padding: 8px 6px;
    }
    
    .metric .value {
        font-size: 16px;
    }
    
    .metric .label {
        font-size: 9px;
    }
    
    .service-card {
        padding: 12px;
    }
    
    .service-card .title {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .service-card .value {
        font-size: 22px;
        margin-bottom: 3px;
    }
    
    .service-card .desc {
        font-size: 10px;
    }
    
    .face-badge {
        font-size: 9px;
        padding: 4px 8px;
        top: 12px;
        left: 12px;
    }
}

/* Extra small devices */
@media (max-width: 400px) {
    .hero-3d-stage {
        height: 380px;
        perspective: 1200px;
    }
    
    .marketing-cube {
        width: 260px;
        height: 260px;
    }
    
    .hero-section .cube-face {
        width: 260px;
        height: 260px;
        padding: 14px;
    }
    
    .hero-section .cube-face.front { transform: translateZ(130px); }
    .hero-section .cube-face.back { transform: rotateY(180deg) translateZ(130px); }
    .hero-section .cube-face.right { transform: rotateY(90deg) translateZ(130px); }
    .hero-section .cube-face.left { transform: rotateY(-90deg) translateZ(130px); }
    .hero-section .cube-face.top { transform: rotateX(90deg) translateZ(130px); }
    .hero-section .cube-face.bottom { transform: rotateX(-90deg) translateZ(130px); }
    
    .hero-section .face-content {
        padding-top: 30px;
        gap: 10px;
    }
    
    .hero-section .cube-face .bar-chart {
        height: 90px !important;
        padding: 6px 10px !important;
    }
    
    .hero-section .cube-face .bar {
        width: 20px !important;
    }
    
    .hero-section .heatmap {
        height: 90px;
        padding: 12px;
        grid-template-columns: repeat(5, 1fr);
        gap: 3px;
    }
    
    .hero-section .performance-chart {
        height: 90px;
    }
    
    .metrics {
        gap: 6px;
        margin-top: 8px;
    }
    
    .metric {
        padding: 6px 4px;
    }
    
    .metric .value {
        font-size: 14px;
    }
    
    .metric .label {
        font-size: 8px;
    }
    
    .service-card {
        padding: 10px;
    }
    
    .service-card .title {
        font-size: 11px;
        margin-bottom: 4px;
    }
    
    .service-card .value {
        font-size: 20px;
        margin-bottom: 2px;
    }
    
    .service-card .desc {
        font-size: 9px;
    }
    
    .face-badge {
        font-size: 8px;
        padding: 3px 6px;
        top: 10px;
        left: 10px;
    }
}

/* Performance optimizations */
.marketing-cube {
    will-change: transform;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .marketing-cube {
        animation: none;
    }
    
    .chart-line,
    .chart-dots circle,
    .bar,
    .heat-cell,
    .metric .value {
        animation: none;
        opacity: 1;
        stroke-dashoffset: 0;
        height: var(--bar-height);
        r: 4;
    }
}
