/**
 * Copyright (c) Enalean, 2021 - Present. All Rights Reserved.
 *
 * This file is a part of Tuleap.
 *
 * Tuleap is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * Tuleap is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
 */

tlp-mermaid-diagram {
    display: block;
    margin: 0 0 var(--tlp-medium-spacing);

    &:last-child {
        margin: 0;
    }

    pre > code {
        word-break: break-all;
        white-space: pre-wrap;
    }
}

.diagram-mermaid-computing {
    visibility: hidden;
}

.diagram-mermaid-source-computing {
    position: relative;

    > pre {
        opacity: 0.5;
        cursor: wait;
    }

    > i {
        $size: 1.5rem;

        position: absolute;
        top: calc(50% - #{$size} / 2);
        left: calc(50% - #{$size} / 2);
        color: var(--tlp-dimmed-color);
        font-size: $size;
    }

    &.diagram-mermaid-source-computing-error {
        > pre {
            cursor: auto;
        }
    }

    &.diagram-mermaid-source-computing-error-with-details {
        > pre {
            margin: 0;
            border-bottom: 0;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
        }

        > .diagram-mermaid-source-computing-explanation {
            margin-top: 0;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
    }
}

.diagram-mermaid {
    cursor: zoom-in;
}

.diagram-mermaid-backdrop-magnified {
    display: flex;
    position: fixed;
    z-index: 2005;
    inset: 0;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
    padding: var(--tlp-x-large-spacing);
    background: var(--tlp-backdrop-color);
    cursor: zoom-out;

    > .diagram-mermaid {
        display: flex;
        box-sizing: border-box;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        padding: var(--tlp-medium-spacing);
        overflow: hidden;
        border-radius: var(--tlp-medium-radius);
        background: var(--tlp-white-color);
        cursor: all-scroll;
    }

    &.diagram-mermaid-panzoom-loading > .diagram-mermaid {
        cursor: wait;
    }

    > .diagram-mermaid-close-button {
        display: inherit;
    }
}

.diagram-mermaid-close-button {
    display: none;
    position: absolute;
    top: var(--tlp-x-large-spacing);
    right: var(--tlp-x-large-spacing);
    padding: var(--tlp-medium-spacing);
    transition: color ease-in-out 150ms;
    border: 0;
    background-color: unset;
    color: var(--tlp-dimmed-color);
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;

    &:hover {
        color: var(--tlp-main-color);
    }
}
