/* ============================================================
   MON BUREAU — COUCHE VISUELLE v5
   Ce fichier se charge APRES styles.css et ne fait que l'ameliorer.
   Si tu le retires, le site revient exactement a son etat precedent.

   Nouveaute v2 : les tuiles n'essaient plus de selectionner du
   texte ni d'ouvrir le menu du navigateur pendant un appui long.
   C'est ce qui empechait l'epinglage de se declencher sur mobile.

   Nouveaute v3 : habillage de la rangee "Mes tuiles les plus
   utilisees" ajoutee sur l'ecran d'accueil du launcher.
   ============================================================ */

/* ---------- 1. TUILES : reponse au toucher plus vivante ---------- */

.tile {
  transition:
    transform 0.28s cubic-bezier(0.2, 0.9, 0.25, 1),
    box-shadow 0.28s ease,
    border-color 0.28s ease;
  will-change: transform;
  -webkit-tap-highlight-color: transparent;

  /* indispensable pour que l'appui long fonctionne au doigt */
  touch-action: manipulation;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.tile:active {
  transform: scale(0.955);
  box-shadow: var(--shadow-sm);
  transition-duration: 0.09s;
}

@media (hover: hover) {
  .tile:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    border-color: var(--ink-low);
  }
}

.tile:focus-visible {
  outline: none;
  box-shadow: var(--shadow), 0 0 0 3px var(--accent-1), 0 0 0 4px var(--accent);
}

/* ---------- 2. ZONE "A LA UNE" ---------- */

.mb-label {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--ink-mid);
  padding: 4px 6px 0;
  margin: 0;
  user-select: none;
}

.mb-label:first-of-type {
  padding-top: 0;
}

.mb-label .mb-label-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.mb-label .mb-label-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-low);
  font-weight: 400;
}

.tile.mb-une {
  border-color: var(--accent-1);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--accent-1);
}

@media (hover: hover) {
  .tile.mb-une:hover {
    border-color: var(--accent);
  }
}

.tile.mb-pinned::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--bg-card);
  z-index: 3;
  pointer-events: none;
}

/* retour visuel pendant l'appui long : la tuile se comprime */
.tile.mb-holding {
  transform: scale(0.93);
  transition-duration: 0.55s;
}

/* ---------- 3. ANIMATION DE REORGANISATION ---------- */

@keyframes mbSlideIn {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.mb-reordered .tile {
  animation: mbSlideIn 0.42s cubic-bezier(0.2, 0.9, 0.25, 1) backwards;
}

.mb-reordered .tile:nth-child(1)  { animation-delay: 0.00s; }
.mb-reordered .tile:nth-child(2)  { animation-delay: 0.03s; }
.mb-reordered .tile:nth-child(3)  { animation-delay: 0.06s; }
.mb-reordered .tile:nth-child(4)  { animation-delay: 0.09s; }
.mb-reordered .tile:nth-child(5)  { animation-delay: 0.12s; }
.mb-reordered .tile:nth-child(6)  { animation-delay: 0.15s; }
.mb-reordered .tile:nth-child(7)  { animation-delay: 0.18s; }
.mb-reordered .tile:nth-child(8)  { animation-delay: 0.21s; }
.mb-reordered .tile:nth-child(n+9) { animation-delay: 0.24s; }

/* ---------- 4. SQUELETTES DE CHARGEMENT ---------- */

.mb-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--line);
  border-radius: var(--radius-sm);
  color: transparent !important;
  min-height: 12px;
}

.mb-skeleton::before {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.75) 50%,
    transparent 100%
  );
  animation: mbShimmer 1.4s infinite;
}

@keyframes mbShimmer {
  100% { transform: translateX(100%); }
}

/* ---------- 5. MESSAGE FLOTTANT ---------- */

.mb-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(16px);
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.35;
  padding: 11px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  z-index: 999999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.2, 0.9, 0.25, 1);
  max-width: calc(100vw - 40px);
  text-align: center;
}

.mb-toast.mb-toast-on {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- 6. TRANSITIONS DE VUE ---------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.32s;
  animation-timing-function: cubic-bezier(0.2, 0.9, 0.25, 1);
}

/* ---------- 7. CONFORT ---------- */

.desktop {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  .tile,
  .mb-toast,
  .mb-reordered .tile {
    animation: none !important;
    transition-duration: 0.01s !important;
  }
  .mb-skeleton::before {
    animation: none;
  }
}


/* ---------- 8. RACCOURCIS SUR L'ECRAN D'ACCUEIL ----------
   La rangee de raccourcis vers les tuiles de Mon Bureau, affichee
   sous "Mes applis". Volontairement plus discrete que les grandes
   tuiles d'applications : ce sont des raccourcis, pas des applis.
------------------------------------------------------------------ */

#mb-raccourcis-titre {
  text-align: center;
  margin: 34px 0 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--ink-mid, #6b6b67);
}

#mb-raccourcis {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 12px;
  width: min(680px, 100%);
  padding: 0;
  margin: 0;
}

