/* Fluvo — le coffre (voir coffre.js). Chargée après net.css : ne touche
   qu'à ses propres classes, et aux tuiles des galeries en mode sélection. */

/* ---------- bulle qui remplace une photo rangée ---------- */
.coffre-masque {
  display: inline-flex; align-items: center; gap: 8px; margin: 2px 0;
  padding: 8px 12px; border-radius: 12px; border: 1px dashed var(--bord);
  background: var(--bg4); color: var(--txt2); font-size: .92em; cursor: pointer;
  font-style: italic; text-align: left;
}
.coffre-masque:hover { color: var(--txt); border-color: var(--accent); }
.coffre-masque .ic { font-style: normal; }
.msg.moi .coffre-masque { color: inherit; background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.35); }

/* ---------- sélection dans les galeries ---------- */
.coffre-sel-btn { padding: 6px 10px; font-size: 12.5px; white-space: nowrap; flex: none; }
.coffre-selection .vign { cursor: pointer; }
.coffre-selection .vign::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px;
  border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.25);
  box-shadow: 0 1px 4px rgba(0,0,0,.4); pointer-events: none;
}
.vign.choisi { outline: 4px solid var(--accent) !important; outline-offset: -4px; }
.vign.choisi img { opacity: .72; }
/* voile d'accent : on voit d'un coup d'oeil ce qui est choisi */
.coffre-selection .vign::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: rgba(0,0,0,.12);
}
.coffre-selection .vign.choisi::before { background: color-mix(in srgb, var(--accent) 30%, transparent); }
.coffre-selection .vign::after { z-index: 2; }
.vign.choisi::after {
  content: "✓"; color: #fff; font-size: 12px; font-weight: 800; line-height: 16px; text-align: center;
  background: var(--accent) !important; border-color: var(--accent) !important;
}
.coffre-sel-barre {
  position: sticky; bottom: 0; z-index: 3; display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap; padding: 10px 12px; margin-top: auto;
  background: var(--bg); border-top: 1px solid var(--bord);
  box-shadow: 0 -8px 24px var(--ombre);
}
.coffre-sel-barre .n { flex: 1 1 auto; font-size: 13px; color: var(--txt2); min-width: 120px; }
.coffre-sel-barre .btn { padding: 7px 12px; font-size: 13px; }
.coffre-sel-barre .btn:disabled { opacity: .45; cursor: default; }
.btn.danger { background: var(--dan); color: #fff; }

/* ---------- fenêtre du coffre ---------- */
#coffre {
  position: fixed; inset: 0; z-index: 71; background: var(--bg);
  display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
#coffre .ch {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--bord); flex-wrap: wrap;
}
#coffre .ch b { font-size: 16px; flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#coffre .ch .info { font-size: 12.5px; color: var(--txt2); }
#coffre .ch .icone { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; font-size: 18px; }
#coffre .ch .icone:hover { background: var(--bg4); }
#coffre .ch .btn { padding: 7px 12px; font-size: 13px; }
#coffre .ch .btn.on { outline: 2px solid var(--accent); }
#coffre .ccorps { flex: 1; overflow-y: auto; padding: 16px 18px 40px; position: relative; display: flex; flex-direction: column; }
#coffre .ccorps.depot { outline: 3px dashed var(--accent); outline-offset: -10px; }
.coffre-titre { font-weight: 600; margin: 8px 0 10px; color: var(--txt2); font-size: 13px; text-transform: uppercase; letter-spacing: .4px; }
.coffre-vide, .coffre-ferme { margin: 8vh auto; text-align: center; max-width: 420px; color: var(--txt2); }
.coffre-vide p, .coffre-ferme p { margin: 6px 0; }
.coffre-vide .btn, .coffre-ferme .btn { margin-top: 12px; }
.coffre-cadenas { font-size: 44px; line-height: 1; margin-bottom: 10px; text-align: center; }
.coffre-envoi { font-size: 13px; color: var(--txt2); margin-bottom: 10px; }

