/* Feuille de style de la bibliothèque d'images MONTECHNICIEN — valeurs de spec/design.md.
   Couleurs : jetons de src/pages/jetons.ts (vérifiés par tests/pages.test.ts, contrastes compris).
   Échelle de texte : 12 / 14 / 16 / 20 / 24 px. Espacements : 4 / 8 / 12 / 16 / 24 / 32 px.
   Rayons : 8 px (boutons, champs), 12 px (cartes), 9999px (pastilles). Aucun style en ligne (CSP). */

:root {
  --rouge: #dd052b;
  --rouge-survol: #c70527; /* rouge assombri de 10 % */
  --rouge-actif: #b10422; /* rouge assombri de 20 % */
  --texte: #161412;
  --gris: #d8d4d3;
  --blanc: #ffffff;
  --texte-secondaire: #6e6d6c;
  --succes: #16a34a;
  --teinte-rouge: rgba(221, 5, 43, 0.1);
  --fond-gris: rgba(216, 212, 211, 0.4);
  --ombre-carte: 0 1px 3px rgba(0, 0, 0, 0.1);
  --police: Poppins, system-ui, "Segoe UI", sans-serif;
  --chasse-fixe: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--blanc);
  color: var(--texte);
  font-family: Poppins, system-ui, "Segoe UI", sans-serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.5;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.3;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 20px;
  font-weight: 600;
}

h3 {
  font-size: 16px;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--rouge);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--rouge-survol);
}

img {
  max-width: 100%;
}

/* Focus toujours visible (navigation au clavier). */
:focus-visible {
  outline: 2px solid var(--rouge);
  outline-offset: 2px;
}

.marque {
  white-space: nowrap;
}

.lecteur-seulement {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Lien d'évitement : visible seulement au focus. */
.lien-evitement {
  position: absolute;
  left: 16px;
  top: -64px;
  z-index: 10;
  padding: 8px 16px;
  background: var(--blanc);
  color: var(--rouge);
  font-weight: 500;
  border-radius: 8px;
}

.lien-evitement:focus {
  top: 12px;
}

/* --- Bandeau d'en-tête ---------------------------------------------------------------------- */

.bandeau {
  background: var(--rouge);
  color: var(--blanc);
}

.bandeau-interieur {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1200px;
  height: 64px;
  margin: 0 auto;
  padding: 0 24px;
}

.bandeau-accueil {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 40px;
  color: var(--blanc);
  text-decoration: none;
  font-weight: 500;
}

.bandeau-accueil:hover {
  color: var(--blanc);
}

.bandeau-logo {
  display: block;
  height: 40px;
  width: auto;
  object-fit: contain;
}

.bandeau-titre {
  font-size: 14px;
}

.bandeau :focus-visible {
  outline-color: var(--blanc);
}

.bandeau form {
  margin: 0;
}

/* --- Boutons -------------------------------------------------------------------------------- */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  min-width: 40px;
  padding: 9px 16px; /* + bordure de 1 px : 10 px × 16 px */
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.bouton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bouton-principal {
  background: var(--rouge);
  color: var(--blanc);
}

.bouton-principal:hover:not(:disabled) {
  background: var(--rouge-survol);
  color: var(--blanc);
}

.bouton-principal:active:not(:disabled) {
  background: var(--rouge-actif);
}

.bouton-secondaire {
  background: var(--blanc);
  border-color: var(--gris);
  color: var(--texte);
}

.bouton-secondaire:hover:not(:disabled) {
  background: var(--fond-gris);
  color: var(--texte);
}

.bouton-destructif {
  background: var(--blanc);
  border-color: var(--rouge);
  color: var(--rouge);
}

/* Survol : rouge sur le gris de survol ne ferait que 4,38:1 ; fond blanc et rouge foncé (≥ 4,5:1). */
.bouton-destructif:hover:not(:disabled) {
  background: var(--blanc);
  border-color: var(--rouge-actif);
  color: var(--rouge-actif);
}

/* Bouton du bandeau : texte blanc sur le rouge. */
.bouton-bandeau {
  background: transparent;
  border-color: var(--blanc);
  color: var(--blanc);
}

.bouton-bandeau:hover {
  background: var(--rouge-survol);
}

.bouton-bandeau:active {
  background: var(--rouge-actif);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

/* --- Champs --------------------------------------------------------------------------------- */

.champ-groupe {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.champ-groupe label {
  font-weight: 500;
}

.champ {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--gris);
  border-radius: 8px;
  background: var(--blanc);
  color: var(--texte);
  font-family: inherit;
  font-size: 16px;
}

.champ:focus {
  border-color: var(--rouge);
  box-shadow: 0 0 0 3px var(--teinte-rouge);
}

.champ[type="file"] {
  height: auto;
  min-height: 40px;
  padding: 7px 12px;
}

.champ[aria-invalid="true"] {
  border-color: var(--rouge);
}

.aide {
  color: var(--texte-secondaire);
  font-size: 14px;
}

.formulaire {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
}

.formulaire-ligne {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 0;
}

.formulaire-ligne .champ-groupe {
  flex: 1 1 200px;
}

/* --- Messages ------------------------------------------------------------------------------- */

.erreur {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--rouge);
  font-size: 14px;
}

.icone-erreur,
.icone-succes {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.icone-erreur {
  background: var(--rouge);
  color: var(--blanc);
}

.icone-succes {
  background: var(--succes);
  color: var(--blanc);
}

.confirmation {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--blanc);
  border: 1px solid var(--gris);
  border-left: 4px solid var(--succes);
  border-radius: 8px;
  color: var(--texte);
}

/* --- Mise en page --------------------------------------------------------------------------- */

.mise-en-page {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.mise-en-page-simple {
  grid-template-columns: minmax(0, 1fr);
}

.contenu {
  display: flex;
  flex-direction: column;
  gap: 24px;
  min-width: 0;
}

.entete-contenu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta {
  color: var(--texte-secondaire);
  font-size: 12px;
}

.carte {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  background: var(--blanc);
  border: 1px solid var(--gris);
  border-radius: 12px;
  box-shadow: var(--ombre-carte);
}

/* --- Liste des catégories ------------------------------------------------------------------- */

.categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.categories h2 {
  font-size: 14px;
  font-weight: 500;
  color: var(--texte-secondaire);
}

.categories ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--gris);
}

