﻿/*
 * Manufacturing Workflow Timeline
 * Scoped to .tl-section
 */

/* ═══════════════════════════════════════════════════════════════
   KEYFRAMES
   ═══════════════════════════════════════════════════════════════ */

@keyframes tlLineDraw {
    from { transform: scaleY(0); }
    to   { transform: scaleY(1); }
}

@keyframes tlNodePop {
    0%   { transform: scale(0);    opacity: 0; }
    70%  { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1);    opacity: 1; }
}

@keyframes tlRingPulse {
    0%   { transform: scale(1);    opacity: 0.6; }
    70%  { transform: scale(1.8);  opacity: 0;   }
    100% { transform: scale(1.8);  opacity: 0;   }
}

@keyframes tlBarGrow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

@keyframes tlStemGrow {
    from { transform: scaleX(0); }
    to   { transform: scaleX(1); }
}

/* ═══════════════════════════════════════════════════════════════
   SECTION SHELL
   ═══════════════════════════════════════════════════════════════ */

.tl-section {
    position: relative;
    background-color: #ffffff;
    padding: 5rem 0 6rem;
    overflow: hidden;
}

@media (min-width: 1024px) {
    .tl-section { padding: 7rem 0 8rem; }
}

.tl-bg-grid {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(249,115,22,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(249,115,22,0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
}

.tl-bg-glow {
    position: absolute;
    bottom: -10%;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 50%;
    background: radial-gradient(
        ellipse at 50% 100%,
        rgba(249,115,22,0.05) 0%,
        transparent 60%
    );
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   SECTION HEADER
   ═══════════════════════════════════════════════════════════════ */

.tl-header {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 4rem;
    align-items: flex-end;
}

@media (min-width: 1024px) {
    .tl-header {
        grid-template-columns: 1fr 1fr;
        gap: 4rem;
        margin-bottom: 5rem;
    }
}

.tl-heading {
    font-family: var(--font-heading, 'Barlow Condensed', sans-serif);
    font-weight: 900;
    text-transform: uppercase;
    line-height: 0.92;
    letter-spacing: -0.025em;
    color: #0f172a;
    font-size: clamp(2.25rem, 5vw, 4rem);
    margin: 0.75rem 0 0;
}

.tl-heading-accent {
    display: block;
    color: #f97316;
}

.tl-intro {
    font-size: 0.9375rem;
    color: #0f172a;
    line-height: 1.8;
    max-width: 480px;
}

/* ═══════════════════════════════════════════════════════════════
   TIMELINE TRACK
   ═══════════════════════════════════════════════════════════════ */

.tl-wrap {
    position: relative;
    /* Max-width so the timeline doesn't get too wide */
    max-width: 960px;
    margin: 0 auto;
}

/* ── Vertical center line ──────────────────────────────────── */

.tl-line {
    /* Hidden on mobile, shown on desktop */
    display: none;
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    transform: translateX(-50%);
    width: 2px;
    z-index: 0;
}

@media (min-width: 768px) {
    .tl-line { display: block; }
}

.tl-line-track {
    position: absolute;
    inset: 0;
    background: rgba(15,23,42,0.08);
}

/* Animated fill that draws from top when section enters viewport */
.tl-line-fill {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        #f97316 0%,
        rgba(249,115,22,0.4) 50%,
        rgba(249,115,22,0.15) 100%
    );
    transform: scaleY(0);
    transform-origin: top;
}

/* Triggered when the section comes into view — class added by JS below */
.tl-wrap.tl-animated .tl-line-fill {
    animation: tlLineDraw 2.5s cubic-bezier(0.4, 0, 0.2, 1) 0.3s both;
}

/* ═══════════════════════════════════════════════════════════════
   STEP ROW
   ═══════════════════════════════════════════════════════════════ */

.tl-step {
    position: relative;
    display: grid;
    z-index: 1;
    margin-bottom: 2rem;
}

/* Mobile: single-column with left rail */
.tl-step {
    grid-template-columns: 48px 1fr;
    grid-template-areas: 'node card';
    gap: 0 1.25rem;
    padding-bottom: 0;
    align-items: flex-start;
}

/* Desktop: three-column zigzag */
@media (min-width: 768px) {
    .tl-step {
        grid-template-columns: 1fr 64px 1fr;
        grid-template-areas: 'left node right';
        gap: 0 0;
        margin-bottom: 3rem;
    }

    .tl-step:last-child { margin-bottom: 0; }

    /* Left-side steps: card in left column */
    .tl-step-left  { grid-template-areas: 'card node spacer'; }
    /* Right-side steps: card in right column */
    .tl-step-right { grid-template-areas: 'spacer node card'; }
}

/* ── Column assignments ──────────────────────────────────── */

.tl-card-col   { grid-area: card; }
.tl-node-col   { grid-area: node; }
.tl-spacer-col { grid-area: spacer; display: none; }

@media (min-width: 768px) {
    .tl-spacer-col { display: block; }
}

/* Mobile: node column is narrow left rail */
@media (max-width: 767px) {
    .tl-node-col {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding-top: 0.25rem;
    }

    /* Vertical connector for mobile (between nodes) */
    .tl-node-col::after {
        content: '';
        flex: 1;
        width: 2px;
        background: linear-gradient(to bottom, rgba(249,115,22,0.3), rgba(249,115,22,0.05));
        margin-top: 0.5rem;
        min-height: 1.5rem;
    }

    .tl-step:last-child .tl-node-col::after { display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   TIMELINE NODE
   ═══════════════════════════════════════════════════════════════ */

.tl-node {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Centre node on the vertical line on desktop */
}

@media (min-width: 768px) {
    .tl-node {
        width: 64px;
        height: 64px;
        margin: 0 auto;
    }
}

/* Outer pulse ring */
.tl-node-ring {
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 1.5px solid rgba(249,115,22,0.35);
    opacity: 0;
}

.tl-node.revealed .tl-node-ring {
    animation: tlRingPulse 2s ease-out 0.8s infinite;
}

/* Inner filled circle */
.tl-node-inner {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #f97316;
    border: 3px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 0 0 1px rgba(249,115,22,0.4),
        0 4px 20px rgba(249,115,22,0.25);
    transition: background 300ms ease, box-shadow 300ms ease;
}

@media (min-width: 768px) {
    .tl-node-inner {
        border-width: 4px;
    }
}

.tl-node:hover .tl-node-inner {
    background: #fb923c;
    box-shadow:
        0 0 0 1px rgba(249,115,22,0.6),
        0 8px 32px rgba(249,115,22,0.4);
}

.tl-node-num {
    font-family: var(--font-heading, 'Barlow Condensed', sans-serif);
    font-size: 0.875rem;
    font-weight: 900;
    color: #fff;
    letter-spacing: -0.02em;
    line-height: 1;
}

@media (min-width: 768px) {
    .tl-node-num { font-size: 1.0625rem; }
}

/* Node pop animation when revealed */
.tl-node.revealed .tl-node-inner {
    animation: tlNodePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ═══════════════════════════════════════════════════════════════
   CONNECTOR STEM (desktop only)
   ═══════════════════════════════════════════════════════════════ */

.tl-stem {
    display: none;
}

@media (min-width: 768px) {
    .tl-stem {
        display: flex;
        align-items: center;
        height: 2px;
        margin-top: 32px; /* vertically align with node center */
        position: relative;
    }

    .tl-stem-right {
        flex-direction: row-reverse; /* dot on right side (toward node) */
        padding-right: 0;
        margin-right: -1px;
    }

    .tl-stem-left {
        flex-direction: row;
        padding-left: 0;
        margin-left: -1px;
    }
}

.tl-stem-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(
        to right,
        rgba(249,115,22,0.1),
        rgba(249,115,22,0.4)
    );
    transform: scaleX(0);
    transform-origin: right;
}

.tl-stem-right .tl-stem-line {
    transform-origin: left;
    background: linear-gradient(
        to left,
        rgba(249,115,22,0.1),
        rgba(249,115,22,0.4)
    );
}

.tl-card-col.revealed .tl-stem-line {
    animation: tlStemGrow 0.4s ease 0.2s both;
}

.tl-stem-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(249,115,22,0.5);
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════════════════════════
   TIMELINE CARD
   ═══════════════════════════════════════════════════════════════ */

.tl-card {
    position: relative;
    background: #ffffff;
    border: 1px solid rgba(15,23,42,0.09);
    padding: 1.5rem;
    overflow: hidden;
    transition:
        border-color 300ms ease,
        box-shadow 300ms ease,
        transform 300ms ease;
}

@media (min-width: 768px) {
    .tl-card { padding: 1.75rem 2rem; }
}

.tl-card:hover {
    border-color: rgba(249,115,22,0.25);
    box-shadow: 0 8px 40px rgba(0,0,0,0.07), 0 0 0 1px rgba(249,115,22,0.1);
    transform: translateY(-3px);
}

/* Orange top bar animates in on card reveal */
.tl-card-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: #f97316;
    transform: scaleX(0);
    transform-origin: left;
}

.tl-card-col.revealed .tl-card-bar {
    animation: tlBarGrow 0.5s cubic-bezier(0.4, 0, 0.2, 1) 0.15s both;
}

/* Card header row */
.tl-card-head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

/* Icon box */
.tl-icon {
    width: 40px;
    height: 40px;
    background: rgba(249,115,22,0.1);
    border: 1px solid rgba(249,115,22,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #f97316;
    transition: background 250ms ease, border-color 250ms ease;
}

.tl-card:hover .tl-icon {
    background: rgba(249,115,22,0.18);
    border-color: rgba(249,115,22,0.4);
}

/* Phase tag */
.tl-tag {
    display: inline-block;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #f97316;
    border: 1px solid rgba(249,115,22,0.25);
    background: rgba(249,115,22,0.07);
    padding: 0.25rem 0.625rem;
}

/* Card title */
.tl-card-title {
    font-family: var(--font-heading, 'Barlow Condensed', sans-serif);
    font-size: clamp(1.125rem, 2vw, 1.375rem);
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #0f172a;
    line-height: 1.15;
    margin-bottom: 0.75rem;
    transition: color 250ms ease;
}

.tl-card:hover .tl-card-title { color: #f97316; }

/* Card description */
.tl-card-desc {
    font-size: 0.8125rem;
    color: #0f172a;
    line-height: 1.75;
    margin-bottom: 1.125rem;
}

/* Checklist */
.tl-checklist {
    list-style: none;
    margin: 0 0 1.125rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tl-check-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #0f172a;
    font-weight: 500;
}

.tl-check-item svg {
    color: #f97316;
    flex-shrink: 0;
}

/* Duration chip */
.tl-duration {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #0f172a;
    padding: 0.3125rem 0.625rem;
    border: 1px solid rgba(15,23,42,0.1);
    background: rgba(15,23,42,0.03);
    transition: color 250ms ease, border-color 250ms ease;
}

.tl-card:hover .tl-duration {
    color: rgba(249,115,22,0.7);
    border-color: rgba(249,115,22,0.15);
}

.tl-duration svg { flex-shrink: 0; }

/* ── Card positioning adjustments for desktop ──────────── */

@media (min-width: 768px) {
    /* Left-step: card sits in left column with stem on right edge */
    .tl-step-left .tl-card-col {
        padding-right: 1.5rem;
    }

    /* Right-step: card sits in right column with stem on left edge */
    .tl-step-right .tl-card-col {
        padding-left: 1.5rem;
    }

    /* Stem is a child of card-col, rendered after the card in DOM */
    /* For left steps: stem on right side of card — already correct */
    /* For right steps: stem needs to be on left → reorder in flex */
    .tl-step-right .tl-card-col {
        display: flex;
        flex-direction: row;
    }

    .tl-step-right .tl-card-col .tl-card {
        order: 2;
        flex: 1;
    }

    .tl-step-right .tl-card-col .tl-stem {
        order: 1;
    }

    .tl-step-left .tl-card-col {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
    }

    .tl-step-left .tl-card-col .tl-card {
        order: 1;
        flex: 1;
    }

    .tl-step-left .tl-card-col .tl-stem {
        order: 2;
    }
}

/* ═══════════════════════════════════════════════════════════════
   SECTION FOOTER / CTA CARD
   ═══════════════════════════════════════════════════════════════ */

.tl-footer {
    margin-top: 4rem;
}

.tl-footer-card {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: rgba(249,115,22,0.07);
    border: 1px solid rgba(249,115,22,0.2);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

@media (min-width: 768px) {
    .tl-footer-card {
        flex-direction: row;
        align-items: center;
        gap: 2rem;
        padding: 2rem 2.5rem;
    }
}

/* Decorative diagonal stripe */
.tl-footer-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 40%;
    background: repeating-linear-gradient(
        -45deg,
        rgba(249,115,22,0.03) 0,
        rgba(249,115,22,0.03) 1px,
        transparent 1px,
        transparent 12px
    );
    pointer-events: none;
}

.tl-footer-icon {
    width: 56px;
    height: 56px;
    background: rgba(249,115,22,0.15);
    border: 1px solid rgba(249,115,22,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #f97316;
    flex-shrink: 0;
}

.tl-footer-title {
    font-family: var(--font-heading, 'Barlow Condensed', sans-serif);
    font-size: 1.25rem;
    font-weight: 900;
    text-transform: uppercase;
    color: #0f172a;
    margin-bottom: 0.375rem;
}

.tl-footer-body {
    font-size: 0.875rem;
    color: #0f172a;
    line-height: 1.6;
}

.tl-footer-ctas {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    margin-left: auto;
}

/* ═══════════════════════════════════════════════════════════════
   STEP ENTRY ANIMATION (when data-reveal fires)
   ═══════════════════════════════════════════════════════════════ */

/* Steps enter from alternating sides */
.tl-step-left  .tl-card-col { --tl-enter-x: -24px; }
.tl-step-right .tl-card-col { --tl-enter-x:  24px; }

@media (min-width: 768px) {
    /* Override data-reveal fadeUp with a sideways slide for timeline cards */
    [data-reveal].tl-card-col:not(.revealed) {
        opacity: 0;
        transform: translateX(var(--tl-enter-x, 0));
        transition: opacity 0.6s cubic-bezier(0.4,0,0.2,1), transform 0.6s cubic-bezier(0.4,0,0.2,1);
    }

    [data-reveal].tl-card-col.revealed {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ═══════════════════════════════════════════════════════════════
   REDUCED MOTION
   ═══════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .tl-line-fill,
    .tl-card-bar,
    .tl-stem-line,
    .tl-node-ring {
        animation: none !important;
        transform: none !important;
        opacity: 1 !important;
    }

    .tl-node-inner { animation: none !important; }

    .tl-card,
    .tl-card-col { transition: none !important; }
}
