/* ==========================================================================
   ORG COMPARE — two side-by-side diagrams (before / after)   (visual only)
   ==========================================================================
   A two-column comparison framed by a rule across the top and a hairline down
   the middle that runs the full height, to the next section — e.g. a chaotic
   phone tree (left) against a clean org chart (right).

   Build the diagram as an ARTICLE `band bg-cream oc-section` → element_group
   `org-compare` with two `text` children (left, right), each = <h3>Title</h3>
   [<p class="oc-sub">…</p>] then the `.oc-tree`.
   ========================================================================== */

/* The article: 80 top, 120 bottom breathing room. The centre rule
   still runs through that padding to meet the next (dark) section. */
.band.oc-section { padding-top: var(--space-80); padding-bottom: 120px; --oc-rule-tail: 120px; }

.org-compare {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding-top: clamp(1.75rem, 3vw, 3rem);
    margin-top: 0;
    column-gap: clamp(32px, 5vw, 72px);
    /* Top rule, INSET to the page gutter. This group is a direct `.band` child, so
       `.band > *` gives it `padding-inline: var(--page-gutter)` and a border-top
       painted a full gutter past the text on both sides. `--rule-inset` is the dial
       (set it to 0 where there is no gutter padding). */
    &::before {
        content: "";
        position: absolute;
        top: 0;
        left: var(--rule-inset, var(--page-gutter));
        right: var(--rule-inset, var(--page-gutter));
        height: 0;
        border-top: 1px solid var(--hairline);
        pointer-events: none;
    }

    /* Centre rule: full height of the diagram block, and in an `oc-section` band
       on through its 120px bottom padding to the next section (--oc-rule-tail). */
    &::after {
        content: "";
        position: absolute;
        top: 0; bottom: calc(-1 * var(--oc-rule-tail, 0px));
        left: 50%;
        border-left: 1px solid var(--hairline);
    }

    h3 {
        font-family: var(--type-display);
        font-weight: 500;
        font-size: clamp(1.2rem, 1.9vw, 1.6875rem);
        color: var(--prime);
        text-align: center;
        margin: 0 0 0.35em;
    }
    .oc-sub { text-align: center; color: var(--text-strong); margin: 0 0 1.75rem; font-size: 0.95rem; }
    .oc-note { display: block; text-align: center; color: var(--heading); font-size: 0.8125rem; margin-top: 1.5rem; padding-bottom: clamp(2rem, 4vw, 3.5rem); }
}

/* ---- CSS boxes + connectors -------------------------------------------- */
.oc-tree { display: flex; flex-direction: column; align-items: center; }
/* Phone tree: red dashed web (boxes + connectors), matching the design. */
.oc-tree--red { color: var(--accent-deep); }
/* The clean side: the fan-OUT to the services is thin grey; the single spine IN is the accent line, heavier. */
.oc-tree--navy { color: var(--placeholder); }
.oc-tree--navy > .oc-link { border-left-color: var(--second); border-left-width: 2.5px; }

.oc-box {
    display: inline-flex; align-items: center; justify-content: center;
    text-align: center;
    padding: 0.95rem 1.6rem;
    border-radius: 8px;
    box-sizing: border-box;
    max-width: 100%;
    font-family: var(--type-body);
    font-weight: 500;
    font-size: clamp(0.9rem, 1.05vw, 1.0625rem);
    line-height: 1.15;
    min-height: 3.5rem;
}
.oc-box--dash { border: 2px dashed var(--accent-deep); color: var(--heading); background: var(--white); }
.oc-box--line { border: 1.25px solid var(--prime); color: var(--text-strong); background: var(--white); }
.oc-box--rose { background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--accent) 50%, white) 0%, var(--accent) 100%); color: var(--text-strong); font-weight: 600; }
.oc-box--nav { background: var(--prime); color: var(--white); font-weight: 600; }

/* Vertical connector between stacked boxes. */
.oc-link { width: 0; border-left: 1.5px solid currentColor; height: 30px; }

