@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap');

/* Colors */

:root {
    /* hsl (fallback color) */
    --bg-dark: hsl(239 69% 3%);
    --bg: hsl(235 48% 6%);
    --bg-light: hsl(233 31% 11%);
    --text: hsl(232 100% 100%);
    --text-muted: hsl(232 38% 75%);
    --highlight: hsl(233 19% 44%);
    --border: hsl(233 24% 33%);
    --border-muted: hsl(235 32% 22%);
    --primary: hsl(233 73% 79%);
    --secondary: hsl(50 43% 58%);
    --danger: hsl(9 31% 65%);
    --warning: hsl(52 22% 56%);
    --success: hsl(147 21% 58%);
    --info: hsl(217 34% 65%);
    /* oklch */
    --bg-dark: oklch(0.1 0.03 278);
    --bg: oklch(0.15 0.03 278);
    --bg-light: oklch(0.2 0.03 278);
    --text: oklch(0.96 0.06 278);
    --text-muted: oklch(0.76 0.06 278);
    --highlight: oklch(0.5 0.06 278);
    --border: oklch(0.4 0.06 278);
    --border-muted: oklch(0.3 0.06 278);
    --primary: oklch(0.76 0.1 278);
    --secondary: oklch(0.76 0.1 98);
    --danger: oklch(0.7 0.06 30);
    --warning: oklch(0.7 0.06 100);
    --success: oklch(0.7 0.06 160);
    --info: oklch(0.7 0.06 260);
}

html.light {
    /* hsl (fallback color) */
    --bg-dark: hsl(231 68% 93%);
    --bg: hsl(231 100% 98%);
    --bg-light: hsl(231 100% 100%);
    --text: hsl(242 70% 8%);
    --text-muted: hsl(233 24% 33%);
    --highlight: hsl(232 100% 100%);
    --border: hsl(232 20% 56%);
    --border-muted: hsl(232 28% 68%);
    --primary: hsl(236 35% 36%);
    --secondary: hsl(52 100% 12%);
    --danger: hsl(9 25% 41%);
    --warning: hsl(51 29% 33%);
    --success: hsl(148 24% 35%);
    --info: hsl(217 26% 42%);
    /* oklch */
    --bg-dark: oklch(0.92 0.03 278);
    --bg-semidark: oklch(0.94 0.03 278);
    --bg: oklch(0.96 0.03 278);
    --bg-light: oklch(1 0.03 278);
    --text: oklch(0.15 0.06 278);
    --text-muted: oklch(0.4 0.06 278);
    --highlight: oklch(1 0.06 278);
    --border: oklch(0.6 0.06 278);
    --border-muted: oklch(0.7 0.06 278);
    --primary: oklch(0.4 0.1 278);
    --secondary: oklch(0.4 0.1 98);
    --danger: oklch(0.5 0.06 30);
    --warning: oklch(0.5 0.06 100);
    --success: oklch(0.5 0.06 160);
    --info: oklch(0.5 0.06 260);
}

/* Generals */

:root {
    --font-family: "Manrope", sans-serif;
}

html, body {
    overscroll-behavior: none;
    touch-action: none;
    overflow: hidden;
    background-color: var(--bg-light);
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
    font-optical-sizing: auto;
    font-style: normal;
}

.hidden {
    display: none !important;
}

.button {
    font-size: 1rem;
    border-radius: 0.25rem;
    border: 1px solid var(--border);
    outline: none;
    background-color: var(--bg-light);
    color: var(--text);
    padding: .5em 1em;
    transition: background-color ease-in .1s;

    &:hover {
        background-color: var(--border-muted);
    }
}

/* Forms */

.form__field {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

input, textarea {
    background-color: var(--bg-light);
    border-radius: .3rem;
    outline: none;
    border: none;
    font-size: 1rem;
    color: var(--text-muted);
    padding: .6rem;
}

textarea {
    resize: none;
    scrollbar-color: var(--border) var(--bg-light);
}


input::placeholder, textarea::placeholder {
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 1rem;
}

/* Overlay */

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: oklab(0% 0 0 / 0.5);
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 2;
    pointer-events: auto;
}

/* Tags */

.tags {
    padding: .5em;
    border-radius: 0.25rem;
    background-color: var(--bg);
}

.tags__list {
    display: flex;
    flex-wrap: wrap;
    gap: .4em;
    list-style: none;
    margin-bottom: .5em;
}

