:root {
    --color-active: #0BB9F3;
}

#exercise {
    max-width: 800px;
    touch-action: manipulation;
}

#playGround {
    text-align: left;

    display: grid;
    grid-template-columns: min-content;
    justify-items: center;
    justify-content: center;
}

#rules h2 {
    text-align: center;
}

/********** INSTRUCTIONS **********/
#title {
    margin: 15px 0;
}

#instructions {
    background-color: white;
    border-radius: 3px;
    line-height: 1.3;
    padding: 15px;
    align-self: stretch;
}

#instructions .limit {
    background-color: var(--lightGray);
    display: inline-block;
    white-space: nowrap;

    border-radius: 1em;
    padding: 2px 5px;

    position: relative;
    z-index: 0;
}

#instructions .limit:after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background-color: var(--faintRed);
    border-radius: 1em;
    opacity: 0;
}

#instructions .limit.over-limit:after {
    animation: blink-inverse 750ms ease-in-out;
}

#instructions .limit-node:before {
    content: '';
    display: inline-block;

    background-color: white;
    border: 1px solid var(--black);
    width: .5em;
    height: .5em;
    border-radius: 50%;
    margin-right: 5px;

    vertical-align: baseline;
}

#instructions .limit-line:before {
    content: '';
    display: inline-block;

    background-color: var(--black);
    width: 1em;
    height: 3px;
    border-radius: 1px;
    vertical-align: middle;
    transform: translate(0, -50%) rotate(-45deg);
}

/********** CANVAS **********/
#canvas-wrapper {
    user-select: none;
    box-sizing: border-box;
    margin: 15px 0;

    background: #E1F1DF linear-gradient(-45deg, #D8F3E6 0%, #E6F6DA 50%, #F5F7DE 100%);
    border-radius: 0.4375rem;
    box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.015), 0 5px 16px 0 rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.03), inset 0 0 100px rgba(50, 63, 77, 0.05);
    position: relative;
}

#canvas-wrapper *, #canvas-wrapper *:before, #canvas-wrapper *:after {
    box-sizing: inherit;
}

#canvas {
    border-radius: inherit;
    box-sizing: border-box;
    display: block;
}
#canvas .touchsurface {
    fill: transparent;
}

#canvas path,
#canvas line {
    stroke-linecap: round;
    stroke-width: 1;
    stroke: rgba(50, 63, 77, 0.45);
    pointer-events: none;
}
#canvas path.taskline,
#canvas line.taskline {
    stroke: var(--black);
    stroke-width: 3;
    pointer-events: auto;
}
#canvas path.userline, #canvas path.selectedline,
#canvas line.userline,
#canvas line.selectedline {
    stroke: var(--color-active);
    stroke-width: 3;
}
#canvas path.solvedline,
#canvas line.solvedline {
    animation: 0.25s ease-in solved-path forwards;
}
#canvas path.flashline,
#canvas line.flashline {
    pointer-events: none;
    animation: 0.35s cubic-bezier(0, 0, 0, 0.7) flash-selected-line forwards;
}
#canvas path.flashline.solvedline,
#canvas line.flashline.solvedline {
    animation: 0.55s cubic-bezier(0, 0, 0, 0.7) flash-solved-line forwards;
}
#canvas .node {
    fill: transparent;
    transition: fill 0.15s ease-out, stroke 0.15s ease-out;
}
#canvas .node.tasknode {
    stroke: var(--black);
    fill: white;
    stroke-width: 2;
}
#canvas .node.usernode, #canvas .node.selectednode {
    stroke: var(--color-active);
    fill: white;
}
#canvas .node.selectednode {
    stroke-width: 2.5;
}
#canvas .node.usernode.solvednode, #canvas .node.tasknode.solvednode, #canvas .node.selectednode.solvednode {
    animation: 0.25s ease-in solved-node forwards;
}
#canvas .node.flashnode {
    pointer-events: none;
    animation: 0.35s cubic-bezier(0, 0, 0, 0.7) flash-selected-node forwards;
}
#canvas .node.flashnode.solvednode {
    animation: 0.55s cubic-bezier(0, 0, 0, 0.7) flash-solved-node forwards;
}
#canvas circle.indicator {
    fill: white;
    stroke-width: 1.5;
    stroke: var(--color-active);
    transition: fill 0.15s ease-out, stroke 0.15s ease-out;
}
#canvas circle.indicator.snapped {
    stroke: var(--violet);
}
#canvas line.indicator {
    stroke-width: 3;
    stroke: var(--color-active);
    transition: fill 0.15s ease-out, stroke 0.15s ease-out;
}
#canvas line.indicator.crosshair {
    stroke-width: 1;
    stroke: rgba(50, 63, 77, 0.5);
}
#canvas line.indicator.crosshair.snapped {
    stroke: var(--violet);
}
@media only screen and (min-width: 900px) {
    #canvas line.indicator.crosshair {
        stroke-width: 0;
    }
}
#canvas line.indicator.snapped {
    stroke: var(--violet);
}
#canvas .label {
    pointer-events: none;
    font-size: 1rem;
    font-weight: 700;
    fill: var(--black);
}
#canvas .no-pointer-events {
    pointer-events: none !important;
}

/********** ANIMATIONS **********/
@keyframes flash-selected-line {
    0% {
        stroke: var(--color-active);
        opacity: .5;
    }
    100% {
        stroke: var(--color-active);
        opacity: 0;
        stroke-width: 16;
    }
}
@keyframes flash-solved-line {
    0% {
        stroke: var(--green);
        opacity: .5;
    }
    100% {
        stroke: var(--green);
        opacity: 0;
        stroke-width: 16;
    }
}
@keyframes flash-selected-node {
    0% {
        stroke: var(--color-active);
        opacity: .5;
    }
    100% {
        stroke: var(--color-active);
        opacity: 0;
        stroke-width: 24;
    }
}
@keyframes flash-solved-node {
    0% {
        stroke: var(--green);
        opacity: .5;
    }
    100% {
        stroke: var(--green);
        opacity: 0;
        stroke-width: 24;
    }
}
@keyframes solved-path {
    0% {
        stroke: var(--color-active);
    }
    100% {
        stroke: var(--green);
        stroke-width: 4;
    }
}
@keyframes solved-node {
    0% {
        stroke: var(--color-active);
    }
    100% {
        stroke: var(--green);
        stroke-width: 2;
    }
}

@keyframes blink-inverse {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}
