html {
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  display: grid;
  font-family: sans-serif;
  width: 100%;
  overflow: hidden;
}

@font-face {
    font-family: 'Marelle';
    src: url('polices/Marelle-Regular.woff2') format('woff2');
    font-display: swap;
}

:root {
  --largeurDroite: 100%;  
}

/* Styles génériques */
#outils, #panneau {
  color: white;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  border: none;
  /* effet glossy */
  background: linear-gradient(to bottom, rgba(255,255,255,0.25), rgba(0,0,0,0.15)),
              linear-gradient(135deg, #6a9ae2, #3a66c6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6),
              0 2px 5px rgba(0,0,0,0.3);
}

#plateau {
  background: #cac6bf;
  background-image: url(images/fond.jpg);
  background-repeat: repeat;
  position: relative;
}

.popup {
  position: absolute;
  z-index: 1000000;
  background-color: #000000a2;
  color: #ffffff;
  padding: 0.5em;
  border: 2px gray solid;
  border-radius: 5px;
  font-size: 24px;
}

.popup button {
  margin: 0.25em;
  padding: 0.1em;
  width: 2em;
  font-size: 24px;
}

body.primtux #educajou {
  visibility: hidden;;
}

#corbeille {
  position: absolute;
  bottom: 5px;
  left: 50%;
  transform: translateX(-50%);
  height: 50px;
  width: 40px;
  background-image: url(images/corbeille2.svg);
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}


#boutonszoom button {
    height: 40px;
    width: 40px;
    font-size: 30px;
    font-family: Arial, Helvetica, sans-serif;
    background-size: contain;
    background-repeat: no-repeat;
    background-color: transparent;
    border: none;
    outline: none;
    opacity: 1;
    transition: opacity 0.2s ease;
}


#unite {
  position: absolute;
  background-color: #d4d4d4;
  height: 60px;
  transition: width 0.3s linear, left 0.3s linear;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 30px;
  font-weight: bold;
  color: #ffffff;
  text-shadow: 1px 1px #978d8d;
  user-select: none;
  position: relative;
  border-radius: 5px;
}

#unite span {
  z-index: 1;
  background-color: #d4d4d4;
  padding: 5px;
}

#trait {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  height: 10px;
  width: calc(100% - 40px);
  background-color: #fff;
  z-index: 0;
}

#trait::before {
  content: '';
  position: absolute;
  top: 50%;
  right: 100%;
  transform: translateY(-50%);
  width: 0;
  height: 0;   
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;  
  border-right: 20px solid #ffffff;
}

#trait::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  transform: translateY(-50%);
  width: 0;
  height: 0;   
  border-top: 20px solid transparent;
  border-bottom: 20px solid transparent;  
  border-left: 20px solid #ffffff;
}

#panneau {
  text-align: center;
}

#outils {
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row;  
}

#outils a {
  display: inline-flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: #fff;
  
}

#outils a img {
  height: 100%;
}


#outils h1 {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 50%;
  margin: 0;
  text-align: center;
  opacity: 0.5;
}

.boutonFraction {
  height: 3em;
  width: 2em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 5px;
  padding: 5px;
  vertical-align: middle;
  border-radius: 5px;
    background: linear-gradient(to bottom, rgba(255,255,255,0.25), rgba(0,0,0,0.15)),
              linear-gradient(135deg, #6a9ae2, #3a66c6);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6),
              0 2px 5px rgba(0,0,0,0.3);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.boutonFraction:hover {
  filter: brightness(1.3);
  cursor: pointer;
}

.boutonFraction.desactive {
  opacity: 0.2;
}

.boutonFraction.actif {
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.6),
        0 0 8px rgba(39, 255, 50, 0.9); /* plus opaque et plus large */
}

#supprimer {
  background-image: url(images/corbeille.svg);
}

#ecouter {
  background-image: url(images/ecouter.svg);
}

#afficherValeurs {
  background-image: url(images/masquer.svg);
}

#couleurs {
  background-image: url(images/pascouleurs.svg);
}

