/* Shared person representations and internal layout. Page placement stays in page stylesheets. */

/* app.css person variants */
.person-identity-layout.has-portrait {
	display: grid;
	grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
	align-items: start;
	gap: 28px
}

.person-identity-fields {
    min-width:  0;
}

.person-identity-portrait {
    width:  100%;
    margin:  0;
}

.person-identity-portrait img {
	display: block;
	width: 100%;
	aspect-ratio: 3 / 4;
	object-fit: contain;
	border: 1px solid var(--line);
	border-radius: 4px;
	background: var(--green-soft)
}

@media (max-width: 800px) {
.person-identity-layout.has-portrait {
    grid-template-columns:  minmax(0, 1fr);
}

.person-identity-portrait {
    grid-row:  1;
    max-width:  280px;
    justify-self:  center;
}
}
.person-selection {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: #edf3ee;
    border: 1px solid var(--line);
    border-radius: 4px;
    font-size: 12px;
}
.person-selection-remove {
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
}
.person-avatar {
    width: 64px;
    height: 64px;
    background: #edf1ee;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-family: 'Manrope',sans-serif;
    font-size: 22px;
    font-weight: 500;
    color: var(--green);
    position: relative;
    margin: 0 0 17px;
}
.person-avatar:after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border: 3px solid white;
    border-radius: 50%;
    background: var(--unknown);
}
.person-avatar.M:after {
    background: var(--male);
}
.person-avatar.F:after {
    background: var(--female);
}
.person-summary {
    padding: 0 23px 22px;
}
.person-summary h1 {
    font-size: 22px;
    line-height: 1.3;
    overflow-wrap: anywhere;
    font-weight: 700;
}
.person-summary .surname {
    display: block;
    color: var(--green);
}
.lifespan {
    margin-top: 9px;
    color: var(--muted);
    font-size: 12px;
}
.facts {
    padding: 22px 23px;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 21px;
}
.fact {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}
.fact>svg {
    color: #8e9b91;
    width: 17px;
    margin-top: 2px;
}
.fact-label {
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 5px;
}
.fact-value {
    font-size: 12px;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.fact-place {
    display: block;
    color: var(--muted);
}
.notes-text {
    white-space: pre-wrap;
    font-size: 11px;
    line-height: 1.5;
}
.search-result {
    display: block;
    background: white;
    border: 0;
    border-bottom: 1px solid #edf0ec;
    text-align: left;
    width: 100%;
    padding: 12px;
    font-size: 12px;
    overflow-wrap: anywhere;
}
.search-result:hover {
    background: var(--green-soft);
}
.search-result small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}
.person-node {
    position: absolute;
    width: 180px;
    height: 42px;
    border: 1px solid #dce3db;
    border-left: 3px solid var(--unknown);
    border-radius: 5px;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 5px 10px;
    text-align: left;
    box-shadow: 0 3px 7px #25312e04;
    pointer-events: auto;
    transition: box-shadow .15s,border-color .15s;
    cursor: pointer;
}
.person-node.M {
    border-left-color: var(--male);
}
.person-node.F {
    border-left-color: var(--female);
}
.person-node:hover {
    box-shadow: 0 4px 12px #25312e17;
    border-color: #94af9a;
    z-index: 2;
}
.person-node.partner-active {
    border-color: #c49d72;
    border-left: 3px solid var(--accent);
    background: #fffcf6;
}
.node-name {
    font-family: 'Manrope',sans-serif;
    font-size: 11px;
    font-weight: 650;
    line-height: 14px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.node-dates {
    margin-top: 1px;
    color: #8b968c;
    font-size: 9px;
    line-height: 11px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}
.person-node.with-portrait {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    padding: 5px 10px;
}
.node-portrait,.node-portrait-fallback {
    display: block;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    margin: 0;
    object-fit: cover;
    object-position: left center;
    border-radius: 3px;
    background: #eef2ed;
}
.node-portrait-fallback {
    display: grid;
    place-items: center;
    border-radius: 50%;
    font-size: 10px;
    color: var(--green);
}
.node-portrait-fallback.M {
    background: #e8f0f1;
}
.node-portrait-fallback.F {
    background: #f5eaea;
}
.person-node.with-portrait .node-copy .node-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar .lifespan {
    line-height: 1.7;
    overflow-wrap: anywhere;
}
.person-media-frame {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 0 0 16px;
    overflow: hidden;
}
.person-media-frame .person-avatar {
    float: none;
    width: min(100%, 180px);
    height: auto;
    aspect-ratio: 3 / 4;
    border-radius: 4px;
    margin: 0;
}
.person-node.focused {
    border: 2px solid #c57d31;
    border-left: 4px solid #c57d31;
    background: #fff9ef;
    box-shadow: 0 0 0 3px #c57d310b;
}

.person-placeholder {
    border: 1px dashed #b6c8ba;
    background: #f7faf6;
    box-shadow: none;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 7px;
    color: var(--green);
    font-size: 11px;
}
.person-placeholder svg {
    width: 14px;
    height: 14px;
}

@media(min-width:1600px){.person-summary,.facts{padding-left:28px;padding-right:28px}
}

@media(max-width:850px){.person-summary{padding:0 16px 18px}
.facts {
    padding: 18px 16px;
}
.person-summary h1 {
    font-size: 20px;
}
}

@media(max-width:580px){.person-avatar{float:left;width:50px;height:50px;margin:0 15px 15px 0}
.person-summary h1 {
    font-size: 21px;
}
.person-summary .surname {
    display: inline;
}
.facts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}
}

