/* defi-du-jour.php — règles propres à cette page.
   L'habillage commun vient de fichiers-partages-des-jeux/css/jeu.css. */

/* Habillage commun (body, #app, top-bar, boutons, info-bar, overlay,
   classement) : fichiers-partages-des-jeux/css/jeu.css.
   Ici, uniquement ce qui est propre a ce jeu. */
#app {
  position: relative;
  z-index: 1;
  padding: 32px 28px 28px;
  max-width: 800px;
  transition: max-width 0.3s ease;
}

#app.expert-actif {
  max-width: 960px;
}

.header {
  text-align: center;
  margin-bottom: 32px;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 8px;
  font-family: var(--font-display);
  color: #f0f3f6;
}

.header .date-jour {
  font-size: 1rem;
  color: var(--texte-doux);
}

/* Intro du mode défi */
.intro-defi {
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 24px;
  text-align: left;
}

.intro-defi-titre {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--texte);
  margin-bottom: 6px;
}

.intro-defi-text {
  font-size: 0.85rem;
  color: var(--texte-doux);
  line-height: 1.5;
}

/* Mode jeu actif : masquer intro, cartes, classement, blocs latéraux */
body.mode-jeu-actif .intro-defi, body.mode-jeu-actif .defi-intro, body.mode-jeu-actif #defis-grille, body.mode-jeu-actif #date-jour, body.mode-jeu-actif .classement-section, body.mode-jeu-actif .bandeau-infos-wrap, body.mode-jeu-actif .bloc-jeux-une-wrap {
  display: none !important;
}

/* Partie terminée : laisser réapparaître classement + blocs latéraux, masquer juste intro + cartes */
body.partie-terminee .intro-defi, body.partie-terminee .defi-intro, body.partie-terminee #defis-grille, body.partie-terminee #date-jour {
  display: none !important;
}

.retry-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.btn-voir-defis {
  display: inline-block;
}

@media (min-width: 1280px) {

  .btn-voir-defis {
    display: none;
  }
}

.back-link {
  margin-bottom: 20px;
  text-align: left;
  align-self: flex-start;
}

/* Cartes difficulté */
.defis-grille {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 32px;
}

.defi-carte {
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 8px;
  padding: 24px 20px;
  text-align: center;
  width: 180px;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  cursor: pointer;
}

.defi-carte:hover {
  background: color-mix(in srgb, var(--color-light) 8%, var(--surface-2));
  border-color: color-mix(in srgb, var(--color-light) 45%, var(--line-forte));
}

/* Difficulte choisie : sans cet ecart, la carte selectionnee est identique aux
   autres et on ne sait plus sur quoi on a cliqué. */
.defi-carte.active {
  background: color-mix(in srgb, var(--color-light) 14%, var(--surface-2));
  border-color: var(--color-light);
}

.defi-carte.gagne {
  border-color: rgba(16, 185, 129, 0.5);
  cursor: default;
}

.defi-carte.gagne:hover {
  transform: none;
  background: var(--surface-2);
  border-color: rgba(16, 185, 129, 0.5);
}

.defi-carte.perdu {
  border-color: rgba(248, 113, 113, 0.5);
  cursor: default;
}

.defi-carte.perdu:hover {
  transform: none;
  background: var(--surface-2);
  border-color: rgba(248, 113, 113, 0.5);
}

.defi-carte.verrouille {
  opacity: 0.5;
  cursor: not-allowed;
}

.defi-carte-icone {
  font-size: 2rem;
  margin-bottom: 8px;
}

.defi-carte h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--texte);
  margin-bottom: 4px;
}

.defi-carte .dims {
  font-size: 0.78rem;
  color: var(--texte-faible);
  margin-bottom: 8px;
}

.defi-carte .defi-statut {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 8px;
  display: inline-block;
}

.defi-statut.non-tente {
  background: var(--surface-2);
  color: var(--texte);
}

.defi-statut.en-cours {
  background: rgba(234, 179, 8, 0.2);
  color: #d2973a;
}

.defi-statut.gagne {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.defi-statut.perdu {
  background: rgba(248, 113, 113, 0.2);
  color: #d07070;
}

/* Non connecté */
.non-connecte {
  text-align: center;
  padding: 40px 20px;
  background: var(--surface-2);
  border-radius: 8px;
  margin-bottom: 32px;
}

.non-connecte p {
  color: var(--texte-doux);
  margin-bottom: 16px;
  font-size: 0.95rem;
}

/* Zone de jeu */
#zone-jeu {
  display: none;
  margin-bottom: 32px;
}

.jeu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.jeu-info {
  font-size: 0.85rem;
  color: var(--texte-doux);
}

.jeu-timer {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-light);
  font-variant-numeric: tabular-nums;
}

.mines-restantes {
  font-size: 0.9rem;
  font-weight: 700;
  color: #d07070;
}

/* Grille démineur */
.grille-container {
  overflow-x: auto;
  padding-bottom: 8px;
  text-align: center;
}

/* Fond du quadrillage : c'est lui qu'on voit dans le gap de 1 px. Le laisser a
   --surface-2 le rendrait invisible entre deux cases fermees. */
.grille-demineur {
  display: inline-grid;
  gap: 1px;
  background: var(--line);
  border: 2px solid var(--line-forte);
  border-radius: 8px;
  padding: 2px;
  user-select: none;
}

.cellule {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

/* Memes conventions que la grille solo (demineur-jeu.css) : la case fermee a du
   relief, la case ouverte est a plat et plus sombre. C'est la difference de FOND
   qui porte l'information, jamais l'ombre seule - une ombre interne ne se voit
   pas a 28 px. */
.cellule.cachee {
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 0.08), inset -1px -1px 0 rgba(0, 0, 0, 0.25);
}

