/* Styles for the private-payments blog. Page-wide rules (body, headings, p,
   code, tables, footer) come from /style.css; everything here is scoped to the
   blog's widgets so it cannot leak into the rest of the site. */

/* Live counters inline in the introduction. */
.live {
    background: #fffbe8;
    border-bottom: 2px solid #d9251c;
    color: #d9251c;
    font-weight: bold;
    font-variant-numeric: tabular-nums;
    padding: 0 3px;
    white-space: nowrap;
}

/* --- Widget controls ------------------------------------------------------ */

.sim-stepper button {
    padding: 5px 8px;
    margin: 0;
    background-color: #0000ee;
    color: white;
    font-family: monospace;
    font-size: 0.9em;
    border-width: 0;
    cursor: pointer;
}

.sim-stepper button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Two small benchmark tables share a row instead of each stretching full width. */
.table-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.table-row .table-col {
    flex: 1 1 0;
    min-width: 0;
}

@media (max-width: 480px) {
    .table-row {
        flex-direction: column;
        gap: 0;
    }
}

.table-row table {
    margin: 10px 0;
}

.table-row th,
.table-row td {
    text-align: center;
}

/* --- Simulation: ecash to our construction -------------------------------- */

.sim-stepper {
    align-items: center;
    display: flex;
    gap: 10px;
    margin: 14px 0 6px;
}

.sim-title {
    flex: 1;
    font-weight: bold;
}

.sim-caption {
    color: #555;
    font-size: 12px;
    line-height: 1.45;
    margin: 0 0 12px;
}

.sim-dots {
    display: flex;
    gap: 6px;
}

.sim-dot {
    background: #ddd;
    border-radius: 50%;
    cursor: pointer;
    display: inline-block;
    height: 9px;
    width: 9px;
}

.sim-dot.on {
    background: #0000ee;
}

.sim-stage {
    border: 1px solid #ddd;
    background: white;
    position: relative;
}

/* [?] markers in panel corners, with a tip that opens beneath them. */
.sim-stage .sim-help {
    background: white;
    border: 1px solid #bbb;
    border-radius: 50%;
    color: #888;
    cursor: help;
    font: bold 12px/18px monospace;
    height: 20px;
    margin: 0;
    padding: 0;
    position: absolute;
    text-align: center;
    width: 20px;
}

.sim-stage .sim-help:hover,
.sim-stage .sim-help.open {
    border-color: #0000ee;
    color: #0000ee;
}

.sim-tip {
    background: #fffef5;
    border: 1px solid #ccc;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    color: #333;
    display: none;
    font-size: 12px;
    line-height: 1.4;
    max-width: 320px;
    padding: 8px 10px;
    position: absolute;
    z-index: 2;
}

.sim-tip.show {
    display: block;
}

.sim-svg {
    display: block;
    font-family: monospace;
    width: 100%;
}

