/* Tree canvas. Colours come from the tokens in app.css ("R G B" triplets), so dark mode needs no extra rules. */

/* ── Viewport & canvas ── */
#tree-viewport {
  overflow: hidden;   /* positioned (absolute inset-0) by the template */
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  background-color: rgb(var(--paper));
}
#tree-viewport:active { cursor: grabbing; }
#tree-canvas {
  position: absolute;
  transform-origin: 0 0;
  will-change: transform;
}

/* ── Person cards (186 × 72, see CW/CH in tree-core.js) ── */
.person-card {
  position: absolute;
  width: 186px;
  height: 72px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 0 10px;
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--n-200));
  border-radius: 14px;
  box-shadow: 0 1px 2px rgb(var(--shadow) / 0.07);
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s, border-color 0.15s;
}
.person-card:hover {
  border-color: rgb(var(--n-300));
  box-shadow: 0 10px 22px -10px rgb(var(--shadow) / 0.3);
  transform: translateY(-1px);
  z-index: 10;
}

.card-photo,
.card-monogram {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgb(var(--surface)), 0 0 0 3.5px rgb(var(--n-300));
}
.card-photo { object-fit: cover; }
.card-monogram {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(var(--n-100));
  color: rgb(var(--n-500));
  font-family: Fraunces, Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
.person-card.male .card-photo,
.person-card.male .card-monogram { box-shadow: 0 0 0 2px rgb(var(--surface)), 0 0 0 3.5px rgb(var(--male) / 0.8); }
.person-card.female .card-photo,
.person-card.female .card-monogram { box-shadow: 0 0 0 2px rgb(var(--surface)), 0 0 0 3.5px rgb(var(--female) / 0.8); }
.person-card.male .card-monogram { background: rgb(var(--male) / 0.12); color: rgb(var(--male)); }
.person-card.female .card-monogram { background: rgb(var(--female) / 0.12); color: rgb(var(--female)); }

.card-text { min-width: 0; flex: 1; }
.card-name,
.card-dates,
.card-place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-name { font-size: 13px; font-weight: 600; line-height: 1.3; color: rgb(var(--n-900)); }
.card-dates { font-size: 11px; line-height: 1.35; color: rgb(var(--n-500)); font-variant-numeric: tabular-nums; }
.card-place { font-size: 10.5px; line-height: 1.35; color: rgb(var(--n-400)); }

.person-card.highlight {
  border-color: rgb(var(--brass));
  box-shadow: 0 0 0 3px rgb(var(--brass) / 0.45), 0 10px 22px -10px rgb(var(--brass) / 0.5);
  animation: pulse-highlight 2.4s ease-out forwards;
  z-index: 15;
}
@keyframes pulse-highlight {
  0% { box-shadow: 0 0 0 6px rgb(var(--brass) / 0.55), 0 0 26px rgb(var(--brass) / 0.5); }
  100% { box-shadow: 0 0 0 3px rgb(var(--brass) / 0.45), 0 10px 22px -10px rgb(var(--brass) / 0.5); }
}

/* ── Connectors ── */
#lines-layer { position: absolute; top: 0; left: 0; pointer-events: none; overflow: visible; }
.connector { fill: none; stroke: rgb(var(--n-300)); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.marriage-line { stroke: rgb(var(--brass)); stroke-width: 1.5; }
.column-bridge { stroke: rgb(var(--brass)); stroke-width: 1.5; stroke-dasharray: 2 6; stroke-linecap: round; }

/* relationship path */
.path-highlight {
  stroke: rgb(var(--brass));
  stroke-width: 3;
  stroke-dasharray: 8 4;
  animation: path-pulse 1.5s ease-in-out infinite;
}
@keyframes path-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.person-card.on-path {
  border-color: rgb(var(--brass));
  box-shadow: 0 0 0 3px rgb(var(--brass) / 0.55), 0 8px 18px -8px rgb(var(--brass) / 0.5) !important;
  z-index: 12;
}

/* ── Expand / collapse ── */
.expand-btn {
  position: absolute;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgb(var(--surface));
  border: 1.5px solid rgb(var(--n-300));
  color: rgb(var(--n-600));
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
  transition: transform 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
}
.expand-btn:hover {
  background: rgb(var(--a-solid-600));
  border-color: rgb(var(--a-solid-600));
  color: #fff;
  transform: scale(1.12);
}
.expand-up-btn { font-size: 9px; }
.expand-count {
  position: absolute;
  top: -9px;
  right: -12px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgb(var(--a-solid-600));
  border: 2px solid rgb(var(--paper));
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  pointer-events: none;
}

/* ── Year ruler on the left ── */
.timeline {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 64px;
  z-index: 15;
  pointer-events: none;
  overflow: hidden;
  background: linear-gradient(to right, rgb(var(--paper)) 55%, transparent);
}
.timeline-marker { position: absolute; left: 0; width: 100%; display: flex; align-items: center; gap: 6px; }
.timeline-label {
  padding-left: 14px;
  font-family: Fraunces, Georgia, serif;
  font-size: 12px;
  font-weight: 600;
  color: rgb(var(--n-400));
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.timeline-line { flex: 1; height: 1px; background: rgb(var(--n-300)); opacity: 0.7; }

/* ── Family columns ── */
.bridge-label { position: absolute; font-size: 18px; color: rgb(var(--brass)); z-index: 5; pointer-events: none; }
.column-header {
  position: absolute;
  transform: translateX(-50%);
  font-family: Fraunces, Georgia, serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: rgb(var(--n-400));
  white-space: nowrap;
  pointer-events: none;
}

/* ── Side panel ── */
.side-panel { transform: translateX(100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
.side-panel.open { transform: translateX(0); }
.breadcrumb-item { transition: color 0.15s; }
.breadcrumb-item:hover { color: rgb(var(--a-600)); }

/* ── Mobile ── */
@media (max-width: 640px) {
  .expand-btn { width: 32px; height: 32px; font-size: 19px; }
  .expand-count { top: -7px; right: -9px; min-width: 20px; height: 20px; font-size: 10px; }
  .timeline { display: none; }
}

/* ── Print ── */
@media print {
  .side-panel, #overlay, #loading, .timeline, .tree-toolbar, .tree-controls,
  .expand-btn, #searchResults { display: none !important; }
  #tree-viewport {
    position: static !important;
    height: auto !important;
    overflow: visible !important;
    border: none !important;
    background: #fff !important;
  }
  #tree-canvas { position: static !important; transform: none !important; }
  .person-card { break-inside: avoid; box-shadow: none !important; border: 1px solid #bbb !important; }
  .person-card.highlight { animation: none !important; }
}
