/* --------------------------------------------------------------------------
   Contrôle Bahut — feuille de style mobile-first.
   Couleurs métier obligatoires :
     BAHUT       -> rouge
     HORS BAHUT  -> vert
     A CONTROLER -> orange
   -------------------------------------------------------------------------- */

:root {
  --c-bg: #0a0a0a;
  --c-fg: #ffffff;
  --c-muted: #b5b5b5;

  --c-bahut: #d12c2c;          /* rouge */
  --c-hors-bahut: #2ea866;     /* vert */
  --c-a-controler: #e6892b;    /* orange */

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--c-bg);
  color: var(--c-fg);
  font-family: var(--font);
  overscroll-behavior: none;
}

body {
  /* Empêche le scroll involontaire en plein écran */
  overflow: hidden;
  touch-action: manipulation;
}

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
}

.view[hidden] {
  display: none;
}

/* ---------- Écran de démarrage ---------- */

.view--idle {
  background: var(--c-bg);
  gap: 32px;
}

.view--pin {
  background: var(--c-bg);
  gap: 18px;
  justify-content: flex-start;
  padding-top: calc(56px + var(--safe-top));
}

.title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin: 0;
  text-align: center;
}

.camera-message {
  width: min(92vw, 520px);
  margin: -12px auto 0;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  color: var(--c-fg);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

.pin-instruction {
  margin: -8px 0 0;
  color: var(--c-muted);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.pin-form {
  width: min(92vw, 340px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
}

.pin-input {
  width: 100%;
  min-height: 70px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.10);
  color: var(--c-fg);
  font-family: inherit;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: 14px;
  text-align: center;
  outline: none;
}

.pin-input:focus {
  border-color: rgba(255, 255, 255, 0.70);
}

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

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  letter-spacing: 0.3px;
  border-radius: var(--radius);
  padding: 18px 28px;
  font-size: 18px;
  min-height: 56px;
  min-width: 200px;
  transition: transform 80ms ease, opacity 120ms ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--c-fg);
  color: var(--c-bg);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.12);
  color: var(--c-fg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.btn--capture {
  background: var(--c-fg);
  color: var(--c-bg);
  border-radius: 999px;
  width: 84px;
  height: 84px;
  min-width: 84px;
  min-height: 84px;
  padding: 0;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.18),
    0 6px 24px rgba(0, 0, 0, 0.4);
}

/* ---------- Vue caméra ---------- */

.view--camera {
  padding: 0;
  background: #000;
}

.video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}

.camera-switch {
  position: absolute;
  top: calc(18px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.46);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.camera-switch__btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: transparent;
  color: var(--c-fg);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
}

.camera-switch__btn.is-active {
  background: var(--c-fg);
  color: var(--c-bg);
}

.camera-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(28px + var(--safe-bottom));
  display: flex;
  justify-content: center;
  z-index: 2;
}

/* ---------- Vue résultat (couleur plein écran) ---------- */

.view--result {
  gap: 18px;
  justify-content: center;
  overflow: hidden;
}

.status-text {
  margin: 0;
  font-size: clamp(32px, 9vw, 52px);
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: 1px;
  text-align: center;
  text-transform: uppercase;
  padding: 0 12px;
}

.subject-photo {
  width: min(52vw, 230px);
  height: min(52vw, 230px);
  max-height: 32vh;
  object-fit: cover;
  border-radius: 22px;
  border: 4px solid rgba(255, 255, 255, 0.88);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  background: rgba(0, 0, 0, 0.18);
}

.subject-photo[hidden] {
  display: none;
}

.subject-text {
  margin: 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
  color: #ffffff;
  font-size: clamp(20px, 6vw, 30px);
  line-height: 1.1;
  font-weight: 800;
  text-align: center;
  max-width: min(92vw, 640px);
  overflow-wrap: anywhere;
}

.subject-text[hidden] {
  display: none;
}

/* Modifie l'arrière-plan du conteneur principal selon le statut courant */
.screen--bahut {
  background: var(--c-bahut);
}
.screen--hors-bahut {
  background: var(--c-hors-bahut);
}
.screen--a-controler {
  background: var(--c-a-controler);
}

/* ---------- Loader ---------- */

.loader {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.loader[hidden] {
  display: none;
}

.loader__spinner {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  animation: spin 0.9s linear infinite;
}

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

/* ---------- Adaptation tablette / desktop ---------- */

@media (min-width: 700px) {
  .title {
    font-size: 36px;
  }
  .status-text {
    font-size: 64px;
  }
  .subject-text {
    font-size: 30px;
  }
}
