/* ===================================
   PIPELINE (homepage)
   Sources -> Clams engine -> reports, as a self-running diagram.
   The markup is the finished end state; pipeline.js replays it
   while the section is on screen. No JS / reduced motion keeps
   the static diagram.
   =================================== */

.pipeline {
    --pl-gap: 14px;
    --pl-line: rgba(241, 238, 231, 0.12);
    --pl-text-dim: rgba(241, 238, 231, 0.74);
    --pl-ember-soft: rgba(194, 52, 42, 0.55);
    --pl-ease-move: cubic-bezier(0.77, 0, 0.175, 1);
}

.pl-inner {
    max-width: var(--container-width);
    margin: 0 auto;
}

/* Header */

.pl-header {
    text-align: center;
    max-width: 52rem;
    margin: 0 auto var(--space-lg);
}

.pl-header .section-label {
    justify-content: center;
    margin-inline: auto;
}

.pl-header h2 {
    letter-spacing: -0.02em;
    margin-bottom: var(--space-md);
}

.pl-header p {
    font-size: 1.125rem;
    line-height: 1.7;
    color: var(--pl-text-dim);
    max-width: 44rem;
    margin: 0 auto;
}

/* Integrations band: runs edge to edge between the header and the diagram. */

.pl-marquee {
    margin: 0 calc(-1 * var(--container-padding)) var(--space-xl);
    border-color: var(--pl-line);
}

.pl-marquee .marquee-item {
    color: var(--color-background);
}

.pl-marquee a.marquee-item:hover {
    color: #f3b1a9;
}

/* The band styles darken logos and multiply them into a light surface. On ink,
   invert them and screen them in instead, so white tiles drop out. */
.pl-marquee .marquee-item img,
.pl-marquee a.marquee-item:hover img {
    filter: grayscale(1) invert(1);
    mix-blend-mode: screen;
}

.pl-marquee .marquee-item img.logo-light,
.pl-marquee a.marquee-item:hover img.logo-light {
    filter: brightness(0) invert(0.9);
}

/* Stage */

.pl-stage {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr);
    column-gap: clamp(48px, 6vw, 96px);
    align-items: center;
}

.pl-wires,
.pl-packets {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.pl-wires path {
    fill: none;
    stroke: var(--pl-line);
    stroke-width: 1;
    transition: stroke 400ms ease;
}

.pl-wires path.is-lit {
    stroke: var(--pl-ember-soft);
    transition-duration: 150ms;
}

.pl-wires rect {
    fill: rgba(241, 238, 231, 0.28);
}

.pl-packets {
    z-index: 2;
}

.pl-packet {
    position: absolute;
    top: 0;
    left: 0;
    width: 8px;
    height: 8px;
    background: var(--color-ember);
    box-shadow: 0 0 0 3px rgba(194, 52, 42, 0.18), 0 0 14px rgba(194, 52, 42, 0.9);
    will-change: transform;
}

.pl-col {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: var(--pl-gap);
    min-width: 0;
}

/* Sources */

.pl-sources {
    display: flex;
    flex-direction: column;
    gap: var(--pl-gap);
}

.pl-src {
    padding: 14px 16px;
    border: 1px solid var(--pl-line);
    border-radius: var(--radius-md);
    background: rgba(241, 238, 231, 0.03);
    transition: border-color 400ms ease, box-shadow 400ms ease, background-color 400ms ease;
}

.pl-src.is-active {
    border-color: var(--pl-ember-soft);
    background: rgba(143, 7, 9, 0.12);
    box-shadow: 0 10px 30px rgba(143, 7, 9, 0.25);
    transition-duration: 150ms;
}

.pl-src-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pl-glyph {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--pl-line);
    color: var(--color-background);
}

.pl-glyph svg {
    width: 18px;
    height: 18px;
}

.pl-src.is-active .pl-glyph {
    border-color: var(--pl-ember-soft);
    color: #f3b1a9;
}

.pl-src-name {
    font-family: var(--font-serif);
    font-size: 1.1rem;
    line-height: 1.2;
}

.pl-src-via {
    display: block;
    font-size: 0.7rem;
    color: var(--pl-text-dim);
    line-height: 1.4;
}

