/* ==========================================================================
   BTA5 — NmaPhoto : bloc « retrouver ma photo »
   Le bloc vit dans une page Elementor : il reprend les variables de la charte
   (définies dans le CSS global du site) avec un repli local,
et n'écrit rien
   hors de .nmap.
   ========================================================================== */

.nmap {
  --nmap-navy-950: var(--navy-950, #081633);
  --nmap-navy-900: var(--navy-900, #0a1e4f);
  --nmap-navy-800: var(--navy-800, #0e2a6b);
  --nmap-blue: var(--blue-500, #2563eb);
  --nmap-blue-400: var(--electric-400, #3b82f6);
  --nmap-ice: var(--ice-50, #eef2fc);
  --nmap-white: #ffffff;
  --nmap-text: var(--text-body, #5b6478);
  --nmap-border: var(--border, #e2e8f5);
  --nmap-error: var(--error, #dc2626);
  --nmap-orange: #ff4d1c;
  --nmap-radius: var(--radius-card, 1.25rem);
  --nmap-shadow: var(--shadow-bta, 0 20px 60px -20px rgba(27, 63, 171, 0.35));
  --nmap-ease: var(--ease-out, cubic-bezier(0.22, 1, 0.36, 1));
  --nmap-font-display: var(--font-display, 'Archivo', ui-sans-serif, system-ui, sans-serif);
  --nmap-font-body: var(--font-body, 'Inter', ui-sans-serif, system-ui, sans-serif);

  position: relative;
  display: grid;
  gap: 1.5rem;
  width: 100%;
  color: var(--nmap-navy-800);
  font-family: var(--nmap-font-body);
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}

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

.nmap [hidden] { display: none !important; }

.nmap h3,
.nmap h4,
.nmap p,
.nmap ul,
.nmap figure { margin: 0; }

.nmap-title {
  font-family: var(--nmap-font-display);
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--nmap-navy-800);
}
.nmap-lead { font-size: 0.95rem; color: var(--nmap-text); }

/* Panneaux -------------------------------------------------------------- */
.nmap-panel {
  background: var(--nmap-white);
  border: 1px solid var(--nmap-border);
  border-radius: var(--nmap-radius);
  padding: 2rem;
  display: grid;
  gap: 1.5rem;
}

.nmap-panel-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.nmap-panel-head > div { display: grid; gap: 0.35rem; }

.nmap-step-num {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  background: var(--nmap-blue);
  color: var(--nmap-white);
  font-family: var(--nmap-font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 1.05rem;
}

/* Alertes --------------------------------------------------------------- */
.nmap-alert {
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid rgba(220, 38, 38, 0.25);
}
.nmap-alert--info {
  background: var(--nmap-ice);
  color: var(--nmap-navy-800);
  border-color: rgba(37, 99, 235, 0.25);
}

.nmap-notice {
  padding: 1rem 1.2rem;
  border-radius: 0.85rem;
  border: 1px dashed rgba(220, 38, 38, 0.5);
  background: #fff5f5;
  color: #991b1b;
  font-size: 0.9rem;
}
.nmap-notice a { color: inherit; font-weight: 600; }

/* Boutons --------------------------------------------------------------- */
.nmap .nmap-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem 1.6rem;
  border-radius: 12px;
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.25s var(--nmap-ease), color 0.25s, border-color 0.25s, transform 0.1s;
  min-width: 0;
  min-height: 0;
}
.nmap .nmap-btn:active { transform: scale(0.99); }
.nmap .nmap-btn:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.35); outline-offset: 2px; }
.nmap .nmap-btn[disabled],
.nmap .nmap-btn.is-busy { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.nmap .nmap-btn svg { flex: none; }

.nmap .nmap-btn--lg { padding: 1rem 1.9rem; font-size: 1rem; }
.nmap .nmap-btn--sm { padding: 0.6rem 1rem; font-size: 0.85rem; }

.nmap .nmap-btn--primary {
  background: var(--nmap-blue);
  color: var(--nmap-white);
  box-shadow: 0 12px 30px -10px rgba(37, 99, 235, 0.55);
}
.nmap .nmap-btn--primary:hover { background: var(--nmap-blue-400); color: var(--nmap-white); }

.nmap .nmap-btn--ghost {
  background: var(--nmap-white);
  color: var(--nmap-navy-800);
  border-color: var(--nmap-border);
}
.nmap .nmap-btn--ghost:hover { border-color: var(--nmap-blue); color: var(--nmap-blue); }

.nmap .nmap-file { position: relative; overflow: hidden; }
.nmap .nmap-file input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.nmap .nmap-file--test { border-style: dashed; }

/* Prise de vue ---------------------------------------------------------- */
.nmap-capture-grid {
  display: grid;
  grid-template-columns: minmax(0, 380px) 1fr;
  gap: 1.75rem;
  align-items: start;
}

.nmap-viewfinder {
  position: relative;
  aspect-ratio: 1 / 1;
  width: 100%;
  overflow: hidden;
  border-radius: 1rem;
  background: var(--nmap-navy-950);
  box-shadow: 0 18px 40px -24px rgba(8, 22, 51, 0.6);
}
.nmap .nmap-viewfinder video,
.nmap .nmap-viewfinder img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nmap .nmap-viewfinder video { display: none; }
.nmap-viewfinder.is-live video { display: block; }
.nmap-viewfinder.is-mirrored video { transform: scaleX(-1); }

.nmap-viewfinder-idle {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.5rem;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem;
}
.nmap-viewfinder.is-live .nmap-viewfinder-idle,
.nmap-viewfinder.has-photo .nmap-viewfinder-idle { display: none; }

.nmap-face-guide {
  display: none;
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58%;
  height: 74%;
  transform: translate(-50%, -52%);
  border: 2px dashed rgba(255, 255, 255, 0.7);
  border-radius: 50% / 45%;
  box-shadow: 0 0 0 999px rgba(8, 22, 51, 0.35);
  pointer-events: none;
}
.nmap-viewfinder.is-live .nmap-face-guide { display: block; }

.nmap-countdown {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--nmap-font-display);
  font-style: italic;
  font-weight: 900;
  font-size: 5rem;
  color: var(--nmap-white);
  text-shadow: 0 6px 30px rgba(8, 22, 51, 0.6);
  pointer-events: none;
}

.nmap-viewfinder.is-flash::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--nmap-white);
  animation: nmap-flash 0.35s ease-out forwards;
}
@keyframes nmap-flash { from { opacity: 0.9; } to { opacity: 0; } }

.nmap-capture-side { display: grid; gap: 1.25rem; }
.nmap-capture-actions { display: grid; gap: 0.7rem; }
.nmap-capture-actions .nmap-btn { width: 100%; }

.nmap-tips {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.45rem;
  font-size: 0.85rem;
  color: var(--nmap-text);
}
.nmap-tips li { position: relative; padding-left: 1.3rem; }
.nmap-tips li::before {
  content: '';
  position: absolute;
  left: 0.15rem;
  top: 0.5em;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--nmap-blue-400);
}

/* Barre de recherche ---------------------------------------------------- */
.nmap-search-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--nmap-border);
}

.nmap-field { display: grid; gap: 0.4rem; }
.nmap-field > span { font-size: 0.8rem; font-weight: 600; color: var(--nmap-navy-800); }
.nmap .nmap-field select {
  appearance: none;
  min-width: 9rem;
  border: 1.5px solid var(--nmap-border);
  border-radius: 0.8rem;
  padding: 0.75rem 2.6rem 0.75rem 1rem;
  font: inherit;
  font-size: 0.95rem;
  color: var(--nmap-navy-800);
  background: var(--nmap-white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6478' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 0.9rem center;
}
.nmap .nmap-field select:focus { outline: none; border-color: var(--nmap-blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }

/* Recherche en cours ---------------------------------------------------- */
.nmap-loading-head {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.nmap-loading-head > div { display: grid; gap: 0.3rem; }
.nmap-loading-logo {
  flex: none;
  display: grid;
  place-items: center;
  padding: 0.9rem 1.1rem;
  border-radius: 1rem;
  background: var(--nmap-ice);
  animation: nmap-pulse 1.6s ease-in-out infinite;
}
.nmap .nmap-loading-logo img { display: block; width: 153px; height: auto; }
@keyframes nmap-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 77, 28, 0.25); }
  50% { transform: scale(1.03); box-shadow: 0 0 0 14px rgba(255, 77, 28, 0); }
}

.nmap-skeleton {
  aspect-ratio: 4 / 3;
  border-radius: 0.9rem;
  background: linear-gradient(100deg, #eef2fc 30%, #f8faff 50%, #eef2fc 70%);
  background-size: 200% 100%;
  animation: nmap-shimmer 1.4s linear infinite;
}
@keyframes nmap-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Résultats ------------------------------------------------------------- */
.nmap-results-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}
.nmap-results-id { display: flex; align-items: center; gap: 1rem; }
.nmap-results-id > div { display: grid; gap: 0.25rem; }
.nmap .nmap-selfie-thumb {
  flex: none;
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--nmap-white);
  box-shadow: 0 0 0 2px var(--nmap-blue);
  background: var(--nmap-ice);
}
.nmap-results-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.nmap-progress { display: grid; gap: 0.5rem; }
.nmap-progress-bar {
  height: 0.5rem;
  border-radius: 999px;
  background: var(--nmap-ice);
  overflow: hidden;
}
.nmap-progress-bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--nmap-blue), var(--nmap-blue-400));
  transition: width 0.3s var(--nmap-ease);
}
.nmap-progress p { font-size: 0.85rem; color: var(--nmap-text); }

