/* ════════════════════════════════════════════════════════════════════════════════════════════════════
   conv-triggers.css - THE TRIGGER LANE, THE TRIGGER DRAWER and THE TYPED FILTER BUILDER
   (PLAN 4.13 / 5.6, docs/claude/CONVERSATION-BUILDER.md section 28; builder-design-bible 3.2 "Starts when ... a dashed +
   slot beside it", 6.2 the drawer). Owns every conv-trig-* and conv-tf-* class and .conv-edge--trigger - ONE STYLESHEET
   OWNS EACH BUILDER CLASS (ConversationBuilderCssOwnershipTests). Tokens only: --theme-* / --conv-* (no hex), so a tenant
   theme - a dark one too - re-skins it. A trigger wears the ACTION hue: it is the act of a way in.
   ════════════════════════════════════════════════════════════════════════════════════════════════════ */

/* ── The trigger lane: one card per trigger above "Starts when" ─────────────────────────────────────── */

.conv-trig-card {
    position: absolute;
    top: 0;
    left: 0;
    translate: var(--conv-x, 0) var(--conv-y, 0);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--conv-node-border);
    border-top: 3px solid var(--conv-act);
    border-radius: var(--theme-radius);
    background: var(--conv-node-bg);
    box-shadow: var(--theme-shadow);
    color: var(--theme-text);
    cursor: pointer;
    overflow: hidden;
    user-select: none;
    animation: conv-trig-in var(--conv-motion);
    transition:
        translate var(--conv-motion),
        box-shadow var(--conv-motion),
        transform var(--conv-motion),
        border-color var(--conv-motion),
        opacity 200ms ease;
}

@keyframes conv-trig-in {
    from {
        opacity: 0;
        scale: .96;
    }
}

.conv-trig-card:hover {
    box-shadow: var(--theme-shadow-lg);
    transform: translateY(-1px);
}

.conv-trig-card.is-selected {
    border-color: var(--conv-act);
    box-shadow:
        0 0 0 2px var(--conv-act),
        0 0 0 6px color-mix(in srgb, var(--conv-act) 20%, transparent),
        var(--theme-shadow-lg);
}

/* Switched off: a quieter card - it starts nothing until a person switches it on. */
.conv-trig-card.is-off {
    border-top-color: var(--conv-end);
    background: color-mix(in srgb, var(--conv-node-bg) 70%, var(--theme-background-subtle));
}

.conv-trig-card.is-off .conv-trig-icon {
    background: var(--conv-end-soft);
    color: var(--conv-end);
}

/* Switched on in the draft without a person's confirm: say so loudly - Save would be refused. */
.conv-trig-card.is-pending {
    border-top-color: var(--theme-warning);
}

.conv-trig-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: var(--conv-act-soft);
    color: var(--conv-act);
    font-size: 1rem;
}

.conv-trig-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.conv-trig-title {
    padding-right: 22px;
    color: var(--theme-text-emphasis);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-trig-detail {
    color: var(--theme-text-muted);
    font-size: 12px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.conv-trig-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 2px;
    color: var(--theme-text-secondary);
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
}

.conv-trig-state {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-weight: 600;
}

.conv-trig-stats {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--theme-text-muted);
}

.conv-trig-stats::before {
    content: "·";
    margin-right: 8px;
}

/* "Needs a person to confirm" takes the whole foot - the count can wait (it was cut to "Not..." at the card's width). */
.conv-trig-card.is-pending .conv-trig-stats {
    display: none;
}

/* The switch dot: grey off, green on, a ringed green once a person confirmed (on at Save), amber when a person must confirm. */
.conv-trig-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--conv-end);
}

.is-on .conv-trig-dot,
.is-confirmed .conv-trig-dot {
    background: var(--theme-success);
}

.is-confirmed .conv-trig-dot {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-success) 25%, transparent);
}

.is-pending .conv-trig-dot {
    background: var(--theme-warning);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-warning) 25%, transparent);
}

.conv-trig-badge {
    position: absolute;
    top: 6px;
    right: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--conv-issue-warn);
    color: var(--theme-text-emphasis);
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
}

.conv-trig-badge.is-error {
    background: var(--conv-issue-error);
    color: var(--theme-text-on-danger);
}

