/* ============================================================
   math-notation.css  v1.0
   Notations mathématiques pour automatismes, quiz, flashcards
   Remplace et étend CSS-FRACTIONS-PARFAIT.css
   Chargé par : automatismes.html, quiz.html, flashcards.html
   ============================================================ */


/* ============================================================
   1. FRACTIONS
   Les nouvelles classes sont .mn-frac / .mn-num / .mn-den.
   Les anciennes classes collège (.fraction / .numerator / .denominator)
   sont aliasées ci-dessous pour compatibilité sans charger l'ancien CSS.
   ============================================================ */

.mn-frac,
.fraction {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 0.15em;
    line-height: 1;
    font-size: 1em;
    position: relative;
}

.mn-frac .mn-num,
.mn-frac .mn-den,
.fraction .numerator,
.fraction .denominator {
    padding: 0.05em 0.25em;
    font-size: 0.85em;
    line-height: 1.3;
    text-align: center;
    white-space: nowrap;
}

/* Trait de fraction */
.mn-frac::after,
.fraction::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: currentColor;
    transform: translateY(-50%);
    pointer-events: none;
}


/* ============================================================
   2. PUISSANCES  (exposant)
   ============================================================ */

.mn-pow {
    display: inline;
    white-space: nowrap;
    vertical-align: baseline;
}

.mn-pow .mn-base {
    display: inline;
}

.mn-pow .mn-exp {
    display: inline;
    font-size: 0.72em;
    vertical-align: super;
    line-height: 0;     /* évite d'augmenter la hauteur de ligne */
}


/* ============================================================
   3. RACINES CARRÉES
   ============================================================ */

.mn-sqrt {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
    white-space: nowrap;
    position: relative;
    margin: 0 0.1em;
}

/* Crochet bas-gauche de la racine */
.mn-sqrt::before {
    content: "√";
    font-size: 1.1em;
    line-height: 1;
    margin-right: 0.05em;
    /* Ajustement vertical pour aligner avec le trait */
    align-self: flex-end;
    padding-bottom: 0.05em;
}

.mn-sqrt .mn-sqrt-body {
    display: inline-block;
    padding: 0.05em 0.25em 0.05em 0.1em;
    /* Trait supérieur = barre de la racine */
    border-top: 1.5px solid currentColor;
    line-height: 1.3;
}


/* ============================================================
   4. VECTEURS  (flèche au-dessus)
   ============================================================ */

.mn-vec {
    display: inline-block;
    position: relative;
    vertical-align: middle;
    text-align: center;
    white-space: nowrap;
}

/* Flèche vectorielle via ::before sur une classe interne */
.mn-vec .mn-vec-label {
    display: inline-block;
    padding-top: 0.45em;   /* espace pour la flèche */
    position: relative;
}

/* Flèche SVG inline encodée en base64 pour compatibilité maximale */
.mn-vec .mn-vec-label::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 0.4em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 8'%3E%3Cline x1='0' y1='4' x2='27' y2='4' stroke='currentColor' stroke-width='1.5'/%3E%3Cpolygon points='27,1 32,4 27,7' fill='currentColor'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    pointer-events: none;
}

/* Fallback CSS pur quand SVG non supporté */
@supports not (background-image: url("data:image/svg+xml,%3Csvg%3E%3C/svg%3E")) {
    .mn-vec .mn-vec-label::before {
        content: "→";
        position: absolute;
        top: -0.1em;
        left: 0;
        right: 0;
        font-size: 0.75em;
        line-height: 1;
        text-align: center;
        height: auto;
        background-image: none;
    }
}


/* ============================================================
   5. COORDONNÉES VERTICALES  (couple colonne)
   ============================================================ */

.mn-coord {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    vertical-align: middle;
    margin: 0 0.1em;
    font-size: 0.9em;
    line-height: 1.3;
    /* Parenthèses via pseudo-éléments */
    position: relative;
    padding: 0 0.35em;
}

.mn-coord::before {
    content: "(";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.6em;
    line-height: 0;
    font-weight: 300;
}

.mn-coord::after {
    content: ")";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.6em;
    line-height: 0;
    font-weight: 300;
}

.mn-coord .mn-coord-x,
.mn-coord .mn-coord-y {
    text-align: center;
    padding: 0 0.3em;
    white-space: nowrap;
}


/* ============================================================
   6. VALEUR ABSOLUE
   ============================================================ */

.mn-abs {
    display: inline;
    white-space: nowrap;
}

.mn-abs::before { content: "|"; margin-right: 0.05em; }
.mn-abs::after  { content: "|"; margin-left:  0.05em; }


/* ============================================================
   7. NOTATION SCIENTIFIQUE  (mantisse × 10^n)
   ============================================================ */

.mn-sci {
    display: inline;
    white-space: nowrap;
}

.mn-sci .mn-sci-mantisse { display: inline; }

.mn-sci .mn-sci-sep {
    display: inline;
    margin: 0 0.15em;
}

/* 10^n utilise mn-pow en interne */


/* ============================================================
   8. INTERVALLES  (crochets + borne)
   ============================================================ */

.mn-interval {
    display: inline;
    white-space: nowrap;
    letter-spacing: 0.02em;
}


/* ============================================================
   9. OPÉRATEURS SPÉCIAUX
   ============================================================ */

/* Signe multiplication centré */
.mn-times { margin: 0 0.2em; }

/* Signe division ÷ */
.mn-div   { margin: 0 0.2em; }

/* Flèche implication */
.mn-arrow { margin: 0 0.25em; }

/* Ensemble (ℝ, ℤ, ℕ, ℚ) */
.mn-set { font-style: normal; }


/* ============================================================
   10. IMPRESSION — OVERRIDES
   ============================================================ */

@media print {

    /* Fractions */
    .mn-frac,
    .fraction {
        display: inline-table !important;
        border-collapse: collapse;
        text-align: center;
        vertical-align: middle;
        margin: 0 0.2em !important;
        page-break-inside: avoid;
    }

    .mn-frac::after,
    .fraction::after { display: none !important; }

    .mn-frac .mn-num,
    .fraction .numerator {
        display: table-row !important;
        border-bottom: 1.5px solid #000 !important;
        padding: 0 0.3em 0.1em !important;
        font-size: 0.9em !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .mn-frac .mn-den,
    .fraction .denominator {
        display: table-row !important;
        padding: 0.1em 0.3em 0 !important;
        font-size: 0.9em !important;
    }

    /* Racines */
    .mn-sqrt .mn-sqrt-body {
        border-top: 1.5px solid #000 !important;
    }

    /* Vecteurs */
    .mn-vec .mn-vec-label::before {
        background-image: none !important;
        content: "→" !important;
        position: absolute !important;
        top: -0.1em !important;
        font-size: 0.75em !important;
        height: auto !important;
    }

    /* Coordonnées */
    .mn-coord::before { content: "(" !important; }
    .mn-coord::after  { content: ")" !important; }

    /* Global */
    .mn-frac, .fraction,
    .mn-sqrt,
    .mn-vec,
    .mn-coord,
    .mn-pow,
    .mn-abs,
    .mn-sci {
        color: #000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}
