/* Layout och rendering för Kvikr Aetts kronologiska släktträd. */

.aett-time-tree-canvas {
    position: absolute;
    left: 0;
    top: 0;
    transform-origin: 0 0;
    will-change: transform;
}

.aett-time-tree-lens {
    position: absolute;
    left: 50%;
    width: 50%;
    top: 50%;
    height: var(--aett-time-tree-lens-height, 50.4px);
    overflow: hidden;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(182, 0, 0, 0.28);
    border-radius: 999px;
    background: #f7f9fb;
    box-shadow:
        inset 0 14px 24px -22px rgba(15, 23, 42, 0.42),
        inset 0 -14px 24px -22px rgba(15, 23, 42, 0.42),
        0 10px 28px rgba(15, 23, 42, 0.10);
    box-sizing: border-box;
    opacity: 0;
    pointer-events: none;
    transition: opacity 140ms ease;
    z-index: 10;
}

.aett-time-tree-lens.is-ready {
    opacity: 1;
    pointer-events: auto;
}

.aett-time-tree-lens .aett-time-tree-canvas {
    transform-origin: 0 0;
}

.aett-time-tree-axis-band {
    position: absolute;
    inset: auto 0 0;
    height: calc(42px + env(safe-area-inset-bottom, 0px));
    overflow: hidden;
    pointer-events: none;
    border-top: 1px solid rgba(111, 125, 137, 0.34);
    background: rgba(255, 255, 255, 0.96);
    box-sizing: border-box;
    z-index: 19;
}

.aett-time-tree-gridline {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed rgba(111, 125, 137, 0.24);
    background: none;
    z-index: 0;
}

.aett-time-tree-gridline.is-major {
    width: 0;
    border-left: 2px solid rgba(82, 96, 112, 0.38);
}

.aett-time-tree-year {
    position: absolute;
    top: 10px;
    transform: translateX(-50%);
    color: #526070;
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    z-index: 3;
}

.aett-time-tree-year.is-major {
    color: #344152;
    font-weight: 800;
}

.aett-time-tree-links {
    position: absolute;
    inset: 0;
    overflow: visible;
    pointer-events: none;
    z-index: 1;
}

.aett-time-tree-link {
    fill: none;
    stroke-width: 2.2;
    stroke-linecap: square;
    vector-effect: non-scaling-stroke;
}

.aett-time-tree-link.is-mother {
    stroke: #b01812;
}

.aett-time-tree-link.is-father {
    stroke: #2f5f8d;
}

.aett-time-tree-link.is-estimated-birth {
    stroke-dasharray: 5 4;
}

.aett-time-tree-origin {
    stroke: none;
    shape-rendering: geometricPrecision;
}

.aett-time-tree-origin.is-mother {
    fill: #b01812;
}

.aett-time-tree-origin.is-father {
    fill: #2f5f8d;
}

.aett-time-tree-card {
    position: absolute;
    height: 40px;
    min-width: 4px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: transparent;
    color: #111827;
    text-align: left;
    cursor: pointer;
    z-index: 3;
    box-sizing: border-box;
    isolation: isolate;
}

.aett-time-tree-card::before {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid rgba(15, 23, 42, 0.22);
    border-radius: inherit;
    background: #d7dade;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
    z-index: -1;
}

.aett-time-tree-card.is-female::before {
    background: linear-gradient(90deg, #eec8cd, #e9bebd);
}

.aett-time-tree-card.is-male::before {
    background: linear-gradient(90deg, #bfd3e5, #c5d2df);
}

.aett-time-tree-card.is-estimated-death::before {
    border-right-color: transparent;
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 54px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 54px), transparent 100%);
}

.aett-time-tree-card.is-estimated-birth::before {
    border-left-color: transparent;
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 54px, #000 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 54px, #000 100%);
}

.aett-time-tree-card.is-estimated-birth.is-estimated-death::before {
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 54px, #000 calc(100% - 54px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 54px, #000 calc(100% - 54px), transparent 100%);
}

.aett-time-tree-card:hover,
.aett-time-tree-card:focus-visible {
    z-index: 7;
    outline: none;
}

.aett-time-tree-card:hover::before,
.aett-time-tree-card:focus-visible::before {
    box-shadow: 0 0 0 2px rgba(182, 0, 0, 0.28), 0 5px 13px rgba(15, 23, 42, 0.28);
}

.aett-time-tree-card.is-focus::before {
    border: 2px solid #f7d24b;
    box-shadow: 0 0 0 2px rgba(182, 0, 0, 0.25), 0 4px 12px rgba(15, 23, 42, 0.28);
}

.aett-time-tree-card-content {
    position: absolute;
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: max(100%, 210px);
    height: 40px;
    padding: 3px 8px;
    overflow: visible;
    box-sizing: border-box;
    pointer-events: none;
    color: #111827;
}

