/* pv-record.css — "THE LIVING LEDGER" for figure.pm-record (#verification).
   Companion to js/pv-record.js. The stage is appended inside the
   aria-hidden .pm-record-sheet; the original static sheet children stay in
   the DOM as the no-JS frame and are hidden only while .pv3-live is set.
   Controls + readout remain untouched and driven by primae-page.js.

   Light paper scene: ink linework, rust for the instrument in motion,
   pm-green / pm-red / pm-faint+amber for the three verdicts. All text
   ≥ 13 px computed; dial SVG numerals only render in the wide layout
   where their computed size stays ≥ 13 px (compact hides SVG text and
   the note line carries the numbers instead). */

.pm-record-sheet.pv3-live > :not(.pv3-stage) { display: none; }

.pm-record-sheet.pv3-live { position: relative; }

.pv3-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    color: var(--pm-ink, #191917);
    font-family: var(--pm-sans, "Geist", Inter, -apple-system, sans-serif);
    pointer-events: none;
}

/* ---------- header: artifact chip + verdict tag ---------- */

.pv3-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .6rem;
}

.pv3-chip {
    min-width: 0;
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .34rem .6rem;
    border: 1px solid var(--pm-line, rgba(25, 25, 23, .22));
    background: var(--pm-paper-2, #ece8de);
}

.pv3-fp {
    flex: 0 0 auto;
    width: 1.2rem;
    height: 1.2rem;
}

.pv3-fp circle {
    fill: none;
    stroke: var(--pm-rust-dark, #8c3018);
    stroke-width: 1.7;
    stroke-linecap: round;
}

.pv3-chip-lab {
    font: 600 .8125rem/1 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    letter-spacing: .06em;
    color: var(--pm-rust-dark, #8c3018);
    white-space: nowrap;
}

.pv3-hash {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font: 500 .8125rem/1 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    color: var(--pm-muted, #5e5a52);
    white-space: nowrap;
}

.pv3-tag {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    padding: .34rem .6rem;
    border: 1px solid transparent;
    font: 700 .8125rem/1 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    letter-spacing: .05em;
    white-space: nowrap;
    transition: background .25s ease, color .25s ease, border-color .25s ease;
}

.pv3-s-passed .pv3-tag {
    color: var(--pm-green, #1d7250);
    border-color: currentColor;
    background: rgba(29, 114, 80, .07);
}

/* the failed tab: a red flag clipped like a ledger tab — it stays attached */
.pv3-s-failed .pv3-tag {
    color: var(--pm-paper, #f4f1e9);
    background: var(--pm-red, #9d3525);
    border-color: var(--pm-red, #9d3525);
    padding-left: .95rem;
    clip-path: polygon(.55rem 0, 100% 0, 100% 100%, .55rem 100%, 0 50%);
}

.pv3-s-unresolved .pv3-tag {
    color: var(--pm-amber, #7a5700);
    border: 1px dashed currentColor;
    background: transparent;
}

.pv3-tag-in { animation: pv3-tagin .38s cubic-bezier(.2, .9, .3, 1.2) both; }

@keyframes pv3-tagin {
    from { transform: translateY(-.3rem); opacity: 0; }
    to { transform: none; opacity: 1; }
}

/* ---------- the dial: engineering-sheet ground + SVG instrument ---------- */

.pv3-dialbox {
    position: relative;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: .35rem;
    border: 1px solid var(--pm-line, rgba(25, 25, 23, .22));
    padding: .6rem;
    background:
        repeating-linear-gradient(0deg, rgba(25, 25, 23, .05) 0 1px, transparent 1px 22px),
        repeating-linear-gradient(90deg, rgba(25, 25, 23, .05) 0 1px, transparent 1px 22px),
        var(--pm-paper, #f4f1e9);
}

.pv3-dial-head {
    min-width: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: .3rem .75rem;
    padding-bottom: .45rem;
    border-bottom: 1px solid var(--pm-line, rgba(25, 25, 23, .22));
    color: var(--pm-muted, #5e5a52);
    font-family: var(--pm-mono, "Geist Mono", ui-monospace, monospace);
}

.pv3-dial-head span {
    font-size: .8125rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: .05em;
}

.pv3-dial-head code {
    font: 500 .8125rem/1.2 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
}

.pv3-dial {
    display: block;
    width: 100%;
    max-width: 30rem;
    height: auto;
    margin: 0 auto;
}

.pv3-dial text { font-family: var(--pm-mono, "Geist Mono", ui-monospace, monospace); }

.pv3-track { fill: none; stroke: var(--pm-ink, #191917); stroke-width: 2; }

.pv3-mirror { fill: none; stroke: rgba(25, 25, 23, .18); stroke-width: 1; }

.pv3-tick { stroke: var(--pm-ink-2, #25231f); opacity: .72; }

.pv3-tick.pv3-tickhot { stroke: var(--pm-rust, #bd4321); opacity: 1; }

.pv3-dlab {
    font-size: 13.5px;
    font-weight: 500;
    fill: var(--pm-muted, #5e5a52);
    stroke: var(--pm-paper, #f4f1e9);
    stroke-width: 4px;
    stroke-linejoin: round;
    paint-order: stroke fill;
}

/* tolerance band — the acceptance zone on the tick track */
.pv3-band-fill { fill: var(--pm-green, #1d7250); opacity: 0; transition: fill .35s ease; }

.pv3-s-unresolved .pv3-band-fill { fill: var(--pm-faint, #8a857b); }

.pv3-band-edge {
    fill: none;
    stroke: var(--pm-green, #1d7250);
    stroke-width: 1.3;
    transition: stroke .35s ease;
}

.pv3-s-unresolved .pv3-band-edge {
    stroke: var(--pm-faint, #8a857b);
    stroke-dasharray: 5 4;
}

/* expected basis marker */
.pv3-exp { stroke: var(--pm-green, #1d7250); stroke-width: 1.7; transition: stroke .35s ease; }

.pv3-s-unresolved .pv3-exp { stroke: var(--pm-faint, #8a857b); stroke-dasharray: 4 4; }

.pv3-exp-d { fill: var(--pm-green, #1d7250); stroke: none; transition: fill .35s ease; }

.pv3-s-unresolved .pv3-exp-d {
    fill: transparent;
    stroke: var(--pm-faint, #8a857b);
    stroke-width: 1.2;
}

/* deviation bracket (failed) — the gap is measured and kept */
.pv3-gap { opacity: 0; transition: opacity .3s ease; }

.pv3-s-failed .pv3-gap { opacity: 1; }

.pv3-gap-arc { fill: none; stroke: var(--pm-red, #9d3525); stroke-width: 1.7; }

.pv3-gap-t { stroke: var(--pm-red, #9d3525); stroke-width: 1.7; }

/* state-specific dial text lives in a reserved band outside the needle sweep */
.pv3-dial-status {
    display: grid;
    grid-template-areas: "status";
    min-height: 1.45rem;
    margin: 0;
    padding-top: .45rem;
    border-top: 1px solid var(--pm-line, rgba(25, 25, 23, .22));
}

.pv3-dial-status > span {
    min-width: 0;
    grid-area: status;
    font: 600 .8125rem/1.25 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    overflow-wrap: anywhere;
    opacity: 0;
    transition: opacity .4s ease .25s;
}

.pv3-deviation { color: var(--pm-red, #9d3525); }

.pv3-basis { color: var(--pm-amber, #7a5700); }

.pv3-s-failed .pv3-deviation { opacity: 1; }

.pv3-s-unresolved .pv3-basis { opacity: 1; }

/* the needle — rust while measuring, verdict color once settled */
.pv3-needle-line {
    stroke: var(--pm-rust, #bd4321);
    stroke-width: 2.4;
    stroke-linecap: round;
    transition: stroke .3s ease;
}

.pv3-needle-tip { fill: var(--pm-rust, #bd4321); transition: fill .3s ease; }

.pv3-settled.pv3-s-passed .pv3-needle-line { stroke: var(--pm-green, #1d7250); }
.pv3-settled.pv3-s-passed .pv3-needle-tip { fill: var(--pm-green, #1d7250); }
.pv3-settled.pv3-s-failed .pv3-needle-line { stroke: var(--pm-red, #9d3525); }
.pv3-settled.pv3-s-failed .pv3-needle-tip { fill: var(--pm-red, #9d3525); }

.pv3-s-unresolved .pv3-needle-line {
    stroke: var(--pm-faint, #8a857b);
    stroke-dasharray: 7 5;
}

.pv3-s-unresolved .pv3-needle-tip { fill: var(--pm-faint, #8a857b); }

/* reduced-motion unresolved: positional uncertainty as ghost needles */
.pv3-ghost {
    stroke: var(--pm-faint, #8a857b);
    stroke-width: 2;
    stroke-dasharray: 6 6;
    opacity: 0;
}

.pv3-ghosts .pv3-ghost { opacity: .35; }

.pv3-hub { fill: var(--pm-ink, #191917); }

.pv3-hubdot { fill: var(--pm-paper, #f4f1e9); }

.pv3-halo {
    fill: none;
    stroke: var(--pm-green, #1d7250);
    stroke-width: 2;
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}

.pv3-settled.pv3-s-passed .pv3-halo { animation: pv3-halo .7s ease-out both; }

.pv3-settled.pv3-s-failed .pv3-halo {
    stroke: var(--pm-red, #9d3525);
    animation: pv3-halo .7s ease-out both;
}

@keyframes pv3-halo {
    0% { opacity: .85; transform: scale(.4); }
    100% { opacity: 0; transform: scale(2.4); }
}

/* ---------- note line ---------- */

.pv3-note {
    margin: 0;
    font: 500 .8125rem/1.45 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    color: var(--pm-muted, #5e5a52);
}

/* ---------- strip chart: the ledger keeps recording ---------- */

.pv3-stripbox {
    border: 1px solid var(--pm-line, rgba(25, 25, 23, .22));
    background: var(--pm-paper-2, #ece8de);
    padding: .38rem .5rem .45rem;
}

.pv3-striphead {
    display: flex;
    justify-content: space-between;
    gap: .6rem;
    margin-bottom: .28rem;
}

.pv3-striphead span {
    font: 600 .8125rem/1 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    letter-spacing: .05em;
    color: var(--pm-muted, #5e5a52);
}

.pv3-trace {
    display: block;
    width: 100%;
    height: 46px;
}

.pv3-tband { fill: rgba(29, 114, 80, .13); transition: fill .35s ease; }

.pv3-s-unresolved .pv3-tband { fill: rgba(138, 133, 123, .10); }

.pv3-tband-e {
    stroke: var(--pm-green, #1d7250);
    stroke-width: 1;
    opacity: .7;
    transition: stroke .35s ease;
}

.pv3-s-unresolved .pv3-tband-e {
    stroke: var(--pm-faint, #8a857b);
    stroke-dasharray: 5 4;
}

.pv3-tgrid line { stroke: rgba(25, 25, 23, .16); stroke-width: 1; }

.pv3-tline {
    fill: none;
    stroke: var(--pm-rust, #bd4321);
    stroke-width: 1.5;
    stroke-linejoin: round;
}

.pv3-pen { fill: var(--pm-rust, #bd4321); transition: fill .3s ease; }

.pv3-settled.pv3-s-passed .pv3-pen { fill: var(--pm-green, #1d7250); }
.pv3-settled.pv3-s-failed .pv3-pen { fill: var(--pm-red, #9d3525); }
.pv3-s-unresolved .pv3-pen { fill: var(--pm-amber, #7a5700); }

/* ---------- value strip ---------- */

.pv3-vals {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border: 1px solid var(--pm-line, rgba(25, 25, 23, .22));
    background: var(--pm-paper, #f4f1e9);
}

.pv3-val {
    min-width: 0;
    padding: .5rem .55rem;
    border-right: 1px solid var(--pm-line, rgba(25, 25, 23, .22));
}

.pv3-val:last-child { border-right: 0; }

.pv3-val > span {
    display: block;
    font: 600 .8125rem/1.15 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    letter-spacing: .02em;
    color: var(--pm-muted, #5e5a52);
}

.pv3-val > code {
    display: block;
    margin-top: .3rem;
    font: 600 .8125rem/1.2 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    color: var(--pm-ink, #191917);
    white-space: nowrap;
}

.pv3-val > code.pv3-v-measured { color: var(--pm-rust-dark, #8c3018); }
.pv3-settled .pv3-val > code.pv3-v-measured { color: var(--pm-ink, #191917); }
.pv3-s-unresolved .pv3-val > code.pv3-v-measured { color: var(--pm-amber, #7a5700); }

.pv3-s-passed .pv3-val > code.pv3-v-dev { color: var(--pm-green, #1d7250); }
.pv3-s-failed .pv3-val > code.pv3-v-dev { color: var(--pm-red, #9d3525); }
.pv3-s-unresolved .pv3-val > code.pv3-v-dev { color: var(--pm-muted, #5e5a52); }

.pv3-val > code.pv3-missing { color: var(--pm-muted, #5e5a52); }

/* ---------- signature + seal ---------- */

.pv3-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--pm-line, rgba(25, 25, 23, .22));
    background: var(--pm-paper-2, #ece8de);
    padding: .55rem .8rem;
}

.pv3-sig {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: .45rem;
}

.pv3-sig-top {
    display: flex;
    align-items: baseline;
    gap: .6rem;
    flex-wrap: wrap;
}

.pv3-sig-lab {
    font: 700 .8125rem/1 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    letter-spacing: .08em;
    color: var(--pm-rust-dark, #8c3018);
}

.pv3-sig-sub {
    font: 500 .8125rem/1 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    color: var(--pm-muted, #5e5a52);
}

.pv3-sig-items {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem .8rem;
}

.pv3-sig-item {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}

.pv3-sig-item i {
    flex: 0 0 auto;
    width: .68rem;
    height: .68rem;
    background: var(--pm-ink, #191917);
    border: 1.5px solid var(--pm-ink, #191917);
    transition: background .25s ease, border-color .25s ease;
}

.pv3-sig-item.pv3-open i {
    background: transparent;
    border: 1.5px dashed var(--pm-amber, #7a5700);
}

.pv3-sig-item code {
    font: 500 .8125rem/1 var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    color: var(--pm-ink-2, #25231f);
    white-space: nowrap;
}

.pv3-sig-item.pv3-open code { color: var(--pm-amber, #7a5700); }

.pv3-seal { flex: 0 0 auto; }

.pv3-seal svg {
    display: block;
    width: 4.75rem;
    height: 4.75rem;
}

.pv3-seal-outer { fill: none; stroke: var(--pm-line, rgba(25, 25, 23, .22)); stroke-width: 1; }

.pv3-seal-dash {
    fill: none;
    stroke: var(--pm-faint, #8a857b);
    stroke-width: 1.5;
    stroke-dasharray: 4 6;
}

.pv3-seal-prog {
    fill: none;
    stroke: var(--pm-green, #1d7250);
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke .3s ease;
}

.pv3-s-failed .pv3-seal-prog { stroke: var(--pm-red, #9d3525); }

.pv3-seal-word {
    font-family: var(--pm-mono, "Geist Mono", ui-monospace, monospace);
    font-size: 13px;
    font-weight: 700;
    text-anchor: middle;
    fill: var(--pm-green, #1d7250);
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
}

.pv3-s-failed .pv3-seal-word { fill: var(--pm-red, #9d3525); }

.pv3-s-unresolved .pv3-seal-word {
    fill: var(--pm-muted, #5e5a52);
    opacity: .95;
}

.pv3-stamped .pv3-seal-word { animation: pv3-stamp .4s cubic-bezier(.2, 1.4, .4, 1) both; }

@keyframes pv3-stamp {
    0% { opacity: 0; transform: rotate(-14deg) scale(1.9); }
    60% { opacity: 1; }
    100% { opacity: 1; transform: rotate(-7deg) scale(1); }
}

/* ---------- slim value strip (460–579 px container) ----------
   the five-up row breaks its labels mid-word before the compact
   layout kicks in — go three-up (3 + 2) at intermediate widths */

.pv3-slim .pv3-vals { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.pv3-slim .pv3-val:nth-child(3n) { border-right: 0; }

.pv3-slim .pv3-val:nth-child(n+4) { border-top: 1px solid var(--pm-line, rgba(25, 25, 23, .22)); }

.pv3-slim .pv3-val:last-child { grid-column: span 2; }

/* ---------- compact composition (< 460 px container) ---------- */

.pv3-compact .pv3-dial text { display: none; }

.pv3-compact .pv3-head { flex-wrap: wrap; }

.pv3-compact .pv3-hash { display: none; }

.pv3-compact .pv3-stripspan { display: none; }

.pv3-compact .pv3-vals { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.pv3-compact .pv3-val:nth-child(2n) { border-right: 0; }

.pv3-compact .pv3-val:nth-child(n+3) { border-top: 1px solid var(--pm-line, rgba(25, 25, 23, .22)); }

.pv3-compact .pv3-val:last-child { grid-column: 1 / -1; border-right: 0; }

.pv3-compact .pv3-foot {
    flex-direction: column;
    align-items: flex-start;
    gap: .7rem;
}

/* ---------- reduced motion: composed static frames ---------- */

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

    .pv3-stamped .pv3-seal-word {
        opacity: 1;
        transform: rotate(-7deg);
    }
}

/* ---------- forced colors: fall back to the original static sheet ---------- */

@media (forced-colors: active) {
    .pm-record-sheet.pv3-live > .pv3-stage { display: none; }

    .pm-record-sheet.pv3-live > .pm-record-meta,
    .pm-record-sheet.pv3-live > .pm-record-seal { display: flex; }

    .pm-record-sheet.pv3-live > dl:not(.pv3-stage) { display: grid; }
}
