/* assets/css/calculatrice.css — le style et les dimensions de assets/calculatrice.html (dimensions FIXES : le texte s’adapte) */
html { color-scheme: light only !important; }
.calculator, .calculator * { color-scheme: light only; }
* { margin: 0; padding: 0; box-sizing: border-box; }
/* ===== les couleurs (reglage ⚙️) : une ligne par theme ===== */
:root { --page: #0a2745; --fond: linear-gradient(175deg, #082240 0%, #0c3a5c 60%, #0f5560 100%); --op: #14577a; --op-bord: #3f8aa8; --egal: linear-gradient(135deg, #00bfa6, #009fc0); --fonction: #e3f2f6; --res: #00796f; }
:root[data-couleur="noir"] { --page: #0b0d10; --fond: linear-gradient(175deg, #0b0d10, #1c2127); --op: #333b45; --op-bord: #59636f; --egal: linear-gradient(135deg, #f59e0b, #ea7a07); --fonction: #e7e9ec; --res: #9a5300; }
:root[data-couleur="ocean"] { --page: #073a68; --fond: linear-gradient(175deg, #073a68, #0e76b0); --op: #07548c; --op-bord: #5bb5e0; --egal: linear-gradient(135deg, #0891b2, #06b6d4); --fonction: #dff3fc; --res: #075985; }
:root[data-couleur="vert"] { --page: #0b2f22; --fond: linear-gradient(175deg, #0b2f22, #17624a); --op: #1d6b4d; --op-bord: #5bb08b; --egal: linear-gradient(135deg, #4d9a12, #65a30d); --fonction: #e4f4ea; --res: #166534; }
:root[data-couleur="violet"] { --page: #23163f; --fond: linear-gradient(175deg, #23163f, #4c2f85); --op: #55369a; --op-bord: #9d7fe0; --egal: linear-gradient(135deg, #c026d3, #9333ea); --fonction: #efe8fc; --res: #6b21a8; }
:root[data-couleur="rose"] { --page: #4a1230; --fond: linear-gradient(175deg, #4a1230, #8e2a5a); --op: #962e60; --op-bord: #e082ab; --egal: linear-gradient(135deg, #e11d48, #f43f5e); --fonction: #fce7f0; --res: #9d174d; }
:root[data-couleur="clair"] { --page: #dbe7ef; --fond: linear-gradient(175deg, #e8f1f7, #c9dbe8); --op: #44708f; --op-bord: #35607e; --egal: linear-gradient(135deg, #2563eb, #1d4ed8); --fonction: #fdf3dc; --res: #1d4ed8; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--page) !important;
    display: flex; justify-content: center; align-items: center;
    padding: 0 !important; margin: 0 !important; min-height: 0 !important;
}
/* la page est SEULEMENT la calculatrice : les boutons flottants du site la recouvriraient */
body > :not(.calculator):not(script):not(style):not(svg) { display: none !important; }
/* tout est en em : la taille suit le cadre (fenetre flottante ou telephone), rien ne depasse */
.calculator {
    position: relative; display: flex; flex-direction: column;
    width: 100%; height: 100%; max-width: 560px; max-height: 940px;
    font-size: 15px; font-size: clamp(9px, min(4.3vw, 2.5vh), 24px);
    padding: .6em; gap: .55em; overflow: hidden;
    background: var(--fond);
    color: #10222f !important;
}

.flot .calculator { max-width: none; max-height: none; }   /* elle remplit TOUTE la fenetre */

/* ===== l'ecran : l'ecriture mathematique en haut, le resultat en grand en bas ===== */
.display-container {
    flex: 0 0 var(--h-ecran, 40%); min-height: 0; display: flex; flex-direction: column;
    background: #f2f5f7; border-radius: 1.4em; padding: .5em .9em;
    border: 1px solid #9db4c4; box-shadow: inset 0 2px 8px rgba(10,34,64,.12);
}
.input-display, .result-display {
    flex: 1 1 50%; min-height: 0; display: flex; align-items: center; overflow: auto; scrollbar-width: none;
    direction: ltr; white-space: nowrap;
}
.input-display::-webkit-scrollbar, .result-display::-webkit-scrollbar { display: none; }
.input-display { color: #10263d !important; -webkit-text-fill-color: #10263d; font-size: 1.55em; }
.input-display > * { margin: 0 auto 0 0 !important; flex: none; }
.result-display { color: var(--res) !important; -webkit-text-fill-color: var(--res); font-size: 2.1em; font-weight: 700; }
.result-display > * { margin: 0 0 0 auto !important; flex: none; }
.input-display mjx-container, .result-display mjx-container { color: inherit; }
.result-display .erreur { direction: rtl; white-space: normal; flex: 1; text-align: right; font-size: .48em; color: #b3261e; -webkit-text-fill-color: #b3261e; }

/* ===== les touches ===== */
.buttons-grid {
    flex: 1 1 0; min-height: 0; display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: repeat(5, minmax(0, 1fr));
    gap: .45em; direction: ltr;
}
/* la rangee des fonctions : plus basse que le pave */
.calculator .buttons-grid.rangee-plus { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.calculator .buttons-grid .btn-sd { background: #fff6e0; color: #8a5a00; -webkit-text-fill-color: #8a5a00; border: 2px solid #e0a526; font-size: 1.2em; }
.calculator .rangee-plus, .calculator .rangee-fleches { flex: 0 0 7.5%; grid-template-rows: minmax(0, 1fr); }
.calculator .rangee-fleches { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.calculator .buttons-grid .btn-fleche { background: #ffd66b; color: #3a2600; font-size: 1.15em; }
.calculator button {
    border: none; cursor: pointer; border-radius: .85em; font-weight: 800; line-height: 1.1;
    font-family: inherit; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.calculator .buttons-grid button {
    width: 100% !important; max-width: none !important; height: 100% !important; min-width: 0 !important; min-height: 0 !important;
    margin: 0 !important; padding: 0 !important; overflow: hidden; font-size: 1.4em;
    box-shadow: 0 .15em .35em rgba(0,0,0,.28);
}
@media (hover: hover) { .calculator button:hover { filter: brightness(1.07); } }   /* au doigt, le survol restait colle */
.calculator button:active { filter: brightness(.9); }
/* la touche enfoncee : elle rentre, s'assombrit et s'entoure d'un halo — visible meme sous le doigt */
.calculator .buttons-grid { touch-action: none; }
.calculator .buttons-grid button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; transition: transform .09s ease-out, filter .09s ease-out, box-shadow .09s ease-out; }
.calculator .buttons-grid button.appuyee { transform: scale(.9) !important; filter: brightness(.76) saturate(1.25) !important; box-shadow: inset 0 .2em .5em rgba(0,0,0,.45), 0 0 0 .22em #ffd66b, 0 0 .8em .15em rgba(255,214,107,.75) !important; transition: none !important; }
.calculator .btn-number { background: #fff; color: #10263d; -webkit-text-fill-color: #10263d; }
.calculator .btn-function, .calculator .btn-parenthesis { background: var(--fonction); color: #10263d; }
.calculator .buttons-grid .petit { font-size: 1.05em; }
.calculator .btn-operator, .calculator .btn-delete, .calculator .btn-clear { background: var(--op); color: #fff; border: 1px solid var(--op-bord); }
.calculator .buttons-grid .btn-equal { background: var(--egal); color: #fff; grid-column: span 2; font-size: 1.9em; }
.pile { display: inline-flex; flex-direction: column; align-items: center; font-size: .62em; line-height: 1; vertical-align: middle; }
.pile i { font-style: normal; padding: 0 .25em; }
.pile i + i { border-top: 2px solid currentColor; padding-top: .12em; margin-top: .12em; }

/* ===== les etapes : DANS l'ecran, entre la saisie et le resultat ; le clavier reste libre ===== */
.volet { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; margin: .25em 0; border-top: 1px dashed #9db4c4; border-bottom: 1px dashed #9db4c4; }
.volet[hidden] { display: none; }
.avec-etapes .input-display, .avec-etapes .result-display { flex: 0 0 auto; max-height: 30%; }
.steps-container { flex: 1; min-height: 0; overflow: auto; }
.note { margin-top: .5em; background: #e3f2f6; border-radius: .6em; padding: .35em; font-size: .75em; color: #0c4a66; text-align: center; }
.step-title { color: var(--res); font-weight: bold; margin: .3em 0 .15em; font-size: .85em; }
.step-line { margin: .2em 0; padding: .25em .4em; background: #f2f6f8; border-radius: .5em; direction: ltr; text-align: left; font-size: 1.08em; overflow-x: auto; overflow-y: hidden; }
/* le CSS du site retrecissait les formules en silence : la mesure « est-ce que ca tient ? » mentait */
.calculator mjx-container, .calculator mjx-container svg { max-width: none !important; min-width: 0 !important; overflow: visible !important; }
.step-line code { display: inline-block; direction: ltr; unicode-bidi: isolate; }
.step-comment { color: #555; font-size: .8em; font-style: italic; margin-right: 10px; }

/* ===== la forme des touches et la taille de l'ecran ===== */
.calculator[data-touches="rondes"] .buttons-grid button { border-radius: 999px; }
.calculator[data-touches="carrees"] .buttons-grid button { border-radius: .2em; }
.calculator[data-ecran="petit"] { --h-ecran: 33%; }
.calculator[data-ecran="grand"] { --h-ecran: 49%; }

/* ===== le bouton ⚙️ et son panneau (il couvre la calculatrice, sans la depasser) ===== */
.display-container { position: relative; }
.calculator .btn-reglages { position: absolute; top: .35em; right: .5em; z-index: 6; width: 2em !important; min-width: 0 !important; height: 2em !important; min-height: 0 !important; margin: 0 !important; padding: 0 !important; font-size: .95em; line-height: 1; border: 1px solid #9db4c4; background: #fff; border-radius: 50%; }
.input-display { padding-right: 2.2em; }
.steps-container[dir="ltr"] { text-align: left; }
.reglages { position: absolute; inset: .5em; z-index: 20; display: flex; flex-direction: column; background: #fff; color: #10263d; border-radius: 1.1em; box-shadow: 0 8px 30px rgba(0,0,0,.45); overflow: hidden; }
.reglages[hidden] { display: none; }
.rg-tete { flex: none; display: flex; align-items: center; justify-content: space-between; padding: .5em .8em; border-bottom: 1px solid #d5e0e8; font-size: 1.1em; }
.rg-corps { flex: 1; min-height: 0; overflow: auto; padding: .4em .8em .9em; }
.rg-bloc { margin: .55em 0; }
.rg-titre { font-weight: 800; font-size: .9em; color: var(--res); margin-bottom: .3em; }
.rg-choix { display: flex; flex-wrap: wrap; gap: .4em; }
.calculator .reglages button { width: auto !important; max-width: none !important; min-width: 0 !important; height: auto !important; min-height: 0 !important; margin: 0 !important; font-size: .9em; transform: none; }
.calculator .reglages .rg-puce { padding: .45em .8em; background: #eef3f6; color: #10263d; border: 2px solid transparent; border-radius: .7em; }
.calculator .reglages .rg-puce[aria-pressed="true"] { background: #fff; border-color: var(--res); box-shadow: 0 0 0 1px var(--res); }
.calculator .reglages .rg-pastille { width: 2.3em !important; height: 2.3em !important; padding: 0; border-radius: 50%; border: 2px solid #c3d0da; }
.calculator .reglages .rg-pastille[aria-pressed="true"] { border-color: #10263d; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #10263d; }
.calculator .reglages .rg-fermer { padding: .2em .65em; background: #eef3f6; color: #10263d; border-radius: .6em; }
.calculator .reglages .rg-defaut { margin-top: .6em !important; padding: .5em 1em; background: #fdeeee; color: #8f1d16; border-radius: .7em; }
/* ===== installee sur le telephone ===== */
html, body { overscroll-behavior: none; }                 /* pas de « tirer pour actualiser » sur les touches */
/* iPhone : rien sous l'encoche ni sous la barre du bas (valeurs nulles ailleurs) */
.calculator { padding: calc(.6em + env(safe-area-inset-top, 0px)) calc(.6em + env(safe-area-inset-right, 0px)) calc(.6em + env(safe-area-inset-bottom, 0px)) calc(.6em + env(safe-area-inset-left, 0px)); }
@media (display-mode: standalone) { .calculator { max-height: none; } }
.calculator .btn-installer { right: 2.9em; }
.calculator .btn-installer[hidden] { display: none; }
.input-display { padding-right: 4.4em; }
.aide-installer p { margin: .5em 0; line-height: 1.6; }
.rg-etapes { margin: .5em 1.4em; line-height: 1.9; }
.reglages[dir="rtl"] .rg-etapes { margin-right: 1.4em; }
.calculator .reglages .rg-installer { margin: .4em 0 !important; background: var(--egal); color: #fff; font-size: 1.05em; padding: .6em 1.2em; }
