/* ==========================================================================
   Locorbe — « Registre d'alpage »
   Un livre genealogique grave : encre anthracite, papier parchemin, laiton de
   sonnaille. Regles filiformes, capitales espacees, chiffres tabulaires.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,300;9..144,400;9..144,600;9..144,900&family=Archivo:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* Encres */
  --encre:        #15110e;
  --encre-2:      #1f1915;
  --encre-3:      #2b231d;
  --encre-4:      #3a3029;

  /* Papier */
  --papier:       #f4ecdc;
  --papier-2:     #e8dcc4;
  --papier-3:     #d6c7a9;

  /* Accents */
  --froment:      #b4551f;   /* robe froment de la Herens */
  --froment-clair:#d98b4a;
  --laiton:       #c9a227;   /* sonnaille, distinctions */
  --glacier:      #4f7f78;   /* donnees genetiques */
  --sang:         #9e2b20;   /* alertes, combats */
  --ardoise:      #6b6257;

  /* Typographie */
  --titre: 'Fraunces', Georgia, serif;
  --texte: 'Archivo', 'Helvetica Neue', sans-serif;
  --mono:  'IBM Plex Mono', 'Courier New', monospace;

  --regle: 1px solid rgba(214, 199, 169, 0.22);
  --regle-papier: 1px solid rgba(21, 17, 14, 0.14);

  --rayon: 2px;
  --transition: 220ms cubic-bezier(0.22, 0.61, 0.36, 1);

  /* Hauteur de l'en-tete collante : sert d'offset aux autres barres sticky. */
  --hauteur-entete: 68px;
}

@media (max-width: 860px) {
  :root { --hauteur-entete: 58px; }
}

/* --- Base ---------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--encre);
  color: var(--papier);
  font-family: var(--texte);
  font-size: 15px;
  line-height: 1.6;
  font-feature-settings: 'tnum' 1;
  -webkit-font-smoothing: antialiased;
}

/* Grain photographique + courbes de niveau : donne de la matiere au fond. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3CfeColorMatrix values='0 0 0 0 0.9 0 0 0 0 0.85 0 0 0 0 0.75 0 0 0 0.07 0'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23g)'/%3E%3C/svg%3E");
}

body > * { position: relative; z-index: 1; }

h1, h2, h3, h4 {
  font-family: var(--titre);
  font-weight: 400;
  font-variation-settings: 'SOFT' 20, 'WONK' 1;
  line-height: 1.08;
  margin: 0;
  letter-spacing: -0.015em;
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--froment); color: var(--papier); }

/* --- Elements typographiques --------------------------------------------- */

.etiquette {
  font-family: var(--texte);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ardoise);
}

.etiquette--clair { color: rgba(244, 236, 220, 0.5); }

.mono { font-family: var(--mono); font-size: 0.92em; letter-spacing: -0.01em; }

.regle { border: 0; border-top: var(--regle); margin: 0; }

/*
 * Le conteneur s'elargit par paliers : sur un 1920 on exploite la largeur au
 * lieu de laisser 340 px de marge morte de chaque cote, ce qui reduit d'autant
 * le defilement vertical. Les blocs de texte restent bornes en `ch`.
 */
.enveloppe {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 clamp(18px, 2.6vw, 40px);
}

@media (min-width: 1500px) { .enveloppe { max-width: 1440px; } }
@media (min-width: 1750px) { .enveloppe { max-width: 1660px; } }

.enveloppe--etroite { max-width: 880px; }

/* --- Entete -------------------------------------------------------------- */

.entete {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(21, 17, 14, 0.86);
  backdrop-filter: blur(14px);
  border-bottom: var(--regle);
}

.entete__interieur {
  display: flex;
  align-items: center;
  gap: 40px;
  height: var(--hauteur-entete);
}

.marque {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--titre);
  font-size: 23px;
  font-weight: 600;
  font-variation-settings: 'SOFT' 40, 'WONK' 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.marque__cornes { color: var(--laiton); font-size: 19px; }

.navigation {
  display: flex;
  gap: 26px;
  margin-left: auto;
  align-items: center;
}