#ciseaux {
  background-image: url(images/ciseaux.svg);
}

#colle {
  background-image: url(images/colle.svg);
}

#egal {
  background-image: url(images/egal.svg);
}

#main {
  background-image: url(images/grab.png);
}

#droite {
  background-image: url(images/droite.svg);
}

#parametres {
  background-image: url(images/parametres.svg);
}


.fraction {
    position: absolute;
    height: 60px;
    background-color: aqua;
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    box-shadow: 0px 0px 5px #0000008a inset;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

.fraction.voisinAGauche::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translateY(-50%) translateX(-50%);
  height: 30%;
  width: 30px;
  max-width: min(7.5vw,40%);
  pointer-events: none;
  background-image: url(images/chaine.svg);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.fraction.lecture {
  z-index: 1000000 !important;
  font-weight: bold;
}

.fraction.lecture::before {
  content: '';
  position: absolute;
  height: 100%;
  width: 100%;
  border: 5px solid red;
  border-radius: 5px;
  top: -5px;
  left: -5px;
  z-index: -1;
}

.fraction.suppression {
  opacity: 0.5;
}

#plateau.animation>.fraction {
  transition: width 0.3s linear, left 0.3s linear;
}

#plateau.animation>.sucette {
  transition: left 0.3s linear;
}

#plateau.colle .fraction.groupable {
  cursor: url(images/colle-penchee.png) 16 16, auto;
}

.d1 {
  background-color: var(--color-d1);
  color: var(--text-color-d1);
}
.d2 {
  background-color: var(--color-d2);
  color: var(--text-color-d2);
}
.d3 {
  background-color: var(--color-d3);
  color: var(--text-color-d3);
}
.d4 {
  background-color: var(--color-d4);
  color: var(--text-color-d4);
}
.d5 {
  background-color: var(--color-d5);
  color: var(--text-color-d5);
}
.d6 {
  background-color: var(--color-d6);
  color: var(--text-color-d6);
}
.d8 {
  background-color: var(--color-d8);
  color: var(--text-color-d8);
}
.d9 {
  background-color: var(--color-d9);
  color: var(--text-color-d9);
}
.d10 {
  background-color: var(--color-d10);
  color: var(--text-color-d10);
}
.d12 {
  background-color: var(--color-d12);
  color: var(--text-color-d12);
}


.conteneurDroite {
  position: absolute;
  width: 95%;
  background-color: #ffffffb0;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding-left: 2.5%;
  padding-right: 2.5%;
  padding-bottom: 10px;
  box-sizing: border-box;
  overflow: hidden;
}

.conteneurDroite::after {
  content: '';
  height: calc(100% + 10px);
  width: calc(100% + 10px);
  position: absolute;
  top: -5px;
  left: -5px;
  border-radius: 10px;
  background-color: #ffffff86;
  z-index: -1;
}

.zoneBoutons {
  background-color: #ffffff;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-evenly;
  box-sizing: border-box;
  width: 105.2631579%;
  padding: 5px;
  box-shadow: 0px 3px 3px gray;
  pointer-events: none;
  user-select: none;
}

.zoneBoutons button {
  height: 2em;
  pointer-events: all;
}

.zoneBoutons span {
  margin-right: 0.6em;
  margin-left: 0.6em;;
  font-weight: bold;
}

.conteneurDroite.entiers button.entiers, .conteneurDroite.fractions button.fractions, .conteneurDroite.decimaux button.decimaux,.conteneurDroite.aucune button.aucune {
  background-color: #4bbe1d !important;
}


.droite {
  height: 100px;
  width: var(--largeurDroite);
  transition: width 0.3s linear, left 0.3s linear;
  pointer-events: none;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-end;
  position: relative;
  z-index: 90000;
  margin-bottom: 50px;
}

.droite::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 50%;
  left: -3px;
  bottom: -6px;
  border-bottom: 6px #000000 solid;
  border-left: 3px #000000 solid;
  border-right: 3px #000000 solid;
  pointer-events: none;
}


