/* ================================
   Complexity Reducer Styles
   Direct Connect Mobile Interactive Feature
   ================================ */

/* ================================
   Page Header
   ================================ */
.complexity-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--text-white);
    padding: 120px 0 80px;
    margin-top: 80px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.complexity-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)" /></svg>');
    opacity: 0.3;
}

.complexity-header .header-content {
    position: relative;
    z-index: 1;
}

.complexity-header h1 {
    color: var(--text-white);
    margin-bottom: 1rem;
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
}

.complexity-header .lead {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.25rem;
    margin-bottom: 3rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.header-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 2rem;
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent-color);
    line-height: 1;
}

.stat-label {
    display: block;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 0.5rem;
}

/* ================================
   Interactive Container
   ================================ */
.complexity-reducer-section {
    padding: 80px 0;
    background-color: var(--bg-light);
}

.interactive-container {
    background-color: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-hover);
    padding: 3rem;
    margin: 3rem 0;
    position: relative;
    overflow: hidden;
}

.stage-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-light), rgba(248, 249, 250, 0.5));
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

.stage-number {
    width: 40px;
    height: 40px;
    background-color: var(--primary-color);
    color: var(--text-white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
}

.stage-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

/* ================================
   Chaos Viewport Container
   ================================ */
.word-cloud-container {
    position: relative;
    height: 400px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: var(--border-radius);
    overflow: hidden;
    margin: 2rem 0;
    border: 2px solid var(--border-light);
}

#three-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.word-cloud-fallback {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: block;
    background: var(--bg-light);
}

.chaotic-words {
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 200%;
    overflow: hidden;
    display: block;
}

.chaos-term {
    position: absolute;
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 25px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(220, 53, 69, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    user-select: none;
    z-index: 1;
}

.chaos-term:hover {
    transform: scale(1.2) !important;
    z-index: 100;
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.5);
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.chaos-term.high-complexity {
    font-size: 1.1rem;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, #8e44ad, #732d91);
    box-shadow: 0 6px 20px rgba(142, 68, 173, 0.4);
}

.chaos-term.medium-complexity {
    font-size: 1rem;
    background: linear-gradient(135deg, #e67e22, #d35400);
    box-shadow: 0 5px 18px rgba(230, 126, 34, 0.4);
}

.chaos-term.vertical-indicator {
    border-left: 4px solid rgba(255, 255, 255, 0.8);
}

.chaos-term.vertical-indicator::after {
    content: attr(data-vertical);
    position: absolute;
    top: -8px;
    right: -8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 400;
}

/* Tooltip for definitions */
.chaos-term[title] {
    position: relative;
}

.chaos-term-tooltip {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.8rem;
    max-width: 250px;
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    line-height: 1.4;
}

.chaos-term:hover .chaos-term-tooltip {
    opacity: 1;
    visibility: visible;
}

.chaos-term-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

/* ================================
   Stage Controls
   ================================ */
.stage-controls {
    text-align: center;
    margin: 2rem 0;
}

.complexity-trigger {
    font-size: 2rem;
    padding: 25px 50px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    font-weight: 700;
}

.complexity-trigger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

.complexity-trigger:disabled:hover {
    transform: none !important;
}

.loading-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.control-hint {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 1rem;
}

/* ================================
   Simplification Grid
   ================================ */
.simplification-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.transformation-pair {
    background-color: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    position: relative;
    transition: var(--transition);
    border: 2px solid var(--border-light);
    box-shadow: var(--shadow);
}

.transformation-pair:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.transformation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.complexity-score {
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.complexity-score.extremely-complex {
    background: linear-gradient(135deg, #8e44ad, #732d91);
    color: white;
}

.complexity-score.very-complex {
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: white;
}

.complexity-score.complex {
    background: linear-gradient(135deg, #f39c12, #e08e0b);
    color: white;
}

.vertical-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--primary-light);
    color: var(--primary-color);
    border-radius: 10px;
    font-weight: 500;
}

.complex-term {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    margin-bottom: 1rem;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.complex-term:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
}

.term-text {
    font-weight: 700;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.term-definition {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.4;
}

.arrow-down {
    text-align: center;
    color: var(--primary-color);
    margin: 1rem 0;
    position: relative;
}

.arrow-down i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.transform-label {
    font-size: 0.8rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.simple-term {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 1rem;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    margin-bottom: 1rem;
}

.simple-term:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 125, 192, 0.4);
}

.plain-explanation {
    font-size: 0.85rem;
    opacity: 0.9;
    margin-top: 0.5rem;
    font-style: italic;
    line-height: 1.4;
}

.dcm-approach {
    background: linear-gradient(135deg, var(--primary-light), rgba(248, 249, 250, 0.8));
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    position: relative;
}

.approach-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.approach-text {
    color: var(--text-dark);
    line-height: 1.5;
    font-weight: 500;
}

/* Modal tooltip styles */
@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    to { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

.term-details-tooltip .tooltip-content {
    position: relative;
    line-height: 1.6;
    color: var(--text-dark);
}

.close-tooltip {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    width: 30px;
    height: 30px;
    border: none;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-tooltip:hover {
    background: var(--primary-dark);
}

/* ================================
   Results Comparison
   ================================ */
.comparison-container {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 2rem;
    align-items: center;
    margin: 2rem 0;
}

.comparison-side {
    background-color: var(--bg-light);
    border-radius: var(--border-radius);
    padding: 2rem;
    text-align: center;
}

.typical-agency {
    border: 2px solid #dc3545;
}

.dcm-approach {
    border: 2px solid var(--primary-color);
}

.comparison-side h4 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

.comparison-divider {
    background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
}

.metrics-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--bg-white);
    border-radius: var(--border-radius);
    border-left: 4px solid transparent;
}

.typical-agency .metric-item {
    border-left-color: #dc3545;
}

.dcm-approach .metric-item {
    border-left-color: var(--primary-color);
}

.metric-label {
    font-weight: 500;
    color: var(--text-dark);
}

.metric-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.typical-agency .metric-value {
    color: #dc3545;
}

.dcm-approach .metric-value {
    color: var(--primary-color);
}

/* ================================
   Industry Selector
   ================================ */
.industry-selector h3 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--text-dark);
}

.industry-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.industry-option {
    background-color: var(--bg-light);
    border: 2px solid var(--border-light);
    border-radius: var(--border-radius);
    padding: 2rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.industry-option:hover {
    border-color: var(--primary-color);
    background-color: var(--primary-light);
    transform: translateY(-2px);
}

.industry-option.selected {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    transform: scale(1.05);
}

.industry-option i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--primary-color);
    display: block;
}