.sim-h {
    font-size: 15px;
    font-weight: bold;
    text-anchor: middle;
}
.sim-h.red { fill: #d9251c; }
.sim-h.blue { fill: #1f1fd1; }

.sim-h.left { text-anchor: start; }
.sim-muted { fill: gray; font-weight: normal; }

.sim-divider {
    stroke: #e5e5e5;
    stroke-width: 1;
}

.sim-box {
    fill: white;
    stroke: #d9251c;
    stroke-width: 2;
}

.sim-spoke {
    stroke: #e0e0e0;
    stroke-width: 1.5;
}

.sim-handoff {
    fill: none;
    stroke: #1f1fd1;
    stroke-dasharray: 5 4;
    stroke-width: 1.5;
    opacity: 0.6;
}

.sim-token.send { fill: #d9251c; }
.sim-token.recv { fill: #1f1fd1; }
/* Red + blue, once send and receive are indistinguishable. */
.sim-token.hidden { fill: #b020c0; }

.sim-token.hollow {
    fill: white;
    stroke: #555;
    stroke-width: 2;
}

/* Marker at the start of each ledger row: the operation, while the ledger can see it. */
.sim-row-mark.send { fill: #d9251c; }
.sim-row-mark.recv { fill: #1f1fd1; }
.sim-row-mark.hidden { fill: #bbb; }

/* Outline that flashes on a balance bar when a debit or credit lands. */
.sim-bal-hit {
    fill: none;
    stroke-width: 2.5;
    opacity: 0;
    pointer-events: none;
}
.sim-bal-hit.send { stroke: #d9251c; }
.sim-bal-hit.recv { stroke: #1f1fd1; }

/* Rule under a storage header showing how far its ownership extends. */
.sim-headrule {
    stroke: #333;
    stroke-width: 1;
}

.sim-node-label {
    font-size: 14px;
    text-anchor: middle;
}

.sim-node-label.bold { font-weight: bold; font-size: 16px; }

.sim-seg-label.bold { font-weight: bold; }

.sim-row {
    font-size: 13px;
}

.sim-rule {
    stroke: #eee;
    stroke-width: 1;
}

.sim-baseline {
    stroke: #999;
    stroke-width: 1;
}

.sim-seg-label {
    font-size: 13px;
}

.sim-seg-label.center { text-anchor: middle; fill: gray; font-style: italic; }
.sim-seg-label.right { text-anchor: end; }
.sim-seg-label.dark { fill: #333; }

/* Storage structures. */
.sim-seg-label.red { fill: #d9251c; }
.sim-seg-label.blue { fill: #1f1fd1; }

.sim-tiny {
    fill: #777;
    font-size: 10px;
}
.sim-tiny.center { text-anchor: middle; }
.sim-tiny.right { text-anchor: end; }

.sim-cell {
    fill: white;
    stroke: #999;
    stroke-width: 1;
}

.sim-cell-val {
    fill: black;
    font-size: 13px;
    text-anchor: middle;
}
.sim-cell-val.hex { fill: #555; }

.sim-nf {
    fill: #d9251c;
    opacity: 0.85;
}

.sim-receipt {
    fill: #1f1fd1;
    opacity: 0.85;
}

.sim-mmr-body {
    fill: #fafafa;
    stroke: #bbb;
    stroke-dasharray: 3 3;
    stroke-width: 1;
}

.sim-peak {
    fill: #1f1fd1;
}

.sim-edge {
    fill: none;
    stroke: #bbb;
    stroke-width: 1;
}

.sim-leaf { fill: #d9251c; }
.sim-leaf.empty { fill: white; stroke: #ccc; stroke-width: 1; }
.sim-inner { fill: #555; }
.sim-inner.empty { fill: white; stroke: #ccc; stroke-width: 1; }

/* A frozen prefix of a nullifier tree: its frontier is kept, the rest is in cold storage. */
.sim-frontier { fill: #1f1fd1; }
.sim-leaf.cold, .sim-inner.cold { fill: #eee; }
.sim-edge.cold { stroke: #eee; }

.sim-flash {
    fill: #ffd54a;
    animation: sim-flash 0.7s ease-out both;
    pointer-events: none;
}

@keyframes sim-flash {
    0% { opacity: 0; }
    15% { opacity: 0.9; }
    100% { opacity: 0; }
}

/* The edge from a recomputed node to its parent lights up as the hash travels upward. */
.sim-edge-hot {
    fill: none;
    stroke: #e0a800;
    stroke-width: 2.5;
    animation: sim-flash 0.6s ease-out both;
    pointer-events: none;
}

/* The inserted leaf pops in. */
.sim-leaf.pop {
    animation: sim-pop 0.35s ease-out both;
    transform-box: fill-box;
    transform-origin: center;
}

@keyframes sim-pop {
    from { transform: scale(0); }
    60% { transform: scale(1.6); }
    to { transform: scale(1); }
}

.sim-bal {
    fill: #c8c8c8;
    stroke: none;
    transition: fill 0.4s, stroke 0.4s;
}

.sim-bal.flight {
    fill: #1f1fd1;
}

.sim-bal.hidden {
    fill: #f4f4f4;
    stroke: #aaa;
    stroke-dasharray: 4 3;
    stroke-width: 1.5;
}

.sim-bal.flight.hidden {
    fill: #eef;
    stroke: #99a;
}

.sim-counters {
    display: flex;
    gap: 14px;
    margin: 10px 0 12px;
}

.sim-counter {
    background: #f5f5f5;
    border: 1px solid #ddd;
    flex: 1;
    font-size: 0.9em;
    line-height: 1.3;
    padding: 8px 10px;
}

.sim-counter.hl {
    background: #fffbe8;
    border-color: #d9251c;
}

.sim-counter .k {
    color: gray;
    display: block;
    font-size: 0.8em;
    letter-spacing: 0.04em;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.sim-counter.hl .k {
    color: #d9251c;
}

.sim-counter .v {
    white-space: pre-line;
}

.sim-counter .n {
    color: gray;
    font-size: 0.85em;
    margin-top: 3px;
}

.sim-counter .n:empty {
    display: none;
}

@media (max-width: 600px) {
    .sim-counters { flex-direction: column; }
}

#rpc-diagram {
    margin: 18px 0;
    font-family: monospace;
    font-size: 14px;
    line-height: 1.45;
}

#rpc-diagram .rpc-controls {
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 6px;
}

#rpc-diagram .rpc-controls .sim-title {
    flex: none;
    margin-right: 4px;
}

#rpc-diagram .rpc-controls button[aria-pressed="false"] {
    background-color: white;
    color: #0000ee;
    box-shadow: inset 0 0 0 1px #0000ee;
}

#rpc-diagram .rpc-controls button:focus-visible {
    outline: 2px solid #0000ee;
    outline-offset: 2px;
}

#rpc-diagram .rpc-flow {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20px minmax(0, 1.4fr) 20px minmax(0, 1.1fr);
    align-items: center;
    gap: 8px;
}

#rpc-diagram .rpc-node {
    min-width: 0;
    padding: 12px;
    border: 1px solid #bbb;
    background: #fafafa;
    overflow-wrap: anywhere;
}

#rpc-diagram .rpc-relay {
    border-color: #1f1fd1;
    background: #fff;
}

#rpc-diagram .rpc-detail {
    display: block;
    margin-top: 6px;
    color: #555;
    font-size: 13px;
}

#rpc-diagram .rpc-arrow {
    color: #1f1fd1;
    justify-self: center;
    text-align: center;
    font-size: 24px;
}

#rpc-diagram .rpc-transactions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
}

#rpc-diagram .rpc-transactions li {
    margin: 0;
    padding: 4px;
    border: 1px solid #bbb;
    background: white;
    text-align: center;
}

#rpc-diagram .rpc-groups {
    margin-top: 12px;
}

#rpc-diagram .rpc-group-title {
    color: #d9251c;
    font-size: 12px;
}

#rpc-diagram .rpc-group {
    display: grid;
    gap: 2px;
    margin-top: 6px;
    padding: 6px 8px;
    border-left: 3px solid #d9251c;
    background: #fffbe8;
}

#rpc-diagram [hidden] {
    display: none;
}

@media (max-width: 600px) {
    #rpc-diagram .rpc-flow {
        grid-template-columns: minmax(0, 1fr);
        gap: 4px;
    }

    #rpc-diagram .rpc-arrow {
        transform: rotate(90deg);
    }

    #rpc-diagram .rpc-transactions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
