/* Relationship Finder: "family album". White paper, deep green ink, one warm clay accent. */
:root {
  --bg: #ffffff;
  --ink: #17322a;
  --muted: #55665e;
  --line: #dfe6e2;
  --tint: #f2f5f3;
  --green: #1e5a43;
  --green-ink: #ffffff;
  --green-soft: #e6f0eb;
  --clay: #a8531a;
  --clay-soft: #fcebd6;
  --you: #dcece4;
  --ca: #f2f5f3;
  --warn: #8a4b12;
  --focus: #c46a00;
  --font: "Avenir Next", Avenir, "Segoe UI", "Helvetica Neue", "Noto Sans", Ubuntu, system-ui, -apple-system, Roboto, Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111815;
    --ink: #e6eee9;
    --muted: #a3b3ab;
    --line: #2b3832;
    --tint: #1a231f;
    --green: #7fcfaa;
    --green-ink: #0d1612;
    --green-soft: #1d3329;
    --clay: #f0a868;
    --clay-soft: #3d2a17;
    --you: #1d3a2e;
    --ca: #1a231f;
    --warn: #f0b27a;
    --focus: #ffb35c;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.6 var(--font); }
a { color: var(--green); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; background: var(--bg); padding: 6px 10px; z-index: 10; }

header.site { border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand svg, .brand img { width: 26px; height: 26px; flex: none; }
header.site nav { margin-left: auto; font-size: 15px; display: flex; gap: 6px; }
header.site nav a { white-space: nowrap; padding: 12px 6px; text-decoration: none; color: var(--muted); }
header.site nav a:hover { color: var(--green); text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; letter-spacing: -.015em; font-weight: 700; }
.hero { padding: 36px 0 4px; }
h1 { font-size: clamp(30px, 6vw, 40px); margin: 0 0 8px; }
.hero p.sub { margin: 0; color: var(--muted); font-size: 18px; max-width: 56ch; }
h2 { font-size: 24px; margin: 56px 0 10px; }
h3 { font-size: 18px; margin: 28px 0 6px; }
.crumbs { font-size: 15px; color: var(--muted); padding-top: 12px; }
.crumbs ol { list-style: none; margin: 0; padding: 0; }
.crumbs li { display: inline; }
.crumbs li + li::before { content: "›"; margin: 0 6px; }
.crumbs a { display: inline-block; padding: 10px 0; }

/* ---------- tool ---------- */
.tool { margin: 24px 0 8px; }
.picker { position: relative; }
.chain-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  border-bottom: 2px solid var(--green); padding: 4px 0 8px; min-height: 58px;
  font-weight: 700; font-size: 22px; line-height: 1.3;
}
.chain-box .my { color: var(--muted); margin-right: 2px; }
#chain { display: contents; list-style: none; }
#chain li { display: inline-flex; align-items: center; }
.link-chip {
  display: inline-flex; align-items: center; gap: 2px; border: 0; cursor: pointer;
  background: var(--green-soft); color: var(--ink); border-radius: 8px; padding: 2px 4px 2px 10px;
  font: inherit; font-size: 19px; min-height: 44px;
}
.link-chip .x { font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px; border-radius: 6px; }
.link-chip:hover .x { background: var(--bg); color: var(--ink); }
.poss { color: var(--muted); font-weight: 400; margin: 0 2px 0 -3px; }
.chain-box .placeholder { color: var(--muted); font-weight: 400; font-size: 17px; }
.chain-actions { margin-left: auto; display: flex; gap: 2px; }
.chain-actions[hidden] { display: none; }
.btn-small {
  font: 600 15px/1 var(--font); padding: 8px 10px; border-radius: 8px; border: 0;
  background: transparent; color: var(--green); cursor: pointer; min-height: 44px;
}
.btn-small:hover { background: var(--green-soft); }

/* Live answer while building the chain. Sticky only inside .picker, so it never covers the text box or selects. */
.quick {
  position: sticky; top: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px;
  margin: 0; padding: 8px 0; background: var(--bg); border-bottom: 1px solid var(--line);
  font-size: 19px; line-height: 1.35;
}
.quick:empty { display: none; }
main section p.quick { max-width: none; }
.quick strong { color: var(--green); }
.q-arrow { color: var(--clay); font-weight: 700; }
.q-more {
  margin-left: auto; font: 600 15px/1 var(--font); color: var(--green); background: transparent;
  border: 0; border-radius: 8px; padding: 8px 10px; min-height: 44px; cursor: pointer;
}
.q-more:hover { background: var(--green-soft); }
fieldset { border: 0; margin: 16px 0 0; padding: 0; min-width: 0; }
legend { font-size: 15px; color: var(--muted); padding: 0; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 500 16px/1 var(--font); padding: 10px 13px; min-height: 44px; border-radius: 8px; cursor: pointer;
  border: 0; background: var(--tint); color: var(--ink);
}
.chip:hover { background: var(--green-soft); }
.chip:active { transform: translateY(1px); }
details.more { margin-top: 6px; }
details.more summary { cursor: pointer; font-size: 15px; color: var(--green); font-weight: 600; padding: 11px 0; }
details.more .chips { margin-top: 4px; }
.chip-group-label { width: 100%; font-size: 15px; color: var(--muted); margin-top: 6px; }

.textrow { margin-top: 20px; }
.textrow label, .opts label { font-weight: 600; font-size: 15px; display: block; margin-bottom: 4px; }
.textrow .inrow { display: flex; gap: 8px; }
input[type=text], select {
  font: 16px/1.3 var(--font); padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); min-height: 44px; width: 100%;
}
input[type=text]:focus, select:focus { border-color: var(--green); }
.btn {
  font: 600 16px/1 var(--font); padding: 11px 18px; border-radius: 8px; border: 0; cursor: pointer;
  background: var(--green); color: var(--green-ink); min-height: 44px; white-space: nowrap;
}
.parse-msg { font-size: 15px; color: var(--muted); margin: 6px 0 0; min-height: 1.4em; }
.parse-msg:empty { min-height: 0; margin: 0; }
.parse-msg.bad { color: var(--warn); }
.opts { display: flex; flex-wrap: wrap; gap: 12px 20px; margin-top: 14px; }
.opts > div { flex: 1 1 200px; }

