/* ------------------------------------------------------------------
   MADEGEECO — les photographies d'un bien, dans le CRM.

   Une grille de vignettes ; sur chacune, une étoile pour désigner la
   principale et une corbeille pour la retirer. Le bouton radio et la
   case ne servent qu'à porter l'état : ils restent atteignables au
   clavier, mais on ne dessine pas leur widget natif.
   ------------------------------------------------------------------ */

.mgc-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 12px;
  margin: 18px 0 10px;
  padding: 0;
  list-style: none;
}

.mgc-photo {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mgc-photo-vue {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--app-line, #e4e7e4);
  border-radius: 10px;
  background: var(--app-surface-soft, #f5f6f4);
}

.mgc-photo-vue img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mgc-photo-absente {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #b3b8b4;
  font-size: 26px;
}

.mgc-etoile,
.mgc-retirer {
  position: absolute;
  top: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 2px 8px rgba(9, 26, 24, 0.18);
  color: #4a524c;
  font-size: 15px;
  cursor: pointer;
}

.mgc-etoile { left: 8px; }
.mgc-retirer { right: 8px; }

.mgc-etoile:hover { color: #c98f1e; }
.mgc-retirer:hover { color: #9c3535; }

.mgc-etoile input,
.mgc-retirer input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  cursor: pointer;
}

.mgc-astre {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
}

.mgc-etoile input:checked ~ .mgc-astre {
  fill: #e0a83c;
  stroke: #c98f1e;
}

/* La principale se repère aussi de loin, sans chercher l'étoile. */
.mgc-photo:has(.mgc-etoile input:checked) .mgc-photo-vue {
  border-color: #e0a83c;
  box-shadow: 0 0 0 2px rgba(224, 168, 60, 0.28);
}

/* Ce qui part à l'enregistrement s'efface tout de suite : sans ce
   retour, on coche sans savoir si le clic a porté. */
.mgc-photo:has(.mgc-retirer input:checked) .mgc-photo-vue {
  opacity: 0.35;
}

.mgc-photo:has(.mgc-retirer input:checked) .mgc-retirer {
  background: #9c3535;
  color: #fff;
}

/* Le contour de focus doit rester visible : sans lui, on navigue au
   clavier à l'aveugle sur des commandes invisibles. */
.mgc-etoile input:focus-visible ~ i,
.mgc-retirer input:focus-visible ~ i {
  outline: 2px solid #2f8f8a;
  outline-offset: 3px;
  border-radius: 2px;
}

.mgc-hors-ecran {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Quand le fichier a disparu de la médiathèque, la tuile le dit plutôt
   que d'afficher un cadre vide dont on ne sait que penser. */
.mgc-photo-absente small {
  display: block;
  margin-top: 4px;
  font-size: 9px;
  letter-spacing: 0.04em;
}

/* La description tient sous sa vignette, discrète tant qu'on n'y
   touche pas. */
.mgc-photo-alt input {
  width: 100%;
  min-height: 0;
  padding: 6px 8px;
  border: 1px solid var(--app-line, #e4e7e4);
  border-radius: 6px;
  background: #fff;
  font-size: 10px;
  color: var(--app-ink, #1d2320);
}

.mgc-photo-alt input::placeholder {
  color: #b3b8b4;
}

.mgc-photo-alt input:focus {
  border-color: var(--app-accent, #2f8f8a);
  outline: none;
  box-shadow: 0 0 0 3px rgba(47, 143, 138, 0.11);
}
