/*
 * org-chart.v9.css  (plugin v1.2.7 / ZIP v11)
 * Additive layer on top of v4 → v5 → v6 → v7 → v8.
 * Do NOT modify v1–v8 CSS files.
 *
 * Two changes in this file:
 *
 *   1. Bridge z-index fix
 *      v8 set z-index:1 on both bridge pseudo-elements.
 *      .org-card-anchor .org-chart__card also has z-index:1.
 *      org-card-anchor has position:relative but no explicit z-index →
 *      it does NOT form its own stacking context.  Both the pseudo-elements
 *      and the card share the same stacking context at z-index:1.
 *      In CSS, elements at equal z-index paint in DOM order.  ::after is
 *      painted last (after all real children), so the right bridge appeared
 *      on top of card text.  The left bridge (::before, no-has-main-children
 *      path) had the same issue.
 *
 *      Fix: set bridge z-index to 0.  The card (z-index:1) paints over the
 *      bridge.  The bridge segment that crosses through the card is hidden;
 *      the segment from the card edge outward to the spine is visible.  The
 *      card itself acts as the visual junction node — no line crosses content.
 *
 *   2. vertical-rail children layout
 *      A physical vertical spine runs beside the child list.  Each child
 *      connects to the spine via a short horizontal stub.  No T-bar.
 *      Children still render through render_node() so a child may have its
 *      own sub-hierarchy.  Exists alongside vertical-list; does not replace it.
 *      Mobile is unaffected.
 *
 * Cascade strategy
 *   Same selectors as v8 where an override is needed → later load order
 *   decides the winner.  No !important used.
 */

/* ─────────────────────────────────────────────────────────────────────────────
 * 1.  Bridge z-index fix
 * ─────────────────────────────────────────────────────────────────────────── */

/*
 * Specificity (0,3,1) — same as v8 bridge rules → v9 cascade wins. ✓
 * The full-height connector (v8 STEP C, specificity 0,4,1) already uses
 * z-index:0 and has higher specificity; it is unaffected by this rule. ✓
 */
.org-card-row.has-side-left  .org-card-anchor::before { z-index: 0; }
.org-card-row.has-side-right .org-card-anchor::after  { z-index: 0; }

/* ─────────────────────────────────────────────────────────────────────────────
 * 2.  vertical-rail children layout
 * ─────────────────────────────────────────────────────────────────────────── */

/* ── 2a.  Children-wrap alignment ────────────────────────────────────────── */

/*
 * PHP emits .org-children-wrap--rail when children_layout === 'vertical-rail'.
 *
 * Converting to a flex column allows org-connector-vert and org-rail to share
 * the same physical edge so the 24px incoming vertical drop meets the spine
 * seamlessly:
 *
 *   LTR  align-items:flex-start → both elements left-aligned.
 *        org-connector-vert (1.5px) at left edge.
 *        org-rail border-inline-start (= border-left in LTR) at left edge.
 *        They coincide. ✓
 *
 *   RTL  align-items:flex-end   → both elements right-aligned.
 *        org-connector-vert (1.5px) at right edge.
 *        org-rail border-inline-start (= border-right in RTL) at right edge.
 *        They coincide. ✓  (Hebrew reference layout)
 */
.org-children-wrap--rail {
	display: flex;
	flex-direction: column;
	align-items: flex-start;   /* LTR default: spine on left */
}

[dir="rtl"] .org-children-wrap--rail {
	align-items: flex-end;     /* RTL (Hebrew): spine on right */
}

/*
 * Override v4's margin:0 auto on org-connector-vert.
 * Inside a flex container, auto margins absorb cross-axis free space and
 * override align-items — without this rule the connector would be centred
 * and would not align with the rail spine.
 */
.org-children-wrap--rail .org-connector-vert {
	margin: 0;
}

/* ── 2b.  org-children wrapper ───────────────────────────────────────────── */

/*
 * Suppress v4's horizontal T-bar and its associated padding.
 * vertical-rail uses a side spine instead of a top border.
 * Specificity (0,2,0) beats v4's .org-children (0,1,0). ✓
 */
.org-children.org-children--vertical-rail {
	border-top: none;
	padding-top: 0;
	padding-inline: 0;
	display: block;
}

/* ── 2c.  Rail spine container ───────────────────────────────────────────── */

/*
 * border-inline-start — the physical vertical spine line.
 *   LTR: left border  (spine on left, items to the right).
 *   RTL: right border (spine on right, items to the left — Hebrew). ✓
 *
 * padding-inline-start — gap between the spine and item content.
 *   Must equal the stub width (see 2d below) so stubs connect flush. ✓
 *
 * gap  — vertical spacing between consecutive rail items.
 *   Modest default (18px) using the same line colour/weight as connectors.
 */
.org-rail {
	display: flex;
	flex-direction: column;
	gap: 18px;
	border-inline-start:
		var(--org-line-weight, 1.5px)
		var(--org-line-style, solid)
		var(--org-line-color, rgba(100,116,139,0.55));
	padding-inline-start: 20px;
}

/* ── 2d.  Rail items and stubs ───────────────────────────────────────────── */

/*
 * position:relative is required for the ::before absolute stub.
 */
.org-rail-item {
	position: relative;
}

/*
 * Horizontal stub: visually connects each item to the spine.
 *
 * top: 28px
 *   Fixed offset ≈ half the minimum card height (~56px).
 *   For leaf nodes this lands at the card vertical centre.
 *   For items whose render_node() output includes sub-children, the stub
 *   connects near the card top; the card is always the topmost element
 *   in a render_node() result so the stub is always within the card area. ✓
 *
 * inset-inline-start: -20px
 *   CSS logical property; resolves per document direction:
 *   LTR: left: -20px — stub left edge is 20px left of the item's left
 *        edge, i.e. exactly at the spine border. ✓
 *   RTL: right: -20px — stub right edge is 20px right of the item's right
 *        edge, i.e. exactly at the spine border (right side). ✓
 *
 * width: 20px  matches padding-inline-start of .org-rail. ✓
 *
 * Uses the same colour variable as all other connectors — visually modest,
 * not dominant. ✓
 */
.org-rail-item::before {
	content: '';
	position: absolute;
	top: 28px;
	inset-inline-start: -20px;
	width: 20px;
	height: var(--org-line-weight, 1.5px);
	background: var(--org-line-color, rgba(100,116,139,0.55));
	pointer-events: none;
}