.pl-record {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--pl-line);
    font-size: 0.72rem;
    color: var(--pl-text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-variant-numeric: tabular-nums;
    transition: opacity 180ms ease, transform 180ms var(--ease-out);
}

.pl-record::before {
    content: "> ";
    color: var(--color-ember);
}

.pl-record.is-swapping {
    opacity: 0;
    transform: translateY(-4px);
}

/* Engine */

.pl-engine {
    border: 1px solid rgba(241, 238, 231, 0.14);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, #1d1f1b, #141613);
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(0, 0, 0, 0.3),
        0 0 70px rgba(143, 7, 9, 0.16);
    overflow: hidden;
}

.pl-ledger {
    position: relative;
    height: 312px;
    padding: 0 16px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: var(--pl-gap);
    overflow: hidden;
    -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 56px);
    mask-image: linear-gradient(180deg, transparent 0, #000 56px);
}

.pl-entry {
    flex-shrink: 0;
    font-size: 0.74rem;
    line-height: 1.6;
    font-variant-numeric: tabular-nums;
}

.pl-entry.is-leaving {
    opacity: 0;
    transition: opacity 300ms ease;
}

.pl-entry-head {
    display: flex;
    gap: 10px;
    color: var(--pl-text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-entry-head b {
    font-weight: 500;
    color: var(--color-background);
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-leg {
    display: grid;
    grid-template-columns: 6ch minmax(0, 1fr) auto;
    gap: 8px;
}

.pl-leg span:nth-child(2) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-leg span:first-child {
    color: var(--pl-text-dim);
}

.pl-leg.is-cr span:nth-child(2) {
    padding-left: 1.2em;
}

.pl-leg span:last-child {
    text-align: right;
    white-space: nowrap;
}

.pl-tag {
    color: var(--color-green-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pl-tag::before {
    content: "\2713  ";
    white-space: pre;
}

/* Lines written by the live loop start hidden and settle in. */
.pl-entry .is-pending {
    opacity: 0;
    transform: translateY(6px);
}

.pl-entry .is-written {
    opacity: 1;
    transform: none;
    transition: opacity 260ms ease, transform 360ms var(--ease-out);
}

/* Reports */

.pl-reports {
    display: flex;
    flex-direction: column;
    gap: var(--pl-gap);
}

.pl-report {
    position: relative;
    padding: 14px 16px;
    border: 1px solid var(--pl-line);
    border-radius: var(--radius-md);
    background: rgba(241, 238, 231, 0.03);
    transition: border-color 500ms ease, background-color 500ms ease;
}

.pl-report.is-hit {
    border-color: var(--pl-ember-soft);
    background: rgba(143, 7, 9, 0.12);
    transition-duration: 120ms;
}

.pl-report-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.pl-report-name {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.2;
}

.pl-report-value {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 6px;
    font-family: var(--font-serif);
    font-size: 1.55rem;
    line-height: 1.1;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pl-report-value small {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0;
    color: var(--pl-text-dim);
}

.pl-delta {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0;
    color: var(--color-green-bright);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 400ms ease, transform 400ms var(--ease-out);
}

.pl-delta.is-shown {
    opacity: 1;
    transform: none;
    transition-duration: 160ms, 300ms;
}

.pl-report-caption {
    display: block;
    margin-top: 4px;
    font-size: 0.7rem;
    color: var(--pl-text-dim);
}

/* Stacked layout: sources and reports go 2-up, wires run vertically. */
@media (max-width: 980px) {
    .pl-stage {
        grid-template-columns: minmax(0, 1fr);
        row-gap: 64px;
    }

    .pl-sources,
    .pl-reports {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--pl-gap);
    }
}

@media (max-width: 560px) {
    .pl-src,
    .pl-report {
        padding: 12px;
    }

    .pl-src-via {
        display: none;
    }

    .pl-record {
        white-space: normal;
        overflow-wrap: anywhere;
        min-height: calc(2 * 1.5em);
        line-height: 1.5;
    }

    .pl-glyph {
        width: 24px;
        height: 24px;
    }

    .pl-src-name {
        font-size: 1rem;
    }

    .pl-report-value {
        flex-wrap: wrap;
        row-gap: 2px;
        font-size: 1.25rem;
    }

    .pl-ledger {
        height: 330px;
        padding: 0 12px 12px;
    }
}
