/* pv-flow.css — "THE SPECIMEN LINE" for figure.pm-flow-studio (#workflow).
   Companion to js/pv-flow.js. One luminous work-item (JOB-01) rides a
   continuous factory rail through six machine stations: radar scope,
   test cell, comparator balance, milling head, stamp battery, sealing
   press. The stage is appended inside .pm-flow-field; the original six
   boxes stay in the DOM as the no-JS frame and are hidden only while
   .pv2-live is set. primae-page.js keeps driving state via the
   data-flow-state attribute on the figure root — this layer only reads.

   NOTE on specificity: the stage div itself matches the site's
   `.pm-flow-field > div` and `.pm-flow-field svg *` rules, so every
   selector below is anchored on .pv2-stage (or deeper) to out-rank them.

   Grounds: ink instrument on the dark workflow section. Rust is reserved
   for live machine activity and the specimen; green/red only for check
   verdicts. Type floor 13 px mono. */

.pm-flow-field.pv2-live {
    display: block;
    min-height: 0;
    padding: 1.1rem 1.1rem 0.35rem;
}

.pm-flow-field.pv2-live > :not(.pv2-stage) { display: none; }

/* undo the site's generic .pm-flow-field > div box styling on the stage */
.pm-flow-field.pv2-live > .pv2-stage {
    display: block;
    position: relative;
    z-index: 1;
    min-height: 0;
    min-width: 0;
    padding: 0;
    gap: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    text-align: left;
    justify-items: normal;
    align-content: normal;
    transition: none;
    font-family: var(--pm-mono, 'Geist Mono', ui-monospace, SFMono-Regular, monospace);
    pointer-events: none;
}

.pv2-stage .pv2-wrap { position: relative; }

/* ---------- rail underlay ---------- */

.pv2-stage svg.pv2-rail {
    position: absolute;
    inset: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    display: block;
}