.navigation a {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: rgba(244, 236, 220, 0.62);
  padding: 4px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.navigation a:hover { color: var(--papier); }
.navigation a.actif { color: var(--papier); border-bottom-color: var(--froment); }

/* --- Menu mobile --------------------------------------------------------- */

.burger {
  display: none;
  margin-left: auto;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(214, 199, 169, 0.28);
  border-radius: var(--rayon);
  background: transparent;
  cursor: pointer;
  position: relative;
}

.burger span,
.burger::before,
.burger::after {
  content: '';
  position: absolute;
  left: 11px;
  width: 20px;
  height: 1.5px;
  background: var(--papier);
  transition: transform var(--transition), opacity var(--transition);
}

.burger::before { top: 14px; }
.burger span { top: 20px; }
.burger::after { top: 26px; }

.burger[aria-expanded='true']::before { transform: translateY(6px) rotate(45deg); }
.burger[aria-expanded='true'] span { opacity: 0; }
.burger[aria-expanded='true']::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 860px) {
  .entete__interieur { gap: 16px; }
  .marque { font-size: 20px; }
  .burger { display: block; }

  /* Le menu se deplie sous l'en-tete, en pleine largeur. */
  .navigation {
    position: fixed;
    top: var(--hauteur-entete);
    left: 0;
    right: 0;
    max-height: calc(100vh - var(--hauteur-entete));
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin: 0;
    padding: 8px 0 20px;
    background: var(--encre-2);
    border-bottom: var(--regle);
    box-shadow: 0 24px 40px -24px rgba(0, 0, 0, 0.9);
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  }

  .navigation.ouvert { transform: translateY(0); opacity: 1; visibility: visible; }

  .navigation a {
    padding: 15px clamp(18px, 2.6vw, 40px);
    font-size: 15px;
    border-bottom: 0;
    border-left: 2px solid transparent;
  }

  .navigation a.actif { border-left-color: var(--froment); background: rgba(244, 236, 220, 0.04); }

  /* Le bouton « Connexion » reprend une largeur de lien dans le menu. */
  .navigation .bouton {
    margin: 12px clamp(18px, 2.6vw, 40px) 0;
    justify-content: center;
  }
}

/* --- Boutons ------------------------------------------------------------- */

.bouton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 11px 22px;
  border: 1px solid var(--froment);
  border-radius: var(--rayon);
  background: var(--froment);
  color: var(--papier);
  font-family: var(--texte);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition);
}

