/*!
 * family-tree.css — styles for the D3 family tree
 * Dark by default; add data-theme="light" on any ancestor for the light palette.
 */

.ft-root {
  --ft-bg: #0f1420;
  --ft-surface: #182031;
  --ft-surface-2: #1e2739;
  --ft-border: #2b3549;
  --ft-text: #e8edf5;
  --ft-text-dim: #93a1b5;
  --ft-text-faint: #64718a;
  --ft-accent: #5b9cf8;
  --ft-link: #3d4a63;
  --ft-link-active: #6ea8ff;
  --ft-root-ring: #f5b942;
  --ft-shadow: rgba(0, 0, 0, 0.45);

  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 520px;
  background: var(--ft-bg);
  color: var(--ft-text);
  font-family: "Inter", "Segoe UI", "Noto Sans", system-ui, -apple-system, sans-serif;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--ft-border);
}

.ft-root[data-theme="light"],
[data-theme="light"] .ft-root {
  --ft-bg: #f6f8fc;
  --ft-surface: #ffffff;
  --ft-surface-2: #eef2f9;
  --ft-border: #d9e1ee;
  --ft-text: #16202f;
  --ft-text-dim: #56637a;
  --ft-text-faint: #8b97ac;
  --ft-link: #b9c5d8;
  --ft-link-active: #2f6fd0;
  --ft-shadow: rgba(24, 40, 72, 0.14);
}

/* ------------------------------- toolbar ------------------------------- */

.ft-toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: var(--ft-surface);
  border-bottom: 1px solid var(--ft-border);
  z-index: 3;
}

.ft-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ft-group.ft-actions {
  margin-left: auto;
  gap: 6px;
}

.ft-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ft-text-dim);
  white-space: nowrap;
}

.ft-field select {
  background: var(--ft-surface-2);
  color: var(--ft-text);
  border: 1px solid var(--ft-border);
  border-radius: 7px;
  padding: 4px 6px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.ft-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ft-text-dim);
  cursor: pointer;
  user-select: none;
}

.ft-check input {
  accent-color: var(--ft-accent);
  cursor: pointer;
}

.ft-actions button {
  min-width: 32px;
  height: 30px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--ft-border);
  background: var(--ft-surface-2);
  color: var(--ft-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.ft-actions button:hover {
  background: var(--ft-accent);
  border-color: var(--ft-accent);
  color: #fff;
}

.ft-actions button:active {
  transform: translateY(1px);
}

/* ------------------------------- search -------------------------------- */

.ft-search-wrap {
  position: relative;
  flex: 1 1 200px;
  max-width: 320px;
}

.ft-search {
  width: 100%;
  height: 30px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--ft-border);
  background: var(--ft-surface-2);
  color: var(--ft-text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.ft-search:focus {
  border-color: var(--ft-accent);
}

.ft-suggest {
  position: absolute;
  top: 36px;
  left: 0;
  right: 0;
  background: var(--ft-surface-2);
  border: 1px solid var(--ft-border);
  border-radius: 10px;
  box-shadow: 0 12px 28px var(--ft-shadow);
  overflow: hidden;
  z-index: 20;
  max-height: 260px;
  overflow-y: auto;
}

.ft-suggest button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--ft-border);
  color: var(--ft-text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.ft-suggest button:last-child {
  border-bottom: 0;
}

.ft-suggest button:hover {
  background: var(--ft-accent);
  color: #fff;
}

.ft-suggest-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--ft-text-faint);
}

/* -------------------------------- stage -------------------------------- */

.ft-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background-image:
    radial-gradient(circle at 1px 1px, var(--ft-border) 1px, transparent 0);
  background-size: 26px 26px;
}

.ft-svg {
  display: block;
  width: 100%;
  height: 100%;
  cursor: grab;
}

.ft-svg:active {
  cursor: grabbing;
}

/* -------------------------------- links -------------------------------- */

.ft-link {
  fill: none;
  stroke: var(--ft-link);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s, stroke-width 0.2s, opacity 0.2s;
}

.ft-link.is-active {
  stroke: var(--ft-link-active);
  stroke-width: 2.4;
}

.ft-link.is-dim {
  opacity: 0.25;
}

.ft-marriage {
  stroke: var(--ft-link);
  stroke-width: 1.8;
  stroke-dasharray: 5 4;
}