.categories li {
  border-bottom: 1px solid var(--gris);
}

.categories a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border-left: 4px solid transparent;
  color: var(--texte);
  text-decoration: none;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.categories a:hover {
  background: var(--fond-gris);
  color: var(--texte);
}

.categories a.active {
  border-left-color: var(--rouge);
}

.pastille {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  padding: 0 8px;
  border-radius: 9999px;
  background: var(--gris);
  color: var(--texte);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
}

.vide {
  color: var(--texte-secondaire);
  font-size: 14px;
}

/* --- Cartes d'image ------------------------------------------------------------------------- */

.grille-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.vignette {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 160px;
  padding: 8px;
  border-radius: 8px;
  background: var(--fond-gris);
}

.vignette img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.nom-image {
  overflow-wrap: anywhere;
}

/* Encadré d'URL et bouton Copier : le composant central de l'outil. */
.encadre-url {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.encadre-url-ligne {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.url {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--teinte-rouge);
  color: var(--texte);
  font-family: var(--chasse-fixe);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  user-select: all;
}

.bouton-copier {
  min-width: 132px;
}

.gestion summary {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--rouge);
  font-weight: 500;
  cursor: pointer;
}

.gestion[open] summary {
  margin-bottom: 12px;
}

.gestion .formulaire-ligne + .formulaire-ligne {
  margin-top: 12px;
}

/* --- Puces : chevron de marque plein, rouge, pointé à droite -------------------------------- */

.puces {
  margin: 0;
  padding: 0;
  list-style: none;
}

.puces li {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.puces li + li {
  margin-top: 4px;
}

.puces li::before {
  content: "";
  flex: none;
  width: 0.7em;
  height: 0.7em;
  color: var(--rouge);
  background-color: currentColor;
  -webkit-mask: url("chevrons/chevron-full.png") center / contain no-repeat;
  mask: url("chevrons/chevron-full.png") center / contain no-repeat;
  transform: rotate(-90deg);
}

/* --- Page de connexion ---------------------------------------------------------------------- */

.page-connexion {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.connexion {
  width: 100%;
  max-width: 400px;
}

.connexion .carte {
  gap: 24px;
  padding: 32px 24px;
}

.logo-connexion {
  display: block;
  height: 48px;
  width: auto;
  object-fit: contain;
}

/* --- Confirmation de suppression ------------------------------------------------------------ */

.confirmer-suppression .vignette {
  max-width: 320px;
}

/* --- Petits écrans (sous 640 px) ------------------------------------------------------------ */

@media (max-width: 639px) {
  .bandeau-interieur {
    padding: 0 16px;
  }

  .bandeau-titre {
    display: none;
  }

  .mise-en-page {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
  }

  .grille-images {
    grid-template-columns: minmax(0, 1fr);
  }

  .encadre-url-ligne {
    flex-direction: column;
  }
}