/* The card's own menu (the one command list) - quiet until the card is hovered or selected. */
.conv-trig-more {
    position: absolute;
    top: 4px;
    right: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: var(--theme-radius-button);
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--conv-motion), background var(--conv-motion);
}

.conv-trig-card:hover .conv-trig-more,
.conv-trig-card.is-selected .conv-trig-more,
.conv-trig-more:focus-visible {
    opacity: 1;
}

.conv-trig-more:hover {
    background: var(--conv-act-soft);
    color: var(--conv-act);
}

/* ── Horizontal: the trigger is a tile like a moment's, its kind as the label below ────────────────── */

.conv-trig-card.is-tile {
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.conv-trig-card.is-tile:hover {
    box-shadow: none;
    transform: none;
}

.conv-trig-card.is-tile .conv-trig-icon {
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    border: 1px solid var(--conv-node-border);
    border-top: 3px solid var(--conv-act);
    border-radius: calc(var(--theme-radius) * 1.5);
    box-shadow: var(--theme-shadow);
    font-size: 1.5rem;
}

.conv-trig-card.is-tile.is-off .conv-trig-icon {
    border-top-color: var(--conv-end);
}

.conv-trig-card.is-tile.is-pending .conv-trig-icon {
    border-top-color: var(--theme-warning);
}

.conv-trig-card.is-tile.is-selected .conv-trig-icon {
    border-color: var(--conv-act);
    box-shadow:
        0 0 0 2px var(--conv-act),
        0 0 0 6px color-mix(in srgb, var(--conv-act) 20%, transparent),
        var(--theme-shadow-lg);
}

.conv-trig-label {
    width: 100%;
    color: var(--theme-text-emphasis);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

.conv-trig-card.is-tile .conv-trig-badge {
    top: -7px;
    right: calc(50% - 39px);
}

.conv-trig-card.is-tile .conv-trig-more {
    top: -4px;
    right: 0;
}

/* ── The dashed "+ Add a trigger" slot (bible 3.2) ─────────────────────────────────────────────────── */

.conv-trig-add {
    position: absolute;
    top: 0;
    left: 0;
    translate: var(--conv-x, 0) var(--conv-y, 0);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    border: 1.5px dashed color-mix(in srgb, var(--conv-act) 45%, var(--conv-node-border));
    border-radius: var(--theme-radius);
    background: color-mix(in srgb, var(--conv-act-soft) 45%, transparent);
    color: var(--theme-text-secondary);
    font-family: var(--theme-font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color var(--conv-motion), color var(--conv-motion), background var(--conv-motion), translate var(--conv-motion);
}

.conv-trig-add:hover,
.conv-trig-add:focus-visible {
    border-color: var(--conv-act);
    background: var(--conv-act-soft);
    color: var(--conv-act);
}

.conv-trig-add.is-tile {
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
}

/* The connectors from each trigger converge into "Starts when", in the Action hue. */
.conv-edge--trigger {
    stroke: color-mix(in srgb, var(--conv-act) 55%, var(--conv-edge));
}

/* Semantic zoom (bible 3.5): compact cards keep the kind; the overview turns them into Action bars. */
.conv-tier-compact .conv-trig-detail,
.conv-tier-compact .conv-trig-foot {
    display: none;
}

.conv-tier-overview .conv-trig-card:not(.is-tile) {
    border-color: transparent;
    background: color-mix(in srgb, var(--conv-act) 45%, var(--conv-node-bg));
    box-shadow: none;
}

.conv-tier-overview .conv-trig-card > *,
.conv-tier-overview .conv-trig-label {
    visibility: hidden;
}

.conv-tier-overview .conv-trig-card.is-tile .conv-trig-icon {
    visibility: visible;
    border-color: transparent;
    background: color-mix(in srgb, var(--conv-act) 55%, var(--conv-node-bg));
    box-shadow: none;
}

.conv-tier-overview .conv-trig-card.is-tile .conv-trig-icon > i {
    visibility: hidden;
}

.conv-tier-overview .conv-trig-add {
    display: none;
}

/* ── The trigger drawer ─────────────────────────────────────────────────────────────────────────────── */

.conv-trig-statusline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--theme-background-subtle);
    color: var(--theme-text-secondary);
    font-size: 12px;
    font-weight: 600;
}

.conv-trig-statusline.is-on,
.conv-trig-statusline.is-confirmed {
    background: var(--theme-success-muted);
    color: var(--theme-text-emphasis);
}

.conv-trig-statusline.is-pending {
    background: var(--theme-warning-muted);
    color: var(--theme-text-emphasis);
}

.conv-trig-mono {
    font-family: var(--theme-font-mono);
    font-size: 12.5px;
}

.conv-trig-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.conv-trig-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 0 12px;
    border: 1px solid var(--conv-node-border);
    border-radius: 999px;
    background: var(--conv-node-bg);
    color: var(--theme-text-secondary);
    font-family: var(--theme-font);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--conv-motion), border-color var(--conv-motion), color var(--conv-motion);
}