.bouton:hover { background: #c9601f; border-color: #c9601f; transform: translateY(-1px); }
.bouton:active { transform: translateY(0); }
.bouton:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.bouton--fantome {
  background: transparent;
  border-color: rgba(214, 199, 169, 0.3);
  color: var(--papier);
}
.bouton--fantome:hover { background: rgba(244, 236, 220, 0.07); border-color: var(--papier-3); }

/* Sur surface parchemin, inverser le contraste : sinon le texte disparait. */
.carte .bouton--fantome,
.sur-papier .bouton--fantome {
  border-color: rgba(21, 17, 14, 0.28);
  color: var(--encre);
}

.carte .bouton--fantome:hover,
.sur-papier .bouton--fantome:hover {
  background: rgba(21, 17, 14, 0.06);
  border-color: var(--encre);
}

.bouton--petit { padding: 7px 14px; font-size: 10.5px; letter-spacing: 0.1em; }

/* --- Champs -------------------------------------------------------------- */

.champ { display: block; margin-bottom: 18px; }

.champ__libelle {
  display: block;
  margin-bottom: 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(244, 236, 220, 0.5);
}

.champ input, .champ select, .champ textarea,
.saisie {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid rgba(214, 199, 169, 0.24);
  border-radius: var(--rayon);
  background: rgba(244, 236, 220, 0.05);
  color: var(--papier);
  font-family: var(--texte);
  font-size: 14px;
  transition: border-color var(--transition), background var(--transition);
}

.champ input:focus, .champ select:focus, .saisie:focus {
  outline: none;
  border-color: var(--froment);
  background: rgba(244, 236, 220, 0.08);
}

.champ select option { background: var(--encre-2); color: var(--papier); }

/* --- Cartes parchemin ---------------------------------------------------- */

.carte {
  background: var(--papier);
  color: var(--encre);
  border-radius: var(--rayon);
  padding: 26px 28px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset,
              0 18px 40px -22px rgba(0, 0, 0, 0.75);
}

.carte .etiquette { color: var(--ardoise); }
.carte h2, .carte h3 { color: var(--encre); }

.carte--encre {
  background: var(--encre-2);
  color: var(--papier);
  border: var(--regle);
  box-shadow: none;
}

.carte--encre .etiquette { color: rgba(244, 236, 220, 0.42); }

/* --- Grilles ------------------------------------------------------------- */

.grille { display: grid; gap: 22px; }
.grille--2 { grid-template-columns: repeat(2, 1fr); }
.grille--3 { grid-template-columns: repeat(3, 1fr); }
.grille--4 { grid-template-columns: repeat(4, 1fr); }
.grille--cartes { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }

/*
 * Deux colonnes inegales (contenu principal + panneau lateral). A utiliser
 * plutot qu'un `style="grid-template-columns:…"` en ligne : une declaration
 * inline gagne sur toute media query, la grille resterait a deux colonnes sur
 * un telephone.
 */
.grille--principal-lateral { grid-template-columns: 1.5fr 1fr; }
.grille--lateral-principal { grid-template-columns: 1fr 1.4fr; }

@media (max-width: 900px) {
  .grille--2, .grille--3, .grille--4,
  .grille--principal-lateral, .grille--lateral-principal { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .grille { gap: 16px; }
  .grille--cartes { grid-template-columns: 1fr; }
}

/* --- Chiffres cles ------------------------------------------------------- */

.chiffre { display: flex; flex-direction: column; gap: 4px; }

.chiffre__valeur {
  font-family: var(--titre);
  font-size: clamp(34px, 4.2vw, 52px);
  font-weight: 300;
  font-variation-settings: 'SOFT' 0, 'WONK' 0;
  line-height: 1;
  letter-spacing: -0.03em;
}

.chiffre__unite { font-size: 0.45em; color: var(--ardoise); margin-left: 4px; }

/* --- Jetons -------------------------------------------------------------- */

.jeton {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid currentColor;
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.jeton--race { border-color: transparent; color: var(--papier); }
.jeton--laiton { color: var(--laiton); }
.jeton--glacier { color: var(--glacier); }
.jeton--sang { color: var(--sang); }
.jeton--sourd { color: var(--ardoise); }

.pastille {
  width: 9px; height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex: none;
}

/* --- Tableaux registre --------------------------------------------------- */

.registre {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.registre th {
  text-align: left;
  padding: 0 14px 9px 0;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ardoise);
  border-bottom: 1px solid rgba(21, 17, 14, 0.22);
  white-space: nowrap;
}

.registre td {
  padding: 11px 14px 11px 0;
  border-bottom: var(--regle-papier);
  vertical-align: middle;
}

.registre tr:last-child td { border-bottom: 0; }
.registre tbody tr { transition: background var(--transition); }
.registre tbody tr:hover { background: rgba(180, 85, 31, 0.06); }

.registre .nombre { font-family: var(--mono); text-align: right; }

/*
 * Sur petit ecran un tableau de donnees ne se replie pas proprement : on le
 * rend defilant horizontalement plutot que de le comprimer illisiblement.
 */
.defilant { overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 720px) {
  .registre { display: block; overflow-x: auto; white-space: nowrap; }
  .registre th, .registre td { padding-right: 18px; }
}

/* --- Pedigree : grille gravee -------------------------------------------- */

.pedigree {
  display: grid;
  gap: 4px 0;
  font-size: 12px;
}

.pedigree__colonne {
  display: grid;
  gap: 4px;
  align-content: stretch;
}

.pedigree__case {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 8px 12px;
  min-height: 46px;
  background: rgba(244, 236, 220, 0.055);
  border-left: 2px solid var(--ardoise);
  transition: background var(--transition), border-color var(--transition);
}

.pedigree__case:hover { background: rgba(180, 85, 31, 0.14); border-left-color: var(--froment); }
.pedigree__case--male { border-left-color: var(--glacier); }
.pedigree__case--femelle { border-left-color: var(--froment); }
.pedigree__case--vide {
  background: repeating-linear-gradient(
    -45deg, transparent, transparent 6px,
    rgba(214, 199, 169, 0.05) 6px, rgba(214, 199, 169, 0.05) 7px);
  border-left-color: rgba(214, 199, 169, 0.16);
}

.pedigree__nom {
  font-family: var(--titre);
  font-size: 14px;
  font-weight: 600;
  font-variation-settings: 'SOFT' 30, 'WONK' 1;
  line-height: 1.15;
}

.pedigree__meta {
  font-family: var(--mono);
  font-size: 10px;
  color: rgba(244, 236, 220, 0.42);
  letter-spacing: -0.02em;
}

/* Trait de liaison entre generations */
.pedigree__case:not(.pedigree__case--racine)::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 50%;
  width: 12px;
  height: 1px;
  background: rgba(214, 199, 169, 0.24);
}

.pedigree__colonne { padding-left: 14px; }
.pedigree__colonne:first-child { padding-left: 0; }

/* En dessous de cette largeur l'arbre devient illisible : on le fait defiler. */
@media (max-width: 1000px) {
  .pedigree { min-width: 860px; }
  .pedigree__nom { font-size: 13px; }
}

/* --- Genotypes ----------------------------------------------------------- */

.genotype {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: var(--regle-papier);
}

.genotype:last-child { border-bottom: 0; }

.genotype__notation {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  padding: 5px 12px;
  background: var(--encre);
  color: var(--papier);
  border-radius: var(--rayon);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.genotype__notation--tare { background: var(--sang); }
.genotype__notation--indemne { background: var(--glacier); }

/* --- Robes : echantillons de pigment ------------------------------------- */

.robe {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
}

.robe__pastille {
  width: 34px; height: 34px;
  border-radius: 3px;
  flex: none;
  border: 1px solid rgba(21, 17, 14, 0.2);
}

.robe__barre {
  flex: 1;
  height: 5px;
  background: rgba(21, 17, 14, 0.1);
  border-radius: 100px;
  overflow: hidden;
}

.robe__remplissage { height: 100%; background: var(--encre); }

/* --- Alertes ------------------------------------------------------------- */

.alerte {
  display: flex;
  gap: 12px;
  padding: 13px 16px;
  border-left: 3px solid var(--ardoise);
  background: rgba(21, 17, 14, 0.05);
  font-size: 13.5px;
  line-height: 1.5;
  margin-bottom: 9px;
}

.alerte--critique { border-left-color: var(--sang); background: rgba(158, 43, 32, 0.09); }
.alerte--attention { border-left-color: var(--laiton); background: rgba(201, 162, 39, 0.1); }
.alerte--ok { border-left-color: var(--glacier); background: rgba(79, 127, 120, 0.09); }

.alerte__marque { font-family: var(--mono); font-weight: 600; flex: none; }

/* --- Rosette de reine ---------------------------------------------------- */

.rosette {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px 5px 8px;
  background: linear-gradient(135deg, var(--laiton), #a8851c);
  color: var(--encre);
  border-radius: 100px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rosette::before {
  content: '';
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--encre);
  box-shadow: inset 0 0 0 2px var(--laiton);
}

/* --- Fiche animal en tete ------------------------------------------------ */

.fiche-entete {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: end;
  padding: 44px 0 30px;
  border-bottom: var(--regle);
}

.fiche-entete__nom {
  font-size: clamp(44px, 6.5vw, 82px);
  font-weight: 300;
  font-variation-settings: 'SOFT' 30, 'WONK' 1;
  letter-spacing: -0.035em;
}

@media (max-width: 800px) {
  .fiche-entete { grid-template-columns: 1fr; align-items: start; }
}

/* --- Onglets ------------------------------------------------------------- */

.onglets {
  display: flex;
  gap: 2px;
  border-bottom: var(--regle);
  margin: 32px 0 28px;
  overflow-x: auto;
  scrollbar-width: none;
}

.onglets::-webkit-scrollbar { display: none; }

/* Sur telephone les onglets restent accessibles au pouce pendant la lecture. */
@media (max-width: 680px) {
  .onglets {
    position: sticky;
    top: var(--hauteur-entete);
    z-index: 15;
    margin: 22px 0 20px;
    padding: 0 clamp(18px, 2.6vw, 40px);
    margin-left: calc(-1 * clamp(18px, 2.6vw, 40px));
    margin-right: calc(-1 * clamp(18px, 2.6vw, 40px));
    background: rgba(21, 17, 14, 0.95);
    backdrop-filter: blur(12px);
    scroll-snap-type: x proximity;
  }

  .onglet { scroll-snap-align: start; }
}

.onglet {
  padding: 12px 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(244, 236, 220, 0.45);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}

.onglet:hover { color: var(--papier); }
.onglet.actif { color: var(--papier); border-bottom-color: var(--froment); }

.panneau { display: none; }
.panneau.actif { display: block; animation: monter 320ms cubic-bezier(0.22, 0.61, 0.36, 1); }

/* --- Vignettes de cheptel ------------------------------------------------ */

.vignette {
  display: flex;
  flex-direction: column;
  min-height: 160px;
  padding: 20px 22px;
  background: rgba(244, 236, 220, 0.04);
  border: var(--regle);
  border-radius: var(--rayon);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.vignette::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--couleur-race, var(--ardoise));
  transition: width var(--transition);
}

.vignette:hover {
  background: rgba(244, 236, 220, 0.07);
  border-color: rgba(214, 199, 169, 0.35);
  transform: translateY(-2px);
}

.vignette:hover::after { width: 5px; }

.vignette__nom {
  font-family: var(--titre);
  font-size: 26px;
  font-weight: 400;
  font-variation-settings: 'SOFT' 40, 'WONK' 1;
  letter-spacing: -0.02em;
  margin-bottom: 3px;
}

.vignette__numero {
  font-family: var(--mono);
  font-size: 11px;
  color: rgba(244, 236, 220, 0.4);
  letter-spacing: -0.02em;
}

/* Le pied est colle en bas : les vignettes d'une meme ligne s'alignent. */
.vignette__pied {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: var(--regle);
  font-size: 11.5px;
  color: rgba(244, 236, 220, 0.45);
  min-width: 0;
}

/* Une robe peut etre longue (« noire, diluee, panachure ») : une seule ligne. */
.vignette__robe {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  flex: 1;
}

.vignette__robe span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Rosette reduite pour les listes denses. */
.rosette--compacte { padding: 4px 9px 4px 7px; font-size: 9.5px; letter-spacing: 0.08em; }
.rosette--compacte::before { width: 10px; height: 10px; }

/* --- Photos -------------------------------------------------------------- */

.portrait {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--encre-3);
  border-radius: var(--rayon);
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 500ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/*
 * Placeholder : la couleur de la race sert de lavis de fond (elle est souvent
 * tres sombre, donc inutilisable pour le glyphe lui-meme, qui reste clair).
 */
.portrait--vide {
  background-image:
    radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--teinte, #6b6257) 45%, transparent), transparent 72%),
    repeating-linear-gradient(-45deg, transparent, transparent 7px,
      rgba(214, 199, 169, 0.05) 7px, rgba(214, 199, 169, 0.05) 8px);
}

.portrait__glyphe {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  color: var(--papier);
  opacity: 0.2;
}

/* Bande photo en tete de vignette : deborde le padding de la carte.
   Format large plutot que 4/3 : les listes restent compactes. */
.vignette__portrait {
  margin: -20px -22px 15px;
  border-radius: var(--rayon) var(--rayon) 0 0;
  aspect-ratio: 16 / 9;
}

.vignette:hover .vignette__portrait img { transform: scale(1.045); }

/* Le portrait d'en-tete est cliquable : c'est le chemin le plus court vers la
   galerie, et l'amorce signale qu'il manque une photo. */
.portrait-bouton {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}

.portrait-bouton .portrait { transition: filter var(--transition); }
.portrait-bouton:hover .portrait { filter: brightness(1.12); }

.portrait-bouton__amorce {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  padding: 4px 11px;
  border-radius: 100px;
  background: var(--froment);
  color: var(--papier);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Galerie de la fiche animal */
.galerie { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }

.galerie__vignette {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: var(--rayon);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  background: none;
}

.galerie__vignette img { width: 100%; height: 100%; object-fit: cover; display: block; }
.galerie__vignette--principale { border-color: var(--laiton); }

.galerie__marque {
  position: absolute;
  top: 5px; left: 5px;
  padding: 2px 7px;
  border-radius: 100px;
  background: var(--laiton);
  color: var(--encre);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Zone de depot */
.depot {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  aspect-ratio: 1;
  border: 1px dashed rgba(21, 17, 14, 0.28);
  border-radius: var(--rayon);
  background: rgba(21, 17, 14, 0.03);
  color: var(--ardoise);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}

.depot:hover, .depot--survol {
  border-color: var(--froment);
  background: rgba(180, 85, 31, 0.08);
  color: var(--froment);
}

.depot span:first-child { font-size: 21px; line-height: 1; }

/* Visionneuse plein ecran */
.visionneuse { padding: 0; border: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
.visionneuse::backdrop { background: rgba(8, 6, 5, 0.93); }
.visionneuse img { max-width: 94vw; max-height: 88vh; display: block; border-radius: var(--rayon); }

.visionneuse__legende {
  margin-top: 12px;
  text-align: center;
  color: rgba(244, 236, 220, 0.7);
  font-size: 13px;
}

/* --- Dialogue d'edition -------------------------------------------------- */

.dialogue {
  width: min(880px, calc(100vw - 40px));
  max-height: calc(100vh - 60px);
  padding: 0;
  border: 0;
  border-radius: var(--rayon);
  background: var(--papier);
  color: var(--encre);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.85);
}

/* Plein ecran sur telephone : plus de place utile, moins de defilement. */
@media (max-width: 680px) {
  .dialogue {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .dialogue__entete, .dialogue__corps, .dialogue__pied { padding-left: 18px; padding-right: 18px; }
  .dialogue__pied { flex-direction: column-reverse; align-items: stretch; }
  .dialogue__pied .ligne { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .dialogue__pied .bouton { width: 100%; }
}

.dialogue::backdrop {
  background: rgba(10, 8, 7, 0.74);
  backdrop-filter: blur(3px);
}

.dialogue[open] { animation: monter 240ms cubic-bezier(0.22, 0.61, 0.36, 1); }

.dialogue__entete {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px 16px;
  background: var(--papier);
  border-bottom: 1px solid rgba(21, 17, 14, 0.16);
}

.dialogue__titre {
  font-family: var(--titre);
  font-size: 25px;
  font-weight: 400;
  font-variation-settings: 'SOFT' 30, 'WONK' 1;
  letter-spacing: -0.02em;
}

.dialogue__corps { padding: 22px 28px; overflow-y: auto; }

.dialogue__pied {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 16px 28px 22px;
  background: var(--papier);
  border-top: 1px solid rgba(21, 17, 14, 0.16);
}

.fermer {
  border: 0;
  background: none;
  font-size: 26px;
  line-height: 1;
  color: var(--ardoise);
  cursor: pointer;
  padding: 0 4px;
  transition: color var(--transition);
}

.fermer:hover { color: var(--encre); }

/* Champs sur fond parchemin : inverser le contraste du theme sombre. */
.sur-papier .champ__libelle { color: var(--ardoise); }

.sur-papier .champ input,
.sur-papier .champ select,
.sur-papier .champ textarea {
  background: rgba(21, 17, 14, 0.04);
  border-color: rgba(21, 17, 14, 0.18);
  color: var(--encre);
}

.sur-papier .champ input:focus,
.sur-papier .champ select:focus,
.sur-papier .champ textarea:focus {
  border-color: var(--froment);
  background: rgba(21, 17, 14, 0.06);
}

.sur-papier .champ select option { background: var(--papier); color: var(--encre); }

.bouton--danger { background: transparent; border-color: var(--sang); color: var(--sang); }
.bouton--danger:hover { background: var(--sang); border-color: var(--sang); color: var(--papier); }

.grille-champs { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
@media (max-width: 640px) { .grille-champs { grid-template-columns: 1fr; } }

/* --- Animations ---------------------------------------------------------- */

@keyframes monter {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fondu {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.apparait {
  opacity: 0;
  animation: monter 700ms cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .apparait { opacity: 1; }
}

/* --- Divers -------------------------------------------------------------- */

.pied {
  margin-top: 90px;
  padding: 36px 0 44px;
  border-top: var(--regle);
  font-size: 12px;
  color: rgba(244, 236, 220, 0.35);
}

.vide {
  padding: 46px 20px;
  text-align: center;
  color: var(--ardoise);
  font-size: 13.5px;
}

.charge {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid rgba(214, 199, 169, 0.25);
  border-top-color: var(--froment);
  border-radius: 50%;
  animation: rotation 700ms linear infinite;
}

@keyframes rotation { to { transform: rotate(360deg); } }

.pile > * + * { margin-top: 22px; }
.entre { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.ligne { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.discret { color: var(--ardoise); }
.centre { text-align: center; }

/* ==========================================================================
   Telephone — « le carnet de poche »
   Sur un telephone on ne parcourt pas le cheptel, on y cherche une bete, debout
   dans l'etable. Le registre reprend donc son idiome d'origine : des lignes
   reglees, la marque auriculaire en colonne d'index a droite, et non des
   cartes illustrees. Une vignette-carte fait 350 px de haut, une ligne 78 px.
   ========================================================================== */

@media (max-width: 680px) {
  .grille--cartes { grid-template-columns: 1fr; gap: 0; }

  .vignette {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    grid-template-rows: auto auto auto;
    column-gap: 12px;
    row-gap: 1px;
    align-items: center;
    min-height: 0;
    padding: 10px 2px;
    border: 0;
    border-bottom: var(--regle);
    border-radius: 0;
    background: none;
  }

  .vignette:hover { transform: none; background: rgba(244, 236, 220, 0.04); }
  .vignette::after { display: none; } /* le filet de race passe sur la vignette */

  .vignette__portrait {
    grid-column: 1;
    grid-row: 1 / 4;
    margin: 0;
    aspect-ratio: 1;
    border-radius: var(--rayon);
    border-left: 2px solid var(--couleur-race, var(--ardoise));
  }

  .vignette__nom { grid-column: 2; grid-row: 1; font-size: 17px; line-height: 1.15; margin: 0; }

  /* La marque auriculaire sert d'index, comme dans un herd-book papier. */
  .vignette__numero {
    grid-column: 3;
    grid-row: 1;
    text-align: right;
    font-size: 10.5px;
    white-space: nowrap;
  }

  .vignette > .ligne { grid-column: 2 / 4; grid-row: 2; gap: 5px; }

  .vignette > .ligne .jeton {
    font-size: 8.5px;
    padding: 1px 6px;
    line-height: 1.5;
    border-radius: 3px;
  }

  /* La couleur de race est deja portee par le liseré du portrait. */
  .vignette > .ligne .jeton--race { display: none; }
  .vignette > .ligne .rosette { font-size: 8.5px; padding: 2px 7px 2px 6px; }
  .vignette > .ligne .rosette::before { width: 8px; height: 8px; }

  .vignette__pied {
    grid-column: 2 / 4;
    grid-row: 3;
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 10.5px;
    line-height: 1.3;
  }
}

/* --- Autres ajustements telephone ---------------------------------------- */

@media (max-width: 680px) {
  body { font-size: 14.5px; }

  .carte { padding: 20px 18px; }

  /* L'en-tete de fiche passe en colonne : le bloc de droite se realigne. */
  .fiche-entete {
    grid-template-columns: 1fr;
    gap: 20px;
    padding: 28px 0 22px;
  }
  .fiche-entete > div:last-child { text-align: left !important; }

  .resume { grid-template-columns: repeat(2, 1fr); }
  .resume > div { padding-right: 14px; }
  .resume b { font-size: 21px; }

  .onglet { padding: 11px 14px; font-size: 10px; }

  .genotype { grid-template-columns: 1fr; gap: 8px; }
  .genotype .ligne { justify-content: flex-start !important; }

  .index-ligne { grid-template-columns: 110px 1fr 54px; gap: 10px; font-size: 12px; }

  .pied .entre { flex-direction: column; align-items: flex-start; gap: 18px; }
  .pied .mono { text-align: left !important; }

  /* Cibles tactiles : au moins 44 px de haut. */
  .bouton { padding: 13px 20px; }
  .bouton--petit { padding: 10px 14px; }
  .champ input, .champ select, .champ textarea, .saisie { padding: 13px 14px; font-size: 16px; }
  /* 16 px evite le zoom automatique de Safari iOS a la mise au point. */
}

@media (max-width: 420px) {
  .resume { grid-template-columns: 1fr; }
  .rosette { font-size: 9.5px; padding: 4px 9px 4px 7px; }
}
