* {
    touch-action: none;
}

html,
body {
    margin: 0;
    background: #dadada;
}

body {
    font-family: 'Inter', sans-serif;
    width: 100%;
    height: 100vh;

    display: flex;
    flex-direction: row;

    font-size: 1.2rem;
}

a {
    color: #444;

    text-decoration: none;
    border-bottom: 1px dotted #333;

    transition: 0.1s color;
}

a:hover {
    color: #222;

    border-bottom: 1px solid #222;
}

input[type='checkbox'] {
    -moz-appearance: none;
    -webkit-appearance: none;
    appearance: none;
    vertical-align: middle;
    outline: none;
    font-size: inherit;
    cursor: pointer;
    width: 1.3em;
    height: 1.3em;
    background: #ccc;
    border-radius: 0.25em;
    border: 0.125em solid #222;
    position: relative;
    margin-right: 0.5rem;
    margin-left: 0;
}

input[type='checkbox']:checked {
    background: #9bcba8;
    /* background: #aec9ff; */
}

input[type='checkbox']:checked::after {
    font-family: 'Roboto Mono', sans-serif;
    content: '✔';
    position: absolute;
    font-size: 90%;
    left: 0.15em;
    top: -0.15em;
}

.sidebar {
    background: #dadada;
    width: 30%;
    min-width: 22rem;
    height: 100vh;
    flex-shrink: 0;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.header {
    flex-shrink: 0;
    margin: 0;
    margin-bottom: 1rem;
}

#share {
    background: #eaeaea;
    border: 2px solid #666;
    border-radius: 0.5rem;
    padding: 0.8rem 1rem;
    margin-bottom: 1rem;
}

#share h2 {
    margin: 0;
    font-size: 1.4rem;
}

#share p {
    margin: 0.25rem 0 0.75rem;
    font-size: 1rem;
}

.share-controls {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

#share-url {
    flex: 1;
    border: 1px solid #222;
    border-radius: 0.5rem;
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    background: #f6f6f6;
}

#share-url:focus {
    outline: 2px solid #666;
}

#share-copy {
    flex-shrink: 0;
}

#share-status {
    min-height: 1.2rem;
    margin-top: 0.4rem;
    font-size: 0.9rem;
    color: #333;
}

#share-status.success {
    color: #1a7f37;
}

#share-status.error {
    color: #a42834;
}

#logo {
    height: 2rem;
    display: inline;
    margin-right: 0.5rem;
    margin-left: 0.5rem;
    transform: translateY(0.1rem);
}

.eqn {
    flex-grow: 1;
    overflow: auto;
    padding: 0.5rem 1rem;
    padding-bottom: 1.5rem;
}

.eqn h2 {
    margin: 0;
    margin-top: 0.8rem;
    font-size: 1.6rem;
}

.eqn p {
    margin: 0;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

#addvector,
#addmatrix,
#addpoint,
#addfunc {
    /* margin-top: 0.5rem; */
    width: 100%;
}

.footer {
    padding-top: 0.5rem;
    flex-shrink: 0;
    text-align: center;
    font-size: 1rem;
    color: #222;
}

.main {
    background: #eee;
    flex-grow: 1;
    box-shadow: inset 0px 0px 5px #00000055;
    border-radius: 0.75rem 0 0 0.75rem;
    overflow: hidden;
    position: relative;
}

#canvas {
    width: 100%;
    height: 100%;
}

.matrix {
    --border-color: #222;

    display: inline-table;
    /* position: absolute; */
    border-left: 2px solid var(--border-color);
    border-right: 2px solid var(--border-color);
    padding: 0.25em 0.5em;
    background-image: linear-gradient(var(--border-color), var(--border-color)),
        linear-gradient(var(--border-color), var(--border-color)),
        linear-gradient(var(--border-color), var(--border-color)),
        linear-gradient(var(--border-color), var(--border-color));

    background-repeat: no-repeat;
    background-size: 8px 2px;
    background-position: top left, top right, bottom left, bottom right;

    font-family: 'Roboto Mono', monospace;
}

.rawcell {
    text-align: center;
    width: 5ch;
    display: inline-block;
}

.cell {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.2rem;
    width: 2.5rem;
    outline: none;
    border: 1px solid #222;
    border-radius: 2px;
    padding: 0.1rem;
    background: #e8e8e8;
    text-align: center;
    /* cursor: ns-resize; */
    cursor: text;
}

.cell.is-dragging {
    background: #fff5ca;
}

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* Firefox */
input[type='number'] {
    -moz-appearance: textfield;
    appearance: textfield;
}

#basis {
    display: flex;
    align-items: center;
    justify-content: center;
    /* margin-bottom: 1rem; */
    /* flex-wrap: wrap; */
    width: 100%;
    overflow: visible;
}

#basis > .vector {
    margin: 0.5rem;
}

#menu {
    border: 2px solid #222;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    background: #eee;
    transition: background 0.1s;
    /* margin: 0.5rem; */
    margin-bottom: 1rem;
}