.industry-option.selected i {
    color: white;
}

.industry-option span {
    font-weight: 600;
    font-size: 1rem;
}

/* ================================
   Complexity Preview
   ================================ */
.complexity-preview {
    background: linear-gradient(135deg, var(--primary-light), rgba(248, 249, 250, 0.8));
    border-radius: var(--border-radius);
    padding: 2rem;
    margin: 2rem 0;
    border: 2px solid var(--primary-color);
    animation: slideInUp 0.5s ease;
}

.preview-content h4 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 2rem;
}

.reduction-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.reduction-stat {
    text-align: center;
    background-color: var(--bg-white);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    line-height: 1;
}

.stat-description {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.simplified-strategy {
    background-color: var(--bg-white);
    border-radius: var(--border-radius);
    padding: 2rem;
    border-left: 4px solid var(--primary-color);
}

.strategy-title {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.strategy-points {
    list-style: none;
    padding: 0;
}

.strategy-points li {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-light);
    position: relative;
    padding-left: 2rem;
}

.strategy-points li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 0.75rem;
    color: var(--primary-color);
    font-weight: bold;
}

.strategy-points li:last-child {
    border-bottom: none;
}

/* ================================
   Final CTA
   ================================ */
.final-cta {
    text-align: center;
    margin-top: 3rem;
    padding: 2rem;
    background: linear-gradient(135deg, var(--bg-white), var(--primary-light));
    border-radius: var(--border-radius);
    border: 2px solid var(--primary-color);
}

/* Center the Free Strategy button in CTA section */
.cta-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn-large {
    font-size: 1.3rem;
    padding: 18px 36px;
    margin-bottom: 1rem;
}

.cta-subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0;
}

/* ================================
   Stage Navigation
   ================================ */
.stage-navigation {
    text-align: center;
    margin: 2rem 0;
    padding: 1rem;
}

.stage-navigation button {
    font-size: 1.1rem;
    padding: 12px 24px;
}

/* ================================
   How It Works Section
   ================================ */
.how-it-works {
    padding: var(--section-padding);
    background-color: var(--bg-white);
    position: relative;
    z-index: 5; /* Lower z-index so chaos text appears above */
}

