/* Insights Cards Animation Section */
:root {
    --primary-orange: #FF7B00;
    --accent-blue: #87CEEB;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --bg-dark: #1a1a1a;
    --border-light: #e5e7eb;
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    --card-width: 280px;  /* Reduced from 360px for better spacing */
    --card-height: 380px; /* Proportionally reduced */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.insights-section {
    position: relative;
    padding: 60px 20px;
    background: transparent;
    overflow: hidden;
    min-height: 700px;
}

.insights-section h2 {
    text-align: center;
    color: var(--text-primary);
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    position: relative;
    z-index: 10;
}

.insights-section h2 .smaller-text {
    display: block;
    font-size: 1.2rem;
    font-weight: 400;
    color: var(--primary-orange);
    margin-top: 8px;
}

.insights-section > p {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin: 0 auto 50px;
    max-width: 800px;
    position: relative;
    z-index: 10;
}

/* Container for the animation */
.insights-animation-container {
    position: relative;
    width: 100%;
    height: 600px;
    overflow: hidden;
}

/* Deck position - against left side */
.insights-deck {
    position: absolute;
    left: 50px;
    top: 50%;
    transform: translateY(-50%);
    width: var(--card-width);
    height: var(--card-height);
}

/* Card base styling - Portrait orientation */
.insight-card {
    position: absolute;
    width: var(--card-width);
    height: var(--card-height);
    transform-style: preserve-3d;
    transition: all 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Initial deck position for all cards */
.insight-card.in-deck {
    left: 50px;
    top: 50%;
    transform: translateY(-50%);
}

/* Stack cards with slight offset - for dealing cards */
.insight-card.dealing.in-deck:nth-child(6) { z-index: 10; }
.insight-card.dealing.in-deck:nth-child(7) { z-index: 9; transform: translateY(-50%) translateY(1px); }
.insight-card.dealing.in-deck:nth-child(8) { z-index: 8; transform: translateY(-50%) translateY(2px); }
.insight-card.dealing.in-deck:nth-child(9) { z-index: 7; transform: translateY(-50%) translateY(3px); }
.insight-card.dealing.in-deck:nth-child(10) { z-index: 6; transform: translateY(-50%) translateY(4px); }

/* Remaining deck cards - always stay in pile */
.insights-deck-card {
    position: absolute;
    width: var(--card-width);
    height: var(--card-height);
    left: 50px;
    top: 50%;
    background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 2px solid rgba(255, 123, 0, 0.3);
    border-radius: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Inner border for deck cards */
.insights-deck-card::before {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    border: 2px solid var(--primary-orange);
    border-radius: 10px;
    pointer-events: none;
    z-index: 1;
}

/* Stack the deck cards */
.insights-deck-card:nth-child(1) { transform: translateY(-50%) translateY(0px); z-index: 1; }
.insights-deck-card:nth-child(2) { transform: translateY(-50%) translateY(2px); z-index: 2; }
.insights-deck-card:nth-child(3) { transform: translateY(-50%) translateY(4px); z-index: 3; }
.insights-deck-card:nth-child(4) { transform: translateY(-50%) translateY(6px); z-index: 4; }
.insights-deck-card:nth-child(5) { transform: translateY(-50%) translateY(8px); z-index: 5; }

/* Card back pattern for deck - Logo instead of text */
.insights-deck-card::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80px;
    height: 80px;
    background-image: url('../assets/logo-navbar.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.4;
    /* Filter to change black parts to orange */
    filter: brightness(0) saturate(100%) invert(56%) sepia(89%) saturate(2466%) hue-rotate(6deg) brightness(102%) contrast(101%);
}

/* Dealt positions - properly spaced for 4 cards desktop */
.insight-card.dealt-1 {
    left: 400px;  /* Deck at 50px + 280px card + 70px gap */
    top: 50%;
    transform: translateY(-50%);
    z-index: 11;
}

.insight-card.dealt-2 {
    left: 720px;  /* 400 + 280 + 40px gap */
    top: 50%;
    transform: translateY(-50%);
    z-index: 12;
}

.insight-card.dealt-3 {
    left: 1040px;  /* 720 + 280 + 40px gap */
    top: 50%;
    transform: translateY(-50%);
    z-index: 13;
}

.insight-card.dealt-4 {
    left: 1360px;  /* 1040 + 280 + 40px gap */
    top: 50%;
    transform: translateY(-50%);
    z-index: 14;
}

/* Card inner container for flip */
.insight-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.8s;
}

.insight-card.flipped .insight-card-inner {
    transform: rotateY(180deg);
}

/* Card faces */
.insight-card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

/* Front face - Shows the actual card content */
.insight-card-front {
    background: var(--bg-white);
    padding: 8px;
}

/* Back face - Shows insights - FORCE complete background coverage */
.insight-card-back {
    background: #000000 !important;
    transform: rotateY(180deg);
    padding: 8px;
    color: white;
    /* Ensure proper isolation from front face */
    isolation: isolate;
    z-index: 100;
    /* Force complete opacity */
    opacity: 1 !important;
    /* Add solid backdrop */
    position: relative;
}

/* Add pseudo-element to create solid backdrop */
.insight-card-back::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000000;
    z-index: -1;
}

/* Card structure matching card-library.css */
.stat-card {
    width: 100%;
    height: 100%;
    background: var(--bg-white);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.stat-card-inner {
    flex: 1;
    border: 1px solid var(--border-light);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    background: var(--bg-white);
    overflow: hidden;
}

/* Card header */
.stat-card-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-white);
}

