:root {
    color-scheme: dark;
}

@font-face {
    font-family: 'Frames';
    src: url('../misc/Square Frames.ttf') format('trueType');
}

html, body {
    margin: 0;
    background-color: #202020;
    color: #ffffff;
    width: 100vw;
    height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

body {
    display: grid;
}

a {
    color: #00a3f5;
    text-decoration: none;
}

a:hover {
    color: #7ed3fd;
}

li {
    text-align: initial;
}

*:not(.block) > label {
    display: grid;
    grid-auto-flow: column;
    grid-template-columns: 2fr 3fr;
}

input, select, textarea {
    box-sizing: border-box;
    width: 100%;
    height: 1.5rem;
    background-color: #171717;
    color: #ffffff;
    border: 1px solid #ffffff;
    color-scheme: dark;
}

input:focus-visible, select:focus-visible {
    outline: none;
    border-color: #00a3f5;
}

input:disabled, select:disabled {
    border-color: #5f5f5f;
    color: #5f5f5f;
}

textarea {
    height: calc(100vh - 17.5rem);
    resize: vertical;
}

.grid {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: repeat(6, 1fr);
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.grid > * {
    display: flex;
    flex-direction: column;
    place-items: center;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.left {
    grid-column: span 1;
    border-right: 2px solid #4f4f4f;
}

.center {
    grid-column: span 4;
    position: relative;
    overflow: hidden;
}

.right {
    grid-column: span 1;
    border-left: 2px solid #4f4f4f;

}

.title {
    display: grid;
    place-items: center;
    text-transform: uppercase;
    font-weight: 600;
    width: calc(100% - 1em);
    padding: 0.5em;
    border-bottom: 2px solid #4f4f4f;
}

.ancestor-list, .form {
    display: flex;
    position: relative;
    flex-direction: column;
    width: calc(100% - 0.5em);
    height: calc(100% - 2em);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.25em;
    gap: 0.2rem;
}

.form button {
    width: calc(100% - 0.5rem);
    height: 1.3rem;
    position: absolute;
    outline: none;
    border-radius: 0.10rem;
    color: #ffffff;
    cursor: pointer;
}

select[data-field="gender"]:disabled {
    pointer-events: none;
}

[data-field^="delete"] {
    background-color: #9d0000;
    border: 1px solid #c50000;
}

[data-field="lock"] {
    background-color: #006be6;
    border: 1px solid #00a3f5;
}

.form button:disabled {
    cursor: initial;
    color: #a6a6a6;
}


[data-field^="delete"]:disabled {
    background-color: #690000;
    border: 1px solid #9d0000;
}

[data-field="lock"]:disabled {
    background-color: #004a9f;
    border: 1px solid #006be6;
}

[data-field^="delete"]:not(:disabled):hover {
    background-color: #c50000;
}

[data-field="lock"]:not(:disabled):hover {
    background-color: #00a3f5;
}

[data-field="lock"][value="false"]::before {
    content: 'Verrouiller';
}

[data-field="lock"][value="true"]::before {
    content: 'Déverrouiller';
}

.form button[data-field="delete"] {
    bottom: 0.25rem;
}

.form button[data-field="delete-picture"] {
    bottom: 1.75rem;
}

.form button[data-field="lock"] {
    bottom: 3.25rem;
}

.ancestor-button {
    --i: 99999;
    display: grid;
    place-items: center start;
    height: 1.5rem;
    min-height: 1.5rem;
    font-size: 0.8rem;
    overflow: hidden;
    padding: 0 2px 2px 2px;
    white-space: nowrap;
    text-overflow: ellipsis;
    box-sizing: border-box;
    border: 1px solid #4f4f4f;
    order: var(--i);
    cursor: pointer;
}

.center {
    --scroll-x: 0px;
    --scroll-y: 0px;
    display: grid;
}

.block {
    --x: 0px;
    --y: 0px;
    --x-additional: 0px;
    --y-additional: 0px;
    --o: 0;
    --i: 0;
    --j: 0;
    --l: 0;
    --d: -1;
    --gap: 1.5rem;
    display: grid;
    position: absolute;
    place-items: center;
    grid-auto-flow: row;
    box-sizing: border-box;
    text-align: center;
    border: 1px solid #4f4f4f;
    height: calc((100% - 4 * var(--gap)) / 3);
    max-height: 250px;
    aspect-ratio: calc(4 / 5);
    cursor: pointer;
    transform: translate(calc(var(--scroll-x) + var(--x) + var(--x-additional)), calc(var(--scroll-y) + var(--y) + var(--y-additional)));
    opacity: var(--o);
    transition:
        background-color 75ms ease,
        color 75ms ease,
        background-image 75ms ease,
        border-color 75ms ease,
        transform 200ms ease,
        opacity 200ms ease;
}

.placeholder {
    opacity: 0;
}

.block::after {
    content: '';
    display: block;
    height: 80%;
    width: 0.25rem;
    max-width: 0rem;
    background-color: #00aa00;
    position: absolute;
    left: -0.25rem;
    opacity: 0;
    transition: background-color 75ms ease, opacity 75ms ease, max-width 200ms ease;
}

.pos-focused.gen-female ~ .block.pos-spouse::after, .pos-focused.gen-female ~ .block.pos-spouse::after {
    left: auto;
    right: -0.25rem;
}

.block:hover::after {
    background-color: #00a3f5;
}

.order-possibility:not(.pos-spouse), .pos-focused.gen-male ~ .order-possibility.pos-spouse, .pos-focused.gen-male ~ .possibility.pos-spouse, .possibility.pos-child {
    --x-additional: calc(0.25rem * max(0, var(--i) + 1 + var(--d)));
}

.pos-focused.gen-female ~ .order-possibility.pos-spouse, .pos-focused.gen-female ~ .possibility.pos-spouse {
    --x-additional: calc(-0.25rem * max(0, var(--i) + 1 + var(--d)));
}

.order-possibility::after {
    opacity: 1;
    max-width: 0.25rem;
}

.possibility {
    border-color: #00aa00;
}

.block:not(.ancestor) {
    border-style: dashed;
    color: #4f4f4f;
    background-image: url("/imgs/+.svg");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 30%;
}

.block:not(.ancestor):hover {
    color: #00a3f5;
    background-image: url("/imgs/+hover.svg");
}

.block:not(.ancestor)::before {
    position: absolute;
    top: 0.5rem;
}

.block.pos-father:not(.ancestor)::before {
    content: 'Père';
}

.block.pos-mother:not(.ancestor)::before {
    content: 'Mère';
}

.block.pos-spouse:not(.ancestor)::before {
    content: 'Conjoint';
}

.block.pos-child:not(.ancestor)::before {
    content: 'Enfant';
}

.block > * {
    display: block;
    position: relative;
    width: 100%;
    height: calc(100% - 0.5rem);
    padding: 0.25rem;
    text-overflow: ellipsis;
    display: block;
    overflow: hidden;
    white-space: nowrap;
}

.block > *:empty {
    padding: 0.25rem 0;
    width: 0;
}

.block > label {
    cursor: text;
}

.picture img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.picture img:not([src]), .picture img[src=""] {
    display: none;
}

.block > *:not(.picture):not(.picture-placeholder)::before {
    content: '';
    display: block;
    position: absolute;
    width: calc(100% - 0.5rem);
    height: 100%;
    top: 0;
    left: 0.25rem;
    background-color: #202020b3;
    z-index: -1;
}

.block > *:not(.picture):empty::after {
    content: '\00a0';
}

.block > .picture {
    position: absolute;
    top: 0;
    left: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background-color: initial;
    z-index: -2;
}

.locked::before {
    content: '';
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background-image: url(/imgs/lock.svg);
    width: 1rem;
    height: 1rem;
    background-repeat: no-repeat;
    background-size: contain;
}

.locked.pos-focused ~ .block:not(.ancestor) {
    pointer-events: none;
    opacity: 0;
}

.ancestor {
    --d: 0;
    grid-template-rows: max-content 1fr max-content max-content;
}

.ancestor-button {
    position: relative;
}

.ancestor-button > * {
    pointer-events: none;
}

.ancestor-button.focused, .block.pos-focused {
    outline: 1px solid #fa0068;
    outline-offset: -1px;
}

.ancestor-button:hover, .block:hover, .sibling-hovered.sibling-hovered {
    border-color: #00a3f5;
}

.ancestor-button.selected, .block.selected {
    border-color: #ffd900;
    color: #ffffff;
    outline-offset: 0;
}

.ancestor-button.selected {
    display: grid !important;
}

.ancestor-button::before {
    top: calc(0.25rem - 1px);
    right: calc(0.25rem - 1px);
}

.ancestor-button:not(.locked)::before, .ancestor-button:not(.locked)::after {
    content: '';
    display: block;
    position: absolute;
    border: 2px solid #fff;
    border-color: #ffffff00;
    border-radius: 50%;
    animation: loading 1s cubic-bezier(0, 0.2, 0.8, 1) infinite;
    transition: border-color 300ms ease;
}

.ancestor-button:not(.locked)::after {
    animation-delay: -0.5s;
}

.ancestor-button.saving:not(.locked)::before, .ancestor-button.saving:not(.locked)::after {
    border-color: #ffffffff;
}

.message-block {
    display: grid;
    place-self: start center;
    top: 1rem;
    text-align: center;
    position: absolute;
    background-color: #00000055;
    padding: 1rem 2rem;
    outline: 1px solid #4f4f4f;
    gap: 1rem;
}

.responses {
    display: grid;
    grid-auto-flow: column;
    gap: 0.5rem;
    width: fit-content;
    place-self: center;
}

.left .title {
    border: none;
}

.ancestor-search {
    outline: 2px solid #4f4f4f;
    border: none;
}

.ancestor-search:focus-visible, .ancestor-search:focus-visible {
    outline: 2px solid #00a3f5;
    width: calc(100% - 2px);
    margin-left: 2px;
}

.ancestor-search::placeholder {
    text-align: center;
}

.ancestor-search:focus-visible::placeholder, .ancestor-search:focus-visible::placeholder {
    margin-right: 2px;
}

.hidden {
    display: none;
}

@keyframes loading {
    0% {
        top: calc(0.5rem + 2px);
        right: calc(0.5rem + 2px);
        width: 0;
        height: 0;
        opacity: 0;
    }
    4.9% {
        top: calc(0.5rem + 2px);
        right: calc(0.5rem + 2px);
        width: 0;
        height: 0;
        opacity: 0;
    }
    5% {
        top: calc(0.5rem + 2px);
        right: calc(0.5rem + 2px);
        width: 0;
        height: 0;
        opacity: 1;
    }
    100% {
        top: 0px;
        right: 0px;
        width: calc(1rem + 4px);
        height: calc(1rem + 4px);
        opacity: 0;
    }
}