/* media-library.css person variants */

.person-portrait {
    display: block;
    aspect-ratio: 4/3;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 240px;
    margin: 0;
    margin-bottom: 16px;
    object-fit: contain;
    object-position: left center;
}
.person-summary-edit {
    display: contents;
    cursor: pointer;
}
.person-summary h1 .person-summary-edit:hover {
    color: var(--green);
}

.library-person {
    display: flex;
    align-items: center;
    padding: 3px 0;
    gap: 6px;
    color: var(--green);
    font-size: 11px;
    overflow-wrap: anywhere
}

.library-person-entry + .library-person-entry {
    margin-top: 4px
}

.library-person-marker {
    display: inline-flex;
    flex-shrink: 0;
    width: 13px;
    height: 13px
}

.library-person-relationship {
    display: block;
    margin: -2px 0 2px 19px;
    color: var(--muted);
    font-size: 10px
}

.library-person svg {
    flex-shrink: 0;
    width: 13px;
    height: 13px
}

.library-person:hover {
    text-decoration: underline
}

.tag-linked-people .media-linked-person {
    position: relative;
    width: 180px;
    min-height: 42px;
    border: 1px solid #dce3db;
    border-left: 3px solid var(--unknown);
    border-radius: 5px;
    background: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding: 5px 10px;
    text-align: left;
    box-shadow: 0 3px 7px #25312e04;
    pointer-events: auto;
    transition: box-shadow .15s, border-color .15s;
    cursor: pointer;
    font-size: 11px;
    overflow-wrap: anywhere;
    gap: 0
}

.tag-linked-people .media-linked-person:hover {
    box-shadow: 0 4px 12px #25312e17;
    border-color: #94af9a;
    z-index: 2;
}

.tag-linked-people .media-linked-person.is-active-marker {
    border-color: #b66a12;
    border-left-color: #b66a12;
    background: #ffe3a3;
    box-shadow: 0 0 0 2px #b66a1240, 0 3px 7px #25312e04
}

.media-linked-person {
    position: relative;
    border: 1px solid #dce3db;
    border-left: 3px solid var(--unknown);
    border-radius: 5px;
    background: white;
    box-shadow: 0 3px 7px #25312e04;
    transition: box-shadow .15s, border-color .15s;
    cursor: pointer;
}