.nmap-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
}

.nmap-tile {
  position: relative;
  display: grid;
  gap: 0;
  border-radius: 0.9rem;
  overflow: hidden;
  background: var(--nmap-ice);
  border: 1px solid var(--nmap-border);
  transition: transform 0.3s var(--nmap-ease), box-shadow 0.3s, border-color 0.3s;
}
.nmap-tile:hover { transform: translateY(-4px); border-color: var(--nmap-blue-400); box-shadow: var(--nmap-shadow); }

.nmap .nmap-tile-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  aspect-ratio: 4 / 3;
  min-width: 0;
  min-height: 0;
  line-height: 0;
  font-size: 0;
  border-radius: 0;
  box-shadow: none;
}
.nmap .nmap-tile-open img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nmap-tile-score {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(8, 22, 51, 0.75);
  color: var(--nmap-white);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  pointer-events: none;
}

.nmap-tile-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.55rem 0.55rem 0.8rem;
  background: var(--nmap-white);
  font-size: 0.75rem;
  color: var(--nmap-text);
}
.nmap-tile-foot span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nmap .nmap-tile-dl {
  flex: none;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  border: 0;
  background: var(--nmap-ice);
  color: var(--nmap-navy-800);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  padding: 0;
  min-width: 0;
  min-height: 0;
  line-height: 1;
  font-size: 0;
}
.nmap .nmap-tile-dl svg,
.nmap .nmap-lightbox-btn svg { display: block; flex: none; }

