.pedigree-viewer {
    margin-block: 24px;
}

.hanssens-tree-page .pedigree-viewer {
    width: min(1120px, calc(100vw - 64px));
    margin-left: 50%;
    transform: translateX(-50%);
}

.pedigree-viewer .pedigree-image-shell {
    position: relative;
    width: 100%;
    margin-left: 0;
    transform: none;
    overflow: auto;
    background: #f4dfc7;
}

.pedigree-viewer .pedigree-image-canvas {
    margin-inline: auto;
}

.pedigree-viewer .pedigree-image-canvas img {
    user-select: none;
    -webkit-user-drag: none;
}

.pedigree-person-link {
    top: 18.5%;
    left: 8.2%;
    width: 12.3%;
    height: 14%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.hanssens-person-link {
    top: 48.3%;
    left: 7.8%;
    width: 13%;
    height: 12.5%;
}

.pedigree-person-link:hover,
.pedigree-person-link:focus-visible {
    border-color: var(--color-support);
    box-shadow: 0 0 0 2px rgba(184, 74, 58, 0.15);
    outline: none;
}

.pedigree-person-info {
    position: absolute;
    right: -9px;
    top: -9px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border: 2px solid #fff8ea;
    border-radius: 50%;
    background: var(--color-support);
    color: #fff8ea;
    font: 700 20px/1 var(--font-base);
    box-shadow: 0 3px 8px rgba(48, 38, 27, 0.2);
}

.pedigree-person-tooltip {
    position: absolute;
    top: calc(100% + 14px);
    left: 0;
    z-index: 3;
    padding: 7px 11px;
    border-radius: 6px;
    background: var(--color-story-text);
    color: #fff8ea;
    font: 600 0.85rem/1.4 var(--font-base);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.pedigree-person-link:hover .pedigree-person-tooltip,
.pedigree-person-link:focus-visible .pedigree-person-tooltip {
    opacity: 1;
    visibility: visible;
}

.cookson-pedigree-link {
    top: 48%;
    left: auto;
    right: 1.2%;
    transform: translateY(-50%);
}

.cookson-pedigree-link:hover,
.cookson-pedigree-link:focus-visible {
    transform: translate(3px, -50%);
}

.bury-pedigree-link {
    top: 25%;
    left: auto;
    right: 1.2%;
    width: clamp(26px, 5.2%, 42px);
    height: auto;
    aspect-ratio: 1;
    font-size: 1.25rem;
    transform: translateY(-50%);
}

.bury-pedigree-link:hover,
.bury-pedigree-link:focus-visible {
    transform: translate(3px, -50%);
}

.pedigree-link-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin: 18px 0 0;
    color: var(--color-story-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.pedigree-link-legend > span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.pedigree-legend-info,
.pedigree-legend-arrow {
    color: var(--color-support);
    font-size: 1.25rem;
    font-weight: 700;
}

.pedigree-zoom-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--color-story-text);
}

.pedigree-zoom-toolbar button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px 14px;
    border: 1px solid rgba(23, 34, 38, 0.25);
    border-radius: 8px;
    background: var(--color-paper);
    color: var(--color-story-text);
    font: 700 1rem var(--font-base);
    cursor: pointer;
}

.pedigree-zoom-toolbar button:hover:not(:disabled) {
    background: var(--color-paper-deep);
}

.pedigree-zoom-toolbar button:disabled {
    opacity: 0.45;
    cursor: default;
}

.pedigree-zoom-toolbar button:focus-visible,
.pedigree-viewer .pedigree-image-shell:focus-visible {
    outline: 3px solid var(--color-support);
    outline-offset: 3px;
}

.pedigree-zoom-level {
    min-width: 5ch;
    text-align: center;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.pedigree-zoom-help {
    margin: 12px 0 0 !important;
    color: var(--color-story-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

.pedigree-zoom-help-desktop {
    display: none;
}

@media (hover: hover) and (pointer: fine) {
    .pedigree-viewer .pedigree-image-shell {
        cursor: zoom-in;
    }

    .pedigree-viewer .pedigree-image-shell.is-zoomed {
        cursor: grab;
    }

    .pedigree-viewer .pedigree-image-shell.is-dragging {
        cursor: grabbing;
        user-select: none;
    }

    .pedigree-zoom-help-desktop {
        display: inline;
    }

    .pedigree-zoom-help-touch {
        display: none;
    }
}

@media (max-width: 640px) {
    .tree-page .subpage-hero h1 {
        white-space: normal;
    }

    .hanssens-tree-page .pedigree-viewer {
        width: 100%;
        margin-left: 0;
        transform: none;
    }
}
