/* Lab tool: Wallet Flow Tracer. Parchment/plate Chemist theme over an interactive onchain flow graph. */

.wf-section {
    max-width: 1180px;
    margin: 0 auto;
    padding: 8px 32px 16px;
}

/* ---- Experimental status ---------------------------------------------------------------- */

.wf-cooking-banner {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    max-width: 1116px;
    margin: 0 auto;
    padding: 13px 16px;
    border: 1px solid color-mix(in srgb, var(--gold, #C8922E) 34%, transparent);
    border-left: 3px solid var(--gold, #C8922E);
    border-radius: 3px;
    background: linear-gradient(90deg, color-mix(in srgb, var(--gold, #C8922E) 10%, transparent), color-mix(in srgb, var(--plate, #E4D8B6) 68%, transparent));
    color: var(--ink2, #5C5238);
}

.wf-cooking-mark {
    display: grid;
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    border: 1px solid color-mix(in srgb, var(--gold, #C8922E) 42%, transparent);
    border-radius: 50%;
    place-items: center;
    color: var(--gold, #C8922E);
    font-size: 11px;
}

.wf-cooking-banner > div { min-width: 0; }

.wf-cooking-kicker {
    display: block;
    margin-bottom: 3px;
    color: var(--gold, #C8922E);
    font-family: Cinzel, serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .17em;
    text-transform: uppercase;
}

.wf-cooking-banner p {
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
}

/* ---- Controls --------------------------------------------------------------------------- */

.wf-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 14px;
    background: var(--plate, #E4D8B6);
    border: 1px solid var(--line, rgba(42, 36, 24, .18));
    border-radius: 3px;
    box-shadow: rgba(20, 15, 8, .16) 0 18px 40px -30px;
    padding: 16px 18px;
}

.wf-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.wf-field-address {
    flex: 1 1 320px;
}

.wf-field label {
    font-family: Cinzel, serif;
    font-size: 10px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--gold, #C8922E);
}

.wf-input,
.wf-select {
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line, rgba(42, 36, 24, .28));
    border-radius: 2px;
    background: color-mix(in srgb, var(--bg, #EDE3C7) 70%, transparent);
    color: var(--ink, #2A2418);
    font-family: "EB Garamond", serif;
    font-size: 16px;
    transition: border-color .2s, box-shadow .2s;
}

.wf-input:focus,
.wf-select:focus {
    outline: none;
    border-color: color-mix(in srgb, var(--gold, #C8922E) 60%, transparent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold, #C8922E) 14%, transparent);
}

.wf-field-address .wf-input {
    width: 100%;
    font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
    font-size: 14px;
    letter-spacing: .01em;
}

.wf-min-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.wf-min-wrap .wf-input {
    width: 130px;
    padding-right: 46px;
}

.wf-min-unit {
    position: absolute;
    right: 12px;
    font-family: Cinzel, serif;
    font-size: 11px;
    letter-spacing: .08em;
    color: var(--ink3, #8A7E60);
    pointer-events: none;
}

.wf-field-actions {
    flex-direction: row;
    gap: 10px;
}

.wf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line, rgba(42, 36, 24, .28));
    border-radius: 2px;
    background: transparent;
    color: var(--ink2, #5C5238);
    cursor: pointer;
    font-family: Cinzel, serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .13em;
    text-transform: uppercase;
    text-decoration: none;
    transition: .22s;
}

.wf-btn:hover {
    border-color: color-mix(in srgb, var(--gold, #C8922E) 55%, transparent);
    color: var(--gold, #C8922E);
}

.wf-btn-primary {
    background: color-mix(in srgb, var(--gold, #C8922E) 16%, transparent);
    border-color: color-mix(in srgb, var(--gold, #C8922E) 55%, transparent);
    color: var(--ink, #2A2418);
}

.wf-btn-primary:hover {
    background: color-mix(in srgb, var(--gold, #C8922E) 26%, transparent);
    color: var(--ink, #2A2418);
}

.wf-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.wf-btn-sm {
    height: 36px;
    padding: 0 13px;
    font-size: 10px;
}

/* ---- Meta row --------------------------------------------------------------------------- */

.wf-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 14px 2px 12px;
    font-size: 14px;
    color: var(--ink2, #5C5238);
}

.wf-window strong {
    color: var(--gold, #C8922E);
}

.wf-status {
    font-family: Cinzel, serif;
    font-size: 10px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink3, #8A7E60);
}

.wf-status.is-error {
    color: #b4451f;
}

.wf-status.is-loading {
    color: var(--gold, #C8922E);
}

/* ---- Stage / graph ---------------------------------------------------------------------- */

.wf-stage {
    position: relative;
    height: clamp(440px, 64vh, 640px);
    background: var(--plate, #E4D8B6);
    border: 1px solid var(--line, rgba(42, 36, 24, .18));
    border-radius: 3px;
    box-shadow: rgba(20, 15, 8, .16) 0 18px 40px -30px;
    overflow: hidden;
}

.wf-graph {
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
}

.wf-graph.is-panning {
    cursor: grabbing;
}

/* SVG primitives (styled here, created in JS) */
.wf-edge-line {
    stroke: color-mix(in srgb, var(--ink3, #8A7E60) 55%, transparent);
    stroke-width: 1.4;
    fill: none;
    transition: stroke .2s, stroke-width .2s;
}

.wf-edge.is-hot .wf-edge-line {
    stroke: var(--gold, #C8922E);
    stroke-width: 2.2;
}

.wf-edge-label {
    fill: var(--ink2, #5C5238);
    font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
    font-size: 10px;
    paint-order: stroke;
    stroke: var(--plate, #E4D8B6);
    stroke-width: 3px;
    pointer-events: none;
}

.wf-node {
    cursor: pointer;
}

.wf-node-circle {
    fill: color-mix(in srgb, var(--bg, #EDE3C7) 88%, var(--gold, #C8922E) 12%);
    stroke: color-mix(in srgb, var(--gold, #C8922E) 55%, transparent);
    stroke-width: 1.5;
    transition: stroke .2s, stroke-width .2s, fill .2s;
}

.wf-node:hover .wf-node-circle {
    stroke: var(--gold, #C8922E);
    stroke-width: 2.4;
}

.wf-node.is-selected .wf-node-circle {
    stroke: var(--gold, #C8922E);
    stroke-width: 3;
    fill: color-mix(in srgb, var(--gold, #C8922E) 22%, var(--bg, #EDE3C7));
}

.wf-node.is-root .wf-node-circle {
    fill: var(--gold, #C8922E);
    stroke: var(--goldb, #E0A93A);
    stroke-width: 2.5;
}

.wf-node.is-expanded .wf-node-circle {
    stroke-dasharray: 3 3;
}

.wf-node-symbol {
    fill: var(--ink, #2A2418);
    font-family: Cinzel, serif;
    font-size: 11px;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: central;
    pointer-events: none;
}

.wf-node.is-root .wf-node-symbol {
    fill: #2A2418;
}

.wf-node-label {
    fill: var(--ink2, #5C5238);
    font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
    font-size: 11px;
    text-anchor: middle;
    pointer-events: none;
}

.wf-arrow-head {
    fill: color-mix(in srgb, var(--ink3, #8A7E60) 70%, transparent);
}

/* Flow direction colours: green = money in, terracotta = money out. */
.wf-section {
    --wf-in: #3f8f5f;
    --wf-out: #c0502b;
}

.wf-edge-in .wf-edge-line {
    stroke: color-mix(in srgb, var(--wf-in) 75%, transparent);
}

.wf-edge-out .wf-edge-line {
    stroke: color-mix(in srgb, var(--wf-out) 75%, transparent);
}

.wf-arrow-in {
    fill: var(--wf-in);
}

.wf-arrow-out {
    fill: var(--wf-out);
}

/* ---- Overlay states --------------------------------------------------------------------- */

.wf-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    background: color-mix(in srgb, var(--plate, #E4D8B6) 80%, transparent);
    backdrop-filter: blur(1px);
}

.wf-overlay[hidden] {
    display: none;
}

.wf-overlay-card {
    max-width: 380px;
}

.wf-overlay-icon {
    width: 46px;
    height: 46px;
    margin: 0 auto 14px;
    color: var(--gold, #C8922E);
}

.wf-overlay-icon svg {
    width: 100%;
    height: 100%;
}

.wf-overlay-card h2 {
    margin: 0 0 8px;
    font-family: "EB Garamond", serif;
    font-weight: 500;
    font-size: clamp(22px, 3vw, 28px);
    color: var(--ink, #2A2418);
}

.wf-overlay-card p {
    margin: 0;
    color: var(--ink2, #5C5238);
    font-size: 16px;
}

.wf-overlay.is-error .wf-overlay-icon {
    color: #b4451f;
}

.wf-spinner {
    width: 34px;
    height: 34px;
    margin: 0 auto 16px;
    border: 3px solid color-mix(in srgb, var(--gold, #C8922E) 25%, transparent);
    border-top-color: var(--gold, #C8922E);
    border-radius: 50%;
    animation: wf-spin .8s linear infinite;
}

@keyframes wf-spin {
    to { transform: rotate(360deg); }
}

/* ---- Legend ----------------------------------------------------------------------------- */

.wf-legend {
    position: absolute;
    left: 14px;
    bottom: 12px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    padding: 8px 12px;
    border: 1px solid var(--line, rgba(42, 36, 24, .18));
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg, #EDE3C7) 80%, transparent);
    backdrop-filter: blur(6px);
    font-size: 12px;
    color: var(--ink2, #5C5238);
}

.wf-legend[hidden] {
    display: none;
}

.wf-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.wf-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.wf-dot-root {
    background: var(--gold, #C8922E);
}

.wf-dot-node {
    background: color-mix(in srgb, var(--bg, #EDE3C7) 70%, var(--gold, #C8922E) 30%);
    border: 1px solid color-mix(in srgb, var(--gold, #C8922E) 55%, transparent);
}

.wf-line {
    width: 16px;
    height: 3px;
    border-radius: 2px;
    flex: 0 0 auto;
}

.wf-line-in {
    background: var(--wf-in, #3f8f5f);
}

.wf-line-out {
    background: var(--wf-out, #c0502b);
}

.wf-legend-hint {
    color: var(--ink3, #8A7E60);
    font-style: italic;
}

/* ---- Drawer ----------------------------------------------------------------------------- */

.wf-drawer {
    position: absolute;
    top: 0;
    right: 0;
    width: min(340px, 86%);
    height: 100%;
    padding: 20px 20px 16px;
    background: color-mix(in srgb, var(--plate, #E4D8B6) 96%, var(--ink, #2A2418) 4%);
    border-left: 1px solid var(--line, rgba(42, 36, 24, .22));
    box-shadow: rgba(20, 15, 8, .22) -18px 0 40px -30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wf-drawer[hidden] {
    display: none;
}

.wf-drawer-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border: 1px solid var(--line, rgba(42, 36, 24, .2));
    border-radius: 50%;
    background: transparent;
    color: var(--ink2, #5C5238);
    cursor: pointer;
    line-height: 1;
}

.wf-drawer-close:hover {
    color: var(--gold, #C8922E);
    border-color: color-mix(in srgb, var(--gold, #C8922E) 55%, transparent);
}

.wf-drawer-kicker {
    font-family: Cinzel, serif;
    font-size: 10px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--gold, #C8922E);
}

.wf-drawer-addr {
    font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
    font-size: 13px;
    word-break: break-all;
    color: var(--ink, #2A2418);
    padding-right: 28px;
}

.wf-drawer-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    font-size: 14px;
    color: var(--ink2, #5C5238);
    border-top: 1px solid var(--line, rgba(42, 36, 24, .14));
    border-bottom: 1px solid var(--line, rgba(42, 36, 24, .14));
    padding: 10px 0;
}

.wf-drawer-stats strong {
    color: var(--ink, #2A2418);
    font-weight: 600;
}

.wf-drawer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.wf-drawer-tx-head {
    font-family: Cinzel, serif;
    font-size: 10px;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink3, #8A7E60);
    margin-top: 4px;
}

.wf-drawer-tx {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wf-tx {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    border: 1px solid var(--line, rgba(42, 36, 24, .14));
    border-radius: 2px;
    background: color-mix(in srgb, var(--bg, #EDE3C7) 50%, transparent);
}

.wf-tx-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
}

.wf-tx-amount {
    font-weight: 600;
    color: var(--ink, #2A2418);
}

.wf-tx.is-in {
    border-left: 2px solid color-mix(in srgb, var(--wf-in, #3f8f5f) 60%, transparent);
}

.wf-tx.is-out {
    border-left: 2px solid color-mix(in srgb, var(--wf-out, #c0502b) 60%, transparent);
}

.wf-tx.is-in .wf-tx-amount {
    color: var(--wf-in, #3f8f5f);
}

.wf-tx.is-out .wf-tx-amount {
    color: var(--wf-out, #c0502b);
}

.wf-tx-time {
    font-size: 12px;
    color: var(--ink3, #8A7E60);
}

.wf-tx-from {
    font-family: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--ink2, #5C5238);
    word-break: break-all;
}

.wf-tx-from a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted color-mix(in srgb, var(--gold, #C8922E) 50%, transparent);
}

.wf-tx-from a:hover {
    color: var(--gold, #C8922E);
}

.wf-drawer-empty {
    font-size: 14px;
    color: var(--ink3, #8A7E60);
    font-style: italic;
}

/* ---- Note ------------------------------------------------------------------------------- */

.wf-note {
    margin-top: 14px;
    padding: 12px 16px;
    border-left: 2px solid color-mix(in srgb, var(--gold, #C8922E) 45%, transparent);
    background: color-mix(in srgb, var(--plate, #E4D8B6) 70%, transparent);
    border-radius: 0 2px 2px 0;
    font-size: 14px;
    color: var(--ink2, #5C5238);
}

/* ---- Responsive ------------------------------------------------------------------------- */

@media (max-width: 720px) {
    .wf-cooking-banner {
        margin-right: 18px;
        margin-left: 18px;
    }

    .wf-section {
        padding: 8px 18px 16px;
    }

    .wf-field-min,
    .wf-min-wrap .wf-input {
        width: 100%;
    }

    .wf-field-actions {
        width: 100%;
    }

    .wf-field-actions .wf-btn {
        flex: 1 1 0;
    }

    .wf-legend-hint {
        display: none;
    }

    .wf-drawer {
        width: 100%;
    }
}

/* ---- Dark theme tweaks ------------------------------------------------------------------ */

:root[data-theme="dark"] .wf-edge-label {
    stroke: color-mix(in srgb, var(--plate, #2A2418) 90%, transparent);
}

:root[data-theme="dark"] .wf-node-circle {
    fill: color-mix(in srgb, var(--plate, #2A2418) 80%, var(--gold, #C8922E) 12%);
}

:root[data-theme="dark"] .wf-section {
    --wf-in: #69c184;
    --wf-out: #e0814e;
}
