/* dependencyFlow.css — left-to-right dependency diagram (js/rule_relation/dependencyFlow.js) */

.dflow {
    --dflow-requires: #0d6efd;
    --dflow-required-by: #fd7e14;
    --dflow-self: #198754;
    background: var(--card-bg-color);
    border-radius: 16px;
}

.dflow__canvas {
    position: relative;
    overflow: auto;
    max-height: 640px;
    padding: 1.25rem 1rem 1.5rem;
    background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 18px 18px;
    border-radius: 16px 16px 0 0;
}

.dflow__edges {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

/* Columns share the available width (190-280px each) and only overflow —
   scrolling horizontally — when there are really too many levels. */
.dflow__cols {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 4rem;
    width: 100%;
    justify-content: center;
    z-index: 2;
}

.dflow__col {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    flex: 1 1 0;
    min-width: 190px;
    max-width: 280px;
}

.dflow__col-head {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--subtle-text-color);
    padding: 0 .25rem .25rem;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: .25rem;
    white-space: nowrap;
}
.dflow__col--requires .dflow__col-head    { border-color: var(--dflow-requires); }
.dflow__col--required_by .dflow__col-head { border-color: var(--dflow-required-by); }
.dflow__col--self .dflow__col-head        { border-color: var(--dflow-self); }

.dflow__col-count {
    display: inline-block;
    margin-left: .35rem;
    padding: 0 .45rem;
    border-radius: 999px;
    background: var(--light-bg-color);
    border: 1px solid var(--border-color);
    font-size: .65rem;
}

/* ── Rule cards ─────────────────────────────────────────────────────────── */
.dflow__node {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    padding: .6rem .75rem .65rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    background: var(--card-bg-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
    color: var(--text-color);
    text-decoration: none;
    transition: opacity .15s, transform .15s, box-shadow .15s;
}
.dflow__node:hover,
.dflow__node:focus,
.dflow__node.is-hovered {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, .12);
    color: var(--text-color);
}
.dflow__node--requires    { border-left-color: var(--dflow-requires); }
.dflow__node--required_by { border-left-color: var(--dflow-required-by); }
.dflow__node--self {
    border: 2px solid var(--dflow-self);
    border-left-width: 6px;
    background: color-mix(in srgb, var(--dflow-self) 7%, var(--card-bg-color));
}
.dflow__node.is-dim { opacity: .28; }

.dflow__node-format {
    align-self: flex-start;
    font-size: .62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .05rem .45rem;
    border-radius: 999px;
    background: var(--light-bg-color);
    border: 1px solid var(--border-color);
    color: var(--subtle-text-color);
}
.dflow__node-title {
    font-size: .82rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* ── Arrows ─────────────────────────────────────────────────────────────── */
.dflow__edge {
    fill: none;
    stroke-width: 2;
    opacity: .75;
    transition: opacity .15s, stroke-width .15s;
}
.dflow__edge--requires    { stroke: var(--dflow-requires); }
.dflow__edge--required_by { stroke: var(--dflow-required-by); }
.dflow__edge.is-active    { stroke-width: 3; opacity: 1; }
.dflow__edge.is-dim       { opacity: .12; }
.dflow__arrow--requires    { fill: var(--dflow-requires); }
.dflow__arrow--required_by { fill: var(--dflow-required-by); }

.dflow__edge-label rect {
    fill: var(--card-bg-color);
    stroke: var(--border-color);
}
.dflow__edge-label text {
    font-size: 10px;
    font-weight: 600;
    fill: var(--subtle-text-color);
}
.dflow__edge-label.is-dim { opacity: .15; }

/* ── Legend ─────────────────────────────────────────────────────────────── */
.dflow__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding: .6rem 1rem;
    border-top: 1px solid var(--border-color);
    font-size: .74rem;
    color: var(--subtle-text-color);
}
.dflow__dot {
    display: inline-block;
    width: .7rem;
    height: .7rem;
    border-radius: 3px;
    margin-right: .35rem;
    vertical-align: -1px;
}
.dflow__dot--requires    { background: var(--dflow-requires); }
.dflow__dot--required_by { background: var(--dflow-required-by); }
.dflow__dot--self        { background: var(--dflow-self); }