.pv2-stage .pv2-rail-base { fill: none; stroke: #403d37; stroke-width: 2; }
.pv2-stage .pv2-rail-flow { fill: none; stroke: #7d4a35; stroke-width: 2; stroke-dasharray: 3 11; opacity: .45; }
.pv2-stage .pv2-rail-on { fill: none; stroke: var(--pm-rust-light, #f09a78); stroke-width: 2; opacity: .9; }

.pv2-stage .pv2-node {
    fill: #191917;
    stroke: #6e6960;
    stroke-width: 1.5;
    transition: fill .3s ease, stroke .3s ease;
}
.pv2-stage .pv2-node.pv2-node-done { stroke: #98917f; }
.pv2-stage .pv2-node.pv2-node-on { fill: var(--pm-rust, #bd4321); stroke: var(--pm-rust-light, #f09a78); }

.pv2-stage .pv2-umb-wide { fill: none; stroke: rgba(240, 154, 120, .14); stroke-width: 8; stroke-linecap: round; }
.pv2-stage .pv2-umb { fill: none; stroke: var(--pm-rust-light, #f09a78); stroke-width: 1.5; stroke-dasharray: 2 4; opacity: .85; }

.pv2-stage .pv2-trail { fill: var(--pm-rust-light, #f09a78); stroke: none; }

/* ---------- station line ---------- */

.pv2-stage .pv2-line {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 1rem .8rem;
    padding-bottom: 60px;
}

.pv2-stage.pv2-cols3 .pv2-line {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    row-gap: 76px;
    padding-inline: 30px;
}

.pv2-stage.pv2-cols2 .pv2-line {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 76px;
    padding-inline: 26px;
}

/* serpentine visual order — travel stays 1→6 while rows alternate direction */
.pv2-stage.pv2-cols3 .pv2-st--adapt { order: 6; }
.pv2-stage.pv2-cols3 .pv2-st--check { order: 5; }
.pv2-stage.pv2-cols3 .pv2-st--return { order: 4; }

.pv2-stage.pv2-cols2 .pv2-st--discover { order: 1; }
.pv2-stage.pv2-cols2 .pv2-st--run { order: 2; }
.pv2-stage.pv2-cols2 .pv2-st--select { order: 4; }
.pv2-stage.pv2-cols2 .pv2-st--adapt { order: 3; }
.pv2-stage.pv2-cols2 .pv2-st--check { order: 5; }
.pv2-stage.pv2-cols2 .pv2-st--return { order: 6; }

/* ---------- station card ---------- */

.pv2-stage .pv2-st {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: .4rem;
    min-height: 11.75rem;
    min-width: 0;
    padding: .6rem .65rem .55rem;
    background: #201f1b;
    border: 1px solid var(--pm-line-dark, #3a3733);
    transition: border-color .35s ease, background .35s ease, box-shadow .35s ease;
}

/* dock notch on the bottom edge — where the rail feeds the machine */
.pv2-stage .pv2-st::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -2px;
    width: 16px;
    height: 3px;
    transform: translateX(-50%);
    background: #45423b;
    transition: background .3s ease, box-shadow .3s ease;
}

.pv2-stage .pv2-st.pv2-on {
    background: #272119;
    border-color: var(--pm-rust-light, #f09a78);
    box-shadow: inset 0 0 0 1px var(--pm-rust-light, #f09a78), 0 0 24px rgba(189, 67, 33, .17);
}
.pv2-stage .pv2-st.pv2-on::after {
    background: var(--pm-rust-light, #f09a78);
    box-shadow: 0 2px 8px rgba(240, 154, 120, .5);
}
.pv2-stage .pv2-st.pv2-done { border-color: #4c483f; }
.pv2-stage .pv2-st.pv2-done::after { background: #6e6960; }

.pv2-stage .pv2-hd { display: flex; align-items: center; gap: .5rem; min-width: 0; }

.pv2-stage .pv2-num {
    color: var(--pm-rust-light, #f09a78);
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 600;
    letter-spacing: .05em;
}

.pv2-stage .pv2-name {
    color: #d7d1c6;
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .09em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pv2-stage .pv2-st.pv2-on .pv2-name { color: var(--pm-paper, #f4f1e9); }

.pv2-stage .pv2-lamp {
    flex: 0 0 auto;
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3c3934;
    border: 1px solid #55514a;
    transition: background .3s ease, border-color .3s ease;
}
.pv2-stage .pv2-st.pv2-on .pv2-lamp {
    background: var(--pm-rust-light, #f09a78);
    border-color: var(--pm-rust-light, #f09a78);
}
.pv2-stage .pv2-st.pv2-done .pv2-lamp { background: #56766a; border-color: #56766a; }
.pv2-stage.pv2-run .pv2-st.pv2-on .pv2-lamp { animation: pv2-lamp 1.7s ease-in-out infinite; }
.pv2-stage.pv2-run .pv2-st.pv2-inc .pv2-lamp { animation: pv2-lamp .55s ease-in-out infinite; }

@keyframes pv2-lamp {
    0%, 100% { box-shadow: 0 0 0 0 rgba(240, 154, 120, .55); }
    60% { box-shadow: 0 0 0 5px rgba(240, 154, 120, 0); }
}

.pv2-stage .pv2-mech { position: relative; min-height: 6.6rem; }
.pv2-stage .pv2-mech svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
}
.pv2-stage .pv2-st.pv2-done .pv2-mech { opacity: .78; }
.pv2-stage .pv2-st.pv2-pend .pv2-mech { opacity: .82; }

.pv2-stage .pv2-status {
    margin: 0;
    min-height: 1.15rem;
    color: #c8c2b7;
    font-family: inherit;
    font-size: .8125rem;
    letter-spacing: .04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: color .3s ease;
}
.pv2-stage .pv2-st.pv2-on .pv2-status { color: var(--pm-paper, #f4f1e9); }

/* ---------- shared mechanism strokes ---------- */

.pv2-stage .pv2-k { fill: none; stroke: #57534b; stroke-width: 1.4; }
.pv2-stage .pv2-kb { fill: none; stroke: #79736a; stroke-width: 1.6; }
.pv2-stage .pv2-st.pv2-on .pv2-k { stroke: #6e685f; }
.pv2-stage .pv2-st.pv2-on .pv2-kb { stroke: #a49d92; }

/* ---------- 01 · discover — radar scope ---------- */

.pv2-stage .pv2-d-wedge { fill: rgba(189, 67, 33, .09); stroke: none; }
.pv2-stage .pv2-st.pv2-on .pv2-d-wedge { fill: rgba(189, 67, 33, .2); }
.pv2-stage .pv2-d-edge { stroke: #6e6960; stroke-width: 1.6; }
.pv2-stage .pv2-st.pv2-on .pv2-d-edge { stroke: var(--pm-rust-light, #f09a78); }
.pv2-stage .pv2-d-dot { fill: #98917f; stroke: none; transition: fill .3s ease; }
.pv2-stage .pv2-d-dot.pv2-d-lock { fill: var(--pm-rust-light, #f09a78); }
.pv2-stage .pv2-d-cand {
    fill: none;
    stroke: var(--pm-rust-light, #f09a78);
    stroke-width: 1.4;
    opacity: 0;
    transition: opacity .35s ease;
}

/* ---------- 02 · run — test cell ---------- */

.pv2-stage .pv2-st.pv2-on .pv2-r-cell { stroke: var(--pm-rust-light, #f09a78); }
.pv2-stage .pv2-r-glyph { fill: rgba(240, 154, 120, .13); stroke: #a49d92; stroke-width: 1.5; }
.pv2-stage .pv2-st.pv2-on .pv2-r-glyph { stroke: var(--pm-paper, #f4f1e9); }
.pv2-stage .pv2-r-nd { stroke: #c8c2b7; stroke-width: 1.7; stroke-linecap: round; }
.pv2-stage .pv2-st.pv2-on .pv2-r-nd { stroke: var(--pm-rust-light, #f09a78); }
.pv2-stage .pv2-r-seg { fill: #33302b; stroke: #57534b; stroke-width: 1; transition: fill .3s ease, stroke .3s ease; }
.pv2-stage .pv2-r-seg.pv2-fill { fill: var(--pm-rust, #bd4321); stroke: var(--pm-rust-light, #f09a78); }
.pv2-stage .pv2-r-ex { fill: #c8c2b7; stroke: none; }

/* ---------- 03 · select — comparator balance ---------- */

.pv2-stage .pv2-s-beam { stroke: #a49d92; stroke-width: 2; stroke-linecap: round; }
.pv2-stage .pv2-st.pv2-on .pv2-s-beam { stroke: #cfc9be; }
.pv2-stage .pv2-s-pan rect { fill: #26231f; stroke: #79736a; stroke-width: 1.4; transition: stroke .3s ease; }
.pv2-stage .pv2-s-pan { transition: opacity .45s ease; }
.pv2-stage .pv2-s-pan.pv2-s-lose { opacity: .32; }
.pv2-stage .pv2-s-pan.pv2-s-win rect { stroke: var(--pm-rust-light, #f09a78); }
.pv2-stage .pv2-s-trace { fill: none; stroke: #c8c2b7; stroke-width: 1.3; }
.pv2-stage .pv2-s-pan.pv2-s-win .pv2-s-trace { stroke: var(--pm-paper, #f4f1e9); }
.pv2-stage .pv2-s-clamp { stroke: var(--pm-rust-light, #f09a78); stroke-width: 2; fill: none; }
.pv2-stage .pv2-s-ring { fill: none; stroke: var(--pm-rust-light, #f09a78); stroke-width: 1.5; }

/* ---------- 04 · adapt — milling head ---------- */

.pv2-stage .pv2-a-keep { fill: #2a2823; stroke: #4c4841; stroke-width: 1; }
.pv2-stage .pv2-st.pv2-on .pv2-a-keep { stroke: #5a564d; }
.pv2-stage .pv2-a-zone { fill: none; stroke: #57534b; stroke-width: 1; stroke-dasharray: 4 4; }
.pv2-stage .pv2-a-delta { fill: none; stroke: #6e6960; stroke-width: 1; stroke-dasharray: 3 3; transition: fill .3s ease; }
.pv2-stage .pv2-a-delta.pv2-fill {
    fill: var(--pm-rust, #bd4321);
    stroke: var(--pm-rust-light, #f09a78);
    stroke-dasharray: none;
}
.pv2-stage .pv2-a-hd { fill: #33302b; }
.pv2-stage .pv2-a-bit { stroke: #c8c2b7; stroke-width: 2; stroke-linecap: round; }
.pv2-stage .pv2-st.pv2-on .pv2-a-bit { stroke: var(--pm-rust-light, #f09a78); }
.pv2-stage .pv2-a-sp { stroke: var(--pm-rust-light, #f09a78); stroke-width: 1.3; stroke-linecap: round; }

/* ---------- 05 · check — stamp battery ---------- */

.pv2-stage .pv2-c-slot { fill: #26231f; stroke: #57534b; stroke-width: 1.2; transition: stroke .2s ease; }
.pv2-stage .pv2-c-slot.pv2-c-hot { stroke: var(--pm-paper, #f4f1e9); }
.pv2-stage .pv2-c-hdr { fill: #33302b; }
.pv2-stage .pv2-st.pv2-on .pv2-c-hdr { fill: #3d382f; }
.pv2-stage .pv2-c-ok { fill: none; stroke: #4cba8c; stroke-width: 2; stroke-linecap: round; }
.pv2-stage .pv2-c-no { fill: none; stroke: #e2705a; stroke-width: 2; stroke-linecap: round; }
.pv2-stage .pv2-c-mark { opacity: 0; transition: opacity .25s ease; }
.pv2-stage .pv2-c-mark.pv2-c-mark-on { opacity: 1; }
.pv2-stage .pv2-c-tag { opacity: 0; transition: opacity .35s ease; }
.pv2-stage .pv2-c-tag.pv2-c-tag-on { opacity: 1; }
.pv2-stage .pv2-c-tag line { stroke: #e2705a; stroke-width: 2; stroke-linecap: round; }
.pv2-stage .pv2-c-tag circle { fill: #e2705a; stroke: none; }

/* ---------- 06 · return — sealing press ---------- */

.pv2-stage .pv2-t-hd { fill: #33302b; }
.pv2-stage .pv2-t-code rect, .pv2-stage .pv2-t-rec rect { fill: #26231f; stroke: #a49d92; stroke-width: 1.4; }
.pv2-stage .pv2-st.pv2-on .pv2-t-code rect, .pv2-stage .pv2-st.pv2-on .pv2-t-rec rect { stroke: #cfc9be; }
.pv2-stage .pv2-t-code line { stroke: #c8c2b7; stroke-width: 1.3; }
.pv2-stage .pv2-t-rec path { stroke: #4cba8c; fill: none; stroke-width: 1.5; stroke-linecap: round; }
.pv2-stage .pv2-t-seal circle { fill: none; stroke: var(--pm-rust-light, #f09a78); stroke-width: 1.5; }
.pv2-stage .pv2-t-seal line { stroke: var(--pm-rust-light, #f09a78); stroke-width: 1.3; }
.pv2-stage .pv2-t-seal { opacity: 0; transition: opacity .4s ease; }
.pv2-stage .pv2-t-seal.pv2-t-seal-on { opacity: 1; }
.pv2-stage .pv2-t-pulse { fill: none; stroke: var(--pm-rust-light, #f09a78); stroke-width: 1.5; }
.pv2-stage .pv2-t-ghost rect { fill: none; stroke: #79736a; stroke-width: 1.2; stroke-dasharray: 3 3; }
.pv2-stage .pv2-t-ghost circle { fill: none; stroke: #79736a; stroke-width: 1.2; }

/* ---------- the specimen ---------- */

.pv2-stage .pv2-job {
    position: absolute;
    z-index: 2;
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .28rem .55rem;
    background: #241d18;
    border: 1px solid var(--pm-rust-light, #f09a78);
    color: var(--pm-paper, #f4f1e9);
    white-space: nowrap;
    box-shadow: 0 0 14px rgba(240, 154, 120, .3), inset 0 0 8px rgba(240, 154, 120, .12);
    transition: box-shadow .35s ease, border-color .35s ease;
    will-change: transform;
}

.pv2-stage .pv2-job b {
    font-family: inherit;
    font-size: .8125rem;
    font-weight: 700;
    letter-spacing: .06em;
}

.pv2-stage .pv2-job.pv2-job-move {
    box-shadow: 0 0 24px rgba(240, 154, 120, .55), inset 0 0 10px rgba(240, 154, 120, .22);
}

.pv2-stage .pv2-job.pv2-job-sealed {
    border-color: var(--pm-paper, #f4f1e9);
    box-shadow: 0 0 0 3px rgba(244, 241, 233, .18), 0 0 18px rgba(240, 154, 120, .4), inset 0 0 8px rgba(240, 154, 120, .15);
}

.pv2-stage .pv2-pips { display: flex; gap: 3px; }
.pv2-stage .pv2-pips i {
    width: 5px;
    height: 5px;
    border-radius: 1px;
    background: #4a453e;
    transition: background .3s ease;
}
.pv2-stage .pv2-pips i.pv2-pip-on { background: var(--pm-rust-light, #f09a78); }

.pv2-stage .pv2-flag {
    display: none;
    width: 6px;
    height: 6px;
    background: #e2705a;
}
.pv2-stage .pv2-job.pv2-job-flag .pv2-flag { display: block; }

/* ---------- accessibility / fallback modes ---------- */

@media (prefers-reduced-motion: reduce) {
    .pv2-stage * { animation: none !important; transition: none !important; }
}

@media (forced-colors: active) {
    .pm-flow-field.pv2-live > .pv2-stage { display: none; }
    .pm-flow-field.pv2-live {
        display: grid;
        min-height: 18rem;
        padding: 3.2rem 1rem 2.2rem;
    }
    .pm-flow-field.pv2-live > div:not(.pv2-stage) { display: grid; }
    /* :not() bumps specificity to (0,3,1) so the connector rail outranks
       the (0,3,0) hiding rule above */
    .pm-flow-field.pv2-live > svg:not(.pv2-stage) { display: block; }
    .pm-flow-field.pv2-live > .pm-flow-token { display: block; }
}
