/* Kinfoly — the family tree canvas (kinfoly-tree.js), shared by the account's
   /Tree and the public GEDCOM viewer. Only what the canvas draws lives here: the
   size and frame of the canvas are each page's own (site.css for /Tree,
   gedcom-viewer.css for the viewer), and so is anything that only one page puts
   on it, like the assistant's panel. Colours are the --kf-* tokens: site.css
   defines them for the app, gedcom-viewer.css maps its own onto them. */

.kt-canvas {
    position: relative;
    /* clip, not hidden: `hidden` is still a scroll container, and focusing the chat
       input while the panel was mid-slide scrolled the canvas sideways, taking the
       editor and everything else absolutely placed in it along. `hidden` first, for
       browsers that do not know `clip`. */
    overflow: hidden;
    overflow: clip;
    cursor: grab;
    touch-action: none;
    /* Dragging the canvas must pan it, not sweep a text selection across the
       marriage labels, the zoom chip and everything else drawn on it. */
    -webkit-user-select: none; user-select: none;
    /* The layout counts on a card of a set height, and the lines inside it are
       what make that height: the app's body gives 1.5 anyway, a page without
       Bootstrap would give its own */
    line-height: 1.5;
    background-color: var(--kf-app-bg);
    background-image: radial-gradient(var(--kf-border) 1.5px, transparent 1.5px);
    background-size: 20px 20px;
}
.kt-canvas.panning { cursor: grabbing; }
/* The bar, the hover card and the finder hide with the `hidden` attribute, which a
   display: flex of their own would override. Bootstrap's reboot sees to it on /Tree;
   a page without Bootstrap needs it said here. */
.kt-canvas [hidden] { display: none !important; }
/* ...but a person's details are there to be copied. */
.kt-canvas .kt-tip { -webkit-user-select: text; user-select: text; }
.kt-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.kt-world.animate { transition: transform 250ms ease; }
/* While a hand is on it the tree is its own layer: moving a few hundred cards a
   frame is work for the compositor rather than the painter. */