.conv-trig-chip:hover:not(:disabled) {
    border-color: var(--conv-act);
    color: var(--conv-act);
}

.conv-trig-chip.is-on {
    border-color: color-mix(in srgb, var(--conv-act) 55%, var(--conv-node-border));
    background: var(--conv-act-soft);
    color: var(--theme-text-emphasis);
}

.conv-trig-chip.is-static {
    cursor: default;
    padding-right: 4px;
}

.conv-trig-chip:disabled {
    cursor: not-allowed;
    opacity: .6;
}

.conv-trig-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
}

.conv-trig-chip-x:hover:not(:disabled) {
    background: var(--theme-danger-muted);
    color: var(--theme-danger);
}

.conv-trig-rung {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--conv-act);
    color: var(--theme-text-on-accent);
    font-size: 10px;
    font-weight: 700;
}

.conv-trig-inline {
    color: var(--theme-text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

.conv-trig-num {
    max-width: 96px;
}

.conv-trig-note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 8px 0;
    padding: 8px 10px;
    border-radius: var(--theme-radius);
    background: var(--theme-background-subtle);
    color: var(--theme-text-secondary);
    font-size: 12.5px;
    line-height: 1.45;
}

.conv-trig-note > i {
    flex: 0 0 auto;
    margin-top: 1px;
    color: var(--conv-act);
}

.conv-trig-note.is-warn {
    background: var(--theme-warning-muted);
    color: var(--theme-text-emphasis);
}

.conv-trig-note.is-warn > i {
    color: var(--theme-warning);
}

.conv-trig-switchline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    color: var(--theme-text-emphasis);
    font-size: 13px;
    font-weight: 600;
}

.conv-trig-confirm {
    padding: 10px 12px;
    border: 1px solid color-mix(in srgb, var(--conv-act) 35%, var(--conv-node-border));
    border-radius: var(--theme-radius);
    background: color-mix(in srgb, var(--conv-act-soft) 50%, var(--conv-node-bg));
}

/* THE DRY RUN, read aloud. */
.conv-trig-run {
    margin: 10px 0;
    padding: 10px 12px;
    border: 1px solid var(--conv-node-border);
    border-left: 4px solid var(--conv-end);
    border-radius: var(--theme-radius);
    background: var(--conv-node-bg);
}

.conv-trig-run.is-started {
    border-left-color: var(--theme-success);
}

.conv-trig-run.is-held {
    border-left-color: var(--theme-warning);
}

.conv-trig-run.is-refused {
    border-left-color: var(--theme-danger);
}

.conv-trig-run-head {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--theme-text-emphasis);
    font-size: 13.5px;
    font-weight: 600;
}

.conv-trig-run.is-started .conv-trig-run-head > i {
    color: var(--theme-success);
}

.conv-trig-run.is-held .conv-trig-run-head > i {
    color: var(--theme-warning);
}

.conv-trig-run.is-refused .conv-trig-run-head > i {
    color: var(--theme-danger);
}

.conv-trig-run-why {
    margin-top: 4px;
    color: var(--theme-text-secondary);
    font-size: 12.5px;
    line-height: 1.45;
}

.conv-trig-walk {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
}

.conv-trig-walk > li {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--theme-text);
    font-size: 12.5px;
    line-height: 1.4;
}

.conv-trig-walk > li > i {
    flex: 0 0 auto;
    margin-top: 1px;
    color: var(--theme-text-muted);
}

.conv-trig-sample {
    margin-top: 10px;
    font-size: 12px;
}

.conv-trig-sample > summary {
    color: var(--theme-text-secondary);
    cursor: pointer;
}

.conv-trig-sample dl {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 4px 12px;
    margin: 8px 0 0;
}