.tags__list:empty {
    margin-bottom: 0;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    background-color: var(--bg-light);
    border: 1px solid var(--border-muted);
    border-radius: .6em;
    padding: .3rem .3rem .3rem .6rem;
    font-size: 1rem;
    color: var(--text);
}

.tag span {
    line-height: 1;
    white-space: nowrap;
}

.tag__remove {
    position: relative;
    width: 1.2rem;
    height: 1.2rem;
    border-radius: 50%;
    border: none;
    background-color: transparent;
    cursor: pointer;
    transition: background-color .2s ease;

    &:hover {
        background-color: var(--danger);

        &::before, &::after {
            background-color: var(--bg);

        }
    }

    &::before, &::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 60%;
        height: 2px;
        background-color: var(--text-muted);
        transform-origin: center;
    }

    &::before {
        transform: translate(-50%, -50%) rotate(45deg);
    }

    &::after {
        transform: translate(-50%, -50%) rotate(-45deg);
    }
}

.tags__add-section {
    display: flex;
    background-color: var(--bg-light);
    border: 1px solid var(--border-muted);
    border-radius: .3em;
}

.tags__input {
    flex: 1;
    background-color: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 1rem;
    padding: .6rem 0 .6rem .6rem;
}

.tags__button {
    padding: .5rem 1rem;
    background-color: transparent;
    border: none;
    outline: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
}

/* Connections */

.connections {
    display: flex;
    flex-direction: column;
    gap: .5em;
    list-style: none;
}

.connection {
    display: flex;
    align-items: stretch;
    gap: .75rem;
}

.connection__content {
    display: flex;
    align-items: center;
    background-color: var(--bg-light);
    padding: 0.6rem 1rem;
    border-radius: 0.25rem;
    gap: .4rem;
    flex: 1;
}

.connection__info {
    display: flex;
    align-items: center;
    gap: .6em;
    flex: 1;
}

.connection__relation {
    display: flex;
    gap: .6em;
}

.connection__direction {
    display: flex;
    align-items: center;
    justify-content: center;
}

.connection__direction svg {
    width: 1rem;
    aspect-ratio: 1/1;
    fill: var(--text)
}

.connection__arrow {
    border: none;
    outline: none;
    width: .5em;
    height: .5em;
    background-color: transparent;
    border-left: 2px solid var(--text);
    border-bottom: 2px solid var(--text);
    transform: rotate(-135deg);
    cursor: pointer;
}

.checkbox__box--from {
    transform: rotate(180deg);
}

.connection__action {
    padding: .6rem;
    border: none;
    outline: none;
    background: var(--bg-light);
    cursor: pointer;
    border-radius: .25rem;
    transition: background-color .2s ease;

    &:hover svg {
        fill: var(--bg);
    }
}

.connection__action svg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: calc(1px + 1.5rem);
    aspect-ratio: 1/1;
    fill: var(--text);
    transition: fill .2s ease;
}

.connection__reverse-button {
    &:hover {
        background-color: var(--info);
    }
}

.connection__disconnect-button {
    &:hover {
        background-color: var(--danger);
    }
}

/* Custom select */

.select-wrapper {
    position: relative;
}

.select {
    font-size: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.6em 1em;
    border: 1px solid var(--border-muted);
    border-radius: 0.25rem;
    background-color: var(--bg-light);
    color: var(--text);
    cursor: pointer;
}

.select[disabled] {
    cursor: not-allowed;
    opacity: 0.6;
}

.arrow {
    border-left: .3em solid transparent;
    border-right: .3em solid transparent;
    border-top: .4em solid var(--text);
    transition: transform ease-in-out 0.1s;
}

.select[aria-expanded="true"] .arrow {
    transform: rotate(180deg);
}

.select__options {
    position: absolute;
    display: flex;
    flex-direction: column;
    gap: .5em;
    top: 100%;
    left: 0;
    width: 100%;
    min-width: 350px;
    border: 1px solid var(--border-muted);
    border-radius: 0.25rem;
    background-color: var(--bg-dark);
    list-style: none;
    padding: .5em;
    margin-top: 10px;
    box-shadow: 0 10px 25px oklch(from var(--border) l c h / 0.3);
    max-height: 200px;
    overflow-y: auto;
    scrollbar-color: var(--border) var(--bg-light);
    z-index: 4;
}


.select__options li {
    padding: .6em;
    cursor: pointer;
    border-radius: 4px;

    &:hover, &:focus {
        background-color: var(--bg-light);
    }
}

