/* NASABA tree — "roots meet circuits": glowing lineage lines on night earth, branch-coloured name cards. */

.tree { display: flex; flex-direction: column; gap: var(--s3); }
.tree__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s2); }
.chip-btn {
  min-height: 40px; padding: 6px 14px; border-radius: var(--radius-pill); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: 600 var(--fs-sm) var(--font-body); cursor: pointer;
}
.chip-btn[aria-pressed="true"] { border-color: var(--leaf); box-shadow: 0 0 0 1px var(--leaf) inset; color: var(--leaf); }
.tree__search { display: flex; flex-direction: column; gap: var(--s2); }
.tree__search input { min-height: 44px; padding: 10px 14px; border-radius: var(--radius-field); border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; }
.tree__path { display: flex; align-items: center; gap: var(--s3); padding: 10px 12px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--gold) 55%, var(--border)); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); }
.tree__path-text { flex: 1; font-weight: 600; }
.tree__note { font-size: var(--fs-sm); }

.tree__canvas {
  position: relative; height: calc(100vh - 290px); min-height: 380px; border-radius: var(--radius-card);
  border: 1px solid var(--border); background-color: var(--bg); overflow: hidden; touch-action: none;
}
@media (min-width: 1024px) { .tree__canvas { height: calc(100vh - 260px); } }
/* phones: chips scroll sideways instead of taking three lines */
@media (max-width: 600px) {
  .tree__chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .tree__chips .chip-btn { flex: none; }
  .tree__bar > .btn { width: 100%; }
}
.tree__svg { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; -webkit-user-select: none; }
.tree__svg:active { cursor: grabbing; }
.tree__status { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: var(--s5); }
.tree__controls { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.tree__controls .icon-btn { width: 44px; height: 44px; font-size: 20px; font-weight: 700; }
.tree__me { color: var(--leaf); }
.tree__legend-box { position: absolute; left: 12px; bottom: 12px; max-width: calc(100% - 90px); font-size: var(--fs-xs); color: var(--muted);
  background: color-mix(in srgb, var(--surface) 88%, transparent); border: 1px solid var(--border); border-radius: 10px; }
.tree__legend-box summary { cursor: pointer; padding: 6px 10px; font-weight: 600; list-style: revert; }
.tree__legend-box[open] summary { padding-bottom: 0; }
.tree__legend { list-style: none; margin: 0; padding: 6px 10px 8px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -2px; border: 2px solid var(--leaf); }
.lg--passive { border: 1.5px dashed var(--muted); }
.lg--deceased { border-color: var(--root); }
.tree__more { font-size: var(--fs-sm); }

/* lines */
.ln { stroke: var(--line); stroke-width: 1.6; fill: none; }
.ln--couple { stroke: var(--gold); stroke-width: 2; }
.ln--coparent { stroke: var(--gold); stroke-width: 1.6; stroke-dasharray: 5 5; }

/* nodes */
.node { cursor: pointer; outline: none; }
.node__hit { fill: transparent; }
.node__card { fill: #1E2532; stroke: var(--border); stroke-width: 1; }
.node__avatar { fill: var(--surface-2); }
.node__ring { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 4 4; }
.ring--active .node__ring { stroke: var(--leaf); stroke-dasharray: none; stroke-width: 2.5; }
.ring--deceased .node__ring { stroke: var(--root); stroke-dasharray: none; }
.node__initials { fill: var(--text); font: 700 15px var(--font-body); }
.node__name { fill: #FFFFFF; font: 700 12.5px var(--font-body); letter-spacing: .01em; }
.node__sub { fill: #E6E9F2; font: 500 11px var(--font-body); }
.br--b0 .node__card { fill: #2454D8; } .br--b0.tone--light .node__card { fill: #A9B3F5; }
.br--b1 .node__card { fill: #C9662A; } .br--b1.tone--light .node__card { fill: #F6C59C; }
.br--b2 .node__card { fill: #2C776C; } .br--b2.tone--light .node__card { fill: #9ED9CE; }
.br--b3 .node__card { fill: #7A35A0; } .br--b3.tone--light .node__card { fill: #D3B4E8; }
.br--b4 .node__card { fill: #A63A28; } .br--b4.tone--light .node__card { fill: #EDB0A3; }
.tone--light .node__name, .tone--light .node__sub { fill: #1A120B; }
.is-repeat { opacity: .55; }
.is-repeat .node__card { stroke-dasharray: 4 3; stroke: var(--gold); }
.is-me .node__ring { stroke: var(--gold); stroke-dasharray: none; stroke-width: 3; filter: drop-shadow(0 0 6px var(--glow)); }
.node:focus-visible .node__card, .node:hover .node__card { stroke: var(--gold); stroke-width: 2; }
.on-path .node__card { stroke: var(--orange); stroke-width: 2.5; filter: drop-shadow(0 0 8px color-mix(in srgb, var(--orange) 60%, transparent)); }

/* kinship path */
.path { fill: none; stroke: var(--orange); stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 12 9; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--orange) 70%, transparent)); }
.path--flow { animation: path-flow 1.2s linear infinite; }
@keyframes path-flow { to { stroke-dashoffset: -36; } }

/* bottom sheet */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: var(--s3) max(16px, env(safe-area-inset-right, 0px)) calc(var(--s4) + 56px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: var(--surface); border-top: 1px solid var(--border); border-radius: 18px 18px 0 0;
  box-shadow: 0 -18px 40px -20px rgba(0, 0, 0, .6); display: flex; flex-direction: column; gap: var(--s3);
}
.sheet__grip { width: 44px; height: 4px; border-radius: 4px; background: var(--border); margin: 0 auto; }
@media (min-width: 1024px) {
  .sheet { left: auto; right: 24px; bottom: 24px; width: 380px; border-radius: 16px; border: 1px solid var(--border); padding-bottom: var(--s4); }
}

.lg-line { display: inline-block; width: 18px; height: 0; border-top: 2px dashed var(--gold); margin-right: 6px; vertical-align: 3px; }

/* official union = solid lines; outside an official union (cohabitation, unknown, no union) = dashed */
.ln--dashed { stroke-dasharray: 7 6; }
.ln--informal { stroke: var(--gold); stroke-width: 1.8; }
.node__photo { pointer-events: none; }
/* link between two people: orange, animated */
.path-ring { fill: none; stroke: var(--orange); stroke-width: 3.5; stroke-dasharray: 10 8; filter: drop-shadow(0 0 5px color-mix(in srgb, var(--orange) 70%, transparent)); }
.path--flow { animation: path-flow 1s linear infinite; }
@keyframes path-flow { to { stroke-dashoffset: -42; } }
@media (prefers-reduced-motion: reduce) { .path--flow { animation: none; } }
.lg-line--official { border-top: 2px solid var(--gold); }
.lg-line--path { border-top: 3px dashed var(--orange); }
/* two-person search */
.tree__pair-hint { font-size: var(--fs-sm); margin: 0; }
.pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s3); align-items: start; }
.pair__slot { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.pair__label { font-size: var(--fs-xs); font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.pair__picked { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; padding: 6px 6px 6px 12px; border-radius: 12px; border: 1px solid var(--orange); background: color-mix(in srgb, var(--orange) 10%, transparent); font-weight: 600; }
.pair__picked[hidden] { display: none; }
.pair__arrow { align-self: center; font-size: 1.4rem; color: var(--orange); margin-top: 18px; }
@media (max-width: 600px) { .pair { grid-template-columns: 1fr; } .pair__arrow { margin: 0 auto; transform: rotate(90deg); } }
/* divorce / legal separation: "//" on the couple's line */
.ln-gap { fill: var(--bg); stroke: none; }
.ln--break { stroke: var(--gold); stroke-width: 2.2; stroke-linecap: round; stroke-dasharray: none; }
.lg-line--broken { position: relative; border-top: 2px solid var(--gold); }
.lg-line--broken b { position: absolute; left: 4px; top: -9px; font-size: 11px; color: var(--gold); background: var(--surface); padding: 0 1px; line-height: 1; font-style: normal; }
