/* ================================================================
   Family tree — styles for the /family screen.

   Extracted from app.css so the tree layouts can evolve (radial today;
   more designs planned — see docs/plans/mobile-and-tree-designs.md)
   without churning the global stylesheet. Loaded via the `extra_head`
   block in family_tree.html only.
   ================================================================ */

/* ---------------- design 1b — radial, you at centre ---------------- */

.tree-head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.tree-head .muted {
  margin-left: auto;
}

/* view switcher — vertical tree / graph */
.tree-tabs {
  display: inline-flex;
  gap: 0.15rem;
  margin-bottom: 0.9rem;
  padding: 0.2rem;
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.tree-tab {
  padding: 0.45rem 0.9rem;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.92rem;
  text-decoration: none;
  color: var(--ink-soft);
}
.tree-tab:hover {
  color: var(--ink);
}
.tree-tab.is-active {
  background: var(--accent);
  color: #fff;
}

.tree-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
/* The viewport is the fixed window; the stage inside it is what pans and
   zooms (one transform moves the SVG and the .ft-node layer together). */
.tree-viewport {
  position: relative;
  overflow: hidden;
  touch-action: none;
  border-radius: var(--radius-sm);
  cursor: grab;
}
.tree-viewport.is-panning {
  cursor: grabbing;
}

.tree-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 72vh;
  transform-origin: 0 0;
  will-change: transform;
}
/* only the button/reset zoom animates; drag + wheel update live */
.tree-stage.is-animating {
  transition: transform 0.18s ease-out;
}
/* the genealogical tree needs more room along the generation axis; pan/zoom
   covers whatever still doesn't fit */
.tree-stage--vertical {
  aspect-ratio: 3 / 4;
  max-height: 82vh;
}

.tree-zoom {
  position: absolute;
  right: 0.6rem;
  bottom: 0.6rem;
  display: flex;
  gap: 0.15rem;
  padding: 0.2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow);
  z-index: 6;
}
.tree-zoom-btn {
  min-height: 40px;
  min-width: 40px;
  padding: 0 0.55rem;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--ink);
  font: 600 1.15rem var(--font-body);
  line-height: 1;
  cursor: pointer;
}
.tree-zoom-btn:hover {
  background: var(--surface-sunken);
}
.tree-zoom-reset {
  font-size: 0.9rem;
}
.tree-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.tree-ring {
  fill: none;
  stroke: rgba(36, 28, 22, 0.06);
  stroke-width: 1;
}
.tree-edge {
  fill: none;
  stroke: var(--border-strong);
  stroke-width: 2;
  pointer-events: none;
  transition: stroke 0.15s, stroke-width 0.15s;
}
.tree-edge.is-hot {
  stroke: var(--accent);
  stroke-width: 3;
}
/* the chain from a selected person back to you */
.tree-edge.is-path {
  stroke: var(--accent);
  stroke-width: 3.5;
}
/* invisible fat path sitting under each edge, just to catch the hover */
.ft-edge-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 7;
  pointer-events: stroke;
  cursor: default;
}

.ft-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  width: 96px;
  padding: 0;
  /* the global `button` rule paints an accent pill on hover/active — this is
     a bare face + name, so hold every one of those properties down */
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
  min-height: 0;
}
.ft-node:hover,
.ft-node:active,
.ft-node:focus {
  background: none;
}
.ft-node .mini-avatar {
  width: 56px;
  height: 56px;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow);
}
.ft-node.is-you .mini-avatar {
  width: 78px;
  height: 78px;
  border: 3px solid var(--accent);
}
/* one-shot pulse when the fitted overview first paints, so the eye finds the
   anchor; JS adds .is-spotlight for ~1.6s (see fitToTree / spotlightYou). */
@keyframes ft-you-spotlight {
  0% {
    box-shadow: 0 0 0 0 rgba(63, 107, 84, 0.55);
  }
  70% {
    box-shadow: 0 0 0 22px rgba(63, 107, 84, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(63, 107, 84, 0);
  }
}
.ft-node.is-you.is-spotlight .mini-avatar {
  animation: ft-you-spotlight 1.5s ease-out;
}
.ft-node-name {
  font-family: var(--font-head);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  line-height: 1.15;
  max-width: 96px;
  padding: 0.05rem 0.4rem;
  border-radius: var(--radius-sm);
  transition: background 0.12s, color 0.12s;
}
/* hover / selection highlight the name only, not the whole face */
.ft-node:hover .ft-node-name {
  background: var(--tint);
}
.ft-node.is-selected .ft-node-name {
  background: var(--accent);
  color: #fff;
}
/* the selected face gives a quick pop so the eye registers the change */
@keyframes ft-node-pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}
.ft-node.is-selected .mini-avatar {
  animation: ft-node-pop 0.3s ease-out;
}

.ft-edge-label {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--ground-deep);
  color: var(--on-ground);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  pointer-events: none;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 5;
}
.ft-edge-label.is-shown {
  opacity: 1;
}

.ft-detail {
  margin-top: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.15rem 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  min-height: 92px;
}
.ft-detail .mini-avatar {
  width: 56px;
  height: 56px;
}
.ft-detail-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  flex: 1;
  min-width: 180px;
}
.ft-detail-name {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 600;
}
.ft-detail-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.ft-detail.is-empty .ft-detail-body {
  color: var(--ink-soft);
}
/* one-shot flash when a new person lands in the strip */
@keyframes ft-detail-flash {
  0% {
    border-color: var(--accent);
    background: var(--tint);
  }
  100% {
    border-color: var(--border);
    background: var(--surface);
  }
}
.ft-detail.just-updated {
  animation: ft-detail-flash 0.7s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .ft-detail.just-updated,
  .ft-node.is-selected .mini-avatar,
  .ft-node.is-you.is-spotlight .mini-avatar {
    animation: none;
  }
}

/* .ft-family-picker lives in app.css — the traditions page reuses it. */
.ft-hint {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  text-align: center;
}
.ft-actions {
  margin-top: 1rem;
}

@media (max-width: 700px) {
  .ft-node {
    width: 74px;
  }
  .ft-node-name {
    font-size: 0.78rem;
    max-width: 74px;
  }
  .ft-node .mini-avatar {
    width: 46px;
    height: 46px;
  }
  .ft-node.is-you .mini-avatar {
    width: 60px;
    height: 60px;
  }
}
