/* Context Definition builder canvas.
   The visual map: an anchor node at the root, binding nodes grouped by what
   they reach from, connector rails making the two-level model legible. All
   colors via --theme-* tokens. */

.cd-node {
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius, 0.5rem);
    background: var(--theme-surface, #fff);
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.cd-node-anchor {
    border-color: var(--theme-primary);
    border-width: 2px;
    box-shadow: 0 1px 6px color-mix(in oklch, var(--theme-primary) 18%, transparent);
}

.cd-node-open {
    border-color: var(--theme-primary);
}

.cd-node-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: color-mix(in oklch, var(--theme-primary) 6%, var(--theme-surface, #fff));
}

.cd-node-head-click {
    cursor: pointer;
    user-select: none;
}

.cd-node-head-click:hover {
    background: color-mix(in oklch, var(--theme-primary) 12%, var(--theme-surface, #fff));
}

.cd-node-anchor .cd-node-head {
    background: color-mix(in oklch, var(--theme-primary) 12%, var(--theme-surface, #fff));
}

.cd-node-badge {
    font-weight: 600;
    color: var(--theme-text, #222);
}

.cd-node-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1;
    flex-wrap: wrap;
}

.cd-node-target {
    font-family: var(--bs-font-monospace, monospace);
    font-size: 0.8rem;
    padding: 0.05rem 0.4rem;
    border-radius: 0.3rem;
    background: color-mix(in oklch, var(--theme-accent, #6c757d) 14%, transparent);
    color: var(--theme-text, #222);
}

.cd-node-card {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--theme-text-muted, #6c757d);
}

.cd-node-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--theme-text-muted, #6c757d);
}

.cd-node-body {
    padding: 0.75rem;
    border-top: 1px solid var(--theme-border);
}

/* The reach rail: a left gutter line tying sibling-grouped bindings to the
   thing they hang off, so "of the Order" vs "of the Customer" is visible. */
.cd-reach-rail {
    margin-top: 0.5rem;
}

.cd-reach-group {
    border-left: 2px dashed color-mix(in oklch, var(--theme-primary) 35%, transparent);
    padding-left: 0.75rem;
    margin-left: 0.5rem;
    margin-bottom: 0.75rem;
}

.cd-reach-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--theme-text-muted, #6c757d);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.cd-subsection {
    border-top: 1px dashed var(--theme-border);
    padding-top: 0.6rem;
}

/* Entity previewer - "what really is a key?" */
.cd-previewer {
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius, 0.5rem);
    background: color-mix(in oklch, var(--theme-accent, #6c757d) 4%, var(--theme-surface, #fff));
    padding: 0.5rem 0.6rem;
}

.cd-prev-head {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

.cd-prev-section {
    margin-bottom: 0.5rem;
}

.cd-prev-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--theme-text-muted, #6c757d);
    margin-bottom: 0.2rem;
}

.cd-prev-key {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-right: 0.5rem;
    margin-bottom: 0.2rem;
    font-size: 0.82rem;
}

.cd-prev-hidden {
    font-size: 0.68rem;
    color: var(--theme-text-muted, #6c757d);
    font-style: italic;
}

.cd-prev-table {
    font-size: 0.78rem;
}

.cd-prev-table th {
    font-size: 0.68rem;
    text-transform: uppercase;
    color: var(--theme-text-muted, #6c757d);
    font-weight: 600;
}

/* Teaching explainer */
.cd-teach {
    border-left: 4px solid var(--theme-primary);
    background: color-mix(in oklch, var(--theme-primary) 5%, var(--theme-surface, #fff));
}

/* Ambient reference chips */
.cd-ambient-chip {
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 0.3rem;
    border: 1px solid var(--theme-border);
    background: color-mix(in oklch, var(--theme-info, #0dcaf0) 8%, var(--theme-surface, #fff));
    color: var(--theme-text, #222);
}

/* Test console */
.cd-testconsole {
    font-size: 0.9rem;
}

.cd-test-section {
    border-top: 1px dashed var(--theme-border);
    padding-top: 0.6rem;
    margin-top: 0.6rem;
}

.cd-test-section:first-child {
    border-top: 0;
    padding-top: 0;
    margin-top: 0;
}

/* Test-against key / parameter rows: label beside a sensibly-sized box,
   not a full-width input crammed against the label. */
.cd-test-key {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.cd-test-key-label {
    min-width: 150px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--theme-text);
}

.cd-test-key-input {
    flex: 0 1 50%;
    max-width: 360px;
    min-width: 200px;
}

/* Save / error toast: a small pill at the top-center that slides in.
   Success auto-dismisses (timer in code-behind); error persists with a close. */
.cd-toast {
    position: fixed;
    top: 4.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1100;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    animation: cd-toast-in 0.2s ease;
}

.cd-toast-success {
    background: var(--theme-success);
    color: #fff;
}

.cd-toast-error {
    background: var(--theme-danger);
    color: #fff;
}

.cd-toast-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    opacity: 0.85;
    margin-left: 0.4rem;
}

.cd-toast-close:hover {
    opacity: 1;
}

@keyframes cd-toast-in {
    from { opacity: 0; transform: translate(-50%, -8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

.cd-results {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.cd-result-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.4rem;
    border-radius: 0.35rem;
    background: color-mix(in oklch, var(--theme-accent, #6c757d) 4%, transparent);
}

.cd-result-name {
    font-weight: 600;
    color: var(--theme-text-emphasis);
    flex: 0 0 auto;
}

.cd-result-detail {
    font-size: 0.8rem;
    margin-left: auto;
    text-align: right;
}

/* Suggestions strip */
.cd-suggest-strip {
    border: 1px dashed color-mix(in oklch, var(--theme-success, #198754) 40%, transparent);
    border-radius: var(--theme-radius, 0.5rem);
    padding: 0.5rem 0.6rem;
    margin-top: 0.5rem;
    background: color-mix(in oklch, var(--theme-success, #198754) 4%, transparent);
}