.stat-module-badge {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
}

.badge-orange { background: linear-gradient(135deg, #FF7B00, #FFA500); }
.badge-blue { background: linear-gradient(135deg, #87CEEB, #4A90E2); }
.badge-green { background: linear-gradient(135deg, #10B981, #059669); }
.badge-purple { background: linear-gradient(135deg, #8B5CF6, #6366F1); }
.badge-red { background: linear-gradient(135deg, #EF4444, #DC2626); }

.stat-header-info {
    flex: 1;
    min-width: 0;
}

/* Make card title styles more specific to override conflicts */
.insights-section .stat-card-title {
    font-size: 16px !important;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.insights-section .stat-card-subtitle {
    font-size: 13px !important;
    color: var(--text-secondary);
    margin-top: 1px;
    line-height: 1.2;
}

/* Header metric styles - be more specific */
.insights-section .stat-primary-metric {
    text-align: right;
    flex-shrink: 0;
}

.insights-section .stat-primary-metric .stat-metric-value {
    font-family: 'Geist Mono', monospace;
    font-size: 28px !important;
    font-weight: 700;
    color: var(--primary-orange);
    line-height: 1;
}

.insights-section .stat-primary-metric .stat-metric-label {
    font-size: 11px !important;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

/* Card content */
.stat-card-content {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Card footer */
.stat-card-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    gap: 8px;
    background: var(--bg-white);
}

.stat-footer-badge {
    padding: 4px 10px;
    background: var(--bg-light);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    flex: 1;
    text-align: center;
}

.stat-footer-badge.primary {
    background: var(--primary-orange);
    color: white;
}

/* Insights styling for back of cards - MAXIMUM blocking power */
.stat-insights-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    background: #000000 !important;
    position: relative;
    z-index: 200 !important;
    /* Force complete opacity */
    opacity: 1 !important;
    /* Ensure text is completely visible */
    isolation: isolate;
}

/* Add pseudo-element backdrop for header too */
.stat-insights-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000000;
    z-index: -1;
}

.stat-insights-badge {
    width: 40px;
    height: 40px;
    background: var(--primary-orange);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Make insights title more specific and prominent - MAXIMUM specificity */
.insights-section .insight-card-back .stat-insights-header .stat-insights-title {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: #FFFFFF !important;
    line-height: 1.1 !important;
    margin: 0 !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.7) !important;
}

.insights-section .insight-card-back .stat-insights-header .stat-insights-subtitle {
    font-size: 13px !important;
    color: var(--primary-orange) !important;
    margin-top: 2px !important;
    line-height: 1.2 !important;
    font-weight: 600 !important;
}

.stat-insights-content {
    padding: 16px;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.4;
    font-size: 13px;
    background: var(--bg-dark);
    position: relative;
    z-index: 5;
}

.stat-insights-content h3 {
    font-size: 14px !important;
}

.stat-insights-content li {
    font-size: 12px !important;
}

/* Specific content styles */
.stat-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-metric-item {
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    text-align: center;
}

/* Metric values inside the grid - override any other styles */
.insights-section .stat-metrics-grid .stat-metric-value {
    font-size: 20px !important;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    margin-bottom: 4px;
}

.insights-section .stat-metrics-grid .stat-metric-label {
    font-size: 11px !important;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-plot-area {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 16px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.stat-data-table {
    width: 100%;
    font-size: 12px;
}

.stat-data-table th {
    padding: 8px;
    background: var(--bg-light);
    font-weight: 600;
    border-bottom: 2px solid var(--border-light);
}

.stat-data-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-light);
}

/* Responsive adjustments - Remove card size changes, let cards flow off-screen naturally */

@media (max-width: 768px) {
    .insights-section {
        padding: 40px 15px;
        min-height: 500px;
    }
    
    .insights-animation-container {
        height: 420px;
    }
    
    /* Full-sized single card for mobile */
    .insight-card,
    .insights-deck-card {
        width: 240px !important;
        height: 320px !important;
    }
    
    .insights-section h2 {
        font-size: 2rem;
    }
    
    .insights-section h2 .smaller-text {
        font-size: 1rem;
    }
    
    .insights-section > p {
        font-size: 1rem;
    }
    
    /* Position deck on far left for mobile */
    .insights-deck,
    .insight-card.in-deck,
    .insights-deck-card {
        left: 20px !important;
    }
    
    /* Center the single dealt card on mobile */
    .insight-card.dealt-1 {
        left: calc(50% - 120px) !important;  /* Center the card */
        right: auto !important;
    }
    
    /* Hide all other dealt positions on mobile */
    .insight-card.dealt-2,
    .insight-card.dealt-3,
    .insight-card.dealt-4 {
        display: none !important;
    }
    
    /* Normal-sized content for single mobile card */
    .insights-section .stat-card-title {
        font-size: 14px !important;
    }
    
    .insights-section .stat-card-subtitle {
        font-size: 11px !important;
    }
    
    .insights-section .stat-primary-metric .stat-metric-value {
        font-size: 24px !important;
    }
    
    .insights-section .stat-primary-metric .stat-metric-label {
        font-size: 10px !important;
    }
    
    .insights-section .stat-metrics-grid .stat-metric-value {
        font-size: 18px !important;
    }
    
    .insights-section .stat-metrics-grid .stat-metric-label {
        font-size: 10px !important;
    }
    
    /* Normal-sized badge and padding */
    .stat-module-badge {
        width: 36px !important;
        height: 36px !important;
        font-size: 16px !important;
    }
    
    .stat-card-header {
        padding: 10px 14px !important;
        gap: 10px !important;
    }
    
    .stat-card-content {
        padding: 14px !important;
    }
    
    .stat-card-footer {
        padding: 8px 12px !important;
        gap: 8px !important;
    }
    
    .stat-footer-badge {
        padding: 4px 8px !important;
        font-size: 10px !important;
    }
    
    /* Normal-sized insights back content */
    .insights-section .insight-card-back .stat-insights-header .stat-insights-title {
        font-size: 16px !important;
    }
    
    .insights-section .insight-card-back .stat-insights-header .stat-insights-subtitle {
        font-size: 12px !important;
    }
    
    .stat-insights-badge {
        width: 36px !important;
        height: 36px !important;
        font-size: 16px !important;
    }
    
    .stat-insights-content {
        padding: 14px !important;
        font-size: 12px !important;
    }
    
    .stat-insights-content h3 {
        font-size: 13px !important;
    }
    
    .stat-insights-content li {
        font-size: 11px !important;
        margin-bottom: 5px !important;
    }
    
    /* Reduce grid gaps */
    .stat-metrics-grid {
        gap: 4px !important;
    }
    
    .stat-metric-item {
        padding: 4px !important;
    }
}