@import "~material-colors/dist/colors";

.demo-copy-code-button,
.demo_code .demo,
.demo_preview,
.demo_button,
.demo_toggle,
.demo_resize {
    box-sizing: border-box;
}

//Docsify themeable
:root {
    --code-block-border-radius: 0;
    --code-block-margin: 0;
}

//Sets up button
.demo-copy-code-button {
    position: absolute;
    bottom: 4px;
    right: 4px;
    text-transform: uppercase;
    padding: 8px;
    user-select: none;
    color: white;
    background: $md-grey-700;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: 350ms opacity;
}

pre:hover .demo-copy-code-button {
    opacity: 1;
}

.demo-copy-code-button.copied {
    animation: pulse 0.5s;
    --pulse-color: rgb(var(--sl-color-neutral-600));
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 $md-grey-600;
    }
    70% {
        box-shadow: 0 0 0 4px transparent;
    }
    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

//Improves code defaults
code {
    font-size: 14px;
    padding: 16px;
}

.markdown-section pre {
    padding: 0 1.5rem;
}

.markdown-section pre > code {
    padding: 2.2em 0;
    margin: 0;
}

//Controls code
.demo_code pre {
    margin: 0;
    max-width: 100%;
    border-left: solid 1px $md-grey-300;
    border-right: solid 1px $md-grey-300;
    border-top: solid 1px $md-grey-300;
}

pre,
.demo_preview_content {
    overflow: scroll;
}

//Style for demo container
.demo {
    overflow: visible;
    box-sizing: border-box;
    border-top-right-radius: 3px;
    position: relative;
    background: #fafafa;
    min-width: 20rem;
    margin-bottom: 1.5rem;
}

.demo_preview {
    padding: 1.5rem 3.25rem 1.5rem 1.5rem;
    border-top: solid 1px $md-grey-300;
    border-left: solid 1px $md-grey-300;
    border-top-right-radius: 3px;
    border-top-left-radius: 3px;
    background: white;
    position: relative;
    min-width: 20rem;
    min-height: 5rem;
    display: flex;
    align-items: center;
    max-width: 100%;
}

.demo_resize {
    color: #e4e4e7;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 1.75rem;
    font-size: 10px;
    color: $md-grey-600;
    border: 1px solid $md-grey-300;
    margin-top: -1px;
    margin-bottom: -1px;
    border-top-right-radius: 3px;
    cursor: ew-resize;
    transition: 250ms background-color;
}

.demo_button {
    background: white;
    position: relative;
    display: flex;
}

.demo_button svg {
    height: 9px;
}

.demo_toggle {
    border: solid 1px $md-grey-300;
    border-bottom-right-radius: 3px;
    border-bottom-left-radius: 3px;
    height: 2.5rem;
    color: $md-grey-600;
    position: relative;
    display: flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-appearance: none;
    transition: 250ms background-color;
}

.demo_resize:active,
.demo_toggle:hover {
    z-index: 2;
    background: $md-light-blue-50;
    color: $md-light-blue-600;
    border-color: $md-light-blue-300;
}

.demo_toggle:active,
.demo_resize:active {
    box-shadow: 0 0 0 1px $md-light-blue-100, 0 0 0 1px $md-light-blue-100;
}

//For smaller screens
@media screen and (max-width: 600px) {
    .demo_preview {
        border-right: solid 1px $md-grey-300;
        border-top-right-radius: 3px;
        padding-right: 1.5rem;
    }

    .demo_resize {
        display: none;
    }
}
