

/* =========================================================
   MATEMATICAZ MATH 1.1
   ========================================================= */


body {
    /*
     * MathLive usa esta variable oficialmente para controlar
     * el orden del teclado virtual.
     */
    --keyboard-zindex: 100300;
}


html.mz-math-open,
html.mz-math-open body {
    overflow: hidden;
}


/* =========================================================
   BOTÓN PI DEL EDITOR PHPBB
   ========================================================= */

.mz-math-button {
    min-width: 42px !important;
    min-height: 36px !important;

    margin-left: 5px !important;

    border-radius: 9px !important;

    background: #eef4ff !important;

    color: #2563eb !important;

    font-family: Georgia, serif !important;
    font-size: 21px !important;
    font-weight: 800 !important;

    line-height: 1 !important;
}


.mz-math-button:hover {
    background: #dbeafe !important;

    color: #1d4ed8 !important;
}


/* =========================================================
   MODAL
   ========================================================= */

#mz-math-modal {
    position: fixed;

    inset: 0;

    z-index: 100000;

    display: none;

    align-items: center;
    justify-content: center;

    padding:
        28px
        20px;

    box-sizing: border-box;

    background:
        rgba(15, 23, 42, .76);

    backdrop-filter:
        blur(7px);
}


#mz-math-modal.is-open {
    display: flex;
}


/*
 * Cuando aparece el teclado virtual dejamos físicamente
 * espacio debajo del diálogo para que no se superpongan.
 */

#mz-math-modal.has-keyboard {
    align-items: flex-start;

    overflow-y: auto;

    padding-top: 16px;

    padding-bottom:
        calc(
            var(--mz-keyboard-height, 300px)
            + 22px
        );
}


/* =========================================================
   DIALOG
   ========================================================= */

.mz-math-dialog {
    width:
        min(
            940px,
            calc(100vw - 30px)
        );

    max-height:
        calc(100vh - 56px);

    display: flex;
    flex-direction: column;

    overflow: hidden;

    border:
        1px solid
        rgba(255,255,255,.2);

    border-radius: 22px;

    background: #ffffff;

    box-shadow:
        0 35px 100px
        rgba(0,0,0,.34);
}


#mz-math-modal.has-keyboard
.mz-math-dialog {

    max-height:
        calc(
            100vh
            - var(--mz-keyboard-height, 300px)
            - 38px
        );
}


/* =========================================================
   HEADER
   ========================================================= */

.mz-math-dialog-header {
    flex: 0 0 auto;

    min-height: 70px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 20px;

    padding:
        14px
        20px;

    box-sizing: border-box;

    border-bottom:
        1px solid #e2e8f0;

    background:
        linear-gradient(
            180deg,
            #ffffff,
            #fbfdff
        );
}


#mz-math-title {
    display: block;

    color: #0f172a;

    font-size: 19px;
    font-weight: 850;
}


.mz-math-subtitle {
    display: block;

    margin-top: 2px;

    color: #94a3b8;

    font-size: 10px;
    font-weight: 750;

    letter-spacing: .08em;

    text-transform: uppercase;
}


.mz-math-close {
    width: 42px;
    height: 42px;

    flex: 0 0 42px;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 0;

    border: 0;
    border-radius: 12px;

    background: #f1f5f9;

    color: #475569;

    font-size: 29px;
    font-weight: 300;

    line-height: 1;

    cursor: pointer;
}


.mz-math-close:hover {
    background: #e2e8f0;

    color: #0f172a;
}


/* =========================================================
   BODY
   ========================================================= */

.mz-math-dialog-body {
    flex: 1 1 auto;

    min-height: 0;

    overflow-y: auto;

    padding:
        20px
        22px;

    box-sizing: border-box;
}


/* =========================================================
   FORMULA LIBRARY
   ========================================================= */

.mz-formula-library {
    margin-bottom: 22px;
}


.mz-formula-library-title,
.mz-math-editor-label {
    margin-bottom: 9px;

    color: #334155;

    font-size: 11px;
    font-weight: 850;

    letter-spacing: .07em;

    text-transform: uppercase;
}


/* tabs */

.mz-formula-tabs {
    display: flex;

    gap: 7px;

    overflow-x: auto;

    padding-bottom: 9px;

    scrollbar-width: thin;
}


.mz-formula-tab {
    min-height: 36px;

    flex: 0 0 auto;

    padding:
        0
        13px;

    border:
        1px solid #e2e8f0;

    border-radius: 999px;

    background: #fff;

    color: #64748b;

    font-size: 11px;
    font-weight: 750;

    cursor: pointer;

    white-space: nowrap;

    transition:
        background .15s ease,
        border-color .15s ease,
        color .15s ease;
}


.mz-formula-tab:hover {
    border-color: #bfdbfe;

    background: #eff6ff;

    color: #2563eb;
}


.mz-formula-tab.is-active {
    border-color: #2563eb;

    background: #2563eb;

    color: #fff;
}


/* formulas */

.mz-formula-grid {
    display: grid;

    grid-template-columns:
        repeat(
            4,
            minmax(0, 1fr)
        );

    gap: 8px;
}


.mz-formula-button {
    min-width: 0;
    min-height: 62px;

    display: flex;
    flex-direction: column;

    align-items: flex-start;
    justify-content: center;

    gap: 4px;

    padding:
        10px
        12px;

    border:
        1px solid #e2e8f0;

    border-radius: 11px;

    background:
        #ffffff;

    text-align: left;

    cursor: pointer;

    transition:
        border-color .15s ease,
        background .15s ease,
        box-shadow .15s ease,
        transform .15s ease;
}


