/* Make the whole page a vertical flex layout */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    display: flex;
    flex-direction: column;
    overflow: hidden; /* prevent double scrollbars */
}

/* Header takes only the space it needs */
header {
    flex: 0 0 auto;
    padding: 1rem;
    background: white;
    border-bottom: 1px solid #ccc;
}

/* Tree canvas fills the remaining space */
#tree-canvas {
    flex: 1 1 auto;
    position: relative;
    overflow: auto; /* internal scrolling */
    /* background-color: black; */
}

/* Orbit layer covers the canvas */
#orbit-layer {
    position: relative;
    inset: 0; /* left:0; right:0; top:0; bottom:0 */
    pointer-events: none;
    /* background-color: blue; */
    /* height: 100%; */
}

#lineage-stack {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center; /* center horizontally */
    gap: 2rem;           /* vertical spacing */
    margin-top: 2rem;
    z-index: 1;
    /* background-color: cyan; */
}

#root-ancestors {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;   /* center the whole row */
    gap: 2rem;                 /* spacing between root ancestors */
    padding-top: 1rem;         /* small top margin */
    z-index: 1;                /* above background, below orbit */
    /* background-color: yellow; */
}

#orbit-layer .person {
    pointer-events: auto;
}

#orbit-layer .person[data-state="expanded"] {
    pointer-events: auto;
}


.person {
    cursor: pointer;
    /* transition: all 0.2s ease; */
}

.person[data-state="hidden"] {
    display: none;
}

.person[data-state="visible"] {
    display: flex;               /* enables centering */
    justify-content: center;     /* horizontal center */
    align-items: center;         /* vertical center */
    
    opacity: 0.9;
    border: 1px solid black;
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
        
    text-align: center;          /* center multi-line text */
    padding: 0.5rem;             /* optional: prevents text touching edges */
}


.person[data-state="expanded"] {
    position: absolute;
    /* transition: none;
    transform: translate(-50%, 0%); */
    display: block !important;
    width: auto !important;
    height: auto !important;
    border-radius: 10px !important;

    border: 1px solid black;
    padding: .5rem;
    margin: .5rem;
    max-width: 14rem;
    background: white;
}


.person[data-state="expanded"] .person-name {
    grid-column: 1 / -1;
    font-weight: bold;
    font-size: 1.2em;
    text-align: left;
    margin-bottom: 0.5rem;
}

.person[data-state="expanded"] .detail-row {
    display: grid;
    grid-template-columns: 4rem 1fr; /* label | value */
    column-gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.person[data-state="expanded"] .detail-label {
    font-weight: bold;
    text-align: right;
}

.person[data-state="expanded"] .detail-value {
    text-align: left;
}

.person[data-state="visible"] .person-expanded {
    display: none;
}

#orbit-layer .person[data-state="visible"] {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;

    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    border: 1px solid black;
    background: white;
    opacity: 0.9;
}

/* #orbit-layer .person[data-state="visible"] {
    position: absolute;
    display: flex;
    justify-content: center;
    align-items: center;

    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    border: 1px solid black;
    background: white;
    opacity: 0.9;
} */

#debug-controls {
    margin-top: 0.5rem;
    display: flex;
    display: none;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

#orbit-offset {
    width: 200px;
}