.select__options li.selected {
    background-color: var(--bg-light);
}

/* Custom checkbox */

.checkbox__input {
    display: none;
}

.checkbox__box {
    border: 1px solid var(--border-muted);
    padding: .25rem;
    max-width: 1.75rem;
    aspect-ratio: 1/1;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .3s ease;
    cursor: pointer;
}

.checkbox__input:checked+.checkbox__box {
    background-color: var(--primary);
}

.checkbox__box svg {
    width: 1rem;
    aspect-ratio: 1/1;
    fill: var(--text);
    stroke: var(--text);
}

.checkbox__input:checked+.checkbox__box svg {
    fill: var(--bg);
    stroke: var(--bg);
}

/* Modals */

.modal[open] {
    display: flex;
    flex-direction: column;
    width: 90vw;
    margin: auto;
    border: 1px solid var(--border-muted);
    border-radius: .5rem;
    background-color: var(--bg-dark);
    color: var(--text);
}

.modal::backdrop {
    background-color: oklab(0% 0 0 / 0.5);

}

.modal__header {
    display: flex;
    align-items: center;
    padding: 1.3rem;
    border-bottom: 1px solid var(--border);
}

.modal__title {
    flex: 1;
    font-size: 1.3rem;
}

.modal__actions {
    display: flex;
    gap: .5em;
    align-items: center;
}

.modal__action {
    background: var(--bg-light);
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 6px;
}

.modal__action svg {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    stroke: var(--text);
    fill: var(--text);
}

.modal__action--submit {
    background-color: var(--primary);
}

.modal__action--submit svg {
    stroke: var(--bg);
    fill: var(--bg);
}

.modal__form, .modal__content {
    overflow-y: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: 1.3rem;
    scrollbar-color: var(--border) var(--bg-light);
}

.modal__form .select-wrapper {
    width: 100%;
    max-width: calc(1.5rem + 1.2rem);
    align-self: center;
    transition: max-width .3s ease;
}

.modal__form .select-wrapper:has(.select[aria-expanded="true"]) {
    max-width: 350px;
}

.modal__form .select {
    text-align: center;
    border-radius: 100vh;
    padding: .6rem;
    height: calc(1.5rem + 1.2rem);
    overflow: hidden;
    white-space: nowrap;
}


.modal__form .select svg {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    stroke: var(--text);
    fill: var(--text);
}

.modal__form .select__options {
    left: 50%;
    transform: translateX(-50%);
}

/* Header */

.header {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    padding: 1rem;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    flex-shrink: 0;
    align-items: center;
}

.header__left {
    pointer-events: auto;
    padding: .25rem 1rem;
    border-radius: .75rem;
    background-color: var(--bg);
}

.header__logo {
    font-size: 1.5rem;
    justify-self: center;
    color: var(--text)
}

.button--theme {
    background-color: var(--bg);
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    border-radius: 50%;
    height: 3rem;
    aspect-ratio: 1/1;
    padding: .5em;
    cursor: pointer;
}

.button--theme svg {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    scale: 0 0;
    transition: scale .3s ease;
}

.button--theme .selected {
    scale: 100% 100%;
}

/* Main content  */

.main-content {
    height: 100dvh;
    position: relative;
}

/* Sidebars */

.sidebar {
    position: fixed;
    display: flex;
    flex-direction: column;
    top: 0;
    right: 0;
    height: 100%;
    width: 100%;
    max-width: 500px;
    background-color: var(--bg-dark);
    border-left: 1px solid var(--border-muted);
    color: var(--text);
    font-size: 1rem;
    z-index: 3;
    transition: transform .3s ease;
}

.sidebar__action {
    background: var(--bg-light);
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 6px;
}

.sidebar__action svg {
    display: block;
    width: 1.5rem;
    height: 1.5rem;
    stroke: var(--text);
    fill: var(--text);
}

.sidebar__action--delete {
    background-color: var(--danger);
}