/* dossiers */
.coffre-grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.coffre-carte {
  display: flex; flex-direction: column; gap: 8px; padding: 0; text-align: left;
  background: transparent; border: 0; cursor: pointer; color: inherit; min-width: 0;
}
.coffre-carte .cv {
  position: relative; aspect-ratio: 1; border-radius: 16px; overflow: hidden;
  background: var(--bg3); border: 1px solid var(--bord);
  transition: transform .18s ease, box-shadow .18s ease;
}
.coffre-carte:hover .cv, .coffre-carte:focus-visible .cv { transform: translateY(-2px); box-shadow: 0 10px 28px var(--ombre); }
.coffre-carte .cv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.coffre-carte .cv.vide {
  display: grid; place-items: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 30%, var(--bg3)), color-mix(in srgb, var(--accent2) 22%, var(--bg3)));
}
.coffre-carte .cv.vide img.avatar { position: absolute; inset: 0; opacity: .55; }
.coffre-carte .cv .ini { position: relative; font-size: 44px; font-weight: 700; color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.3); }
.coffre-carte .cv .lie {
  position: absolute; left: 8px; bottom: 8px; font-size: 12px; padding: 2px 7px; border-radius: 999px;
  background: rgba(0,0,0,.55); color: #fff;
}
.coffre-carte .t { display: flex; flex-direction: column; min-width: 0; padding: 0 2px; }
.coffre-carte .t b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coffre-carte .t small { font-size: 12px; color: var(--txt2); }

/* éléments d'un dossier */
.coffre-grille-el { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; }
.coffre-grille-el .vign {
  position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden;
  background: var(--bg3); padding: 0; display: block; border: 0; cursor: pointer;
}
.coffre-grille-el .vign img { width: 100%; height: 100%; object-fit: cover; display: block; }
.coffre-grille-el .vign:hover { outline: 2px solid var(--accent); outline-offset: -2px; }
.coffre-grille-el .vign.sansapercu::before { content: "🖼️"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 28px; opacity: .5; }
.coffre-grille-el .vign .play {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,.6); pointer-events: none;
}
.coffre-grille-el .vign .couv {
  position: absolute; left: 6px; bottom: 6px; font-size: 11px; padding: 2px 7px; border-radius: 999px;
  background: var(--accent); color: #fff; pointer-events: none;
}
#coffre .ccorps .coffre-sel-barre { margin: 14px -18px -40px; }
.coffre-grille-el.choix-couverture .vign { cursor: copy; }
.coffre-grille-el.choix-couverture .vign.sansapercu { opacity: .4; }
.coffre-grille-el.choix-couverture .vign:hover { outline: 3px solid var(--accent); outline-offset: -3px; }
.coffre-grille-el .vign.choisi::after {
  content: "✓"; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
}

/* ---------- dialogues ---------- */
.modal.coffre-code .boite, .modal.coffre-choix .boite { width: min(420px, 100%); }
.modal.coffre-code .boite { text-align: center; }
.coffre-champ {
  width: 100%; background: var(--bg3); border: 1px solid var(--bord); border-radius: 10px;
  padding: 11px 14px; outline: none; margin: 6px 0; font-size: 16px; color: inherit;
}
.modal.coffre-code .coffre-champ { text-align: center; letter-spacing: 6px; font-size: 20px; }
/* l'espacement sert aux chiffres tapés, pas au texte indicatif (« N o u v e a u ») */
.modal.coffre-code .coffre-champ::placeholder { letter-spacing: normal; font-size: 15px; }
.coffre-champ:focus { border-color: var(--accent); }
.coffre-err { min-height: 18px; color: var(--dan); font-size: 13px; margin: 4px 0; }
.coffre-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.modal.coffre-code .coffre-actions { justify-content: center; }
.coffre-choix-liste { display: flex; flex-direction: column; gap: 4px; max-height: 44vh; overflow-y: auto; margin: 6px 0 10px; }
.coffre-choix-ligne {
  display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; text-align: left;
  background: transparent; border: 1px solid transparent; cursor: pointer; color: inherit; width: 100%;
}
.coffre-choix-ligne:hover { background: var(--bg4); }
.coffre-choix-ligne.suggere { border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.coffre-choix-ligne .vg {
  width: 44px; height: 44px; border-radius: 10px; overflow: hidden; flex: none;
  display: grid; place-items: center; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
}
.coffre-choix-ligne .vg img { width: 100%; height: 100%; object-fit: cover; }
.coffre-choix-ligne .t { display: flex; flex-direction: column; min-width: 0; }
.coffre-choix-ligne .t b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coffre-choix-ligne .t small { color: var(--txt2); font-size: 12px; }
.coffre-nouveau { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--bord); padding-top: 10px; }