.mz-formula-button:hover {
    transform: translateY(-1px);

    border-color: #93c5fd;

    background: #f8fbff;

    box-shadow:
        0 5px 16px
        rgba(37,99,235,.08);
}


.mz-formula-name {
    max-width: 100%;

    color: #334155;

    font-size: 11px;
    font-weight: 800;

    line-height: 1.2;
}


.mz-formula-preview {
    max-width: 100%;

    overflow: hidden;

    color: #2563eb;

    font-family:
        Georgia,
        "Times New Roman",
        serif;

    font-size: 14px;

    line-height: 1.2;

    text-overflow: ellipsis;

    white-space: nowrap;
}


/* =========================================================
   MATH FIELD
   ========================================================= */

#mz-math-field {
    width: 100%;

    min-height: 82px;

    padding:
        16px
        18px;

    box-sizing: border-box;

    border:
        2px solid #cbd5e1;

    border-radius: 15px;

    background: #fff;

    color: #0f172a;

    font-size: 27px;

    transition:
        border-color .15s ease,
        box-shadow .15s ease;
}


#mz-math-field:focus-within {
    border-color: #2563eb;

    box-shadow:
        0 0 0 4px
        rgba(37,99,235,.11);
}


/* MathLive toggles */

math-field::part(
    virtual-keyboard-toggle
) {
    color: #2563eb;
}


math-field::part(
    menu-toggle
) {
    color: #2563eb;
}


/* =========================================================
   HINT / KEYBOARD BUTTON
   ========================================================= */

.mz-math-hints {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 15px;

    margin-top: 10px;

    color: #64748b;

    font-size: 11px;
}


.mz-keyboard-button {
    flex: 0 0 auto;

    min-height: 34px;

    padding:
        0
        12px;

    border:
        1px solid #dbe4f0;

    border-radius: 9px;

    background: #fff;

    color: #2563eb;

    font-size: 11px;
    font-weight: 750;

    cursor: pointer;
}


.mz-keyboard-button:hover {
    background: #eff6ff;

    border-color: #bfdbfe;
}


/* =========================================================
   BIG INSERT BUTTONS
   ========================================================= */

.mz-math-dialog-actions {
    flex: 0 0 auto;

    display: flex;

    align-items: stretch;
    justify-content: center;

    gap: 14px;

    padding:
        17px
        22px
        19px;

    border-top:
        1px solid #e2e8f0;

    background: #f8fafc;
}


.mz-insert-button {
    width: min(280px, 45%);

    min-height: 58px;

    display: flex;
    align-items: center;
    justify-content: center;

    gap: 11px;

    padding:
        9px
        18px;

    border-radius: 13px;

    cursor: pointer;

    text-align: left;

    transition:
        transform .15s ease,
        box-shadow .15s ease,
        background .15s ease;
}


.mz-insert-button:hover {
    transform:
        translateY(-2px);
}


.mz-insert-button span:last-child {
    display: flex;
    flex-direction: column;

    gap: 2px;
}


.mz-insert-button strong {
    font-size: 13px;
    font-weight: 850;

    line-height: 1.2;
}


.mz-insert-button small {
    font-size: 10px;
    font-weight: 600;

    line-height: 1.2;

    opacity: .74;
}


.mz-insert-icon {
    flex: 0 0 auto;

    font-size: 22px;
    font-weight: 700;
}


.mz-insert-inline {
    border:
        1px solid #cbd5e1;

    background: #ffffff;

    color: #334155;
}


.mz-insert-inline:hover {
    border-color: #93c5fd;

    color: #1d4ed8;

    box-shadow:
        0 8px 22px
        rgba(37,99,235,.10);
}


.mz-insert-display {
    border:
        1px solid #2563eb;

    background:
        linear-gradient(
            115deg,
            #2563eb,
            #4f46e5
        );

    color: #ffffff;

    box-shadow:
        0 9px 24px
        rgba(37,99,235,.20);
}


.mz-insert-display:hover {
    color: #ffffff;

    box-shadow:
        0 13px 30px
        rgba(37,99,235,.28);
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 820px) {

    .mz-formula-grid {
        grid-template-columns:
            repeat(
                2,
                minmax(0,1fr)
            );
    }

}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 560px) {

    #mz-math-modal {
        padding:
            8px;
    }


    #mz-math-modal.has-keyboard {
        padding:
            6px
            6px
            calc(
                var(
                    --mz-keyboard-height,
                    270px
                )
                + 8px
            );
    }


    .mz-math-dialog {
        width: 100%;

        border-radius: 17px;
    }


    .mz-math-dialog-header {
        min-height: 60px;

        padding:
            10px
            13px;
    }


    .mz-math-dialog-body {
        padding:
            14px
            13px;
    }


    .mz-formula-grid {
        grid-template-columns:
            repeat(
                2,
                minmax(0,1fr)
            );

        gap: 6px;
    }


    .mz-formula-button {
        min-height: 58px;

        padding:
            8px
            9px;
    }


    #mz-math-field {
        min-height: 72px;

        padding:
            12px;

        font-size: 23px;
    }


    .mz-math-hints {
        align-items: flex-start;
        flex-direction: column;
    }


    .mz-math-dialog-actions {
        display: grid;

        grid-template-columns:
            1fr;

        gap: 8px;

        padding:
            11px
            13px
            13px;
    }


    .mz-insert-button {
        width: 100%;

        min-height: 54px;
    }

}

