/* ========================================
   DATA X SYSTEM - Print/PDF Styles v3.0
   Professional PDF Export with D3.js Support
======================================== */

@media print {
    @page {
        size: A4 landscape;
        margin: 1.5cm;
    }
    
    @page :first {
        margin-top: 1cm;
    }
    
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }
    
    body {
        font-size: 11pt;
        line-height: 1.4;
        color: #0f172a;
        background: #fff !important;
        margin: 0;
        padding: 0;
    }
    
    /* ========================================
       HIDE NON-PRINTABLE ELEMENTS
    ======================================== */
    
    .site-header,
    .site-footer,
    button,
    .btn,
    .hero-actions,
    .cta-actions,
    nav,
    .section-icon,
    .replay-btn,
    #replay-race-btn,
    .scroll-indicator,
    .loading-indicator,
    .pipeline-label {
        display: none !important;
    }
    
    /* ========================================
       BUILDER MODULE - D3.js Animation
    ======================================== */
    
    .builder-animation-card {
        page-break-inside: avoid;
        margin: 1cm 0;
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
        box-shadow: none !important;
    }
    
    #d3-builder-viz {
        background: rgba(34, 197, 94, 0.06) !important;
        border-radius: 16px !important;
        height: 450px !important;
    }
    
    #d3-builder-viz svg {
        display: block !important;
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Force show all elements in final state */
    #d3-builder-viz circle,
    #d3-builder-viz rect,
    #d3-builder-viz text,
    #d3-builder-viz path {
        opacity: 1 !important;
        animation: none !important;
        transition: none !important;
    }
    
    /* Hide animated particles for clean print */
    #d3-builder-viz .ambient-particle,
    #d3-builder-viz .data-packet {
        display: none !important;
    }
    
    /* ========================================
       PAGE BREAK CONTROL
    ======================================== */
    
    .module {
        page-break-after: always;
        page-break-inside: avoid;
        min-height: calc(100vh - 3cm);
        padding: 1.5cm 1cm !important;
        margin: 0 !important;
        opacity: 1 !important;
        transform: none !important;
        visibility: visible !important;
    }
    
    .module:last-child {
        page-break-after: auto;
    }
    
    /* ========================================
       SECTION BACKGROUNDS
    ======================================== */
    
    .hero-section {
        background: linear-gradient(135deg, #f1f5f9 0%, #ffffff 100%) !important;
    }
    
    .capabilities-section,
    .cta-section {
        background: #0f172a !important;
        color: #ffffff !important;
    }
    
    .capabilities-section *,
    .cta-section * {
        color: #ffffff !important;
    }
    
    .capabilities-section .section-badge {
        background: rgba(34, 197, 94, 0.2) !important;
        color: #22c55e !important;
    }
    
    .capability-card {
        background: #1e293b !important;
        border-color: #22c55e !important;
    }
    
    .builder-section,
    .ocr-section,
    .comparison-section,
    .onelayer-section {
        background: #f8f9fa !important;
    }
    
    .process-section,
    .specs-section {
        background: #ffffff !important;
    }
    
    /* ========================================
       CONTAINER & GRID ADJUSTMENTS
    ======================================== */
    
    .container {
        max-width: 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .pure-g {
        display: flex !important;
        flex-wrap: wrap !important;
        width: 100% !important;
    }
    
    .pure-u-1 {
        width: 100% !important;
    }
    
    .pure-u-md-1-2,
    .pure-u-lg-1-2 {
        width: 48% !important;
        margin: 0 1% !important;
    }
    
    .pure-u-lg-1-4 {
        width: 23% !important;
        margin: 0 1% !important;
    }
    
    .pure-u-lg-1-5 {
        width: 18% !important;
        margin: 0 1% !important;
    }
    
    /* ========================================
       TYPOGRAPHY SCALING
    ======================================== */
    
    h1 {
        font-size: 2.25rem !important;
        margin-bottom: 1rem !important;
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: 1.875rem !important;
        margin-bottom: 0.75rem !important;
        line-height: 1.3 !important;
    }
    
    h3 {
        font-size: 1.25rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    p {
        font-size: 0.95rem !important;
        line-height: 1.5 !important;
    }
    
    /* ========================================
       BADGES AND LABELS
    ======================================== */
    
    .hero-badge,
    .section-badge,
    .pipeline-label,
    .pillar-label {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    /* ========================================
       CARDS - KEEP TOGETHER
    ======================================== */
    
    .card,
    .builder-step,
    .timeline-card,
    .process-card,
    .benefit-item,
    .pillar-card,
    .capability-card,
    .comparison-card {
        page-break-inside: avoid !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* ========================================
       D3.JS VISUALIZATIONS - CRITICAL
    ======================================== */
    
    /* Force D3 SVGs to show final state */
    .d3-visualization,
    .d3-chart,
    .comparison-chart-card svg,
    .hero-d3-container svg,
    .builder-d3-container svg,
    .process-d3-container svg,
    .specs-d3-container svg,
    .ocr-d3-container svg {
        page-break-inside: avoid !important;
        max-width: 100% !important;
        height: auto !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Ensure all D3 elements are visible */
    .d3-visualization *,
    .d3-chart *,
    svg circle,
    svg rect,
    svg path,
    svg line,
    svg text,
    svg g {
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* Time to Production chart - show completed state */
    .comparison-chart-card {
        background: #ffffff !important;
        padding: 1rem !important;
        border: 2px solid #22c55e !important;
        border-radius: 8px !important;
    }
    
    /* Force green colors for Data X elements */
    .datax-runner,
    .dx-beam,
    .dx-laser,
    .datax-element {
        fill: #22c55e !important;
        stroke: #22c55e !important;
    }
    
    /* Force red colors for traditional elements */
    .traditional-runner,
    .legacy-element {
        fill: #ef4444 !important;
        stroke: #ef4444 !important;
    }
    
    /* Track backgrounds */
    .track-bg,
    .race-track {
        fill: #f1f5f9 !important;
    }
    
    /* Labels and text */
    .track-label,
    .status-label,
    .counter-text {
        fill: #0f172a !important;
        font-weight: 600 !important;
    }
    
    /* Success marks */
    .success-mark,
    .checkmark {
        fill: #22c55e !important;
    }
    
    /* ========================================
       LEGACY SVG DIAGRAMS
    ======================================== */
    
    .mermaid,
    .mermaid svg,
    .pipeline-svg,
    svg {
        page-break-inside: avoid !important;
        max-width: 100% !important;
        height: auto !important;
    }
    
    .mermaid {
        opacity: 1 !important;
        padding: 1rem 0 !important;
    }
    
    /* Force green color in diagrams */
    rect[fill="#22c55e"],
    .chart-bar,
    .step-count,
    .timeline-index,
    .process-number,
    .benefit-icon {
        background: #22c55e !important;
        fill: #22c55e !important;
        color: #0f172a !important;
    }
    
    /* ========================================
       COMPARISON CARDS
    ======================================== */
    
    .comparison-card.traditional .card-header {
        background: #fcebeb !important;
        border-bottom-color: #ef4444 !important;
    }
    
    .comparison-card.datax .card-header {
        background: #eafaf1 !important;
        border-bottom-color: #22c55e !important;
    }
    
    /* ========================================
       PROCESS FLOW - HORIZONTAL LAYOUT
    ======================================== */
    
    .process-flow {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
    }
    
    .process-card {
        flex: 1 !important;
        min-width: 0 !important;
        margin: 0 0.25rem !important;
    }
    
    .process-arrow {
        display: block !important;
        flex-shrink: 0 !important;
    }
    
    /* ========================================
       LOGOS AND IMAGES
    ======================================== */
    
    .onelayer-logo-box img,
    .footer-brand img,
    .logo img {
        max-height: 50px !important;
        width: auto !important;
    }
    
    /* ========================================
       DISABLE ALL ANIMATIONS
    ======================================== */
    
    *,
    *::before,
    *::after {
        animation: none !important;
        animation-delay: 0s !important;
        animation-duration: 0s !important;
        animation-iteration-count: 1 !important;
        transition: none !important;
        transition-delay: 0s !important;
        transition-duration: 0s !important;
    }
    
    /* ========================================
       HIDE LINK URLS
    ======================================== */
    
    a[href]:after {
        content: none !important;
    }
    
    /* ========================================
       LISTS
    ======================================== */
    
    ul {
        margin: 0.5rem 0 !important;
    }
    
    li {
        margin-bottom: 0.25rem !important;
    }
    
    /* ========================================
       COMPACT SPACING FOR PDF
    ======================================== */
    
    .section-header {
        margin-bottom: 1.5rem !important;
    }
    
    .builder-grid,
    .ocr-grid,
    .onelayer-content {
        margin-bottom: 1rem !important;
    }
    
    /* ========================================
       HIGHLIGHT ITEMS (FEATURE LISTS)
    ======================================== */
    
    .highlight-list {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    .highlight-item {
        background: rgba(34, 197, 94, 0.05) !important;
        border: 2px solid #22c55e !important;
        padding: 0.5rem !important;
    }
    
    /* ========================================
       SPECS DASHBOARD
    ======================================== */
    
    .specs-dashboard-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 1rem !important;
    }
    
    .metric-large .value {
        font-size: 2.5rem !important;
    }
    
    .chart-bar-animated {
        width: var(--width) !important;
    }
    
    /* ========================================
       OCR SECTION
    ======================================== */
    
    .ocr-diagram,
    .builder-visual {
        background: #ffffff !important;
        padding: 1rem !important;
    }
    
    /* ========================================
       PRINT-SPECIFIC ADDITIONS
    ======================================== */
    
    /* Add page numbers */
    @page {
        @bottom-center {
            content: "Data X System - Page " counter(page) " of " counter(pages);
            font-size: 9pt;
            color: #64748b;
        }
    }
    
    /* Ensure white backgrounds don't bleed */
    .card,
    .comparison-chart-card,
    .specs-card {
        background: #ffffff !important;
        border: 1px solid #e2e8f0 !important;
    }
    
    /* Dark section text visibility */
    .capabilities-section h2,
    .capabilities-section h3,
    .capabilities-section p,
    .cta-section h2,
    .cta-section p {
        color: #ffffff !important;
    }
    
    /* Green accent visibility */
    .text-green,
    .accent-green,
    [class*="green"] {
        color: #22c55e !important;
    }
}

/* ========================================
   PRINTING STATE CLASS
   Applied by JavaScript before printing
======================================== */

body.printing {
    overflow: visible !important;
}

body.printing .module {
    opacity: 1 !important;
    transform: none !important;
}

body.printing .d3-visualization,
body.printing svg {
    opacity: 1 !important;
}

/* Force D3 animations to complete state when printing */
body.printing .comparison-chart-card svg * {
    animation-play-state: paused !important;
}
