/* Garde-robe — Normaliser la photo (htdocs/assets/garderobe/normalisation.css), lot page.
   Cahier « Normaliser la photo » § 7.11. Racines : la feuille (.nm-feuille : formulaire, attente, validation ; et
   « Photo d'origine et photo normalisée »), le plein écran du comparateur (.nm-plein), la pilule et le repère posés
   dans la zone photo de la fiche (.ec-fiche .nm-puce, .ec-fiche .nm-repere), l'aide du formulaire d'une pièce
   (.ec-formulaire .nm-fo-*). Le comparateur montre les vraies couleurs : images en contain, SANS multiply, sur la
   surface ; seules les tuiles « Dans la grille » sont posées sur le tirage, comme la grille. Couleurs : jetons. */

/* ---------------- Fiche : pilule et repère dans la zone photo ---------------- */
.ec-fiche .nm-puce, .ec-fiche .nm-repere {
    position: absolute; bottom: 12px; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
    border: 0; border-radius: 18px; color: var(--gr-texte); font: 500 13px/1 var(--gr-sans); white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.ec-fiche .nm-puce { right: 12px; max-width: calc(100% - 24px); cursor: pointer; -webkit-tap-highlight-color: transparent; transition: transform var(--d-instant) var(--c-standard); }
/* Cible de 44 : la pilule fait 36 de haut. */
.ec-fiche .nm-puce::before { content: ''; position: absolute; inset: -4px 0; }
.ec-fiche .nm-puce:where(:active) { transform: scale(.97); }
.ec-fiche .nm-puce:where(:focus-visible) { outline: none; box-shadow: 0 0 0 2px var(--gr-fond), 0 0 0 4px var(--gr-focus); }
.ec-fiche .nm-repere { left: 12px; pointer-events: none; }
.ec-fiche :where(.nm-puce, .nm-repere) > .g-ic { flex: none; }
.ec-fiche .nm-puce > span { overflow: hidden; text-overflow: ellipsis; }

/* ---------------- Commun ---------------- */
.nm-tourne { animation: nm-tourne 800ms linear infinite; }
@keyframes nm-tourne { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .nm-tourne { animation-duration: 2400ms; } }
.nm-environ { width: 14px; height: 14px; vertical-align: -2px; margin-right: 1px; }
/* Un coût ne se coupe jamais de son unité. */
.nm-somme { white-space: nowrap; }
.nm-corps { display: flex; flex-direction: column; gap: 24px; padding: 4px 0 8px; min-width: 0; }
.nm-alerte {
    display: flex; gap: 8px; align-items: flex-start; margin: 0 var(--gr-marge); padding: 12px 14px; border-radius: var(--r-ctrl);
    background: var(--gr-danger-doux); color: var(--gr-danger); font: 500 15px/21px var(--gr-sans); overflow-wrap: anywhere;
}
.nm-alerte[hidden] { display: none; }
.nm-alerte > .g-ic, .nm-motif > .g-ic { flex: none; margin-top: 1px; }
.nm-aide { margin: 0; font: 500 13px/18px var(--gr-sans); color: var(--gr-texte-2); overflow-wrap: anywhere; }
.nm-legende { margin: 0 var(--gr-marge); font: 500 13px/18px var(--gr-sans); color: var(--gr-texte-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.nm-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 var(--gr-marge); }
.nm-actions > :where(.g-bouton.texte:first-child) { margin-left: -12px; }

/* ---------------- La feuille ---------------- */
.nm-feuille .g-feuille-pied { flex-direction: column; align-items: stretch; gap: 6px; }
.nm-feuille .g-feuille-pied > :where(.g-bouton) { flex: 0 0 auto; }
.nm-feuille .nm-statut { margin: 0; font: 500 13px/18px var(--gr-sans); color: var(--gr-texte-2); text-align: center; overflow-wrap: anywhere; }
.nm-feuille :where(.g-squelette.ligne) { margin-left: var(--gr-marge); }
.nm-feuille .nm-motif { display: flex; gap: 8px; align-items: flex-start; margin: 8px var(--gr-marge) 0; font: 500 15px/21px var(--gr-sans); color: var(--gr-texte-2); }
.nm-feuille .nm-retour { margin: -12px var(--gr-marge) -12px; }
.nm-retour > :where(.g-bouton.texte) { margin-left: -12px; }
.nm-feuille .nm-source { display: flex; align-items: center; gap: 12px; margin: 0 var(--gr-marge); }
.nm-feuille .nm-source-vg { flex: none; width: 96px; }
.nm-feuille .nm-source-texte { margin: 0; min-width: 0; font: 500 13px/18px var(--gr-sans); color: var(--gr-texte-2); }
.nm-feuille .nm-champs { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.nm-feuille .nm-champs:where(:disabled) { opacity: .55; }
.nm-feuille .nm-section { display: flex; flex-direction: column; gap: 10px; margin: 0 var(--gr-marge); min-width: 0; }
.nm-feuille .nm-titre { margin: 0; font: 600 15px/20px var(--gr-sans); }
.nm-feuille .nm-phrase { margin: 0; font: 400 17px/24px var(--gr-sans); }
.nm-feuille .nm-cases { display: flex; flex-direction: column; }
.nm-feuille .nm-groupe { background: var(--gr-surface-2); }
.nm-feuille :where(.nm-groupe) .g-valeur { max-width: 65%; }
/* Segmenté « Nombre d'essais » : un chiffre désactivé (au-delà des places) reste lisible comme tel. */
.nm-feuille .g-segmente > :where([role="radio"]:disabled) { opacity: .4; cursor: default; }
.nm-feuille .nm-cout { margin: 0 var(--gr-marge); font: 500 13px/18px var(--gr-sans); color: var(--gr-texte-2); font-variant-numeric: tabular-nums; }
.nm-feuille .nm-confidentiel { margin: -16px var(--gr-marge) 0; }
.nm-feuille [aria-busy="true"] { opacity: .6; transition: opacity var(--d-court); }
/* La consigne envoyée : repliée ; le prompt en chasse fixe, coupé à la largeur. */
.nm-feuille .nm-consigne { margin: 0 var(--gr-marge); font: 500 13px/18px var(--gr-sans); color: var(--gr-texte-2); }
.nm-feuille .nm-consigne > summary {
    list-style: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; cursor: pointer;
    color: var(--gr-texte); font: 600 15px/20px var(--gr-sans); border-radius: var(--r-ctrl);
}
.nm-feuille .nm-consigne > summary::-webkit-details-marker { display: none; }
.nm-feuille .nm-consigne-ic { width: 16px; height: 16px; transition: transform var(--d-court) var(--c-standard); }
.nm-consigne:where([open]) .nm-consigne-ic { transform: rotate(90deg); }
.nm-feuille .nm-prompt {
    margin: 4px 0 12px; padding: 12px; border-radius: var(--r-ctrl); background: var(--gr-surface-2); color: var(--gr-texte);
    font: 400 13px/18px var(--gr-mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.nm-feuille .nm-images { margin: 0 0 8px; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.nm-feuille .nm-distante { color: var(--gr-texte-3); }
.nm-feuille .nm-avertissements { display: flex; flex-direction: column; gap: 6px; margin: 0 0 8px; color: var(--gr-attention); }
.nm-avertissements[hidden] { display: none; }
.nm-feuille .nm-avert { display: flex; gap: 6px; align-items: flex-start; }
.nm-avert > .g-ic { margin-top: 1px; }

/* L'attente du premier essai : le carré de l'image à venir. */
.nm-feuille .nm-attente { width: min(560px, calc(100% - 2 * var(--gr-marge))); aspect-ratio: 1; margin: 0 auto; }

/* ---------------- Le comparateur (validation, comparer, plein écran) ---------------- */
.nm-vue { display: flex; flex-direction: column; gap: 12px; margin: 0 var(--gr-marge); min-width: 0; }
.nm-comparateur {
    position: relative; width: 100%; max-width: 560px; aspect-ratio: 1; margin: 0 auto; overflow: hidden;
    background: var(--gr-surface); border-radius: var(--r-tirage); box-shadow: inset 0 0 0 1px var(--gr-ligne);
    touch-action: pan-y; -webkit-user-select: none; user-select: none;
}
/* Les vraies couleurs : contain, sans multiply. */
.nm-comparateur > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.nm-comparateur > img[hidden] { display: none; }
.nm-comparateur[data-mode="comparer"] { cursor: ew-resize; }
.nm-comparateur:where([data-mode="comparer"]) > .nm-img-apres { clip-path: inset(0 0 0 var(--nm-pos, 50%)); }
/* La glissière native : le clavier et les lecteurs d'écran ; le pointeur passe par la zone de l'image. */
.nm-glissiere {
    position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none;
    -webkit-appearance: none; appearance: none; background: none;
}
.nm-glissiere[hidden] { display: none; }
/* Le trait : 2 px d'encre bordé de 1 px de papier, et sa poignée ronde de 36. */
.nm-trait { display: none; position: absolute; top: 0; bottom: 0; left: var(--nm-pos, 50%); width: 2px; margin-left: -1px; background: var(--gr-texte); box-shadow: 0 0 0 1px var(--gr-fond); pointer-events: none; }
.nm-comparateur:where([data-mode="comparer"]) > .nm-trait { display: block; }
.nm-poignee {
    position: absolute; top: 50%; left: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; color: var(--gr-texte); box-shadow: 0 0 0 1px var(--gr-ligne-forte);
}
.nm-poignee > .g-ic { width: 16px; height: 16px; margin: 0 -2px; }
.nm-comparateur:where(:has(> .nm-glissiere:focus-visible)) .nm-poignee { box-shadow: 0 0 0 2px var(--gr-fond), 0 0 0 4px var(--gr-focus); }
/* Le verre posé sur l'image (.g-bouton-ic, plus loin dans composants.css, l'effacerait). */
.nm-agrandir {
    position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 50%; color: var(--gr-texte);
    background: var(--gr-verre); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 0 0 1px var(--gr-ligne);
}
.nm-agrandir:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--gr-fond), 0 0 0 4px var(--gr-focus); }
.nm-expire {
    position: absolute; inset: 0; margin: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    background: var(--gr-surface); color: var(--gr-texte-2); font: 500 15px/21px var(--gr-sans); text-align: center;
}
.nm-expire[hidden] { display: none; }

/* ---------------- Étape de validation ---------------- */
.nm-feuille .nm-validation { gap: 20px; }
.nm-validation > .nm-legende { margin-top: -8px; }
/* La bande des essais : vignettes de 56, l'essai choisi cerclé d'encre (et aria-checked). */
.nm-feuille .nm-essais { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px var(--gr-marge) 0; }
.nm-essais[hidden] { display: none; }
.nm-feuille .nm-essai {
    position: relative; flex: none; width: 56px; height: 56px; padding: 0; border: 0; border-radius: var(--r-tirage); overflow: visible;
    background: var(--gr-surface); box-shadow: inset 0 0 0 1px var(--gr-ligne); cursor: pointer;
}
.nm-feuille .nm-essai::before { content: ''; position: absolute; inset: -4px; }
.nm-feuille .nm-essai > img { width: 100%; height: 100%; object-fit: contain; display: block; border-radius: var(--r-tirage); }
.nm-essai[aria-checked="true"] { box-shadow: 0 0 0 2px var(--gr-fond), 0 0 0 4px var(--gr-texte); }
.nm-essai:focus-visible { outline: 2px solid var(--gr-focus); outline-offset: 6px; }
.nm-essai.attente { cursor: default; box-shadow: none; }
.nm-essai > .g-squelette { width: 100%; height: 100%; }
.nm-feuille .nm-controles { list-style: none; margin: -8px var(--gr-marge) 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.nm-controles[hidden] { display: none; }
/* « Retourner l'image » (paires) : le bouton, et sous lui ce qu'il fait. */
.nm-feuille .nm-controles > li.nm-retourner { flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 2px; }
.nm-feuille .nm-retourner .nm-aide { margin: 0; font: 400 12px/16px var(--gr-sans); color: var(--gr-texte-2); }
.nm-feuille .nm-controles > li { display: flex; gap: 8px; align-items: flex-start; font: 500 13px/18px var(--gr-sans); color: var(--gr-texte); }
.nm-controles .g-ic { flex: none; margin-top: 1px; color: var(--gr-attention); }
/* « Dans la grille » : deux tuiles de 96 sur le tirage, en multiply, comme la grille. */
.nm-feuille .nm-grille { display: flex; flex-direction: column; gap: 8px; margin: 0 var(--gr-marge); }
.nm-feuille .nm-tuiles { display: flex; gap: 16px; }
.nm-feuille .nm-tuile { margin: 0; width: 96px; display: flex; flex-direction: column; gap: 6px; }
.nm-feuille .nm-tuile-vg { display: block; width: 96px; }
.nm-feuille .nm-tuile > figcaption { font: 500 13px/18px var(--gr-sans); color: var(--gr-texte-2); }
.nm-actions .g-bouton { max-width: 100%; }
.nm-actions .g-bouton > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nm-validation > .nm-aide { margin: -12px var(--gr-marge) 0; }
.nm-aide[hidden] { display: none; }

/* ---------------- Plein écran ---------------- */
.nm-plein {
    width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; padding: 0; border: 0;
    background: var(--gr-fond); color: var(--gr-texte); display: flex; flex-direction: column; overflow: hidden;
}
.nm-plein:not([open]) { display: none; }
.nm-plein::backdrop { background: var(--gr-fond); }
.nm-plein-haut {
    flex: none; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    min-height: 56px; padding: env(safe-area-inset-top) var(--gr-marge-d) 0 var(--gr-marge);
}
.nm-plein-titre { margin: 0; font: 400 28px/1.1 var(--gr-serif); }
.nm-plein-fermer { width: 44px; height: 44px; }
.nm-plein-corps { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 0 env(safe-area-inset-bottom); overflow: auto; }
/* Le même comparateur, au plus grand : min(100vw, 100dvh − 120px), le segmenté au-dessus. */
.nm-plein .nm-vue { margin: 0 auto; width: min(100vw, calc(100dvh - 120px)); }
/* Le segmenté garde ses marges sans déborder (le .plein du socle le met à 100 %). */
.nm-plein .nm-affichage { margin: 0 var(--gr-marge); width: auto; }
.nm-plein .nm-comparateur { max-width: none; width: 100%; border-radius: 0; }

/* ---------------- Formulaire d'une pièce : photo normalisée ---------------- */
.ec-formulaire .nm-fo-outils { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ec-formulaire .nm-fo-aide { grid-column: 1 / -1; margin-top: 4px; text-align: center; }

@media (min-width: 1024px) {
    .nm-feuille .nm-comparateur, .nm-feuille .nm-attente { max-width: min(560px, calc(86dvh - 360px)); }
}