.sidebar__title {
    flex: 1;
    font-size: 1.3rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar__subtitle {
    font-size: 1.2rem;
}

.sidebar__header {
    display: flex;
    align-items: center;
    padding: 1.3rem;
    border-bottom: 1px solid var(--border);
}

.sidebar__content {
    overflow-y: auto;
    scrollbar-color: var(--border) var(--bg-light);
}

.sidebar__section {
    display: flex;
    flex-direction: column;
    padding: 1.3rem;
    gap: .8rem;
    border-bottom: 1px solid var(--border);
}

.sidebar__section-header {
    display: flex;
    align-items: center;
}

.sidebar__edit-button {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: .3rem;
    border-radius: .4rem;
    background-color: var(--bg-light);
    border: 1px solid var(--border-muted);
    cursor: pointer;
    transition: background-color .2s ease;

    &:hover {
        background-color: var(--border-muted);
        border: 1px solid var(--border);
    }
}

.sidebar__edit-button svg {
    width: 1.2rem;
    fill: var(--text);
    transition: fill .2s ease;
}

.sidebar__section--connections .select-wrapper {
    margin-left: auto;
}

.sidebar__section--connections .select[aria-expanded="true"] {
    background-color: var(--danger);
}

.sidebar__section--connections .select[aria-expanded="true"] svg {
    fill: var(--bg);
}

.sidebar__section--connections .select__options {
    right: 0;
    left: unset;
}

.sidebar__section--description {
    border-bottom: none;
}

.sidebar__section--description:has(textarea) .sidebar__edit-button {
    background-color: var(--success);

    & svg {
        fill: var(--bg);
    }
}

.sidebar__description-text {
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: break-word;
    hyphens: auto;
}

.sidebar__label {
    margin-bottom: .2em;
    font-size: .9em;
}

.sidebar__actions {
    display: flex;
    justify-content: center;
    gap: 0.5em;
}

.sidebar--hidden {
    transform: translateX(100%);
}

/* Graph */

.graph {
    position: relative;
    height: 100%;
}

.graph__toolbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    bottom: 1em;
    left: 50%;
    transform: translateX(-50%);
}

.toolbar__search {
    display: flex;
    flex-direction: column;
    border-radius: .75rem;
    width: 100%;
    height: 100%;
    margin-bottom: .9rem;
    background-color: var(--bg-dark);
    color: var(--text)
}

.toolbar__search-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.toolbar__search-content {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    padding: 1rem;
}

.toolbar__search-field {
    display: flex;
    align-items: center;
    border-radius: .3rem;
    padding-right: .6rem;
    background-color: var(--bg-light);
}

.toolbar__search-input {
    flex: 1;
    background-color: transparent
}

.toolbar__search-clear {
    position: relative;
    padding: .6rem;
    background: transparent;
    border: none;
    cursor: pointer;
    visibility: hidden;
}

.toolbar__search-clear::before,
.toolbar__search-clear::after {
    content: '';
    position: absolute;
    background-color: var(--text-muted);
    top: 50%;
    left: 50%;
    width: 1px;
    height: 75%;
}

.toolbar__search-clear::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.toolbar__search-clear::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.toolbar__filters {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}

.toolbar__filters h3 {
    font-size: 1rem;
    color: var(--text-muted);
}

.toolbar__filter {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.toolbar__filter .checkbox__input:not(:checked)+.checkbox__box svg {
    visibility: hidden;
}

.toolbar__buttons {
    display: flex;
    border-radius: .75rem;
    background-color: var(--bg);
}

.toolbar__button {
    padding: .75rem;
    border: none;
    outline: none;
    cursor: pointer;
    background-color: transparent;
    transition: background-color .2s ease;

    &:first-child {
        border-radius: .75rem 0 0 .75rem;
    }

    &:last-child {
        border-radius: 0 .75rem .75rem 0;
    }

    &:hover {
        background-color: var(--border-muted);
    }
}

.toolbar__button svg {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    aspect-ratio: 1/1;
    fill: var(--text);
}

.toolbar__button--active {
    background-color: var(--border-muted);
}

.toolbar__button--add-node {
    position: absolute;
    bottom: calc(-1.5rem / 2);
    left: 50%;
    transform: translate(-50%);
    padding: 1.25rem;
    border-radius: 50%;
    aspect-ratio: 1/1;
    border: 5px solid var(--bg-light);
    background-color: var(--bg);
}

.toolbar__button--link-nodes {
    padding-right: calc(1.25rem + 1.5rem);
}

.toolbar__button--delete-node {
    padding-left: calc(1.25rem + 1.5rem);
}

.graph__area {
    --selected-node: var(--primary);
    --highlighted-node: oklch(from var(--primary) calc(l + 0.1) c h);
    --muted-node: oklch(from var(--primary) calc(l - 0.3) calc(c - 0.05) h);
    height: 100%;
    width: 100%;
    display: block;
    background-color: var(--bg-light);
    transition: background-color .3s ease;
}