.blocUnite {
  flex: 1;
  height: 50%;
  box-sizing: border-box;
  box-shadow: inset 3px 0 0 #000000, inset -3px 0 0 #000000;
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: space-evenly;
  align-items: flex-end;
}

.graduation {
  height: 25%;
  width: 3px;
  background-color: #0e2799;
  position: relative;
  top: 25%;
}

.droite.den10 .blocUnite .graduation:nth-of-type(5) {
  height: 40% !important;
  top: 40%;
}


.etiquette {
  position: absolute;
  top: 100%;
  left: 100%;
  transform: translateX(-50%);
  font-size: 20px;
  font-family: Marelle;
  font-weight: bold;  
  width: 1em;
  text-align: center;
}

.graduation > .etiquette {
  width: auto !important;
  color: #0e2799;
  font-size: 12px;  
  top: 100%;
  left: 50%;
  letter-spacing: -15%;
}

.droite.den10 .blocUnite .graduation:nth-of-type(5) > .etiquette {
  color: purple;
}


.graduation > .etiquette > span {
  line-height: 15px;
}


.graduation > .etiquette.frac {
  top: 130%;
}


.conteneurDroite:not(.fractions) .frac {
  display: none !important;
}

.conteneurDroite:not(.decimaux) .dec {
  display: none;
}

.etiquette.debut {
  left: 0%;
}

.conteneurDroite.aucune .etiquette {
  display: none;
}

#plateau.monochrome>.fraction {
  background-color: #b46c41 !important;
  color: #000000 !important;
}

.spanEcritureFractionnaire {
    position: relative;
    display: flex;
    flex-direction: column;
    font-weight: bolder;
    border-radius: 50%;
    font-family: Marelle;
    font-size: 18px;
    line-height: 28px;
    transition: color 0.2s ease, top 0.3s ease, padding 0.3s ease, background-color 0.3s ease;
    top: 0%;
    padding: 0px;
}

.fraction.place .spanEcritureFractionnaire {
  top: -25%;
  padding: 3px 10px 3px 10px;
  box-shadow: 0 10px 5px -7px #0000008a inset;
  background-color: inherit;
}

#plateau.masquerValeurs .spanEcritureFractionnaire {
  display: none;
}


.spanNumerateur, .spanDenominateur {
    padding-left: 0.1em;
    padding-right: 0.1em;
    pointer-events: none;
    flex: 1;
    user-select: none;
    text-align: center;
    transition: color 0.2s ease;
}

.spanBarreFraction {
    width: 100%;
    height: 3px;
    background-color: currentColor;
    pointer-events: none;
    transition: background-color 0.2s ease;
}

.boutonFraction .spanBarreFraction {
  background-color: #fff !important;  
}

.fraction .spanEcritureFractionnaire, .fraction .spanNumerateur, .fraction .spanDenominateur {
  color: inherit;
}

#plateau.monochrome .spanBarreFraction {
  background-color: #000000 !important;
}


#darkbox {
  position: absolute;
  z-index: 99999;
  top: 0px;
  left: 0px;
  width: 100%;
  height: 100%;
}

