/* Cro Timeline Module - Block 9
 * Professional Design with Soft Animations
 * ------------------------------------------------------------------------------------------------------------------ */

.cro-timeline {
    /* T9 senior-UX: token-mapped — was hardcoded #497beb / #10B981 */
    --timeline-primary: var(--ds-cta, #e36218);
    --timeline-primary-rgb: 227, 98, 24;
    --timeline-accent: var(--ds-trust, #4d5e3a);
    --timeline-accent-rgb: 77, 94, 58;
    --timeline-gray: 118, 115, 106; /* maps to ds-ink-mute */
}

.cro-timeline {
    background-color: var(--gray-50);
    padding: 3rem 1.5rem;
    overflow: hidden;
}

.cro-timeline .horizontal-timeline-container {
    max-width: 1000px;
    margin: 2rem auto 0;
    position: relative;
}

/* Timeline Nodes Container */
.cro-timeline .timeline-nodes {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 3;
    gap: 0.5rem;
}

/* Connection Line - Behind nodes */
.cro-timeline .timeline-nodes::before {
    content: '';
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    height: 2px;
    background: rgba(var(--timeline-gray), 0.2);
    z-index: 1;
}

/* Progress Line - Shows completed progress up to current node */
.cro-timeline .timeline-nodes::after {
    content: '';
    position: absolute;
    top: 24px;
    left: 24px;
    height: 3px;
    background: linear-gradient(90deg, var(--timeline-accent), var(--timeline-primary));
    z-index: 2;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 2px;
}

/* Progress line width based on current step - instant transition to completed nodes */
.cro-timeline .timeline-nodes[data-step="1"]::after { width: 0%; }
.cro-timeline .timeline-nodes[data-step="2"]::after { width: 25%; }
.cro-timeline .timeline-nodes[data-step="3"]::after { width: 50%; }
.cro-timeline .timeline-nodes[data-step="4"]::after { width: 75%; }
.cro-timeline .timeline-nodes[data-step="5"]::after { width: calc(100% - 48px); }

/* Individual Node */
.cro-timeline .timeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    text-align: center;
    flex: 1;
    transition: transform 0.2s ease;
    position: relative;
    z-index: 4;
    /* native <button> reset (W2-A17) */
    background: transparent;
    border: 0;
    padding: 0;
    font: inherit;
    color: inherit;
    appearance: none;
    -webkit-appearance: none;
}

.cro-timeline .timeline-node:hover {
    transform: translateY(-2px);
}

/* Node Circle Wrapper - Positions both circle and progress ring */
.cro-timeline .node-circle-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Active state scales the wrapper for proper progress ring alignment */
.cro-timeline .timeline-node.active .node-circle-wrapper {
    transform: scale(1.15);
    transition: transform 0.3s ease;
}

/* Node Circle - T9 senior-UX: ≥1.5rem step numbers, ≥48px circle
   WAVE3-F09 (2026-05-08): doctrine anti-pattern row 1/6 — `var(--scheme-fg, #fff)`
   resolves to --ds-ink (near-black) on every light scheme (paper, paper-2, sand,
   cream), painting the node circle BLACK with `--ds-ink-soft` text → ~1.5:1.
   Switched the surface to `--scheme-card-bg` (paper-tinted on light schemes,
   card surface on dark), and the box-shadow halo to `--scheme-bg` so it always
   reads as the section's background. The numeric color stays as `--ds-ink-soft`
   on light schemes; the dark-scheme guardrail in design-system.css remaps
   `--ds-ink-soft` → `--scheme-fg-soft` (white-soft), so the digit stays legible
   on `.scheme-ink`/`.scheme-steel`/`.scheme-accent`/`.scheme-trust`. */
.cro-timeline .node-circle {
    width: 48px;
    height: 48px;
    background-color: var(--scheme-card-bg, #fff);
    border: 3px solid rgba(var(--timeline-gray), 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--ds-font-body);
    font-size: var(--ds-fs-h3, 1.5rem); /* T9: 1.125rem (18) -> 1.5rem (24) for senior-readable step number */
    line-height: 1;
    font-weight: 800;
    color: var(--ds-ink-soft, #4a4842); /* T9: was tertiary gray */
    transition: all 0.3s ease;
    position: relative;
    z-index: 5;
    /* Ensure solid background covers timeline */
    box-shadow: 0 0 0 4px var(--scheme-bg, #fff), var(--ds-shadow-sm);
}

/* Node Circle with SVG Icon */
.cro-timeline .node-circle.has-icon {
    padding: 8px;
}

.cro-timeline .node-circle-svg {
    width: 22px;
    height: 22px;
    /* WAVE3-F09 (2026-05-08): was `var(--color-outline-primary-normal-bg, #f5c011)`
       which resolves via theme.min.css to Tailwind blue `#2b65e8` (and the
       literal fallback was yellow). Pin to brand CTA orange — matches the
       active-node primary color and the doctrine. */
    color: var(--ds-cta, #e36218);
    stroke: var(--ds-cta, #e36218);
    stroke-width: 2;
    fill: none;
}

.cro-timeline .node-title {
    margin-top: 0.75rem;
    font-weight: 600;
    color: var(--ds-ink-soft, #4a4842); /* T9: AAA contrast on paper */
    transition: color 0.3s ease;
    font-size: var(--ds-fs-fineprint, 0.875rem); /* T9 senior-UX: 0.75rem (12px) -> 14px AAA floor for label */
    line-height: 1.3;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =================================================================
   ACTIVE NODE - Seamless Inward Pulse Animation (5 Circles)
   Uses staggered animations for seamless infinite loop
   ================================================================= */

.cro-timeline .timeline-node.active .node-circle {
    /* WAVE3-F09: was `var(--scheme-fg, #fff)` → BLACK on light schemes. */
    background-color: var(--scheme-card-bg, #fff);
    border: 3px solid var(--timeline-primary);
    overflow: hidden;
    position: relative;
    animation: activeBreath 2s ease-in-out infinite, activeNumberColor 1.2s ease-out forwards;
}

/* =================================================================
   CIRCULAR PROGRESS LOADER - Outside ring that fills over 4s
   Uses SVG stroke-dasharray technique for clock-like animation
   ================================================================= */
.cro-timeline .node-circle-progress {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 62px;
    height: 62px;
    transform: translate(-50%, -50%) rotate(-90deg);
    pointer-events: none;
    z-index: 4;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cro-timeline .timeline-node.active .node-circle-progress {
    opacity: 1;
}

.cro-timeline .node-circle-progress svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Track circle - 10% opacity background ring */
.cro-timeline .node-circle-progress .progress-track {
    fill: none;
    stroke: var(--timeline-primary);
    stroke-opacity: 0.15;
    stroke-width: 3;
}

/* Progress circle - animated fill with theme primary blue */
.cro-timeline .node-circle-progress .progress-fill {
    fill: none;
    stroke: var(--timeline-primary);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 201;
    stroke-dashoffset: 201;
    filter: drop-shadow(0 0 6px rgba(var(--timeline-primary-rgb), 0.6));
}

.cro-timeline .timeline-node.active .node-circle-progress .progress-fill {
    animation: progressStroke 4s linear forwards;
}

@keyframes progressStroke {
    0% { stroke-dashoffset: 201; }
    100% { stroke-dashoffset: 0; }
}

/* Number color transition: gray → green → blue */
@keyframes activeNumberColor {
    0% { color: rgba(var(--timeline-gray), 0.6); }
    40% { color: var(--timeline-accent); }
    100% { color: var(--timeline-primary); }
}


/* Inward pulse ring 1 - reaches center (T9: token-mapped via rgb token) */
.cro-timeline .timeline-node.active .node-circle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle,
        rgba(var(--timeline-primary-rgb), 0.5) 0%,
        rgba(var(--timeline-primary-rgb), 0.35) 25%,
        rgba(var(--timeline-primary-rgb), 0.2) 50%,
        rgba(var(--timeline-primary-rgb), 0.1) 75%,
        transparent 100%);
    animation: inwardPulseActive 2s ease-in-out infinite;
}

/* Inward pulse ring 2 - offset */
.cro-timeline .timeline-node.active .node-circle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 120%;
    height: 120%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle,
        rgba(var(--timeline-primary-rgb), 0.4) 0%,
        rgba(var(--timeline-primary-rgb), 0.25) 30%,
        rgba(var(--timeline-primary-rgb), 0.12) 60%,
        transparent 100%);
    animation: inwardPulseActive 2s ease-in-out infinite 0.5s;
}

/* Inward pulse - contracts to center with full visibility */
@keyframes inwardPulseActive {
    0% { 
        transform: translate(-50%, -50%) scale(1.5); 
        opacity: 0; 
    }
    15% { 
        opacity: 1; 
    }
    85% { 
        opacity: 0.6; 
    }
    100% { 
        transform: translate(-50%, -50%) scale(0.1); 
        opacity: 0; 
    }
}

/* Breathing box-shadow with inset rings — T9: ds-cta-mapped via rgb token
   WAVE3-F09 (2026-05-08): outer halo was `var(--scheme-fg, #fff)` → BLACK on
   light schemes. Switched to `var(--scheme-bg, #fff)` so the halo always
   reads as the section background (paper on light, dark on dark). */
@keyframes activeBreath {
    0%, 100% {
        box-shadow:
            0 0 0 4px var(--scheme-bg, #fff),
            inset 0 0 0 3px color-mix(in srgb, var(--ds-cta) 25%, transparent),
            inset 0 0 0 8px color-mix(in srgb, var(--ds-cta) 18%, transparent),
            inset 0 0 0 14px color-mix(in srgb, var(--ds-cta) 10%, transparent),
            0 4px 16px color-mix(in srgb, var(--ds-cta) 25%, transparent);
    }
    50% {
        box-shadow:
            0 0 0 4px var(--scheme-bg, #fff),
            inset 0 0 0 6px color-mix(in srgb, var(--ds-cta) 30%, transparent),
            inset 0 0 0 12px color-mix(in srgb, var(--ds-cta) 22%, transparent),
            inset 0 0 0 18px color-mix(in srgb, var(--ds-cta) 12%, transparent),
            0 4px 16px color-mix(in srgb, var(--ds-cta) 25%, transparent);
    }
}

.cro-timeline .timeline-node.active .node-title {
    color: var(--timeline-primary);
    font-weight: 700;
}

/* =================================================================
   COMPLETED NODES - Green Accent with Subtle Inward Animation
   Same style as active but green, slower, and more subtle
   ================================================================= */

.cro-timeline .timeline-node.completed .node-circle {
    /* WAVE3-F09: was `var(--scheme-fg, #fff)` → BLACK on light schemes. */
    background-color: var(--scheme-card-bg, #fff);
    border-color: var(--timeline-accent);
    color: var(--timeline-accent);
    overflow: hidden;
    position: relative;
    animation: completedBreath 3s ease-in-out infinite;
}

/* Completed node - Inward pulse ring 1 — T9: ds-trust mapped via rgb token */
.cro-timeline .timeline-node.completed .node-circle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 110%;
    height: 110%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle,
        rgba(var(--timeline-accent-rgb), 0.35) 0%,
        rgba(var(--timeline-accent-rgb), 0.22) 30%,
        rgba(var(--timeline-accent-rgb), 0.1) 60%,
        transparent 100%);
    animation: inwardPulseCompleted 3s ease-in-out infinite;
}

.cro-timeline .timeline-node.completed .node-circle::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 110%;
    height: 110%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    pointer-events: none;
    background: radial-gradient(circle,
        rgba(var(--timeline-accent-rgb), 0.28) 0%,
        rgba(var(--timeline-accent-rgb), 0.15) 35%,
        rgba(var(--timeline-accent-rgb), 0.06) 70%,
        transparent 100%);
    animation: inwardPulseCompleted 3s ease-in-out infinite 0.75s;
}

/* Inward pulse for completed - contracts to center */
@keyframes inwardPulseCompleted {
    0% { 
        transform: translate(-50%, -50%) scale(1.4); 
        opacity: 0; 
    }
    20% { 
        opacity: 0.9; 
    }
    80% { 
        opacity: 0.4; 
    }
    100% { 
        transform: translate(-50%, -50%) scale(0.15); 
        opacity: 0; 
    }
}

/* Completed node breathing — T9: ds-trust (rgb 77,94,58)
   WAVE3-F09 (2026-05-08): outer halo was `var(--scheme-fg, #fff)` → BLACK. */
@keyframes completedBreath {
    0%, 100% {
        box-shadow:
            0 0 0 4px var(--scheme-bg, #fff),
            inset 0 0 0 2px color-mix(in srgb, var(--ds-trust) 18%, transparent),
            inset 0 0 0 6px color-mix(in srgb, var(--ds-trust) 10%, transparent),
            inset 0 0 0 10px color-mix(in srgb, var(--ds-trust) 5%, transparent),
            0 2px 8px color-mix(in srgb, var(--ds-trust) 15%, transparent);
    }
    50% {
        box-shadow:
            0 0 0 4px var(--scheme-bg, #fff),
            inset 0 0 0 4px color-mix(in srgb, var(--ds-trust) 22%, transparent),
            inset 0 0 0 9px color-mix(in srgb, var(--ds-trust) 14%, transparent),
            inset 0 0 0 14px color-mix(in srgb, var(--ds-trust) 6%, transparent),
            0 2px 8px color-mix(in srgb, var(--ds-trust) 15%, transparent);
    }
}

.cro-timeline .timeline-node.completed .node-title {
    color: var(--timeline-accent);
    font-weight: 600;
}

/* =================================================================
   CONTENT PANES
   ================================================================= */

.cro-timeline .timeline-content-panes {
    margin-top: 2.5rem;
}

.cro-timeline .timeline-pane {
    display: none;
    background: var(--scheme-card-bg, #fff);
    padding: 2rem 1.5rem;
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-lg);
    border-top: 4px solid var(--timeline-primary);
    animation: paneFadeIn 0.4s ease;
    position: relative;
    overflow: hidden;
}

.cro-timeline .timeline-pane.active {
    display: block;
}

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

/* Progress bar removed - using timeline progress line instead */

.cro-timeline .pane-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--ds-space-5);
    text-align: center;
}

/* Icon Container */
.cro-timeline .pane-icon {
    display: flex;
    justify-content: center;
    align-items: center;
}

.cro-timeline .pane-icon-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cro-timeline .pane-icon-inner {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(var(--timeline-accent-rgb), 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
    border: 1px solid rgba(var(--timeline-accent-rgb), 0.15);
}

.cro-timeline .pane-icon-inner:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(var(--timeline-accent-rgb), 0.2);
}

.cro-timeline .pane-icon .timeline-svg-icon {
    width: 32px;
    height: 32px;
    filter: brightness(0) saturate(100%) invert(60%) sepia(61%) saturate(476%) hue-rotate(109deg) brightness(93%) contrast(92%);
    transition: transform 0.3s ease;
}

.cro-timeline .pane-icon-inner:hover .timeline-svg-icon {
    transform: scale(1.1);
}

/* Text Content — T9 senior-UX: ds-h3-humane sentence-case + 18px body */
.cro-timeline .pane-text h3 {
    font-family: var(--ds-font-body);
    font-size: var(--ds-fs-h3, 1.5rem); /* 24px */
    line-height: var(--ds-lh-display, 1.15);
    text-transform: none;
    letter-spacing: 0;
    color: var(--ds-ink, #0e0f0c);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.cro-timeline .pane-text p {
    font-size: var(--ds-fs-body, 1.125rem); /* T9: 0.95 -> 18px AAA body floor */
    line-height: 1.6;
    color: var(--ds-ink-soft, #4a4842);
    margin-bottom: 1rem;
}

/* Highlight Badge - T9 senior-UX: 14px floor + 48px hit area for link variant */
.cro-timeline .pane-highlight {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(var(--timeline-accent-rgb), 0.12);
    color: var(--timeline-accent);
    font-weight: 700;
    /* T9 BUG-FIX: padding bumped (0.6 -> 0.75) so rendered height clears 48px floor (was rendering 44px) */
    padding: 0.75rem 1.125rem;
    border-radius: 50px;
    font-size: var(--ds-fs-body-sm, 1rem); /* T9: 0.75rem (12px) -> 16px */
    line-height: 1.4;
    border: 1px solid rgba(var(--timeline-accent-rgb), 0.25);
    transition: all 0.2s ease;
    min-height: var(--ds-touch-target, 48px);
    box-sizing: border-box;
}

.cro-timeline a.pane-highlight {
    text-decoration: none;
}

.cro-timeline a.pane-highlight:focus-visible {
    outline: none;
    box-shadow: var(--ds-focus-ring);
}

.cro-timeline .pane-highlight .highlight-svg-icon {
    width: 12px;
    height: 12px;
    filter: brightness(0) saturate(100%) invert(60%) sepia(61%) saturate(476%) hue-rotate(109deg) brightness(93%) contrast(92%);
    flex-shrink: 0;
}

/* Clickable Highlight Pill - Opens smart-form */
.cro-timeline .pane-highlight-link {
    text-decoration: none;
    cursor: pointer;
}

.cro-timeline .pane-highlight-link:hover {
    background: rgba(var(--timeline-accent-rgb), 0.15);
    border-color: rgba(var(--timeline-accent-rgb), 0.3);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(var(--timeline-accent-rgb), 0.2);
}

.cro-timeline .pane-highlight-link .highlight-arrow {
    flex-shrink: 0;
    opacity: 0.7;
    transition: transform 0.2s ease, opacity 0.2s ease;
    stroke: var(--timeline-accent);
}

.cro-timeline .pane-highlight-link:hover .highlight-arrow {
    transform: translateX(2px);
    opacity: 1;
}

/* CTA Button - T9 senior-UX: primary CTA ≥56px, ≥18px text
   WAVE3-F09 (2026-05-08): `--scheme-fg` resolved to --ds-ink (black) on
   light schemes, painting CTA text BLACK on the dark `--timeline-primary`
   background. Pin to white — this CTA is always on a saturated brand bg. */
.cro-timeline .pane-cta {
    background: var(--timeline-primary);
    color: #fff;
    padding: 0 1.5rem;
    border-radius: var(--ds-radius);
    text-decoration: none;
    font-weight: 700;
    font-size: var(--ds-fs-body, 1.125rem); /* T9: 0.875 -> 18px */
    line-height: 1.3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.25s ease, box-shadow 0.25s ease;
    margin-top: 0.75rem;
    box-shadow: 0 2px 8px rgba(var(--timeline-primary-rgb), 0.3);
    min-height: var(--ds-touch-target-primary, 56px); /* T9: 56px primary CTA */
    box-sizing: border-box;
}

.cro-timeline .pane-cta:focus-visible {
    outline: none;
    box-shadow: var(--ds-focus-ring);
}

.cro-timeline .pane-cta:hover {
    background: var(--ds-cta-dk, #bb4d0d); /* T9: token swap from var(--color-primary-hover-bg) */
    box-shadow: 0 4px 12px rgba(var(--timeline-primary-rgb), 0.45);
}

.cro-timeline .pane-cta::after {
    content: '→';
    font-size: 0.9em;
    transition: transform 0.2s ease;
}

.cro-timeline .pane-cta:hover::after {
    transform: translateX(3px);
}

/* =================================================================
   RESPONSIVE - Desktop
   ================================================================= */

@media (min-width: 768px) {
    .cro-timeline {
        padding: 4rem 2rem;
    }

    .cro-timeline .timeline-nodes::before,
    .cro-timeline .timeline-nodes::after {
        top: 30px;
        left: 30px;
        right: 30px;
    }

    .cro-timeline .pane-grid {
        grid-template-columns: 100px 1fr;
        text-align: left;
        align-items: flex-start;
        gap: var(--ds-space-6);
    }

    .cro-timeline .pane-icon {
        justify-content: flex-start;
    }

    .cro-timeline .pane-icon-wrapper {
        width: 90px;
        height: 90px;
    }

    .cro-timeline .pane-icon-inner {
        width: 72px;
        height: 72px;
        border-radius: var(--ds-radius-lg);
    }

    .cro-timeline .pane-icon .timeline-svg-icon {
        width: 36px;
        height: 36px;
    }

    .cro-timeline .pane-text h3 {
        font-size: 1.875rem; /* 30px desktop */
    }

    .cro-timeline .pane-text p {
        font-size: var(--ds-fs-body, 1.125rem); /* T9: keep 18px AAA on desktop */
        line-height: 1.6;
    }

    .cro-timeline .node-circle {
        width: 60px;
        height: 60px;
        font-size: 1.75rem; /* T9: 1.25 -> 28px senior-readable step number desktop */
    }

    .cro-timeline .node-circle-progress {
        width: 76px;
        height: 76px;
    }

    .cro-timeline .node-title {
        font-size: var(--ds-fs-body-sm, 1rem); /* T9: 14 -> 16px desktop */
    }

    .cro-timeline .timeline-pane {
        padding: 2.5rem;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .cro-timeline *, .cro-timeline *::before, .cro-timeline *::after {
        animation: none !important;
        transition-duration: 0.01ms !important;
    }
}