/* ---------- result: the one card on the page ---------- */
#result { margin-top: 24px; }
#result:empty { display: none; }
.answer { border: 1px solid var(--line); border-radius: 14px; padding: 20px 20px 16px; }
.big { font-size: clamp(24px, 4.6vw, 32px); line-height: 1.25; font-weight: 700; letter-spacing: -.015em; margin: 0 0 8px; }
.big strong, .lead strong { color: var(--green); }
.lead { font-size: 20px; line-height: 1.35; font-weight: 600; margin: 0 0 6px; }
.also { color: var(--muted); font-size: 16px; margin: 0 0 4px; }
.also .dot, .legend .dot { margin: 0 4px; }
.claim { font-size: 18px; margin: 0 0 12px; }
.claim strong { color: var(--clay); }
.claim.yes strong { color: var(--green); }
.note { font-size: 15px; color: var(--muted); margin: 6px 0; }
.persp { font-size: 18px; margin: 10px 0; }
.persp strong { color: var(--green); }
.tree-wrap { overflow-x: auto; margin: 18px 0 6px; padding: 4px 0; -webkit-overflow-scrolling: touch; }
.tree-wrap svg { display: block; max-width: 100%; height: auto; }
/* the tree is the picture people came for: draw it a little larger than its natural size */
.tree-wrap svg { width: 100%; max-width: 640px; }
.tree-wrap svg[data-cols="1"] { max-width: 230px; }
.tree-wrap svg[data-cols="2"] { max-width: 440px; }
/* wide trees keep readable text on phones and scroll sideways instead of shrinking */
.tree-wrap svg[data-cols="3"] { min-width: 430px; }
.tree-wrap svg[data-cols="4"] { min-width: 540px; }
.tree-wrap svg[data-cols="5"], .tree-wrap svg[data-cols="6"] { min-width: 640px; }
@media (max-width: 640px) {
  .tree-wrap:has(> svg[data-cols="3"], > svg[data-cols="4"], > svg[data-cols="5"], > svg[data-cols="6"])::before {
    content: "Swipe sideways to see the whole tree →"; display: block; font-size: 14px; color: var(--muted); margin: 0 0 6px;
  }
}
.tree .tl { fill: none; stroke: var(--muted); stroke-width: 1.6; }
.tree .tl-m { fill: none; stroke: var(--clay); stroke-width: 1.6; }
.tree .tn rect { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.tree .tn text { fill: var(--ink); font: 600 12.5px var(--font); }
.tree .tn text.ts { fill: var(--muted); font-weight: 400; font-size: 11px; }
.tree .tn-you rect { fill: var(--you); stroke: var(--green); stroke-width: 2; }
.tree .tn-them rect { fill: var(--clay-soft); stroke: var(--clay); stroke-width: 2.5; }
.tree .tn-ca rect { fill: var(--ca); stroke: var(--ink); stroke-width: 1.5; }
.legend { font-size: 14px; color: var(--muted); margin: 0 0 4px; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 4px 0 0; vertical-align: 0; }
.key-you { background: var(--you); border: 2px solid var(--green); }
.key-them { background: var(--clay-soft); border: 2px solid var(--clay); }
.key-ca { background: var(--ca); border: 1.5px solid var(--ink); }
.working { margin-top: 10px; border-top: 1px solid var(--line); }
.working summary, .possibility summary { cursor: pointer; color: var(--green); font-weight: 600; font-size: 15px; padding: 11px 0; }
.working p, .working li { font-size: 16px; }
.working p { margin: 0 0 8px; }
.possibility { padding: 14px 0 4px; border-top: 1px solid var(--line); }
.possibility:first-of-type { border-top: 0; padding-top: 6px; }
.possibility .cond { display: block; font-size: 15px; color: var(--muted); margin: 0 0 2px; }
.less { margin: 18px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.share { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.share .btn-small { padding-left: 0; }
.share .btn-small:hover { background: transparent; text-decoration: underline; }
.share .ok { font-size: 15px; color: var(--green); }

/* ---------- content ---------- */
main section p, main section li { max-width: 68ch; }
.steps li { margin-bottom: 6px; }
.chart-more summary { cursor: pointer; color: var(--green); font-weight: 600; padding: 11px 0; }
.chart-wrap { position: relative; overflow-x: auto; margin-top: 8px; }
table.chart { border-collapse: collapse; font-size: 13px; min-width: 760px; width: 100%; }
table.chart th, table.chart td { border: 1px solid var(--line); padding: 6px; text-align: center; vertical-align: middle; }
table.chart thead th { background: var(--tint); font-size: 12px; }
table.chart tbody th { background: var(--tint); font-size: 12px; text-align: left; white-space: nowrap; }
table.chart td.c-cousin { background: var(--bg); }
table.chart td.c-aunt, table.chart td.c-niece { background: var(--clay-soft); }
table.chart td.c-line { background: var(--green-soft); }
table.chart td.c-self { background: var(--tint); }
.chart-caption { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
table.chart tbody th, table.chart thead th:first-child { position: sticky; left: 0; z-index: 1; box-shadow: 1px 0 0 var(--line); }
.faq dt { font-weight: 700; font-size: 18px; line-height: 1.3; margin-top: 22px; }
.faq dd { margin: 4px 0 0; max-width: 68ch; }
.linkgrid { columns: 2 260px; column-gap: 28px; padding: 0; margin: 0; list-style: none; }
.linkgrid li { break-inside: avoid; padding: 2px 0; }
.linkgrid a { display: inline-block; padding: 6px 0; }
.linkgrid small { color: var(--muted); font-size: 15px; display: block; margin-top: -4px; padding-bottom: 4px; }
.answerbox { margin: 18px 0 0; }
.answerbox p.first { font-size: clamp(22px, 4.4vw, 28px); line-height: 1.3; font-weight: 700; letter-spacing: -.01em; margin: 0 0 8px; }
.answerbox p.first strong { color: var(--green); }

footer.site { margin-top: 64px; border-top: 1px solid var(--line); padding: 24px 0 32px; font-size: 15px; color: var(--muted); }
footer.site p { margin: 4px 0; max-width: 72ch; }
.site-note { margin-bottom: 14px !important; }
.sb-footer { display: grid; gap: 6px; }
.sb-footer p { margin: 0; }
.sb-footer a { color: var(--green); display: inline-block; padding: 4px 0; }
.sb-more { color: var(--ink); }
.sb-credit { font-size: 14px; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .hero { padding-top: 22px; }
  .hero p.sub { font-size: 17px; }
  .quick { font-size: 17px; }
  .chain-box { font-size: 19px; }
  .link-chip { font-size: 17px; }
  .chain-actions { margin-left: auto; }
  .answer { padding: 16px 14px 12px; }
  .lead { font-size: 18px; }
  header.site nav { font-size: 15px; gap: 0; }
  h2 { font-size: 22px; margin-top: 44px; }
}
@media (max-width: 440px) {
  header.site nav .nav-how { display: none; }
  table.chart tbody th { white-space: normal; min-width: 104px; }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .chip:active { transform: none; }
}

@media print {
  header.site, footer.site, .tool form, .tool .share, .tool:not(:has(.answer)), .no-print, nav { display: none !important; }
  .answer { border: 0; padding: 0; }
  .tree-wrap { break-inside: avoid; }
  body { background: #fff; color: #000; }
  body.print-chart main > *:not(#cousin-chart) { display: none !important; }
  body.print-chart #cousin-chart { display: block !important; }
  .chart-more summary { display: none; }
  .chart-wrap { overflow: visible; }
  table.chart { min-width: 0; font-size: 9pt; }
  table.chart th, table.chart td { border: 1px solid #555; background: #fff !important; color: #000; }
}

/* ---------- 404 ---------- */
.notfound { padding: 48px 0 24px; }
.notfound .btn { display: inline-flex; align-items: center; text-decoration: none; margin-top: 18px; }