/* Branch row: horizontal bus above + a drop into each child column. */
.oc-branch { position: relative; display: flex; justify-content: center; align-items: flex-start; gap: clamp(8px, 1.2vw, 16px); width: 100%; padding-top: 30px; }
.oc-branch::before { content: ""; position: absolute; top: 0; height: 30px; border-top: 1.5px solid currentColor; }
.oc-branch--3::before { left: 16.666%; right: 16.666%; }
.oc-branch--4::before { left: 12.5%; right: 12.5%; }
.oc-branch {
    > * { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; }
    > *::before { content: ""; position: absolute; top: -30px; height: 30px; border-left: 1.5px solid currentColor; }
}
.oc-drop { width: 0; border-left: 1.5px solid currentColor; height: 30px; margin: 0 auto; }

/* ---- Mobile: stack the two sides; drop the centre rule ------------------ */
@media only screen and (max-width: 760px) {
    .org-compare { grid-template-columns: 1fr; row-gap: 2.5rem; }
    .org-compare::after { display: none; }
    .org-compare > *:first-child {
        border-bottom: 1px solid var(--hairline);
        padding-bottom: 2.5rem;
    }
    .oc-box { min-height: 3rem; padding: 0.75rem 1.1rem; }
}

/* ---- Scroll-in reveal ----------------------------------------------------
   So the LEFT column draws node by node, top to bottom, the way you would
   actually walk a phone tree — each node and its connector arriving in turn,
   which is what makes the length of it land. Only once the left has finished
   does the RIGHT column resolve, as a single quick settle rather than another
   node-by-node crawl: that contrast IS the point being made. One pass, no
   repeat, no reverse on scroll-up.

   Both directions keep the weights the design asks for — outbound stays the
   thin grey connector, inbound the single accent line — because this only
   animates opacity and position, never colour or width.

   Gated on `.js-reveal` (the j_reveal template), so with JS off or reduced
   motion both columns render complete and static. */
.js-reveal {
    .org-compare .oc-box, .org-compare .oc-link, .org-compare .oc-drop { opacity: 0; }
    .org-compare.is-in .oc-box, .org-compare.is-in .oc-link, .org-compare.is-in .oc-drop { animation: ocReveal 0.45s ease both; }

    /* Left column — the phone tree, walked one node at a time. */
    .org-compare.is-in > *:first-child .oc-box:nth-of-type(1), .org-compare.is-in > *:first-child .oc-link:nth-of-type(1) { animation-delay: 0.05s; }
    .org-compare.is-in > *:first-child .oc-box:nth-of-type(2), .org-compare.is-in > *:first-child .oc-link:nth-of-type(2) { animation-delay: 0.35s; }
    .org-compare.is-in > *:first-child .oc-box:nth-of-type(3), .org-compare.is-in > *:first-child .oc-link:nth-of-type(3) { animation-delay: 0.65s; }
    .org-compare.is-in > *:first-child .oc-box:nth-of-type(4), .org-compare.is-in > *:first-child .oc-link:nth-of-type(4) { animation-delay: 0.95s; }
    .org-compare.is-in > *:first-child .oc-drop { animation-delay: 1.25s; }
    .org-compare.is-in > *:first-child .oc-branch::before, .org-compare.is-in > *:first-child .oc-branch > *::before { animation-delay: 0.65s; }

    /* Right column — the clean model, arriving AFTER the tree has finished,
       as one settle rather than a crawl. */
    .org-compare.is-in > *:last-child .oc-box, .org-compare.is-in > *:last-child .oc-link, .org-compare.is-in > *:last-child .oc-drop {
        animation-duration: 0.6s;
        animation-delay: 1.6s;
    }
    .org-compare.is-in > *:last-child .oc-box:nth-of-type(2) { animation-delay: 1.75s; }

    /* The centre rule and the branch hairlines fade with their own side. */
    .org-compare .oc-branch::before, .org-compare .oc-branch > *::before { opacity: 0; }
    .org-compare.is-in .oc-branch::before, .org-compare.is-in .oc-branch > *::before { animation: ocReveal 0.45s ease both; }
}

@keyframes ocReveal {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
