:root {
    --node-size: 100px;
    --node-z-index: 3;
    --edge-thickness: 5px;
    --edge-hitbox-size: 40px;
    --edge-hitbox-display: none;
    --edge-color: rgb(34, 34, 34);
    --hover-color: rgb(230, 230, 230);
    --weight-label-opacity: 0;
    --arrow-width-factor: 5;
    --arrow-width: calc(var(--edge-thickness)*var(--arrow-width-factor));
    --adj-matrix-min-cell-size: 35px;
    --dimension-adjuster-thickness: 20px;
}

* {
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    width: 100vw;
    /* height: 100vh; */
    font-family: sans-serif;
    background-color: white;
}

#page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

button:disabled {
    cursor: not-allowed;
}

/* PREVIEW SECTION STYLES */
#preview_section {
    width: 100%;
    height: 100%;
    /* background-color: white; */
    background-color: green;
    overflow: hidden;
    position: relative;
    background: radial-gradient(rgb(224, 224, 224) 5%, white 8%);
    background-size: 50px 50px;
}

/* ADJACENCY MATRIX AND LIST STYLES */
#adj_box {
    width: clamp(300px, 20%, 20%);
    height: 100%;
    position: absolute;
    bottom: 0%;
    display: flex;
    flex-direction: column;
    justify-content: end;
    z-index: 98;
    pointer-events: none;
}

.adj_header {
    height: fit-content;
    display: block;
    font-weight: lighter;
    box-shadow: 0px 0px 8px black;
    background-color: rgb(54, 54, 54);
    color: white;
    padding: 5px;
    text-align: center;
    font-size: 1.75rem;
}

#adj_list_box, #adj_matrix_box {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.616);
    border-top: 1px solid black;
    border-right: 1px solid black;
    display: none;
    flex-direction: column;
    box-sizing: border-box;
    overflow: hidden;
    pointer-events: all;
}

.adj_list_item, #adj_matrix {
    font-size: 20pt;
}

#adj_matrix_box {
    height: 50%;
    position: relative;
}
#adj_list_box {
    height: fit-content;
    max-height: 50%;
}

#adj_matrix_content {
    width: 100%;
    height: 100%;
    padding: 8px;
    box-sizing: border-box;
    overflow: scroll;
}
#adj_matrix_wrapper {
    width: 100%;
    height: 100%;
    overflow: scroll;
}

#adj_matrix {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1/1;
    text-align: center;
    border-spacing: 0px;
    border-collapse: collapse;
    table-layout: fixed;
}
#adj_matrix th, #adj_matrix td {
    overflow: hidden;
    text-wrap: nowrap;
    width: clamp(var(--adj-matrix-min-cell-size), var(--adj-matrix-min-cell-size), var(--adj-matrix-min-cell-size));
    height: clamp(var(--adj-matrix-min-cell-size), var(--adj-matrix-min-cell-size), var(--adj-matrix-min-cell-size));
}
#adj_matrix th {
    color: black;
    padding: 5px;
}
.adj_matrix_label_inside {
    width: 100%;
    height: fit-content;
    text-align: center;
    overflow-x: auto;
}
#adj_matrix td {
    background-color: var(--hover-color);
    color: black;
    border: 1px solid black;
}

#adj_list_content {
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    text-wrap: nowrap;
}
#adj_list_content_wrapper {
    width: 100%;
    height: 100%;
    padding: 10px;
    overflow: hidden;
    box-sizing: border-box;
}

.adj_list_item {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    align-items: center;
}
.adj_list_node_name {
    max-width: 30%;
    height: 100%;
    padding: 0px 10px;
    box-sizing: border-box;
}
.adj_list_node_name_inside {
    font-weight: bold;
    overflow-x: auto;
}
.adj_list_adj_nodes {
    width: 70%;
    height: 100%;
    padding: 0px 10px;
    border-left: 1px solid black;
    flex-grow: 1;
    box-sizing: border-box;
} 
.adj_list_adj_nodes_inside {
    overflow-x: auto;
}

/* Commas between list entries */
.comma:first-child:empty ~ .comma:not(:empty) {
    margin-left: 0;  
}
.comma:first-child:empty ~ .comma:not(:empty) ~ .comma:not(:empty) {
    margin-left: -.3em;  
}
.comma:empty {
    display: none;
}
.comma:not(:first-child):before {
    content: ", ";
}
.comma:empty + .comma:not(:empty):before {
    content : "";
}
.comma:not(:empty) ~ .comma:empty + .comma:not(:empty):before {
    content : ", ";
}