.aett-time-tree-card.is-estimated-birth .aett-time-tree-card-content {
    left: 30px;
}

.aett-time-tree-name,
.aett-time-tree-years {
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    -webkit-text-stroke: 2px rgba(255, 255, 255, 0.96);
    paint-order: stroke fill;
}

.aett-time-tree-name {
    font-family: "Ubuntu Condensed", var(--k-font-heading, var(--k-font, sans-serif));
    flex: 0 1 auto;
    font-size: 1.416rem;
    font-weight: 700;
    line-height: 1;
}

.aett-time-tree-years {
    flex: 0 0 auto;
    font-size: 0.84rem;
    font-weight: 500;
    line-height: 1;
    opacity: 0.82;
}

.aett-time-tree-birth-mark {
    position: absolute;
    left: -2px;
    top: 50%;
    width: 5px;
    height: 18px;
    transform: translateY(-50%);
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.2);
    pointer-events: none;
}

.aett-time-tree-card.is-estimated-birth .aett-time-tree-birth-mark {
    display: none;
}

.aett-time-tree-empty-detail {
    display: block;
    max-width: 42rem;
    margin-top: 0.45rem;
    font-size: 0.82rem;
}

.aett-time-tree-legend {
    position: absolute;
    left: 1rem;
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    z-index: 18;
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    max-width: calc(100% - 2rem);
    padding: 0.42rem 0.62rem;
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 0.7rem;
    background: rgba(255, 255, 255, 0.9);
    color: #526070;
    font-size: 0.76rem;
    box-sizing: border-box;
    pointer-events: none;
}

.aett-time-tree-legend span {
    display: inline-flex;
    gap: 0.3rem;
    align-items: center;
}

.aett-time-tree-legend i {
    display: inline-block;
    width: 22px;
    border-top: 2px solid #6f7a86;
}

.aett-time-tree-legend .is-mother {
    border-color: #b01812;
}

.aett-time-tree-legend .is-father {
    border-color: #2f5f8d;
}

.aett-time-tree-legend .is-estimated {
    height: 8px;
    border: 0;
    background: linear-gradient(to right, #6f7a86, transparent);
}

html[data-theme="dark"] .aett-time-tree-axis-band {
    border-color: var(--k-border, rgba(226, 232, 240, 0.22));
    background: rgba(15, 23, 42, 0.96);
}

html[data-theme="dark"] .aett-time-tree-lens {
    border-color: rgba(250, 204, 21, 0.30);
    background: #10172a;
    box-shadow:
        inset 0 14px 24px -22px rgba(0, 0, 0, 0.88),
        inset 0 -14px 24px -22px rgba(0, 0, 0, 0.88),
        0 10px 32px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .aett-time-tree-gridline {
    border-left-color: rgba(203, 213, 225, 0.24);
    background: none;
}

html[data-theme="dark"] .aett-time-tree-gridline.is-major {
    border-left-color: rgba(203, 213, 225, 0.42);
}

html[data-theme="dark"] .aett-time-tree-year,
html[data-theme="dark"] .aett-time-tree-legend {
    color: var(--k-muted, #a7b0c0);
}

html[data-theme="dark"] .aett-time-tree-year.is-major {
    color: var(--k-text, #f8fafc);
}

html[data-theme="dark"] .aett-time-tree-card,
html[data-theme="dark"] .aett-time-tree-card-content {
    color: #07111f;
}

html[data-theme="dark"] .aett-time-tree-card.is-female::before {
    background: linear-gradient(90deg, #ba7d83, #a04f56);
}

html[data-theme="dark"] .aett-time-tree-card.is-male::before {
    background: linear-gradient(90deg, #6e94c2, #426fab);
}

html[data-theme="dark"] .aett-time-tree-card.is-unknown-gender::before {
    background: #8c94a3;
}

html[data-theme="dark"] .aett-time-tree-link.is-mother {
    stroke: #fca5a5;
}

html[data-theme="dark"] .aett-time-tree-link.is-father {
    stroke: #93c5fd;
}

html[data-theme="dark"] .aett-time-tree-origin.is-mother {
    fill: #fca5a5;
}

html[data-theme="dark"] .aett-time-tree-origin.is-father {
    fill: #93c5fd;
}

html[data-theme="dark"] .aett-time-tree-legend {
    border-color: var(--k-border, rgba(226, 232, 240, 0.22));
    background: rgba(15, 23, 42, 0.88);
}

@media (max-width: 760px) {
    #treeViewport {
        min-height: 68dvh;
    }

    .aett-time-tree-legend {
        display: none;
    }

}

@media (max-width: 760px) and (orientation: portrait) {
    .aett-time-tree-lens {
        width: 90%;
    }
}

/* Hjälptexten ligger ovanför den fasta tidsaxeln. */
#treeViewport .aett-tree-hint {
    bottom: calc(52px + env(safe-area-inset-bottom, 0px));
}