.conv-trig-sample dt {
    color: var(--theme-text-muted);
    font-weight: 500;
}

.conv-trig-sample dd {
    margin: 0;
    color: var(--theme-text);
    word-break: break-word;
}

.conv-trig-run-note {
    margin-top: 8px;
    color: var(--theme-text-muted);
    font-size: 11.5px;
}

/* History - the Enrollment history in the drawer. */
.conv-trig-fires {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
}

.conv-trig-fire {
    display: grid;
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
        "outcome when run"
        "detail detail detail";
    align-items: baseline;
    gap: 2px 10px;
    padding: 6px 8px;
    border-left: 3px solid var(--conv-end);
    border-radius: 4px;
    background: var(--theme-background-subtle);
    font-size: 12.5px;
}

.conv-trig-fire.is-started {
    border-left-color: var(--theme-success);
}

.conv-trig-fire.is-held {
    border-left-color: var(--theme-warning);
}

.conv-trig-fire.is-refused {
    border-left-color: var(--theme-danger);
}

.conv-trig-fire-outcome {
    grid-area: outcome;
    color: var(--theme-text-emphasis);
    font-weight: 600;
}

.conv-trig-fire-when {
    grid-area: when;
    color: var(--theme-text-muted);
}

.conv-trig-fire-detail {
    grid-area: detail;
    color: var(--theme-text-secondary);
    font-size: 12px;
}

.conv-trig-fire-run {
    grid-area: run;
    color: var(--conv-act);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.conv-trig-fire-run:hover {
    text-decoration: underline;
}

.conv-trig-json {
    max-height: 260px;
    margin: 0;
    padding: 8px 10px;
    overflow: auto;
    border: 1px solid var(--conv-node-border);
    border-radius: var(--theme-radius);
    background: var(--theme-background-subtle);
    color: var(--theme-text);
    font-family: var(--theme-font-mono);
    font-size: 11.5px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── THE TYPED FILTER BUILDER (PLAN 5.6) ────────────────────────────────────────────────────────────── */

.conv-tf {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conv-tf-empty {
    padding: 10px 12px;
    border: 1px dashed var(--conv-node-border);
    border-radius: var(--theme-radius);
    color: var(--theme-text-muted);
    font-size: 12.5px;
}

.conv-tf-rule {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--conv-node-border);
    border-left: 3px solid color-mix(in srgb, var(--conv-act) 60%, var(--conv-node-border));
    border-radius: var(--theme-radius);
    background: var(--conv-node-bg);
}

.conv-tf-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.conv-tf-row > .conv-input {
    flex: 1 1 0;
    min-width: 0;
}

.conv-tf-op {
    flex: 0 1 44% !important;
}

.conv-tf-remove {
    flex: 0 0 auto;
}

.conv-tf-hint {
    color: var(--theme-text-muted);
    font-size: 11.5px;
    line-height: 1.35;
}

.conv-tf-kept {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--theme-text-secondary);
    font-size: 12px;
}

.conv-tf-add {
    align-self: flex-start;
}

.conv-tf-words {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--theme-radius);
    background: var(--theme-background-subtle);
    color: var(--theme-text);
    font-size: 12.5px;
    line-height: 1.45;
}

.conv-tf-words-label {
    color: var(--theme-text-muted);
    font-weight: 600;
}

.conv-tf-try {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
}

.conv-tf-try.is-yes {
    color: var(--theme-success);
}

.conv-tf-try.is-no {
    color: var(--theme-text-secondary);
}

@media (prefers-reduced-motion: reduce) {
    .conv-trig-card,
    .conv-trig-add,
    .conv-trig-more,
    .conv-trig-chip {
        animation: none;
        transition: none;
    }
}

/* THE TEST BENCH (CONVERSATION-TRIGGERS.md 4d) - a held / edited event and a test fire to your own phone, as a preview. */
.conv-trig-bench {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--conv-node-border);
}

.conv-trig-bench-editor {
    font-family: var(--theme-font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
    font-size: 12px;
    line-height: 1.45;
    min-height: 140px;
    white-space: pre;
}

.conv-trig-bench-number {
    max-width: 180px;
}

.conv-trig-fire-test {
    padding: 0 6px;
    border-radius: var(--theme-radius);
    background: var(--theme-background-subtle);
    color: var(--theme-text-secondary);
    font-size: 11px;
    font-weight: 600;
}