@media (max-width: 768px) {
    .dflow__cols { gap: 3rem; justify-content: flex-start; }
    .dflow__col  { min-width: 180px; }
}

/* ── Toolbar above the diagram (linked rules page): filters + download ───── */
.dflow-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1.5rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--card-bg-color);
}
.dflow-toolbar__group {
    display: flex;
    align-items: center;
    gap: .5rem;
}
.dflow-toolbar__label {
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--subtle-text-color);
    margin: 0;
}
.dflow-toolbar__select {
    width: auto;
    font-size: .8rem;
    border-radius: 8px;
    background-color: var(--light-bg-color);
    color: var(--text-color);
    border-color: var(--border-color);
}
.dflow-toolbar__note {
    font-size: .74rem;
    color: var(--subtle-text-color);
}

.dflow-chip {
    --chip: var(--subtle-text-color);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .25rem .7rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--subtle-text-color);
    font-size: .8rem;
    font-weight: 600;
    transition: background .15s, border-color .15s, color .15s;
}
.dflow-chip--requires    { --chip: #0d6efd; }
.dflow-chip--required_by { --chip: #fd7e14; }
.dflow-chip i { color: var(--chip); }
.dflow-chip.is-on {
    border-color: var(--chip);
    background: color-mix(in srgb, var(--chip) 10%, transparent);
    color: var(--text-color);
}
.dflow-chip:disabled { opacity: .45; cursor: not-allowed; }
.dflow-chip__count {
    font-size: .7rem;
    padding: 0 .4rem;
    border-radius: 999px;
    background: var(--light-bg-color);
    color: var(--subtle-text-color);
}

/* Search hit */
.dflow__node.is-match {
    box-shadow: 0 0 0 3px color-mix(in srgb, #ffc107 60%, transparent), 0 6px 16px rgba(0, 0, 0, .12);
}

/* "+N more" / "Show less" at the bottom of a long column */
.dflow__more {
    border: 1px dashed var(--border-color);
    border-radius: 12px;
    background: var(--light-bg-color);
    color: var(--subtle-text-color);
    font-size: .78rem;
    font-weight: 600;
    padding: .55rem .75rem;
    transition: color .15s, border-color .15s;
}
.dflow__more:hover { color: var(--text-color); border-color: var(--subtle-text-color); }

.dflow-toolbar__search {
    width: 200px;
    font-size: .8rem;
    border-radius: 8px;
    background-color: var(--light-bg-color);
    color: var(--text-color);
    border-color: var(--border-color);
}

/* ── Full screen: the diagram card covers the viewport ─────────────────── */
.dflow-card.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 2050;
    margin: 0;
    border-radius: 0 !important;
    display: flex;
    flex-direction: column;
    background: var(--card-bg-color);
}
.dflow-card.is-fullscreen .dflow {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-radius: 0;
}
.dflow-card.is-fullscreen .dflow__canvas {
    flex: 1;
    max-height: none;
    border-radius: 0;
}

/* Dense graph (40+ arrows, e.g. a base rule needed by 150 rules): faint
   arrows so the cards stay readable; hovering a card brings its chain back. */
.dflow--dense .dflow__edge { opacity: .16; stroke-width: 1.5; }
.dflow--dense .dflow__edge.is-active { opacity: 1; stroke-width: 3; }

/* "needs: …" line on a card whose long arrow isn't drawn (dense graph) */
.dflow__node-link {
    font-size: .7rem;
    color: var(--subtle-text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dflow__node--required_by .dflow__node-link i { color: var(--dflow-required-by); }
.dflow__node--requires .dflow__node-link i    { color: var(--dflow-requires); }