/* Node Styles */
.node, .preview_node {
    width: var(--node-size);
    aspect-ratio: 1/1;
    background-color: rgb(218, 218, 218);
    border: 2px solid var(--edge-color);
    border-radius: 50%;
    position: absolute;
    z-index: var(--node-z-index);
    font-size: 20pt;
    font-family: sans-serif;
    padding: 5px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    text-wrap: nowrap;
}

.preview_node {
    pointer-events: none;
}

.node:hover {
    background-color: rgb(170, 168, 168);
    cursor: move;
}

/* Style applied to the start node of edge creation */
.create_edge_start {
    outline: 5px solid rgb(55, 175, 0);
}

/* Style applied to the end nodes of edge creation */
.create_edge_end {
    outline: 5px solid rgb(255, 187, 0);
}

/* Style applied to each node when delete mode is activated */
.delete_node {
    outline: 5px solid red;
}


/* Algorithm graph styles */
.visited {
    background-color: rgb(43, 139, 14);
}
.next_visit {
    background-color: goldenrod;
    /* background: repeating-linear-gradient(45deg, goldenrod, goldenrod 10px, white 10px, white 20px) !important;     */
}

.algorithmStartNode {
    outline: 8px solid lime;
    outline-offset: 0px;
}
.edge_unvisited {
    background-color: none !important;
    background: repeating-linear-gradient(90deg, grey, grey 20px, transparent 20px, transparent 40px) !important;    
}
.edge_unvisited > .arrow {
    background-color: grey !important;
}

/* Edge, Weight, and Arrow Styles */
.edge {
    position: absolute;
    height: var(--edge-thickness);
    z-index: 1;
    transform-origin: center;
}

.edge_mask {
    height: 100%;
    z-index: 2;
    position: relative;
    background-color: var(--edge-color);
    border-right: 1px solid var(--edge-color); /* To remove tiny, impure space between edge end and arrow start */
}

.edge_hitbox {
    width: 100%;
    height: var(--edge-hitbox-size);
    top: calc(var(--edge-thickness)/2 - var(--edge-hitbox-size)/2);
    position: absolute;
    z-index: 4;
    display: var(--edge-hitbox-display);
}
.edge_hitbox:hover {
    background-color: rgba(255, 0, 0, 0.329);
}

.weight_label {
    background-color: var(--edge-color);
    color: white;
    padding: 0px 5px;
    width: fit-content;
    height: fit-content;
    font-size: 20pt;
    position: absolute;
    z-index: 3;
    border-radius: 3px;
    opacity: var(--weight-label-opacity);
} 
.weight_label:focus {
    background-color: black;
}

.arrow {
    width: var(--arrow-width);
    aspect-ratio: 1/1;
    background-color: var(--edge-color);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    position: absolute;
    left: 100%;
    z-index: 2;
}

/* Prompt Section Styles */
#prompt_section {
    width: 100%;
    height: 100%;
    position: absolute;
    background-color: rgba(0, 0, 0, 0.658);
    /* display: flex; */
    justify-content: center;
    align-items: center;
    display: none;
    z-index: 102;
}

#prompt_box {
    width: 500px;
    height: auto;
    background-color: white;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#prompt_message {
    width: 100%;
    height: auto;
    background-color: rgb(228, 228, 228);
    padding: 30px;
    box-sizing: border-box;
    font-size: 15pt; 
}

#prompt_button_box {
    width: 100%;
    height: 50%;
    background-color: rgb(194, 194, 194);
    padding: 30px;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    align-items: center;
}

.prompt_btn {
    width: 25%;
    padding: 20px;
    font-size: 15pt;
}

.width_adjuster {
    width: var(--dimension-adjuster-thickness);
    height: 50%;
    border-radius: 5px;
    background-color: rgba(5, 107, 107, 0.253);
    position: absolute;
    right: calc(-1/2 * var(--dimension-adjuster-thickness));
    top: 25%;
    opacity: 0;
    pointer-events: all;
}
.width_adjuster:hover {
    opacity: 1;
}


/* Once all of the menu section go into hamburger */
@media screen and (max-width: 760px) {
    :root {
        --node-size: 75px;
    }

    #adj_box {
        width: 100%;
        height: 40%;
        flex-direction: row;
        justify-content: start;
    }

    #adj_list_box, #adj_matrix_box {
        width: 50%;
        height: 100%;
    }

    #adj_list_content {
        height: 100%;
    }

    #adj_list_box {
        max-height: none;
    }
    #prompt_box {
        width: 75%;
    }
}