.cellule.cachee:hover {
  background: color-mix(in srgb, var(--color-light) 14%, var(--surface-2));
  border-color: var(--color-light);
}

.cellule.cachee:active {
  box-shadow: inset -1px -1px 0 rgba(255, 255, 255, 0.06), inset 1px 1px 0 rgba(0, 0, 0, 0.25);
}

.cellule.revelee {
  background: #000;
  border: 1px solid var(--line);
  cursor: default;
  box-shadow: none;
}

/* Une grille avancee compte des dizaines de drapeaux : le marqueur, c'est
   l'emoji, pas la couleur de la case. */
.cellule.drapeau {
  background: color-mix(in srgb, var(--color-light) 6%, var(--surface-2));
}

.cellule.mine {
  background: color-mix(in srgb, #d07070 20%, var(--surface-0));
  border: 1px solid #6b3238;
  box-shadow: none;
  animation: mine-pop 0.3s ease-out;
}

.cellule.mine-explosee {
  background: #7a2732;
  border-color: #a33a48;
}

@keyframes mine-pop {

  0% {
    transform: scale(0.3);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Memes chiffres qu'en solo : le code couleur historique du demineur est une
   information de jeu, il doit etre identique d'un mode a l'autre. */
.cellule.v1 {
  color: #6f9fd8;
}

.cellule.v2 {
  color: #64ab7c;
}

.cellule.v3 {
  color: #d07070;
}

.cellule.v4 {
  color: #9b8ac9;
}

.cellule.v5 {
  color: #b08641;
}

.cellule.v6 {
  color: #59a8b5;
}

.cellule.v7 {
  color: var(--texte);
}

.cellule.v8 {
  color: var(--texte-doux);
}

/* Case de départ sûre : clignote au lancement tant qu'aucune case n'est ouverte */
.cellule.case-depart {
  animation: case-depart-blink 1s ease-in-out infinite;
  z-index: 2;
}

@keyframes case-depart-blink {

  0%, 100% {
    background: #1d4030;
    border-color: #2f7f52;
  }

  50% {
    background: #2a6244;
    border-color: #57b483;
  }
}

@media (prefers-reduced-motion: reduce) {

  .cellule.case-depart {
    animation: none;
    background: #26583d;
    border-color: #57b483;
  }
}

/* Message fin */
.msg-fin {
  text-align: center;
  padding: 20px;
  margin-top: 16px;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  display: none;
}

.msg-fin.victoire {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.msg-fin.defaite {
  background: rgba(248, 113, 113, 0.15);
  color: #d07070;
  border: 1px solid rgba(248, 113, 113, 0.3);
}

/* Classement : bloc grisé pour bien délimiter l'ensemble du classement du jour */
.classement-section h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--texte);
  text-align: center;
  margin-bottom: 16px;
}

.onglets-diff {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 16px;
}

.onglet-diff {
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 16px;
  border: 1px solid var(--line-forte);
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--texte-doux);
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.onglet-diff:hover {
  background: var(--surface-2);
}

.onglet-diff.active {
  background: rgba(99, 102, 241, 0.3);
  border-color: var(--line-forte);
  color: var(--texte);
}

.podium {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.podium-item {
  text-align: center;
  padding: 16px;
  background: var(--surface-2);
  border-radius: 6px;
  min-width: 100px;
}

.podium-rang {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.podium-pseudo {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--texte);
}

.podium-temps {
  font-size: 0.78rem;
  color: var(--texte-doux);
  margin-top: 2px;
}

/* Lignes de classement en cartes (même présentation que le Mastermind) */
.classement-liste {
  max-width: 500px;
  margin: 10px auto 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.classement-liste-titre {
  font-family: var(--font-display);
  max-width: 500px;
  margin: 14px auto 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--texte-doux);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.classement-ligne {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 6px;
  font-size: 0.82rem;
}

.classement-ligne.perdu {
  border-color: rgba(248, 113, 113, 0.25);
}

.classement-ligne.perdu .classement-pseudo {
  color: #d07070;
}

.classement-rang {
  font-weight: 700;
  color: var(--texte-doux);
  min-width: 28px;
  text-align: center;
}

.classement-pseudo {
  flex: 1;
  color: var(--texte);
  font-weight: 600;
  text-align: left;
}

.classement-temps-val {
  color: var(--color-light);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.classement-temps-val.perdu {
  color: #d07070;
}

.val-temps-sec {
  color: var(--texte-faible);
  font-weight: 600;
  font-size: 0.8em;
}

.settings-toggle {
  background: var(--surface-2);
  border: 2px solid var(--line-forte);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}

.settings-toggle:hover {
  background: var(--surface-2);
}

.settings-panel {
  display: none;
  background: var(--surface-2);
  border: 1px solid var(--line-forte);
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  text-align: left;
}

.settings-panel.visible {
  display: block;
}

.settings-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--texte-doux);
  cursor: pointer;
  padding: 4px 0;
}

.settings-panel input[type="checkbox"] {
  accent-color: var(--color-mid);
  width: 16px;
  height: 16px;
}

.settings-info {
  font-size: 0.75rem;
  color: var(--texte-faible);
  margin-top: 6px;
  line-height: 1.4;
}

.settings-info a {
  color: var(--texte-doux);
  text-decoration: none;
}

.settings-info a:hover {
  color: var(--color-light);
}

@media (max-width: 480px) {

  #app {
    padding: 24px 14px 20px;
  }

  .header h1 {
    font-size: 1.5rem;
  }

  .cellule {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
  }

  .defi-carte {
    width: 100%;
  }

  .podium {
    flex-direction: column;
    align-items: center;
  }

  .classement-ligne {
    padding: 8px 10px;
  }
}
