/* /tools/join-visualizer - page-specific rules ONLY. Shared primitives (tokens,
   headings, buttons, cards, notices, form controls) come from tokens.css /
   site.css / tools.css. No new colors: every value here is a site token. Mono
   is for SQL, table data and NULL markers only. Blue is the employees (left)
   table and green the departments (right) table, everywhere on the page. */

.jv-sr {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ---------- Full-width tool ---------- */
/* The head and the tool break out of the 1140px .wrap; the prose sections below
   keep the readable width. */
.jv-wide { max-width: none; padding: 0 clamp(16px, 2vw, 32px); }
.jv-head .lede { max-width: 68ch; }
.jv-tool { padding: 24px 0 clamp(48px, 6vw, 72px); }
.jv-noscript { max-width: 72ch; }

.jv-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "left" "right" "out" "tips";
    align-items: start;
}
.jv-pane-l { grid-area: left; }
.jv-pane-r { grid-area: right; }
.jv-tips { grid-area: tips; }
.jv-out { grid-area: out; }

@media (min-width: 640px) {
    .jv-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas: "left right" "out out" "tips tips";
    }
}
@media (min-width: 1000px) {
    .jv-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
        grid-template-areas: "left out" "right out" "tips out";
    }
}
@media (min-width: 1440px) {
    .jv-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, .85fr) minmax(0, 1.75fr);
        grid-template-areas: "left right out" "tips tips out";
    }
}

/* ---------- Editable sample tables ---------- */
.jv-pane, .jv-out {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    min-width: 0;
}
.jv-pane-l { border-top: 3px solid var(--blue-bright); }
.jv-pane-r { border-top: 3px solid var(--green); }
.jv-pane-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.jv-pane-title { margin: 0; font-size: 1.05rem; font-family: "JetBrains Mono", monospace; }
.jv-alias {
    display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 999px;
    font-size: .78rem; font-weight: 500; vertical-align: 2px;
}
.jv-pane-l .jv-alias { background: var(--blue-soft); color: var(--blue-on-soft); }
.jv-pane-r .jv-alias { background: var(--green-soft); color: var(--green-on-soft); }

.jv-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; flex: none; }

.jv-add, .jv-copy, .jv-chip {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--cream); color: var(--ink); border: 1px solid var(--line); border-radius: 999px;
    padding: 8px 16px; font: inherit; font-size: .86rem; cursor: pointer; min-height: 44px;
    transition: border-color .15s ease, color .15s ease;
}
.jv-add:hover, .jv-copy:hover, .jv-chip:hover { border-color: var(--link); color: var(--heading); }
.jv-add:focus-visible, .jv-copy:focus-visible, .jv-chip:focus-visible, .jv-del:focus-visible, .jv-anchor:focus-visible {
    outline: 2px solid var(--link); outline-offset: 2px;
}
.jv-add[hidden], .jv-copy[hidden], .jv-scenarios[hidden], .jv-out[hidden] { display: none; }

.jv-scroll { overflow-x: auto; max-width: 100%; }
.jv-scroll:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; border-radius: 6px; }

.jv-table, .jv-result {
    width: 100%; border-collapse: collapse; font-size: .92rem;
    font-variant-numeric: tabular-nums;
}
.jv-table th, .jv-table td, .jv-result th, .jv-result td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.jv-table thead th { background: var(--cream); color: var(--heading); white-space: nowrap; }
.jv-table td { font-family: "JetBrains Mono", monospace; font-size: .88rem; }
.jv-table td[contenteditable] { min-width: 6ch; cursor: text; }
.jv-table td[contenteditable]:hover { background: var(--cream); }
.jv-table td[contenteditable]:focus { outline: 2px solid var(--link); outline-offset: -2px; background: var(--cream); }
.jv-table tr.jv-blank td[contenteditable] { background: var(--cream); border-style: dashed; }

/* Numeric columns: employees id and dept_id, departments dept_id. */
.jv-pane-l .jv-table :is(th, td):is(:nth-child(1), :nth-child(3)),
.jv-pane-r .jv-table :is(th, td):nth-child(1) { text-align: right; }