.media-linked-person:hover {
    box-shadow: 0 4px 12px #25312e17;
    border-color: #94af9a;
}

.media-linked-person .node-copy {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.media-linked-person .node-name {
    font-family: 'Manrope', sans-serif;
    font-size: 11px;
    font-weight: 650;
    line-height: 14px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--ink);
}

.media-linked-person .node-dates,
.media-person-suggestion .node-dates {
    margin-top: 1px;
    color: #8b968c;
    font-family: 'DM Sans', sans-serif;
    font-size: 9px;
    line-height: 11px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-linked-person .node-partnership-dates {
    margin-top: 0px;
    color: #c49d72;
    font-size: 8px;
    line-height: 10px;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-linked-controls {
    display: flex;
    align-items: center;
    gap: 2px;
    position: static;
}

.media-linked-person .media-linked-relationship,
.media-person-suggestion summary {
    height: 24px;
    padding: 2px 4px;
    border: 1px solid #dce3db;
    border-radius: 3px;
    background: white;
    color: var(--ink);
    font-size: 9px;
    line-height: 1.3
}

.media-person-controls .icon-button {
    width: 24px;
    height: 24px;
    padding: 4px;
    border: 1px solid #dce3db;
    border-radius: 3px;
    background: white;
    color: #8b968c;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0
}

.media-person-controls .icon-button:hover,
.media-person-controls .icon-button:focus-visible {
    border-color: #94af9a;
    background: #f5f7f6;
    color: var(--ink)
}

.media-linked-person .media-linked-remove:hover,
.media-linked-person .media-linked-remove:focus-visible {
    border-color: #94af9a;
    background: #f5f7f6;
    color: #d32f2f
}


.tag-frame-controls .tag-person-relationship {
    width: 118px;
    min-width: 0;
    padding: 4px;
    border: 0;
    border-left: 1px solid #ffffff36;
    background: #25312e;
    color: white;
    font-size: 9px
}

.media-person-suggestion > strong mark {
    background: #fff0aa;
    color: var(--ink);
    padding: 1px 3px;
    border-radius: 2px
}

.media-suggestion-linked {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    color: var(--green);
    background: var(--green-soft);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 2px 5px;
}

.media-suggestion-linked svg {
    width: 13px;
    height: 13px
}

.media-person-suggestion {
    display: flex;
    flex-direction: column;
    position: relative;
    margin-top: 0;
    padding: 12px;
    border: 1px solid #dce3db;
    border-left: 3px solid var(--unknown);
    border-radius: 5px;
    background: white;
    font-size: 12px;
    overflow-wrap: anywhere;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 60px;
    flex: 1;
}

.media-person-suggestion:hover {
    border-color: #a9a9a9;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

.media-person-suggestion .node-copy {
    display: flex;
    flex-direction: column;
    gap: 0;
    white-space: normal;
    flex: 1;
}

.media-person-suggestion .node-name {
    font-family: 'Manrope', sans-serif;
    font-size: 11px;
    font-weight: 650;
    line-height: 14px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-person-suggestion .node-name mark {
    background: #fff0aa;
    color: var(--ink);
    padding: 1px 3px;
    border-radius: 2px;
}

.media-linked-person .node-dates,
.media-person-suggestion .node-dates {
    white-space: normal;
    overflow-wrap: anywhere;
}

.media-person-suggestion details {
    min-width: 0;
    margin: 0
}

.media-person-suggestion summary {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    list-style: none;
    font-family: inherit
}

.media-person-suggestion summary::-webkit-details-marker {
    display: none
}

.media-person-suggestion summary::after {
    content: '';
    width: 5px;
    height: 5px;
    margin: -3px 2px 0;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg);
    flex-shrink: 0
}

.media-person-suggestion details[open] summary::after {
    margin-top: 3px;
    transform: rotate(225deg)
}

.media-person-suggestion details strong {
    display: block;
    margin-top: 8px;
}

.media-person-suggestion ul {
    margin: 4px 0;
    padding: 0;
    list-style: none
}

.media-person-suggestion li + li {
    margin-top: 11px
}

.media-family-name,
.media-family-detail {
    display: block
}

.media-family-name {
    font-family: 'Manrope', sans-serif;
    font-size: 11px;
    line-height: 14px;
    font-weight: 400;
    text-decoration: underline;
    text-underline-offset: 2px
}

.media-family-detail {
    font: 9px/11px 'DM Sans', sans-serif;
    color: #8b968c
}

.tag-frame-controls {
    display: flex;
    z-index: 4;
    position: absolute;
    bottom: calc(100% + 2px);
    left: 0;
    align-items: center;
    width: max-content;
    max-width: min(220px, 70vw);
    border-radius: 3px;
    background: #25312ecc;
    color: white;
    text-shadow: none;
    line-height: 1.2
}

.tag-frame-controls a,
.tag-frame-controls > span {
    padding: 5px 7px;
    color: inherit;
    font-size: 10px;
    overflow-wrap: anywhere
}

.tag-frame-controls a:hover,
.tag-frame-controls a:focus-visible {
    text-decoration: underline
}

.tag-frame-controls .icon-button {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    color: white
}

.tag-frame-controls .icon-button:hover,
.tag-frame-controls .icon-button:focus-visible {
    background: #465c52;
    color: white
}

.tag-frame-controls .icon-button svg {
    width: 14px;
    height: 14px
}

@media(min-width:1200px) {

    :is(.media-tag-dialog, .person-display-gallery) .media-linked-person {
        position: relative;
        width: 100%;
        max-width: 300px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        align-items: stretch;
        min-width: 0
    }

    :is(.media-tag-dialog, .person-display-gallery) .media-linked-person .node-copy {
        flex: 1;
        min-width: 0
    }

    :is(.media-tag-dialog, .person-display-gallery) .media-linked-controls {
        position: static;
        gap: 4px;
        margin-left: 0
    }
}

.tag-linked-people .media-linked-person,
.media-person-suggestion {
    margin: 0;
    padding: 12px;
    gap: 0
}

.media-person-controls {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 4px;
    width: 100%;
    min-width: 0;
    margin: 8px 0 0
}

.media-person-controls .media-linked-relationship {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%
}

.media-person-controls .icon-button svg {
    width: 14px;
    height: 14px
}

.media-person-controls .icon-button[hidden] {
    display: none
}

/* people-directory.css person variants */
.directory-person {
    font-weight: 650;
    color: var(--ink);
    text-decoration: none;
}
.directory-person:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}
.directory-id {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 10px;
}

/* events.css person variants */
.event-person {
    display: inline;
    color: var(--green);
    font-weight: 550;
}
.event-person:hover {
    text-decoration: underline;
}

/* tree-connection.css person variants */

.person-node.connection-path {
    box-shadow:  0 0 0 2px var(--green);
}

.person-root-context, .family-root-description {
    font-size:  12px;
    color:  var(--muted);
    line-height:  1.6;
}
.person-root-name {
    font-weight:  700;
}
.partnership-partner-name {
    font-size:  12px;
}
.family-selector select {
    min-width:  140px;
    max-width:  100%;
    padding:  8px;
    border:  1px solid var(--line);
    border-radius:  4px;
    background:  white;
}
@media(max-width:700px) { .family-selector select { min-width: 0; } }

/* Tree sidebar: keep picture and name in place, scroll only the facts. */
@media(min-width:581px) {
    .sidebar:has(#person-details) {
        overflow: hidden;
    }
    #person-details {
        flex: 1;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    #person-details .person-summary {
        flex-shrink: 0;
    }
    #person-details .facts {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        align-content: start;
    }
}