#mb-raccourcis .launcher-tile.mb-raccourci {
  padding: 12px 6px;
  gap: 6px;
  background: transparent;
  border-style: dashed;
  border-color: var(--line, #e5e7eb);
}

#mb-raccourcis .launcher-tile.mb-raccourci .lt-icon-emoji {
  font-size: 22px;
  line-height: 1;
}
/* Le vrai badge SVG (repris directement de la tuile du Bureau, cf.
   app-launcher.js/tuilesDuBureau) est pense pour une grande tuile — on le
   retrecit ici pour la carte compacte du raccourci. */
#mb-raccourcis .launcher-tile.mb-raccourci .tile-icon-slot {
  width: 34px;
  height: 34px;
  margin: 0;
  border-radius: 10px;
}
#mb-raccourcis .launcher-tile.mb-raccourci .tile-icon-slot svg {
  width: 18px;
  height: 18px;
}

#mb-raccourcis .launcher-tile.mb-raccourci .lt-label {
  font-size: 11px;
  line-height: 1.25;
  color: var(--ink-mid, #6b6b67);
}

#mb-raccourcis .launcher-tile.mb-raccourci:active {
  transform: scale(0.95);
}

@media (hover: hover) {
  #mb-raccourcis .launcher-tile.mb-raccourci:hover {
    background: var(--bg-card, #fff);
    border-style: solid;
    border-color: var(--accent, #2d6a4f);
  }
}


/* ---------- 9. TIROIR ARCHIVES ----------
   Les applis gardees mais rangees. Le bouton se souvient de son
   etat : ferme par defaut, ouvert si tu l'avais laisse ouvert.
------------------------------------------------------------------ */

#mb-archives-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 34px auto 0;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 999px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-mid, #6b6b67);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

@media (hover: hover) {
  #mb-archives-btn:hover {
    background: var(--bg-card, #fff);
    border-color: var(--ink-low, #c4c2bc);
  }
}

#mb-archives-btn:active {
  transform: scale(0.97);
}

#mb-archives-btn .mb-arch-fleche {
  display: inline-flex;
  line-height: 1;
}
#mb-archives-btn .mb-arch-fleche svg {
  width: 12px;
  height: 12px;
  stroke-width: 2.4;
}

#mb-archives-btn .mb-arch-nb {
  min-width: 18px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--line, #e8e6e1);
  font-size: 11px;
  color: var(--ink-mid, #6b6b67);
}

#mb-archives {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 16px;
  width: min(680px, 100%);
  padding: 0;
  margin: 18px 0 0;
  opacity: 0.75;
}

#mb-archives.hidden {
  display: none;
}

@media (hover: hover) {
  #mb-archives:hover {
    opacity: 1;
  }
}


/* ---------- 10. MENU DE L'APPUI LONG ----------
   Apparait par le bas quand tu maintiens une tuile 0,6 s.
   Deux choix : epingler en haut, ou ranger dans les archives.
------------------------------------------------------------------ */

#mbMenu {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.42);
  z-index: 999998;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

#mbMenu.mb-menu-on {
  opacity: 1;
  pointer-events: auto;
}

#mbMenu .mb-menu-carte {
  width: min(420px, calc(100vw - 24px));
  margin: 0 0 12px;
  background: var(--bg-elev, #fff);
  border-radius: var(--radius-lg, 26px);
  padding: 8px;
  box-shadow: var(--shadow-lg);
  transform: translateY(18px);
  transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.25, 1);
}

#mbMenu.mb-menu-on .mb-menu-carte {
  transform: none;
}

#mbMenu .mb-menu-titre {
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-mid, #6b6b67);
  text-align: center;
  padding: 10px 8px 12px;
}

#mbMenu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius, 18px);
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--ink, #1a1a18);
  cursor: pointer;
}

#mbMenu button:active {
  background: var(--line, #e8e6e1);
}

#mbMenu .mb-menu-annuler {
  text-align: center;
  color: var(--ink-mid, #6b6b67);
  font-size: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--line, #e8e6e1);
  border-radius: 0;
}

/* ---------- 11. TIROIR ARCHIVES DU BUREAU ---------- */

#mbArchivesBtn {
  grid-column: 1 / -1;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 4px;
  padding: 9px 18px;
  background: transparent;
  border: 1px solid var(--line, #e8e6e1);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-mid, #6b6b67);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

@media (hover: hover) {
  #mbArchivesBtn:hover {
    background: var(--bg-card, #fff);
    border-color: var(--ink-low, #c4c2bc);
  }
}

#mbArchivesBtn:active {
  transform: scale(0.97);
}

#mbArchivesBtn .mb-arch-fleche {
  font-size: 11px;
  line-height: 1;
}

#mbArchivesBtn .mb-arch-nb {
  min-width: 18px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--line, #e8e6e1);
  font-size: 11px;
}

.tile.mb-archivee {
  opacity: 0.62;
}

@media (hover: hover) {
  .tile.mb-archivee:hover {
    opacity: 1;
  }
}