/* ================================
   Responsive Design
   ================================ */
@media (max-width: 968px) {
    .complexity-header {
        padding: 100px 0 60px;
    }
    
    .header-stats {
        gap: 2rem;
    }
    
    .interactive-container {
        padding: 2rem;
    }
    
    .word-cloud-container {
        height: 300px;
    }
    
    .comparison-container {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .comparison-divider {
        width: 40px;
        height: 40px;
        margin: 1rem auto;
    }
    
    .industry-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .reduction-stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-stats {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .stat-number {
        font-size: 2.5rem;
    }
    
    .interactive-container {
        padding: 1.5rem;
        margin: 2rem 0;
    }
    
    .stage-indicator {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .simplification-grid {
        grid-template-columns: 1fr;
    }
    
    .industry-grid {
        grid-template-columns: 1fr;
    }
    
    .industry-option {
        padding: 1.5rem;
    }
    
    .btn-large {
        width: 100%;
        font-size: 1.1rem;
        padding: 15px 20px;
    }
}

@media (max-width: 480px) {
    .complexity-header {
        padding: 80px 0 40px;
    }
    
    .complexity-header h1 {
        font-size: 2rem;
    }
    
    .interactive-container {
        padding: 1rem;
    }
    
    .word-cloud-container {
        height: 250px;
    }
    
    .chaotic-words {
        padding: 1rem;
    }
    
    .word-item {
        padding: 0.25rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .transformation-pair {
        padding: 1rem;
    }
}

/* ================================
   Print Styles
   ================================ */
@media print {
    .complexity-header,
    .interactive-container,
    .stage-controls,
    .stage-navigation,
    .final-cta,
    #three-canvas {
        display: none;
    }
    
    .how-it-works {
        page-break-inside: avoid;
    }
}

/* ================================
   Accessibility Enhancements
   ================================ */
@media (prefers-reduced-motion: reduce) {
    .word-item.chaotic {
        animation: none;
    }
    
    .complexity-preview {
        animation: none;
    }
    
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

@media (prefers-contrast: high) {
    .word-item.complex {
        background: #000;
        color: #fff;
        border: 2px solid #fff;
    }
    
    .industry-option {
        border-width: 3px;
    }
    
    .complexity-trigger {
        border-width: 3px;
    }
}

/* ================================
   Full Page Background Words
   ================================ */
.page-background-words {
    position: fixed;
    top: 10%;
    left: 10%;
    width: 80vw;
    height: 80vh;
    pointer-events: none;
    z-index: 50;
    overflow: hidden;
    border-radius: 20px;
}

.background-word {
    position: absolute;
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0.8;
    color: rgba(108, 117, 125, 0.9);
    text-shadow: 0 2px 8px rgba(108, 117, 125, 0.1);
    user-select: none;
    transform-origin: center;
    transition: opacity 0.3s ease;
    z-index: 55 !important;
}

.background-word.high-complexity {
    font-size: clamp(3.375rem, 6.75vw, 5.625rem);
    font-weight: 700;
    opacity: 0.9;
    color: rgba(220, 53, 69, 0.8);
    text-shadow: 0 3px 12px rgba(220, 53, 69, 0.15);
}

.background-word.medium-complexity {
    font-size: clamp(2.7rem, 5.625vw, 4.5rem);
    font-weight: 600;
    opacity: 0.85;
    color: rgba(253, 126, 20, 0.8);
    text-shadow: 0 2px 10px rgba(253, 126, 20, 0.12);
}

.background-word.low-complexity {
    font-size: clamp(2.25rem, 4.5vw, 3.375rem);
    font-weight: 500;
    opacity: 0.8;
    color: rgba(0, 123, 192, 0.7);
    text-shadow: 0 2px 8px rgba(0, 123, 192, 0.1);
}

/* Background words hover effect on page interaction */
body:hover .background-word {
    opacity: 0.4;
}

/* Background Words Notice Styling */
.background-words-notice {
    text-align: center;
    padding: 2rem;
    background: rgba(248, 249, 250, 0.8);
    border: 2px solid var(--border-light);
    border-radius: 12px;
    margin: 2rem 0;
}

.background-words-notice p {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-style: italic;
}

.complexity-level {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.level-indicator {
    font-weight: 600;
    color: var(--text-dark);
}

.level-meter {
    width: 400px;
    height: 40px;
    background: rgba(220, 53, 69, 0.1);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(220, 53, 69, 0.3);
}

.level-fill {
    display: block;
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ffc107, #fd7e14, #dc3545);
    border-radius: 20px;
    animation: pulse-chaos 2s ease-in-out infinite;
}

.level-text {
    font-weight: 700;
    color: #dc3545;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 1.2rem;
    animation: flash-text 1.5s ease-in-out infinite;
}

@keyframes pulse-chaos {
    0%, 100% { 
        transform: scaleX(1);
        opacity: 1;
    }
    50% { 
        transform: scaleX(1.05);
        opacity: 0.8;
    }
}

@keyframes flash-text {
    0%, 100% { 
        opacity: 1;
        transform: scale(1);
    }
    50% { 
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Smooth, performant CSS animations */
@keyframes float-gentle {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    25% {
        transform: translate(30px, -20px) rotate(5deg) scale(1.05);
    }
    50% {
        transform: translate(-20px, 30px) rotate(-3deg) scale(0.95);
    }
    75% {
        transform: translate(25px, 15px) rotate(4deg) scale(1.02);
    }
    100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
}

@keyframes drift-slow {
    0% {
        transform: translate(0, 0) rotate(0deg);
    }
    33% {
        transform: translate(-40px, 20px) rotate(-10deg);
    }
    66% {
        transform: translate(35px, -25px) rotate(8deg);
    }
    100% {
        transform: translate(0, 0) rotate(0deg);
    }
}

@keyframes orbit-center {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
    }
    25% {
        transform: translate(20px, -30px) rotate(90deg) scale(1.1);
    }
    50% {
        transform: translate(0, -20px) rotate(180deg) scale(0.9);
    }
    75% {
        transform: translate(-20px, -30px) rotate(270deg) scale(1.05);
    }
    100% {
        transform: translate(0, 0) rotate(360deg) scale(1);
    }
}

/* Mobile fallback - static background pattern */
@media (max-width: 768px) {
    .background-word {
        animation: none !important;
        opacity: 0.15 !important;
        transform: rotate(5deg) scale(0.8);
        transition: opacity 0.3s ease;
    }
    
    .background-word.high-complexity {
        opacity: 0.25 !important;
        font-size: clamp(1.5rem, 4vw, 2.5rem);
    }
    
    .background-word.medium-complexity {
        opacity: 0.2 !important;
        font-size: clamp(1.2rem, 3.5vw, 2rem);
    }
    
    .background-word.low-complexity {
        opacity: 0.15 !important;
        font-size: clamp(1rem, 3vw, 1.5rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .background-word {
        animation: none !important;
        opacity: 0.2 !important;
    }
}

/* Position background words above header but below content */
.page-background-words {
    z-index: 5 !important;
}

.background-word {
    z-index: 5 !important;
}

/* Make sure main content has proper background for readability but lower z-index than chaos */
main {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.65);
}

.navbar {
    position: relative;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.footer {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.75);
}

/* Ensure all sections have transparent backgrounds to show chaos words behind them */
.complexity-reducer-section,
.how-it-works,
.cta-section {
    position: relative;
    z-index: 10;
    background: rgba(255, 255, 255, 0.8);
    margin: 2rem 0;
    padding: 2rem;
    border-radius: 12px;
    backdrop-filter: blur(5px);
}

/* CSS-Only Chaos Background - Efficient Implementation */
.chaos-background {
    position: fixed;
    top: 80px; /* Start below navbar */
    left: 0;
    width: 100vw;
    height: calc(100vh - 80px);
    overflow: hidden;
    pointer-events: none;
    z-index: 200;
}

/* Left column of chaos text - Scary red effects */
.chaos-background::before {
    content: "Customer Lifetime Value Attribution •   Omnichannel Journey Orchestration • Programmatic Bidding Optimization •     Cross-Device Identity Resolution •  Multi-Touch Attribution Modeling •    Behavioral Segmentation Algorithms • Dynamic Creative Optimization •   Marketing Mix Modeling •  Propensity Scoring Models •     Incrementality Testing Frameworks • Conversion Attribution Windows •   Audience Overlap Analysis •  Lookalike Modeling Algorithms •    Marketing Automation Workflows • Cohort Analysis Frameworks •   Customer Lifetime Value Attribution •    Omnichannel Journey Orchestration •  Programmatic Bidding Optimization • Cross-Device Identity Resolution •     Multi-Touch Attribution Modeling • Behavioral Segmentation Algorithms •   Dynamic Creative Optimization •  Marketing Mix Modeling •    Propensity Scoring Models • Incrementality Testing Frameworks •   Conversion Attribution Windows •  Audience Overlap Analysis •     Lookalike Modeling Algorithms • Marketing Automation Workflows •   Cohort Analysis Frameworks •  Customer Lifetime Value Attribution •    Omnichannel Journey Orchestration • Programmatic Bidding Optimization •   Cross-Device Identity Resolution •  Multi-Touch Attribution Modeling •     Behavioral Segmentation Algorithms • Dynamic Creative Optimization •   Marketing Mix Modeling •  Propensity Scoring Models • Customer Lifetime Value Attribution •   Omnichannel Journey Orchestration • Programmatic Bidding Optimization •     Cross-Device Identity Resolution •  Multi-Touch Attribution Modeling •    Behavioral Segmentation Algorithms • Dynamic Creative Optimization •   Marketing Mix Modeling •  Propensity Scoring Models •     Incrementality Testing Frameworks • Conversion Attribution Windows •   Audience Overlap Analysis •  Lookalike Modeling Algorithms •    Marketing Automation Workflows • ";
    position: absolute;
    left: 15%;
    width: 40%;
    height: 800vh;
    top: 0;
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 4vw, 3.5rem);
    line-height: 1.1;
    color: #cc1100;
    white-space: normal;
    overflow: hidden;
    /* Scary effects - Left column */
    text-shadow: 
        0 0 8px #cc1100,
        0 0 16px #cc110080,
        0 0 24px #cc110040;
    filter: blur(1px);
    animation: 
        scroll-chaos-left 30s linear infinite,
        chaos-flicker-red 0.8s ease-in-out infinite alternate;
}

/* Right column of chaos text - Scary orange effects */
.chaos-background::after {
    content: "  Advanced Programmatic Display •     Cross-Platform Attribution Analytics • Real-Time Bidding Engine •   Multi-Dimensional Segmentation •    Predictive Behavior Modeling • Campaign Performance Optimization •     Cross-Channel Conversion Tracking •  Dynamic Retargeting Algorithms •   Advanced Analytics Dashboard •    Competitive Intelligence Frameworks •  Marketing Technology Integration •     Customer Journey Mapping • Advanced Email Automation •   Social Algorithm Optimization •    Content Performance Attribution •  Advanced Programmatic Display •     Cross-Platform Attribution Analytics •  Real-Time Bidding Engine •   Multi-Dimensional Segmentation • Predictive Behavior Modeling •     Campaign Performance Optimization •  Cross-Channel Conversion Tracking •    Dynamic Retargeting Algorithms • Advanced Analytics Dashboard •     Competitive Intelligence Frameworks •  Marketing Technology Integration •   Customer Journey Mapping •    Advanced Email Automation • Social Algorithm Optimization •     Content Performance Attribution •  Advanced Programmatic Display •   Cross-Platform Attribution Analytics •    Real-Time Bidding Engine • Multi-Dimensional Segmentation •     Predictive Behavior Modeling •  Campaign Performance Optimization • Advanced Programmatic Display •     Cross-Platform Attribution Analytics • Real-Time Bidding Engine •   Multi-Dimensional Segmentation •    Predictive Behavior Modeling • Campaign Performance Optimization •     Cross-Channel Conversion Tracking •  Dynamic Retargeting Algorithms •   Advanced Analytics Dashboard • ";
    position: absolute;
    left: 45%;
    width: 40%;
    height: 800vh;
    top: 0;
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 700;
    font-size: clamp(1.9rem, 4.2vw, 3.6rem);
    line-height: 1.1;
    color: #FF4500;
    white-space: normal;
    overflow: hidden;
    /* Scary effects - Right column */
    text-shadow: 
        0 0 6px #FF4500,
        0 0 12px #FF450080,
        0 0 20px #FF450040;
    filter: blur(1.2px);
    animation: 
        scroll-chaos-right 25s linear infinite,
        chaos-flicker-orange 1.2s ease-in-out infinite alternate;
    animation-delay: -8s, 0.3s;
}

.chaos-scroll-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 300vh; /* Triple height for seamless loop */
    display: flex;
    flex-direction: column;
    justify-content: space-evenly;
}

.chaos-column-left .chaos-scroll-container {
    animation: scroll-up-slow 20s linear infinite;
    animation-delay: 0s;
}

.chaos-column-right .chaos-scroll-container {
    animation: scroll-up-fast 15s linear infinite;
    animation-delay: -5s;
}

.chaos-word {
    font-family: 'Inter', Arial, sans-serif;
    font-weight: 700;
    font-size: clamp(2.2rem, 4.5vw, 3.8rem);
    color: #cc1100;
    white-space: nowrap;
    text-align: left;
    display: block;
    margin: 1.5rem 0;
    line-height: 1.1;
    padding: 0.5rem 1rem;
    animation: chaos-shake 0.15s ease-in-out infinite;
    flex-shrink: 0;
}

/* Scary warm color variations */
.chaos-word:nth-child(2n) {
    color: #FF4500; /* Orange Red */
    animation: chaos-vibrate 0.12s ease-in-out infinite;
}

.chaos-word:nth-child(3n) {
    color: #B22222; /* Fire Brick */
    animation: chaos-jitter 0.18s ease-in-out infinite;
}

.chaos-word:nth-child(4n) {
    font-size: clamp(2.8rem, 5.5vw, 4.5rem);
    font-weight: 800;
    color: #8B0000; /* Dark Red */
    margin: -12px 0;
}

.chaos-word:nth-child(5n) {
    color: #CD853F; /* Peru - Red Brown */
    font-weight: 800;
}

.chaos-word:nth-child(6n) {
    color: #A0522D; /* Saddle Brown */
    font-size: clamp(1.9rem, 4vw, 3.2rem);
}

.chaos-word:nth-child(7n) {
    color: #D2691E; /* Chocolate */
    margin: -5px 0;
}

.chaos-word:nth-child(8n) {
    color: #800000; /* Maroon */
    font-weight: 900;
    margin: -15px 0;
}

/* CSS-Only Chaos Scrolling Animations with Rotation - SEAMLESS LOOP */
@keyframes scroll-chaos-left {
    0% {
        transform: translateY(50vh) rotate(-2deg);
    }
    100% {
        transform: translateY(-350vh) rotate(-2deg);
    }
}

@keyframes scroll-chaos-right {
    0% {
        transform: translateY(50vh) rotate(2.5deg);
    }
    100% {
        transform: translateY(-350vh) rotate(2.5deg);
    }
}

/* Scary Effects - Flickering */
@keyframes chaos-flicker-red {
    0% { opacity: 0.7; }
    100% { opacity: 0.95; }
}

@keyframes chaos-flicker-orange {
    0% { opacity: 0.75; }
    100% { opacity: 0.9; }
}

/* Scary Effects - Color Pulsing (Seizure-safe speeds) */
@keyframes chaos-color-pulse-red {
    0% { color: #cc1100; }
    33% { color: #8B0000; }
    66% { color: #B22222; }
    100% { color: #cc1100; }
}

@keyframes chaos-color-pulse-orange {
    0% { color: #FF4500; }
    33% { color: #CD853F; }
    66% { color: #A0522D; }
    100% { color: #FF4500; }
}


/* Responsive scary effects - reduce on small screens */
@media (max-width: 768px) {
    .chaos-background::before,
    .chaos-background::after {
        font-size: clamp(1.2rem, 5vw, 2.8rem);
        text-shadow: 
            0 0 4px currentColor,
            0 0 8px currentColor;
        /* Reduce height and animation range on mobile to minimize gaps */
        height: 400vh;
    }
    
    @keyframes scroll-chaos-left {
        0% { transform: translateY(30vh) rotate(-2deg); }
        100% { transform: translateY(-170vh) rotate(-2deg); }
    }
    
    @keyframes scroll-chaos-right {
        0% { transform: translateY(30vh) rotate(2.5deg); }
        100% { transform: translateY(-170vh) rotate(2.5deg); }
    }
}

@media (max-width: 480px) {
    .chaos-background::before,
    .chaos-background::after {
        /* Even more conservative on small phones */
        height: 300vh;
        opacity: 0.6;
    }
}

/* Z-Index Hierarchy - Interactive elements above chaos */
.interactive-container {
    position: relative;
    z-index: 600;
    isolation: isolate;
}

.complexity-stage {
    position: relative;
    z-index: 300;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
}

/* All other elements should be below chaos text */
.simplification-stage,
.transformation-pair,
.results-stage,
.personalization-stage,
.stage-controls,
.btn,
.button,
.cta-button,
.background-words-notice,
.complexity-level,
button,
a.button,
.btn-primary,
.btn-secondary {
    position: relative;
    z-index: 50 !important; /* Below chaos text */
}

/* Exception: complexity-stage needs to be ABOVE chaos text */
.complexity-stage {
    z-index: 300 !important; /* Above chaos text */
}

/* Specifically target CTA buttons */
.cta-actions,
.cta-actions .btn,
.final-cta,
.final-cta .btn,
.cta-section .btn {
    position: relative !important;
    z-index: 50 !important; /* Below chaos text */
}

.transformation-pair {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.page-header,
.complexity-header {
    position: relative;
    z-index: 1;
    background: linear-gradient(135deg, 
        rgba(0, 123, 192, 0.95) 0%, 
        rgba(0, 123, 192, 0.85) 100%);
}

/* Header content (container) below chaos words but above background */
.complexity-header .container,
.page-header .container {
    position: relative;
    z-index: 2;
}

/* Chaos text fade-in animation */
@keyframes chaos-fade-in {
    0% {
        opacity: 0;
        transform: scale(0.95);
    }
    100% {
        opacity: 0.8;
        transform: scale(1);
    }
}

.background-word {
    animation: chaos-fade-in 1s ease-out;
}

/* MOBILE MENU Z-INDEX FIX */
/* When mobile menu is open, hide chaos animation and ensure proper layering */
.menu-open {
    overflow: hidden;
}

.menu-open .chaos-background::before,
.menu-open .chaos-background::after {
    opacity: 0.1 !important; /* Dim chaos during mobile menu */
    z-index: 1 !important; /* Much lower than mobile menu */
}

.nav-menu.active {
    z-index: 9999 !important; /* Above everything including chaos */
}

.nav-toggle {
    z-index: 10000 !important; /* Above mobile menu */
    position: relative;
}

/* Ensure chaos pseudo-elements respect the hierarchy */
.chaos-container::before,
.chaos-container::after {
    z-index: 200; /* Default chaos level */
}

.chaos-background::before,
.chaos-background::after {
    z-index: 200; /* Default chaos level */
}

.menu-open .chaos-container::before,
.menu-open .chaos-container::after {
    z-index: 1 !important; /* Lower during mobile menu */
    opacity: 0.2 !important; /* Even dimmer */
}

/* MODAL POPUP APPROACH - NO BACKDROP, FLOATING ABOVE CHAOS */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent; /* No dark backdrop - let chaos show through */
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    pointer-events: none; /* Allow interaction with chaos behind */
}

.modal-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 
        0 0 0 20px rgba(255, 255, 255, 0.95),  /* Large white halo/padding */
        0 25px 80px rgba(0, 0, 0, 0.4);        /* Strong shadow for separation */
    width: 80%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
    margin-top: -5vh;
    pointer-events: auto; /* Re-enable interaction for the modal itself */
    border: 3px solid #007dc0; /* Clear border definition */
}

.modal-content {
    padding: 0;
}

.modal-header {
    padding: 2rem 2.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 1.0); /* Ensure solid white background */
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: #aaa;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.3s ease;
}

.modal-close:hover {
    color: #007dc0;
}

.modal-body {
    padding: 2.5rem 3rem;
    text-align: center;
    background: rgba(255, 255, 255, 1.0); /* Ensure solid white background */
}

.modal-footer {
    padding: 2rem 2.5rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 1.0); /* Ensure solid white background */
}

.demo-card {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    max-width: 500px;
    margin: 0 auto;
}

.demo-card h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
}

.demo-card p {
    color: #7f8c8d;
    margin-bottom: 2rem;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* When complexity stage is visible, dim the chaos even more (ONLY if it has .active class) */
.complexity-stage.active ~ .chaos-background::before,
.complexity-stage.active ~ .chaos-background::after {
    opacity: 0.15 !important;
    z-index: 1 !important;
}

/* JavaScript-created full-page chaos should not interfere with layout */
.full-page-chaos-background {
    z-index: 50 !important; /* Below complexity stage (10000) and navbar (1000) */
    pointer-events: none !important;
    /* Ensure it doesn't create stacking context issues */
    isolation: isolate;
}

/* Ensure any chaos columns respect z-index hierarchy */
.chaos-column {
    z-index: inherit !important;
}