.coffre-lier { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--txt2); }
.menu.coffre-menu button.danger { color: var(--dan); }

/* ---------- visionneuse du coffre ---------- */
#coffre-visio {
  position: fixed; inset: 0; z-index: 85; background: rgba(0,0,0,.95);
  display: flex; flex-direction: column;
}
#coffre-visio .vh {
  display: flex; align-items: center; gap: 14px; padding: 10px 14px; color: #fff;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: linear-gradient(rgba(0,0,0,.62), transparent); flex: 0 0 auto; flex-wrap: wrap;
}
#coffre-visio .vh .nom { font-weight: 600; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#coffre-visio .vh .meta { flex: 1; font-size: 13px; color: rgba(255,255,255,.72); }
#coffre-visio .outils { display: flex; gap: 4px; align-items: center; background: rgba(255,255,255,.08); border-radius: 12px; padding: 4px; }
#coffre-visio .icone {
  width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center;
  color: #fff; text-decoration: none; background: transparent; font-size: 17px; border: 0; cursor: pointer;
}
#coffre-visio .icone:hover { background: rgba(255,255,255,.2); }
#coffre-visio .scene {
  flex: 1 1 auto; min-height: 0; min-width: 0; display: flex; align-items: center; justify-content: center;
  overflow: auto; padding: 6px 68px 16px;
}
#coffre-visio .scene img { max-width: 100%; max-height: 100%; object-fit: contain; cursor: zoom-in; user-select: none; }
#coffre-visio .scene img.zoom { max-width: none; max-height: none; cursor: zoom-out; }
#coffre-visio .scene video { max-width: 100%; max-height: 100%; border-radius: 8px; }
#coffre-visio .nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 62px;
  border-radius: 12px; background: rgba(255,255,255,.09); color: #fff; font-size: 30px; border: 0; cursor: pointer;
}
#coffre-visio .nav:hover { background: rgba(255,255,255,.24); }
#coffre-visio .nav.gauche { left: 12px; }
#coffre-visio .nav.droite { right: 12px; }

@media (max-width: 760px) {
  #coffre .ch { padding: 10px 12px; gap: 8px; }
  /* 1re ligne : ‹ titre ⋯ ✕ — 2e ligne : les actions */
  #coffre .ch .icone { order: 0; }
  #coffre .ch b { order: 1; flex: 1 1 0; }
  #coffre .ch .icone ~ .icone, #coffre .ch b ~ .icone { order: 2; }
  #coffre .ch .info { display: none; }
  /* moitié de ligne chacun : ils passent sur la 2e ligne et le titre garde la sienne */
  #coffre .ch .btn { order: 3; flex: 1 1 calc(50% - 4px); }
  #coffre .ccorps { padding: 12px 12px 32px; }
  #coffre .ccorps .coffre-sel-barre { margin: 12px -12px -32px; }
  .coffre-grille { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .coffre-grille-el { grid-template-columns: repeat(3, 1fr); gap: 3px; }
  #coffre-visio .scene { padding: 4px 4px 12px; }
  #coffre-visio .nav { display: none; }
  #coffre-visio .vh .nom { max-width: 60vw; }
  .coffre-sel-btn span { font-size: 12px; }
}