.jv-keytag {
    display: inline-block; margin-left: 4px; padding: 1px 6px;
    font-family: "JetBrains Mono", monospace; font-size: .7rem; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; line-height: 1.4;
    color: var(--link); border: 1px solid var(--link); border-radius: 999px; vertical-align: 1px;
}

.jv-table th.jv-act, .jv-table td.jv-act { width: 44px; padding: 0; text-align: center; border-left-color: transparent; }
.jv-table thead th.jv-act { background: transparent; border-top-color: transparent; border-right-color: transparent; }
.jv-table td.jv-act { border-top-color: transparent; border-bottom-color: transparent; border-right-color: transparent; }
.jv-del {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; padding: 0; border: 0; border-radius: 999px;
    background: transparent; color: var(--muted); cursor: pointer;
}
.jv-del:hover { color: var(--pink-strong); background: var(--pink-wash); }

/* ---------- Tips and scenarios ---------- */
.jv-hint { list-style: none; margin: 0; padding: 0; font-size: .9rem; color: var(--muted); max-width: 72ch; }
.jv-hint li { padding: 6px 0 6px 16px; position: relative; line-height: 1.55; }
.jv-hint li::before { content: ""; position: absolute; left: 2px; top: 1em; width: 5px; height: 5px; border-radius: 50%; background: var(--line); }
.jv-scenarios { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.jv-scenarios-label { font-size: .86rem; font-weight: 600; color: var(--heading); }
.jv-scenario-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Live result pane ---------- */
.jv-out { display: flex; flex-direction: column; gap: 14px; }
.jv-picker { border: 0; margin: 0; padding: 0; min-width: 0; }
.jv-out-title { padding: 0; margin: 0 0 8px; font-size: .86rem; font-weight: 600; color: var(--heading); }
.jv-pills { display: flex; flex-wrap: wrap; gap: 8px; }
.jv-pill { position: relative; display: inline-flex; }
.jv-pill input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.jv-pill span {
    display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px;
    border: 1px solid var(--line); border-radius: 999px; background: var(--cream); color: var(--ink);
    font-family: "JetBrains Mono", monospace; font-size: .84rem; font-weight: 600;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.jv-pill:hover span { border-color: var(--link); color: var(--heading); }
.jv-pill input:checked + span { background: var(--blue-bright); border-color: var(--blue-bright); color: #fff; }
.jv-pill input:focus-visible + span { outline: 2px solid var(--link); outline-offset: 2px; }

.jv-out-detail { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: center; }
@media (min-width: 560px) {
    .jv-out-detail { grid-template-columns: 180px minmax(0, 1fr); }
}
.jv-out-venn svg { width: 100%; max-width: 200px; height: auto; display: block; margin: 0 auto; }
.jv-out-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 18px; font-size: .88rem; color: var(--muted); }
.jv-out-meta .jv-count { font-weight: 600; color: var(--heading); font-size: .95rem; }
.jv-key-legend code { font-family: "JetBrains Mono", monospace; font-size: .9em; }
.jv-result-live tbody tr.jv-more td { text-align: center; color: var(--muted); font-style: italic; }

/* ---------- Code blocks with their copy button ---------- */
.jv-code { position: relative; min-width: 0; }
.jv-code .fmt-code { padding-right: 112px; }
.jv-code .jv-copy { position: absolute; top: 8px; right: 8px; }

/* ---------- Per-join sections ---------- */
.jv-join { margin-top: 56px; }
.jv-join .tools-h3 { margin-top: 0; }
.jv-join > p { color: var(--ink); max-width: 66ch; margin: 0 0 16px; }
.jv-anchor { margin-left: 6px; color: var(--muted); text-decoration: none; opacity: 0; transition: opacity .15s ease; }
.jv-join .tools-h3:hover .jv-anchor, .jv-anchor:focus-visible { opacity: 1; }
.jv-detail { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 18px; align-items: center; }
.jv-countline { margin: 12px 0 8px; font-size: .88rem; color: var(--muted); }
.jv-venn { width: 100%; max-width: 200px; height: auto; display: block; }

.jv-l { fill: var(--blue-soft); stroke: var(--blue-bright); stroke-width: 1.5; }
.jv-r { fill: var(--green-soft); stroke: var(--green); stroke-width: 1.5; }
.jv-ls { fill: var(--blue-bright); fill-opacity: .6; stroke: var(--blue-bright); stroke-width: 1.5; }
.jv-rs { fill: var(--green); fill-opacity: .5; stroke: var(--green); stroke-width: 1.5; }
.jv-hl { fill: var(--blue-bright); fill-opacity: .6; }
.jv-pairs line { stroke: var(--muted); stroke-width: 1.2; stroke-opacity: .7; }
.jv-vlabel { fill: var(--muted); font-family: "JetBrains Mono", monospace; font-size: 13px; }

/* ---------- Result tables ---------- */
.jv-result thead th { background: var(--card); color: var(--heading); white-space: nowrap; }
.jv-result thead .jv-group th { font-size: .78rem; font-weight: 600; text-align: center; font-family: "JetBrains Mono", monospace; }
.jv-result thead .jv-g-l { background: var(--blue-soft); color: var(--blue-on-soft); }
.jv-result thead .jv-g-r { background: var(--green-soft); color: var(--green-on-soft); }
.jv-result td { font-family: "JetBrains Mono", monospace; font-size: .86rem; }
.jv-result :is(th, td):is(:nth-child(1), :nth-child(3), :nth-child(4)) { text-align: right; }
.jv-result thead .jv-group th { text-align: center; }
.jv-result .jv-match td:is(:nth-child(3), :nth-child(4)) { background: var(--green-soft); color: var(--green-on-soft); font-weight: 600; }
.jv-result .jv-unmatch { background: var(--amber-soft); }
.jv-result .jv-null { font-size: .8em; color: var(--muted); }

.jv-legend { margin: 32px 0 0; font-size: .9rem; color: var(--muted); max-width: 72ch; }
.jv-legend code, .jv-hint code { font-family: "JetBrains Mono", monospace; font-size: .9em; }
.jv-swatch {
    display: inline-block; width: 14px; height: 14px; margin: 0 6px 0 0; vertical-align: -2px;
    background: var(--amber-soft); border: 1px solid var(--amber-line); border-radius: 4px;
}
.jv-swatch-match { background: var(--green-soft); border-color: var(--green); }
.jv-key-legend .jv-swatch:not(:first-child), .jv-legend .jv-swatch:not(:first-child) { margin-left: 10px; }

@media (prefers-reduced-motion: no-preference) {
    .jv-result tr.jv-fresh td { animation: jv-fresh 900ms cubic-bezier(.16, 1, .3, 1); }
}
@keyframes jv-fresh {
    from { background-color: var(--blue-soft); }
}
@media (prefers-reduced-motion: reduce) {
    .jv-add, .jv-copy, .jv-chip, .jv-pill span, .jv-anchor { transition: none; }
}

/* ---------- Readable measure for the shared prose blocks on this page ---------- */
.tools-intro, .tools-points, .tools-faq, .tools-xref, .tools-xref-also { max-width: 66ch; }

/* The breadcrumb's "/" separators are decoration; keep screen readers quiet. */
.tools-crumbs li + li::before { content: "/" / ""; }

/* tools.css .tools-cta p (#aebfe2) measures 4.3:1 on the blue end of the CTA
   gradient; use the strip's own lighter body color on this page. */
.tools-cta p { color: #cfe0ff; }

@media (max-width: 820px) {
    .jv-detail { grid-template-columns: 1fr; }
    .jv-venn { margin: 0 auto; }
}
@media (max-width: 480px) {
    .jv-pane, .jv-out { padding: 14px; }
    .jv-table th, .jv-table td, .jv-result th, .jv-result td { padding: 6px 8px; }
    .jv-table th.jv-act, .jv-table td.jv-act { padding: 0; }
    .jv-code .fmt-code { padding-right: 18px; padding-top: 58px; }
}
