/* Family page: toolbar, diagram (SVG), outline view, person panel. Tokens only. */

.page-head--center { justify-items: center; text-align: center; }
.page-summary { color: var(--ink-soft); margin-inline: auto; }

/* ---------- Toolbar ---------- */

.tree-app { margin-top: var(--space-m); }

.tree-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.segmented, .zoom {
  display: inline-flex;
  border: 1px solid var(--ink-soft);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 70%, white);
}
.segmented[hidden], .zoom[hidden] { display: none; }

.segmented button, .zoom button {
  font: 500 var(--step--1) / 1 var(--font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: none;
  border: 0;
  padding: 0.6em 1em;
  min-height: 2.5rem;
  cursor: pointer;
}
.segmented button + button, .zoom button + button { border-left: 1px solid var(--rule); }
.segmented button:hover, .zoom button:hover { color: var(--accent); }
.segmented button[aria-pressed="true"] { background: var(--accent); color: var(--paper); }
.zoom button[data-zoom="in"], .zoom button[data-zoom="out"] { font-size: var(--step-1); letter-spacing: 0; min-width: 2.75rem; }

/* ---------- Stage ---------- */

.tree-area { position: relative; }

.tree-stage {
  height: clamp(22rem, 72vh, 46rem);
  border: 1px solid var(--ink-soft);
  outline: 1px solid var(--rule);
  outline-offset: -7px;
  background: color-mix(in srgb, var(--paper) 55%, white);
  border-radius: var(--radius);
  overflow: hidden;
}
.tree-stage:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tree-stage[hidden] { display: none; }

.tree-svg {
  width: 100%;
  height: 100%;
  max-width: none;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.tree-svg.is-dragging { cursor: grabbing; }

.tree-hint {
  margin: var(--space-2xs) auto 0;
  text-align: center;
  font-size: var(--step--1);
  font-style: italic;
  color: var(--ink-faint);
}
.tree-hint[hidden] { display: none; }

/* ---------- SVG parts ---------- */

.tree-svg .edge { fill: none; stroke: var(--ink-soft); stroke-width: 1.25; }
.tree-svg .edge-dot { fill: var(--ink); }

.tree-svg .card { fill: color-mix(in srgb, var(--paper) 80%, white); stroke: var(--ink-soft); stroke-width: 1; }
.tree-svg .card-inner { fill: none; stroke: var(--rule); stroke-width: 0.75; }
.tree-svg .root .card { stroke: var(--accent); stroke-width: 1.5; }
.tree-svg .root .card-inner { stroke: var(--accent-3); stroke-width: 1; }
.tree-svg .list .card { fill: color-mix(in srgb, var(--paper) 92%, white); }
.tree-svg .divider { stroke: var(--rule); stroke-width: 0.75; }

.tree-svg text { fill: var(--ink); }
.tree-svg .t-place {
  font: 500 10.5px var(--font-body);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  fill: var(--accent-2);
}
.tree-svg .t-name { font: 600 20px var(--font-display); }
.tree-svg .root .t-name { font-size: 22px; }
.tree-svg .t-spouse, .tree-svg .t-item { font: 400 15.5px var(--font-body); }
.tree-svg .t-spouse { fill: var(--ink-soft); }
.tree-svg .t-union { fill: var(--accent-2); font-size: 13px; }
.tree-svg .t-caption {
  font: 500 10.5px var(--font-body);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  fill: var(--accent-2);
}
.tree-svg .t-num { font: 500 13px var(--font-body); fill: var(--accent); font-variant-numeric: oldstyle-nums; }
.tree-svg .t-mark { font-size: 11px; fill: var(--accent-2); }

.tree-svg .person { cursor: pointer; outline: none; }
.tree-svg .person .hit { fill: transparent; stroke: none; }
.tree-svg .person:hover .hit { fill: color-mix(in srgb, var(--accent-3) 14%, transparent); }
.tree-svg .person:focus-visible .hit { stroke: var(--accent); stroke-width: 1.5; }
.tree-svg .person.is-selected .hit { fill: color-mix(in srgb, var(--accent) 12%, transparent); }
.tree-svg .person.is-selected text { fill: var(--accent); }
.tree-svg .person.is-uncertain text { font-style: italic; }

/* ---------- Outline ---------- */

.tree-outline {
  border: 1px solid var(--ink-soft);
  outline: 1px solid var(--rule);
  outline-offset: -7px;
  background: color-mix(in srgb, var(--paper) 55%, white);
  padding: var(--space-m) var(--space-m) var(--space-l);
  border-radius: var(--radius);
}
.tree-outline[hidden] { display: none; }

.outline-tree, .o-children { margin: 0; padding: 0; }
.outline-tree { list-style: none; }
.o-children {
  list-style: decimal;
  padding-left: 2.2em;
  margin-left: 0.4em;
  border-left: 1px solid var(--rule);
}
.o-children > li { padding-left: 0.2em; margin-block: 0.15em; }
.o-children > li::marker { color: var(--accent); font-size: var(--step--1); font-variant-numeric: oldstyle-nums; }
.outline-tree > li > .o-line .o-name { font-family: var(--font-display); font-size: var(--step-2); font-weight: 600; }
.outline-tree > li > .o-children > li > .o-line .o-name { font-family: var(--font-display); font-size: var(--step-1); font-weight: 600; }

.o-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.6em; }
.o-line--union { padding-left: 1em; }
.o-name {
  font: inherit;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0.1em 0;
  cursor: pointer;
  text-align: left;
}
.o-name:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 0.2em; }
.o-name.is-selected { color: var(--accent); }
.o-name.is-uncertain { font-style: italic; }
.o-mark { color: var(--accent-2); margin-left: 0.15em; }
.o-place {
  font-size: var(--step--1);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.o-spouse { color: var(--ink-soft); display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 0 0.4em; }
.o-spouse .o-name { color: var(--ink-soft); }
.o-union { color: var(--accent-2); font-size: var(--step--1); }

/* ---------- Person panel ---------- */

.person-panel {
  position: absolute;
  top: var(--space-s);
  right: var(--space-s);
  width: min(22rem, calc(100% - 2 * var(--space-s)));
  max-height: calc(100% - 2 * var(--space-s));
  overflow: auto;
  padding: var(--space-m);
  background: var(--paper);
  border: 1px solid var(--ink-soft);
  outline: 1px solid var(--rule);
  outline-offset: -6px;
  border-radius: var(--radius);
  box-shadow: 0 0.5rem 1.5rem color-mix(in srgb, var(--ink) 14%, transparent);
  z-index: 2;
}
.person-panel[hidden] { display: none; }
.panel-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  font: 400 1.6rem/1 var(--font-body);
  color: var(--ink-soft);
  background: none;
  border: 0;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
}
.panel-close:hover { color: var(--accent); }
.panel-title { font-size: var(--step-2); margin: 0.15em 0 var(--space-s); outline: none; padding-right: 2rem; }
.panel-facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35em var(--space-s); margin: 0; }
.panel-facts dt {
  font-size: var(--step--1);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 0.2em;
}
.panel-facts dd { margin: 0; }
.panel-link {
  font: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}
.panel-link:hover { color: var(--accent-2); }
.panel-note { font-style: italic; color: var(--ink-soft); }

/* In the outline view, or on small screens, the panel follows the content instead of floating. */
.tree-stage[hidden] ~ .person-panel,
.tree-outline:not([hidden]) ~ .person-panel { position: sticky; bottom: var(--space-s); top: auto; right: auto; margin: var(--space-s) 0 0 auto; max-height: 60vh; }

@media (max-width: 720px) {
  .person-panel { position: static; width: 100%; max-height: none; margin-top: var(--space-s); box-shadow: none; }
}

/* ---------- Notes / errors ---------- */

.tree-notes { margin-top: var(--space-l); }
.tree-notes p { margin-inline: auto; text-align: center; font-size: var(--step--1); font-style: italic; color: var(--ink-faint); }
.tree-error { text-align: center; font-style: italic; color: var(--accent-2); margin: var(--space-l) auto; }