.lightbox {
  position: absolute;
  z-index: 100000;
  top: 50%;
  left: 50%;
  transform: translateX(-50%) translateY(-50%);
  background-color: white;
  border: 2px black solid;
  border-radius: 20px;
  max-width: 80%;
  max-height: 80%;
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.boutonFermer {
  position: absolute;
  top: 3px;
  right: 3px;
  height: 30px;
  width: 30px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  font-weight: bold;
  background-color: #ffffff;
  color: #000000;
  border-radius: 50%;
  z-index: 1000;
  font-family: Arial, Helvetica, sans-serif;
}

.lightbox h2 {
  padding-left: 50px;
  padding-right: 50px;
}

.contenu-lightbox {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  color: #000000;
}

.section {
  border-top: 1px black solid;
}

.sous-section {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.reglage {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 5px;
}

.intituleReglageCouleur {
  display: inline-block;
  font-size: 20px;
  width: 3em;
  text-align: center;
}

.boutonVerrouillage {
  height: 2em;
  width: 2em;
  background-image: url(images/locker.svg);
  background-size: 90%;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 0.2em;
}

.conteneurDroite:not(.deplacable) .boutonVerrouillage {
  background-color: red;
}


.boutonSucette {
  height: 2em;
  width: 2em;
  background-image: url(images/sucette.svg);
  background-size: 90%;
  background-position: center;
  background-repeat: no-repeat;
  border-radius: 0.2em;
}

.sucette {
  position: absolute;
  width: 20px;
  height: 50px;
  --couleur: #e63946;}

/* Disque coloré avec reflet */
.sucette::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background:
    /* reflet brillant, en haut à gauche */
    radial-gradient(circle at 32% 28%,
      rgba(255, 255, 255, 0.95) 0,
      rgba(255, 255, 255, 0.55) 12%,
      rgba(255, 255, 255, 0) 38%),
    /* volume : zone claire vers zone sombre */
    radial-gradient(circle at 38% 34%,
      var(--couleur) 0%,
      var(--couleur) 45%,
      rgba(0, 0, 0, 0.45) 100%);
  background-color: var(--couleur);
  box-shadow:
    inset -2px -3px 4px rgba(0, 0, 0, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Aiguille fine */
.sucette::after {
  content: "";
  position: absolute;
  top: 19px;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: 6px;
  height: 31px;
  background:
    /* assombrit progressivement vers la pointe */
    linear-gradient(to bottom,
      rgba(40, 40, 40, 0) 0%,
      rgba(40, 40, 40, 0) 50%,
      rgba(40, 40, 40, 0.8) 100%),
    /* shading horizontal */
    linear-gradient(to right,
      #6b6b6b 0%, #d9d9d9 35%, #f5f5f5 50%, #d9d9d9 65%, #6b6b6b 100%);
  clip-path: polygon(0 0, 100% 0, 100% 80%, 50% 100%, 0 80%);
  z-index: -1;
}

.menuConextuel {
    position: fixed;
    z-index: 1000000;
    display: flex;
    flex-direction: column;
    background: white;
    border: 1px solid #ccc;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    padding: 4px;
    min-width: 120px;
}

.menuConextuel button {
    background: none;
    border: none;
    padding: 6px 10px;
    text-align: left;
    font: inherit;
    cursor: pointer;
    border-radius: 4px;
}

.menuConextuel button:hover {
    background: #e8f0fe;
}

.survol {
  filter: brightness(1.1);
}

.d9.survol {
  background-color: #2c2c2c;
}

.d1.survol {
  filter: none;
  box-shadow: 0px 0px 5px #214aff8a inset;
}

/* Mode paysage */
@media (orientation: landscape) {
  body {
    grid-template-areas:
      "outils outils"
      "panneau plateau";
    grid-template-rows: 60px 1fr; /* outils à 100px */
    grid-template-columns: 125px 1fr; /* panneau latéral */
  }

  #outils {
    grid-area: outils;
  }

  #panneau {
    grid-area: panneau;
    overflow-y: auto;
  }

  #plateau {
    grid-area: plateau;
  }
}

/* Mode portrait */
@media (orientation: portrait) {
  
  .hideMobile {
    display: none !important;
  }
    

  body {
    grid-template-areas:
      "outils"
      "plateau"
      "panneau";
    grid-template-rows: 75px 1fr auto;
    grid-template-columns: 1fr;
  }

  #outils {
    grid-area: outils;
    max-width: 100%;
    overflow-x: hidden;
  }

  #panneau {
    grid-area: panneau;
    max-width: 100%;
    overflow-x: auto;

    height: fit-content;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .boutonFraction {
    flex-shrink: 1;
    margin: 2px;
  }

  #plateau {
    grid-area: plateau;
  }
}

@media (max-height: 674px) {
  .hidePetitsEcrans {
    display: none !important;
  }
}

.hide {
  display: none !important;
}