// main: backend.scss
@import "colors";

.widget.snippet-preview {

    > div {

        font-family: arial,sans-serif;
        font-size: 20px;
        padding: 15px;
        margin-top: 3px;
        border: 1px solid $col-gray;

        > div {
            width: calc(100% - 15px);
            max-width: 560px;
            overflow: hidden;
        }

        @media screen and (max-width: 560px) {

            font-size: 16px;

            > .url,
            > .title { white-space: normal; }
        }
    }

    .url {

        position: relative;

        font-size: 12/20*1em;
        line-height: 18/12*1;
        font-weight: 400;
        color: #4d5156;

        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
    }

    .title {

        font-size: 1em;
        line-height: 26/20*1;
        padding-top: 4px;
        margin-bottom: 3px;
        font-weight: 400;
        color: #1a0dab;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;

        span {
            font-size: inherit;
            line-height: inherit;
            font-weight: inherit;
        }
    }

    .description {
        font-size: 14/20*1em;
        line-height: 22/14*1;
        font-weight: 400;
        color: #4d5156;
    }

    p.explanation {

        margin-top: 1em;
        margin-bottom: 0;
        padding: 15px;

        background: $col-yellow-light;

        line-height: 1.4;
        color: darken($col-yellow-light,40%);

        a {
            color: inherit;
            text-decoration: underline;
        }

        em {
            font-style: normal;
            font-family: "Courier New", Courier, "Lucida Console", Monaco, monospace;
        }
    }

    &:has(p.explanation) {

        .title span {
            color: $col-orange;
        }
    }
}

.widget.snippet {

    > input, > textarea {
        display: none;
    }

    > div[contenteditable] {

        width: 100%;
        line-height: normal;
        font-size: .875rem;
        min-height: 30px;

        mark {
            background: $col-red;
            color: $col-white;
        }

        &[class*="length_"] {

            outline: none;

            &.length_short { box-shadow: 0px 3px 0px 0px $col-yellow-light; }
            &.length_long { box-shadow: 0px 3px 0px 0px $col-red; }
            &.length_optimal { box-shadow: 0px 3px 0px 0px $col-green; }
        }

    }

    > input + div[contenteditable] {
        @media screen and (min-width: 1500px) {
            white-space: nowrap;
        }
        overflow: hidden;
    }

    > textarea + div[contenteditable] {
        height: auto !important;
        min-height: 30px;
    }

    h3 label {

        display: flex;
        justify-content: space-between;

        .snippet-count {
            font-weight: 400;
            font-size: 0.8em;
        }

        + img { display: none; }
    }

    h3:has(label + button) {

        display: flex;

        label {
            flex-grow: 1;
            flex-basis: 0;
        }
    }
}

html[data-color-scheme="dark"] {

    .widget.snippet-preview {

        > div {

            border-color: var(--content-border);
            background: #1f1f1f;
        }

        .url,
        .description {
            color: #bdc1c6;
        }

        .title {
            color: #99c3ff;
        }

        p.explanation {
            background: #{rgba($col-yellow-light,0.2)};
        }
    }
}