#menu-header:hover {
    background: #ddd;
}

#menu-header {
    display: flex;
    align-items: center;
    cursor: pointer;
    width: 100%;
    padding: 0.5rem;
    box-sizing: border-box;
    border-radius: 0.5rem;
}

#menu-header > span {
    margin-left: 1rem;
    font-size: 1.2rem;
}

#menu-closed,
#menu-open {
    fill: '#222';
    width: 1.2rem;
    height: 1.2rem;
}

#menu.is-closed #menu-open,
#menu #menu-closed {
    display: none;
}

#menu.is-closed #menu-closed,
#menu #menu-open {
    display: inline;
}

#controls {
    display: flex;
    flex-direction: column;
    /* flex-wrap: wrap; */
    justify-content: center;
    align-items: stretch;
    padding: 0.5rem;
    margin-top: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

#menu.is-closed > #controls {
    display: none;
}

#controls button {
    margin: 0.25rem;
}

button {
    border: 2px solid #222;
    border-radius: 0.5rem;
    padding: 0.5rem;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    /* margin: 0.5rem; */
    cursor: pointer;
    background: #eee;
    transition: background 0.1s;
}

button:hover {
    background: #ddd;
}

.vector-input {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0;
    padding: 0.8rem 1rem;
    background: #e8e8e8;
    border-radius: 0.5rem;
    border: 2px solid #666;
}

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

.vector > span {
    /* position: relative; */
    /* top: 0.45rem; */
    margin-right: 0.5rem;
    /* flex-wrap: nowrap; */
    white-space: nowrap;
}

.vector-name {
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
}

#basis-header {
    margin: 0;
}

#ihat,
#jhat {
    padding: 0.2rem;
    border-radius: 0.25rem;
}

#ihat {
    background: #ff0000;
}

#jhat {
    background: #0000ff;
    color: #fff;
}

.delete {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    margin: 0;
}

.delete > svg {
    fill: '#222';
    width: 1.2rem;
    height: 1.2rem;
}

.enable {
    margin-right: 0.5rem;
}

#zoombuttons {
    position: fixed;
    right: 1rem;
    top: 1rem;
}

#zoombuttons > * {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    margin: 0.5rem;
}

#zoombuttons svg {
    fill: '#222';
    width: 1.5rem;
    height: 1.5rem;
}

.matrix-input {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0;
    padding: 0.8rem 1rem;
    background: #e8e8e8;
    border-radius: 0.5rem;
    border: 2px solid #666;
    cursor: move;
}

.matrix-input.is-sorting {
    background: #d4d7ff;
}

.matrix-input > .matrix-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.point-input {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0;
    padding: 0.8rem 1rem;
    background: #e8e8e8;
    border-radius: 0.5rem;
    border: 2px solid #666;
}

.point {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5em 0.5em;
    background-repeat: no-repeat;
    background-size: 8px 2px;
    background-position: top left, top right, bottom left, bottom right;
    font-family: 'Roboto Mono', monospace;
}

.func-input {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    margin: 0.5rem 0;
    padding: 0.8rem 1rem;
    background: #e8e8e8;
    border-radius: 0.5rem;
    border: 2px solid #666;
}

.func {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    padding: 0.5em 0.8em;
    background-repeat: no-repeat;
    background-size: 8px 2px;
    background-position: top left, top right, bottom left, bottom right;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.9rem;
}

.func-eqn-container {
    display: flex;
    width: 100%;
    align-items: center;
    font-size: 1.2rem;
}

.func-eqn-wrapper {
    flex: 1;
}

.func-eqn {
    font-family: 'Roboto Mono', monospace;
    font-size: 1.5rem;
    width: 100%;
    outline: none;
    border: 1px solid #222;
    border-radius: 2px;
    padding: 0.1rem;
    background: #e8e8e8;
    text-align: center;
    cursor: text;
}

.func-eqn.has-error {
    background: #d99d9d;
}

@media (max-width: 600px) {
    body {
        flex-direction: column;
    }

    .main {
        border-radius: 0 0.75rem 0.75rem;
    }

    .sidebar {
        height: 40vh;
        width: 100%;
        order: 2;
        overflow: scroll;
    }

    .eqn {
        overflow: initial;
    }
}

#draggables-container {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;

    /* prevent losing mouseup events */
    -webkit-user-select: none; /* Chrome all / Safari all */
    -moz-user-select: none; /* Firefox all */
    -ms-user-select: none; /* IE 10+ */
    user-select: none; /* Likely future */

    overflow: hidden;
}

#draggables-container.is-animating .dragging-cursor {
    display: none;
}

.dragging-cursor {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #0002;
    position: absolute;
    transform: translateX(-50%) translateY(-50%);
    top: 50%;
    left: 50%;
    transition: background 0.1s;
    cursor: grab;
}

.dragging-cursor:hover {
    background: #00000033;
}

.dragging-cursor.is-dragging {
    background: #9bcba89b;
    cursor: grabbing;
}

.dragging-cursor.is-hidden {
    display: none;
}