.kt-canvas.panning .kt-world { will-change: transform; }
.kt-connectors { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.kt-connectors path { fill: none; stroke: var(--kf-border-strong); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.kt-connectors path.sel { stroke: var(--kf-accent); }

.kt-node {
    position: absolute; width: 180px;
    /* A double click opens the editor; without this it also selects the name */
    -webkit-user-select: none; user-select: none;
    background: var(--kf-panel);
    border: 1px solid var(--kf-border);
    border-radius: 10px; padding: 10px 12px;
    cursor: pointer; overflow: visible;
    transition: border-color 120ms ease, box-shadow 120ms ease;
}
.kt-node:hover { border-color: var(--kf-border-strong); background: var(--kf-rail); }
.kt-node.sel { border-color: var(--kf-accent); box-shadow: 0 0 0 3px var(--kf-accent-soft); }

/* Someone just added: rises into place, then one soft ring of the accent spreads out.
   The delays are set per card by kinfoly-tree.js, so several arrive one by one. */
.kt-node--new {
    border-color: var(--kf-accent);
    animation:
        kt-node-appear 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both,
        kt-node-ring 1400ms ease-out both;
}
@keyframes kt-node-appear {
    0%   { opacity: 0; transform: translateY(10px) scale(0.9); }
    70%  { opacity: 1; transform: translateY(0) scale(1.03); }
    100% { opacity: 1; transform: none; }
}
@keyframes kt-node-ring {
    0%   { box-shadow: 0 0 0 0 rgba(110, 139, 94, 0.45); }
    100% { box-shadow: 0 0 0 14px rgba(110, 139, 94, 0); }
}
/* Someone the assistant was asked to find: three soft blinks once the canvas has
   arrived at them (the pan takes 250ms) */
.kt-node--found { animation: kt-node-blink 700ms ease-in-out 280ms 3; }
@keyframes kt-node-blink {
    0%, 100% { background: var(--kf-panel); box-shadow: 0 0 0 3px var(--kf-accent-soft); }
    50%      { background: var(--kf-accent-soft); border-color: var(--kf-accent); box-shadow: 0 0 0 9px rgba(110, 139, 94, 0.30); }
}

/* Lines and marriage years, drawn for the new places once the cards have got there */
.kt-fade-in { animation: kt-fade-in 320ms ease both; }
@keyframes kt-fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
    .kt-node--new, .kt-node--found, .kt-fade-in { animation: none; }
}
.kt-node-row { display: flex; align-items: center; gap: 9px; }
.kt-node-info { min-width: 0; }
.kt-node-name { font-size: 13px; font-weight: 600; color: var(--kf-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kt-node-name.unknown { color: var(--kf-text3); font-style: italic; }
.kt-node-years { font-size: 11px; color: var(--kf-text3); font-variant-numeric: tabular-nums; margin-top: 1px; min-height: 14px; }

/* Also the face beside a name on the app's other pages — the lists, the person page */
.kt-avatar {
    border-radius: 50%; font-weight: 600; flex: none;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.kt-avatar img { width: 100%; height: 100%; object-fit: cover; }
.kt-avatar.f { background: #E7EFE0; color: #4F6B41; }
.kt-avatar.m { background: #E2EBE6; color: #3E5A4C; }
.kt-avatar.u { background: var(--kf-chip); color: var(--kf-text3); }
.kt-avatar-26 { width: 26px; height: 26px; font-size: 11px; }
.kt-avatar-22 { width: 22px; height: 22px; font-size: 10px; }
.kt-avatar-40 { width: 40px; height: 40px; font-size: 14px; }
.kt-avatar-48 { width: 48px; height: 48px; font-size: 16px; }
.kt-avatar-60 { width: 60px; height: 60px; font-size: 19px; }

.kt-marr-label {
    position: absolute; transform: translate(-50%, -50%);
    background: var(--kf-panel); border: 1px solid var(--kf-border);
    border-radius: 999px; padding: 1px 7px; font-size: 11px;
    color: var(--kf-text3); white-space: nowrap; z-index: 2;
    cursor: pointer;
}
.kt-marr-label:hover { border-color: var(--kf-accent); color: var(--kf-accent-text); }
/* A couple whose wedding has no date yet: still a way in, but not a claim */
.kt-marr-label--undated { opacity: .45; }
.kt-marr-label--undated:hover { opacity: 1; }
/* On a canvas that only reads, the chip is the year and nothing to press */
.kt-marr-label--static { cursor: default; }
.kt-marr-label--static:hover { border-color: var(--kf-border); color: var(--kf-text3); }
.kt-marr-label--static.kt-marr-label--undated:hover { opacity: .45; }

/* Branch collapse/expand toggles on card edges */
.kt-toggle {
    position: absolute; left: 50%; transform: translateX(-50%);
    min-width: 18px; height: 18px; padding: 0 4px;
    background: var(--kf-panel); border: 1px solid var(--kf-border-strong);
    border-radius: 999px; color: var(--kf-text2);
    font-size: 11px; font-weight: 600; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0; z-index: 3;
    transition: opacity 120ms ease;
}
.kt-toggle-up { top: -9px; }
.kt-toggle-down { bottom: -9px; }
.kt-node:hover .kt-toggle, .kt-toggle.on { opacity: 1; }
.kt-toggle:hover { background: var(--kf-hover); color: var(--kf-text); border-color: var(--kf-accent); }
.kt-toggle.on { background: var(--kf-accent-soft); color: var(--kf-accent-text); border-color: var(--kf-accent); }
@media (hover: none) { .kt-toggle { opacity: .85; } }
/* An 18px circle is too small for a finger. On a touch screen the toggle answers in a
   band around it that reaches mostly away from the card, so a tap on the card's own
   edge still opens the person. */
@media (pointer: coarse) {
    .kt-toggle::before { content: ''; position: absolute; left: -12px; right: -12px; }
    .kt-toggle-down::before { top: -4px; bottom: -14px; }
    .kt-toggle-up::before { top: -14px; bottom: -4px; }
}

/* Add a relative: a filled disc, so it is not taken for the outlined ± of a branch.
   It shows with the pointer on the card and stays on the selected one, which is where
   the eye already is. The top right corner is the one nothing else wants: the ± sit
   mid-edge and a marriage chip hangs between a couple's bottom corners. Partners
   stand 10px apart, which is all it may reach past the card. */
.kt-add {
    position: absolute; right: -8px; top: -10px;
    width: 20px; height: 20px; padding: 0;
    background: var(--kf-accent); border: 2px solid var(--kf-panel);
    border-radius: 50%; color: var(--kf-panel);
    font-size: 15px; line-height: 1; box-sizing: content-box;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; opacity: 0; transform: scale(0.8); z-index: 4;
    transition: opacity 150ms ease, transform 150ms ease, background 150ms ease;
}
.kt-node:hover .kt-add, .kt-node.sel .kt-add, .kt-add.on, .kt-add:focus-visible { opacity: 1; transform: none; }
.kt-node .kt-add:hover, .kt-node .kt-add.on { background: var(--kf-accent-hover, var(--kf-accent)); transform: scale(1.1); }
.kt-add:focus-visible { outline: 2px solid var(--kf-accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .kt-add { transition: none; } }
/* That corner already carries the dot of a message waiting; the `+` takes the other */
.kt-node:has(.kt-node-told) .kt-add { right: auto; left: -8px; }

.kt-add-menu {
    position: absolute; z-index: 26; min-width: 168px; padding: 5px;
    background: var(--kf-panel); border: 1px solid var(--kf-border);
    border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    animation: kt-tip-in 120ms ease;
}
.kt-add-head {
    padding: 4px 9px 5px; font-size: 11px; color: var(--kf-text3);
    max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kt-add-item {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 7px 9px; border: none; border-radius: 7px; background: none;
    font-size: 13px; color: var(--kf-text); text-align: left; cursor: pointer;
}
.kt-add-item i { font-size: 13px; color: var(--kf-text3); }
.kt-add-item:hover, .kt-add-item:focus-visible { background: var(--kf-hover); outline: none; }
.kt-add-item:hover i, .kt-add-item:focus-visible i { color: var(--kf-accent-text); }

.kt-canvas-controls {
    position: absolute; right: 16px; bottom: 16px;
    display: flex; flex-direction: column; gap: 6px; z-index: 10;
    transition: right 200ms ease;
}
.kt-canvas-controls.shifted { right: 336px; }
.kt-ctl {
    width: 36px; height: 36px;
    background: var(--kf-panel); border: 1px solid var(--kf-border);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--kf-text2); font-size: 13px;
}
.kt-ctl:hover { background: var(--kf-hover); color: var(--kf-text); }
.kt-zoom-chip {
    position: absolute; left: 12px; bottom: 16px;
    background: var(--kf-panel); border: 1px solid var(--kf-border);
    border-radius: 6px; padding: 4px 9px; font-size: 11px;
    color: var(--kf-text2); z-index: 10;
}

/* The map in the zoom chip's corner: the whole tree, and a frame around what is on
   screen. Up while the view moves and a moment after (kinfoly-tree.js), and out of
   the pointer's way the rest of the time. One thing stands in that corner at a time:
   the chip steps aside while the map is up, and comes back when it goes. */
.kt-zoom-chip { transition: opacity 120ms ease; }
.kt-zoom-chip.away { opacity: 0; }
.kt-minimap svg { cursor: pointer; }
.kt-minimap {
    position: absolute; left: 12px; bottom: 16px; z-index: 10;
    padding: 6px; background: var(--kf-panel); border: 1px solid var(--kf-border);
    border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    touch-action: none;
    opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity 220ms ease, visibility 0s linear 220ms;
}
.kt-minimap.on { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity 120ms ease; }
.kt-minimap svg { display: block; overflow: hidden; }
.kt-minimap-lines { fill: none; stroke: var(--kf-border-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
/* The stroke keeps a card of a tree of thousands from thinning to nothing */
.kt-minimap-cards { fill: var(--kf-text3); stroke: var(--kf-text3); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .75; }
.kt-minimap-frame {
    fill: var(--kf-accent); fill-opacity: .16;
    stroke: var(--kf-accent); stroke-width: 1.5; vector-effect: non-scaling-stroke;
}
@media (prefers-reduced-motion: reduce) { .kt-minimap, .kt-minimap.on, .kt-zoom-chip { transition: none; } }

/* The focused view's bar. On the canvas only while one person's line is on
   screen, so the whole tree keeps the canvas it had. */
.kt-focus-bar {
    position: absolute; left: 12px; top: 12px; z-index: 12;
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
    max-width: calc(100% - 24px);
    background: var(--kf-panel); border: 1px solid var(--kf-border);
    border-radius: 10px; padding: 5px 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}
.kt-focus-name {
    border: 0; background: none; padding: 0; cursor: pointer;
    font-size: 12.5px; font-weight: 600; color: var(--kf-text);
    max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kt-focus-name:hover { color: var(--kf-accent-text); }
.kt-focus-modes { display: flex; border: 1px solid var(--kf-border); border-radius: 8px; overflow: hidden; }
.kt-focus-mode {
    border: 0; border-right: 1px solid var(--kf-border); background: none;
    padding: 4px 9px; font-size: 12px; line-height: 1.2; white-space: nowrap;
    color: var(--kf-text2); cursor: pointer;
}
.kt-focus-mode:last-child { border-right: 0; }
.kt-focus-mode:hover { background: var(--kf-hover); color: var(--kf-text); }
.kt-focus-mode.on { background: var(--kf-accent-soft); color: var(--kf-accent-text); font-weight: 600; }
.kt-focus-step { display: flex; align-items: center; gap: 3px; font-size: 12px; color: var(--kf-text3); }
.kt-focus-step b { min-width: 24px; text-align: center; font-weight: 600; color: var(--kf-text); }
.kt-focus-pm, .kt-focus-close {
    display: flex; align-items: center; justify-content: center; flex: none;
    border: 1px solid var(--kf-border); border-radius: 6px; background: none;
    color: var(--kf-text2); cursor: pointer; line-height: 1;
}
.kt-focus-pm { width: 20px; height: 20px; font-size: 12px; }
.kt-focus-close { width: 26px; height: 26px; font-size: 11px; }
.kt-focus-pm:hover, .kt-focus-close:hover {
    background: var(--kf-accent-soft); border-color: var(--kf-accent); color: var(--kf-accent-text);
}
.kt-focus-count { font-size: 11px; color: var(--kf-text3); white-space: nowrap; }
.kt-focus-pill {
    border: 1px solid var(--kf-border); border-radius: 8px; background: none;
    color: var(--kf-text2); font-size: 12px; line-height: 1.2; padding: 4px 9px;
    white-space: nowrap; cursor: pointer;
}
.kt-focus-pill:hover { background: var(--kf-hover); color: var(--kf-text); }
.kt-focus-pill.on { background: var(--kf-accent-soft); color: var(--kf-accent-text); border-color: var(--kf-accent); font-weight: 600; }

/* Finding a person by name: a box over the canvas, not a field taking up room on
   it. Opens on the magnifier or `/`, closes on Escape or a click outside. */
.kt-find {
    position: absolute; z-index: 30; top: 18%; left: 50%; transform: translateX(-50%);
    width: 340px; max-width: calc(100% - 24px);
    background: var(--kf-panel); border: 1px solid var(--kf-border);
    border-radius: 12px; padding: 8px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
}
.kt-find-input {
    width: 100%; border: 1px solid var(--kf-border); border-radius: 8px;
    background: var(--kf-app-bg); color: var(--kf-text);
    font-size: 13px; padding: 7px 10px; outline: none;
}
.kt-find-input:focus { border-color: var(--kf-accent); }
.kt-find-list { max-height: 260px; overflow-y: auto; margin-top: 6px; }
.kt-find-note { font-size: 11.5px; color: var(--kf-text3); padding: 6px 8px; }
.kt-find-row {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    width: 100%; text-align: left; border: 0; background: none;
    border-radius: 8px; padding: 6px 8px; cursor: pointer;
}
.kt-find-row:hover, .kt-find-row.on { background: var(--kf-hover); }
.kt-find-name { font-size: 13px; font-weight: 600; color: var(--kf-text); }
.kt-find-name.unknown { color: var(--kf-text3); font-style: italic; }
.kt-find-note-inline { font-size: 11px; color: var(--kf-text3); }
@media (max-width: 767px) {
    .kt-find { top: 10px; left: 8px; right: 8px; width: auto; transform: none; max-width: none; }
}

.kt-focus-select {
    border: 1px solid var(--kf-border); border-radius: 8px; background: var(--kf-panel);
    color: var(--kf-text); font-size: 12px; font-weight: 600; padding: 4px 6px; max-width: 130px;
}
.kt-tip-focus.on { background: var(--kf-accent-soft); border-color: var(--kf-accent); color: var(--kf-accent-text); }
/* A phone gives the bar two rows whatever is done to it, so the job is to keep
   those two rows short: the canvas underneath is the point of the screen */
@media (max-width: 767px) {
    .kt-focus-bar { left: 8px; top: 8px; right: 8px; max-width: none; gap: 5px 6px; padding: 4px 6px; }
    .kt-focus-count { display: none; }
    .kt-focus-name { max-width: 110px; }
    .kt-focus-bar .kt-avatar-26 { width: 22px; height: 22px; font-size: 10px; }
    .kt-focus-select, .kt-focus-pill { padding: 3px 6px; }
    .kt-focus-pm { width: 18px; height: 18px; }
    .kt-focus-close { width: 22px; height: 22px; }
    .kt-focus-step { gap: 2px; }
    .kt-focus-step b { min-width: 18px; }
}

/* Hover card: what a person's card has no room for, shown beside it while the
   pointer rests there. It carries a pencil, so it does take the pointer — moving
   onto it keeps it open, moving off it closes it. */
/* Three buttons now, so the name keeps the column it had before the third one */
.kt-tip {
    position: absolute; z-index: 25; width: 290px;
    background: var(--kf-panel); border: 1px solid var(--kf-border);
    border-radius: 10px; padding: 10px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    animation: kt-tip-in 120ms ease;
}
@keyframes kt-tip-in { from { opacity: 0; transform: translateY(2px); } }

/* Where there is a photo it takes the top of the card, edge to edge — the
   negative margins undo the card's own padding. Faces sit above the middle of a
   picture, so a crop that has to lose something loses it from the bottom. The
   height gives way on a short window rather than pushing the facts off screen. */
.kt-tip-photo {
    margin: -10px -12px 10px; height: min(180px, 26vh); overflow: hidden;
    background: var(--kf-chip); border-radius: 9px 9px 0 0;
}
.kt-tip-photo img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: 50% 25%; }
.kt-tip--photo .kt-tip-name { font-size: 14px; }

.kt-tip-head { display: flex; align-items: center; gap: 9px; }
.kt-tip-head-mid { min-width: 0; flex: 1; }
.kt-tip-edit {
    width: 26px; height: 26px; border-radius: 7px; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: none; border: 1px solid var(--kf-border);
    color: var(--kf-text3); cursor: pointer; font-size: 12px;
}
.kt-tip-edit:hover { background: var(--kf-accent-soft); border-color: var(--kf-accent); color: var(--kf-accent-text); }
.kt-tip-delete { margin-left: -3px; }
.kt-tip-delete:hover { background: var(--kf-danger-soft, #FBEFE9); border-color: var(--kf-danger, #B4552F); color: var(--kf-danger, #B4552F); }

/* A deleted person's card, on its way out before the tree closes up */
.kt-node--leaving { animation: kt-node-leave 220ms ease forwards; pointer-events: none; }
@keyframes kt-node-leave { to { opacity: 0; transform: scale(0.9); } }
@media (prefers-reduced-motion: reduce) { .kt-node--leaving { animation: none; } }
.kt-tip-name { font-size: 13px; font-weight: 700; color: var(--kf-text); line-height: 1.25; overflow-wrap: break-word; }
.kt-tip-name.unknown { color: var(--kf-text3); font-style: italic; }
.kt-tip-sub { font-size: 11px; color: var(--kf-text3); margin-top: 1px; }
.kt-tip-facts {
    margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--kf-border);
    display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 11.5px;
}
.kt-tip-k { color: var(--kf-text3); white-space: nowrap; }
.kt-tip-v { color: var(--kf-text2); overflow-wrap: break-word; }
.kt-tip-empty { margin-top: 8px; font-size: 11.5px; color: var(--kf-text3); }
@media (hover: none) { .kt-tip { display: none; } }

/* Cards are narrower on a phone; kinfoly-tree.js lays them out at the same width */
@media (max-width: 767px) {
    .kt-node { width: 150px; padding: 8px 10px; }
}

/* A relative has written about this person and the owner has not dealt with it yet.
   A dot, not a count: what was said is on their page, and the tree is for reading
   the family, not the post. It goes out when the message is ticked off. */
.kt-node-told {
    position: absolute; top: -4px; right: -4px; width: 10px; height: 10px;
    border-radius: 50%; background: var(--kf-accent);
    border: 2px solid var(--kf-panel); box-sizing: content-box;
}