.ft-dot {
  fill: var(--ft-link);
}

.ft-link.is-active + .ft-dot,
.ft-dot.is-active {
  fill: var(--ft-link-active);
}

/* -------------------------------- nodes -------------------------------- */

.ft-node {
  cursor: pointer;
  transition: opacity 0.2s;
}

.ft-node.is-dim {
  opacity: 0.18;
}

.ft-node.is-hi .ft-card {
  stroke: var(--ft-accent);
  stroke-width: 1.6;
}

.ft-card {
  fill: var(--ft-surface);
  stroke: var(--ft-border);
  stroke-width: 1;
  transition: fill 0.2s, stroke 0.2s;
}

.ft-node:hover .ft-card {
  fill: var(--ft-surface-2);
  stroke: var(--ft-accent);
}

.ft-node.is-selected .ft-card {
  stroke: var(--ft-accent);
  stroke-width: 2;
}

.ft-root-ring {
  fill: none;
  stroke: var(--ft-root-ring);
  stroke-width: 1.6;
  stroke-dasharray: 4 3;
  opacity: 0.85;
}

.ft-name {
  fill: var(--ft-text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.ft-name-lc {
  fill: var(--ft-text-dim);
  font-size: 11px;
}

.ft-meta {
  fill: var(--ft-text-faint);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.ft-avatar-initials {
  font-size: 14px;
  font-weight: 700;
  pointer-events: none;
}

.ft-deceased-mark text {
  fill: var(--ft-text-faint);
  font-size: 12px;
}

.ft-node.is-deceased .ft-card {
  stroke-dasharray: 3 3;
}

/* ------------------------------- overlay ------------------------------- */

.ft-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: color-mix(in srgb, var(--ft-bg) 82%, transparent);
  color: var(--ft-text-dim);
  font-size: 13px;
  z-index: 8;
  backdrop-filter: blur(2px);
}

.ft-overlay[hidden] {
  display: none;
}

.ft-spinner {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2.5px solid var(--ft-border);
  border-top-color: var(--ft-accent);
  animation: ft-spin 0.75s linear infinite;
}

@keyframes ft-spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------- details panel ---------------------------- */

.ft-panel {
  position: absolute;
  top: 58px;
  right: 14px;
  bottom: 14px;
  width: 316px;
  padding: 16px;
  overflow-y: auto;
  background: var(--ft-surface);
  border: 1px solid var(--ft-border);
  border-radius: 14px;
  box-shadow: 0 18px 44px var(--ft-shadow);
  z-index: 6;
}

.ft-panel[hidden] {
  display: none;
}

.ft-panel-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
}

.ft-panel-avatar {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--ft-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  background: var(--ft-surface-2);
  overflow: hidden;
}

.ft-panel-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ft-panel-title h3 {
  margin: 0 0 2px;
  font-size: 15px;
  line-height: 1.25;
  color: var(--ft-text);
}

.ft-panel-lc {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--ft-text-dim);
}

.ft-tag {
  display: inline-block;
  padding: 1px 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 10px;
  text-transform: capitalize;
  letter-spacing: 0.04em;
}

.ft-panel-close {
  position: absolute;
  top: -6px;
  right: -4px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: var(--ft-surface-2);
  color: var(--ft-text-dim);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.ft-panel-close:hover {
  background: var(--ft-accent);
  color: #fff;
}

.ft-panel-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 16px 0 0;
  font-size: 12.5px;
}

.ft-panel-list dt {
  color: var(--ft-text-faint);
  white-space: nowrap;
}

.ft-panel-list dd {
  margin: 0;
  color: var(--ft-text);
}

.ft-panel-sub {
  margin: 18px 0 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ft-text-faint);
}

.ft-panel-bio {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--ft-text-dim);
}

.ft-panel-actions {
  margin-top: 18px;
}

.ft-btn-primary {
  width: 100%;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--ft-accent);
  background: var(--ft-accent);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.ft-btn-primary:hover {
  filter: brightness(1.1);
}

/* ------------------------------- responsive ---------------------------- */

@media (max-width: 720px) {
  .ft-toolbar {
    gap: 10px;
    padding: 8px 10px;
  }
  .ft-panel {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 8px;
    width: auto;
    max-height: 52%;
  }
  .ft-search-wrap {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }
}