.nmap .nmap-tile-dl:hover { background: var(--nmap-blue); color: var(--nmap-white); }
.nmap .nmap-tile-dl.is-busy { opacity: 0.5; pointer-events: none; }

.nmap-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding-top: 0.5rem;
}
.nmap-pager-status { font-size: 0.9rem; font-weight: 600; color: var(--nmap-navy-800); }

.nmap-empty {
  display: grid;
  justify-items: center;
  gap: 0.8rem;
  text-align: center;
  padding: 1.5rem 1rem;
  max-width: 520px;
  margin: 0 auto;
}
.nmap-empty-icon {
  display: grid;
  place-items: center;
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 50%;
  background: var(--nmap-ice);
  color: var(--nmap-blue);
}

/* Pied ------------------------------------------------------------------ */
.nmap-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-size: 0.8rem;
  color: var(--nmap-text);
}
.nmap .nmap-foot img { display: block; width: 102px; height: auto; }
.nmap-foot a { display: inline-flex; }

/* Photo en grand --------------------------------------------------------- */
.nmap-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  background: rgba(8, 22, 51, 0.94);
  padding: 4.5rem 4rem 2rem;
}
.nmap-lightbox-figure {
  display: grid;
  gap: 0.9rem;
  max-width: min(1200px, 100%);
  max-height: 100%;
  justify-items: center;
}
.nmap .nmap-lightbox-figure img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 11rem);
  object-fit: contain;
  border-radius: 0.6rem;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}
.nmap-lightbox-figure figcaption {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
}
.nmap .nmap-lightbox-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: var(--nmap-white);
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
  min-width: 0;
  min-height: 0;
  line-height: 1;
  font-size: 0;
  box-shadow: none;
}
.nmap .nmap-lightbox-btn:hover { background: rgba(255, 255, 255, 0.22); }
.nmap .nmap-lightbox-close { top: 1.25rem; right: 1.25rem; }
.nmap .nmap-lightbox-prev { left: 1rem; top: 50%; transform: translateY(-50%); }
.nmap .nmap-lightbox-next { right: 1rem; top: 50%; transform: translateY(-50%); }

/* Responsive ------------------------------------------------------------ */
@media (max-width: 860px) {
  .nmap-panel { padding: 1.5rem; }
  .nmap-capture-grid { grid-template-columns: 1fr; }
  .nmap-viewfinder { max-width: 420px; margin: 0 auto; }
  .nmap-search-bar > .nmap-btn--search { width: 100%; }
  .nmap-field { width: 100%; }
  .nmap .nmap-field select { width: 100%; }
  .nmap-results-actions { width: 100%; }
  .nmap-results-actions .nmap-btn { flex: 1; }
  .nmap-lightbox { padding: 4rem 0.75rem 1.5rem; }
  .nmap .nmap-lightbox-prev { left: 0.4rem; }
  .nmap .nmap-lightbox-next { right: 0.4rem; }
  .nmap .nmap-lightbox-figure img { max-height: calc(100vh - 9rem); }
}

@media (max-width: 640px) {
  /* Sur téléphone, chaque action des résultats occupe sa propre ligne :
     côte à côte, « Tout télécharger (N) » finit tronqué. */
  .nmap-results-head { flex-direction: column; align-items: stretch; }
  .nmap-results-actions { flex-direction: column; gap: 0.6rem; }
  .nmap-results-actions .nmap-btn { width: 100%; flex: none; }
}

@media (max-width: 480px) {
  .nmap-panel { padding: 1.25rem 1rem; }
  .nmap-grid { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }
  .nmap-tile-foot span { display: none; }
  .nmap-tile-foot { justify-content: flex-end; }
  .nmap-loading-head { flex-direction: column; align-items: flex-start; }
  .nmap-lightbox-figure figcaption { flex-direction: column; gap: 0.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  .nmap-loading-logo,
  .nmap-skeleton,
  .nmap-viewfinder.is-flash::after { animation: none; }
  .nmap-tile,
  .nmap .nmap-btn { transition: none; }
}
