/* Rapports terrain — outil de chantier pour téléphone.
   Idée : fond ardoise froid, un seul accent chaud (orange), et la palette d'une caméra
   thermique réservée à la jauge qui se réchauffe quand le rapport se remplit. */
:root {
  --fond: #eef1f4;
  --surface: #ffffff;
  --creux: #f5f7f9;
  --encre: #14202b;
  --encre-2: #566573;
  --trait: #d3dae0;
  --accent: #d9480f;
  --sur-accent: #ffffff;
  --ok: #1f8a4c;
  --alerte: #a86a10;
  --info: #2b6cb0;
  --danger: #c0392b;
  --barre: #14202b;
  --sur-barre: #ffffff;
  --thermo: linear-gradient(90deg, #1b1464, #5b1a8f, #a3197a, #d93a3a, #f4731e, #fdd835);
  --police: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  --rayon: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --fond: #0c1217;
    --surface: #151e26;
    --creux: #0f171d;
    --encre: #e8edf1;
    --encre-2: #9aa8b4;
    --trait: #2a3741;
    --accent: #ff7a33;
    --sur-accent: #1c0f05;
    --ok: #4cc38a;
    --alerte: #e0a440;
    --info: #6aa9e9;
    --danger: #ff7b6b;
    --barre: #0a0f13;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--encre);
  font: 16px/1.45 var(--police);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
#app { min-height: 100%; display: flex; flex-direction: column; max-width: 760px; margin: 0 auto; }
.chargement { padding: 32px 16px; color: var(--encre-2); }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--info); outline-offset: 2px; }
.ico { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Barre du haut ---------- */
.barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px 16px;
  background: var(--barre); color: var(--sur-barre);
}
.barre h1 { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2; overflow-wrap: anywhere; }
.barre .titres { flex: 1; min-width: 0; }
.barre .sous { font-size: 12.5px; opacity: 0.72; font-variant-numeric: tabular-nums; }
.barre .rond {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer;
}
.barre .rond:active { background: rgba(255, 255, 255, 0.14); }
.barre.avec-retour { padding-left: 4px; }
.pastille {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 4px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 700;
  background: rgba(255, 255, 255, 0.14);
}
.pastille::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #4cc38a; }
.pastille.hors::before { background: #f4731e; }

/* Jauge thermique : froide au départ, chaude quand le rapport est complet */
.jauge { height: 6px; background: color-mix(in srgb, var(--barre) 82%, #fff); position: sticky; top: 0; z-index: 4; }
.jauge i { display: block; height: 100%; background-image: var(--thermo); background-repeat: no-repeat; transition: width 0.3s ease; }
.jauge-texte { padding: 8px 16px 0; font-size: 12.5px; color: var(--encre-2); font-variant-numeric: tabular-nums; }

/* ---------- Contenu ---------- */
main { flex: 1; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
main.avec-onglets { padding-bottom: calc(env(safe-area-inset-bottom) + 96px); }
.bloc { background: var(--surface); border-radius: var(--rayon); padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.bloc > h2 { font-size: 17px; font-weight: 800; letter-spacing: -0.01em; }
.aide { font-size: 14px; color: var(--encre-2); }
.rangee { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.rangee > * { flex: 1 1 140px; min-width: 0; }
.rangee > .etroit { flex: 0 1 120px; }

.champ { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.champ > label, .etiquette {
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: var(--encre-2);
}
input[type="text"], input[type="tel"], input[type="email"], input[type="date"], input[type="password"], select, textarea {
  width: 100%; min-height: 48px; padding: 11px 12px;
  background: var(--creux); border: 1.5px solid var(--trait); border-radius: 10px;
}
/* field-sizing : la zone grandit avec le texte, pas de petit ascenseur à l'intérieur. */
textarea { min-height: 112px; resize: vertical; line-height: 1.45; field-sizing: content; }
textarea.grand { min-height: 190px; }
input:focus, select:focus, textarea:focus { border-color: var(--info); outline: none; background: var(--surface); }

.voix { position: relative; }
.voix textarea { padding-right: 58px; }
.micro {
  position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; display: grid; place-items: center;
  border: 1.5px solid var(--trait); border-radius: 50%; background: var(--surface); color: var(--encre); cursor: pointer;
}
.micro.ecoute { background: var(--danger); border-color: var(--danger); color: #fff; animation: pouls 1.2s ease-in-out infinite; }
.entendu { min-height: 0; font-size: 14px; font-style: italic; color: var(--encre-2); }
.entendu:not(:empty) { padding-top: 6px; }
@keyframes pouls { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 25%, transparent); } }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 16px; border-radius: 12px; cursor: pointer;
  border: 1.5px solid var(--trait); background: var(--surface); font-weight: 700; text-align: center; text-decoration: none; color: var(--encre);
}
.btn:active { transform: translateY(1px); }
.btn.principal { background: var(--accent); border-color: var(--accent); color: var(--sur-accent); }
.btn.grand { min-height: 60px; font-size: 17px; width: 100%; }
.btn.danger { color: var(--danger); }
.btn.petit { min-height: 44px; padding: 8px 12px; font-size: 14px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions > .btn { flex: 1 1 150px; }

.puces { display: flex; flex-wrap: wrap; gap: 8px; }
.puce {
  min-height: 44px; padding: 8px 14px; border-radius: 99px; cursor: pointer;
  border: 1.5px solid var(--trait); background: var(--creux); font-size: 14.5px; font-weight: 600;
}
.puce[aria-pressed="true"] { background: var(--encre); border-color: var(--encre); color: var(--surface); }

/* ---------- Liste des rapports ---------- */
.carte {
  display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface); border: 0; border-radius: var(--rayon); padding: 14px 16px 0; overflow: hidden;
}
.carte .haut { display: flex; align-items: baseline; gap: 10px; }
.carte .nom { flex: 1; min-width: 0; font-size: 17px; font-weight: 800; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.carte .infos { font-size: 14px; color: var(--encre-2); font-variant-numeric: tabular-nums; }
.carte .jauge { position: static; height: 4px; margin: 6px -16px 0; background: var(--trait); }
.etat { flex: none; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.etat.brouillon { background: color-mix(in srgb, var(--alerte) 18%, transparent); color: var(--alerte); }
.etat.termine { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.etat.exemple { background: color-mix(in srgb, var(--info) 18%, transparent); color: var(--info); }
.pied-liste { font-size: 13.5px; color: var(--encre-2); padding: 4px 4px 24px; }

/* ---------- Photos ---------- */
.photo { background: var(--surface); border-radius: var(--rayon); overflow: hidden; display: flex; flex-direction: column; }
.cadre { position: relative; display: block; width: 100%; padding: 0; border: 0; background: var(--creux); cursor: zoom-in; line-height: 0; }
.cadre img { width: 100%; height: auto; display: block; }
.cadre .numero {
  position: absolute; left: 10px; top: 10px; padding: 3px 9px; border-radius: 6px; line-height: 1.4;
  background: rgba(20, 32, 43, 0.82); color: #fff; font-size: 13px; font-weight: 800;
}
.repere {
  position: absolute; aspect-ratio: 1; transform: translate(-50%, -50%); pointer-events: none;
  border: 3px solid #ff3d00; border-radius: 50%; box-shadow: 0 0 0 2px #fff, inset 0 0 0 2px #fff;
}
.photo .corps { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.outils-photo { display: flex; gap: 8px; }
.outils-photo .btn { flex: 1; }
.vide { text-align: center; color: var(--encre-2); padding: 28px 12px; border: 2px dashed var(--trait); border-radius: var(--rayon); }

/* ---------- Onglets du bas ---------- */
.onglets {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; max-width: 760px; margin: 0 auto;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--trait);
}
.onglets button {
  flex: 1; min-height: 62px; padding: 8px 2px; border: 0; background: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 12.5px; font-weight: 700; color: var(--encre-2); border-top: 3px solid transparent;
}
.onglets button[aria-current="page"] { color: var(--accent); border-top-color: var(--accent); }

/* ---------- Avertissements ---------- */
.note { padding: 12px 14px; border-radius: 10px; font-size: 14.5px; border-left: 4px solid var(--info); background: color-mix(in srgb, var(--info) 10%, var(--surface)); }
.note.alerte { border-left-color: var(--alerte); background: color-mix(in srgb, var(--alerte) 12%, var(--surface)); }
.note.ok { border-left-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.note ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Aperçu du rapport : une feuille de papier, claire dans les deux thèmes ---------- */
.papier { background: #fff; color: #1d2a35; border-radius: 6px; overflow: hidden; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); font-size: 14px; }
.papier .bandeau { background: #14202b; color: #fff; padding: 16px; display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.papier .bandeau strong { display: block; font-size: 16px; letter-spacing: 0.01em; }
.papier .bandeau span { font-size: 12.5px; color: #c9d3dc; }
.papier .bandeau .droite { text-align: right; margin-left: auto; }
.papier .filet { height: 4px; background: var(--thermo); }
.papier .corps { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.papier .colonnes { display: flex; gap: 16px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid #d5dce2; }
.papier .colonnes > div { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.papier .t { font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase; color: #5c6b78; }
.papier .nomc { font-weight: 800; font-size: 15.5px; color: #14202b; }
.papier .res { padding: 9px 12px; border-left: 4px solid #2b6cb0; background: #e3eefb; }
.papier .res b { display: block; font-size: 15px; color: #2b6cb0; }
.papier .res.localisee, .papier .res.aucune { border-color: #1f8a4c; background: #e6f4ea; }
.papier .res.localisee b, .papier .res.aucune b { color: #1f8a4c; }
.papier .res.non_localisee { border-color: #b7791f; background: #fdf3e0; }
.papier .res.non_localisee b { color: #b7791f; }
.papier h3 { font-size: 15px; color: #14202b; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.papier h3::before { content: ""; width: 7px; height: 7px; background: #e8590c; flex: none; }
.papier p { white-space: pre-wrap; overflow-wrap: anywhere; }
.papier .grille { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.papier figure { margin: 0; min-width: 0; }
.papier figure .cadre { cursor: default; background: #f3f5f7; }
.papier figcaption { font-size: 12.5px; padding-top: 6px; overflow-wrap: anywhere; }
.papier figcaption b { display: block; color: #14202b; }
.papier figcaption i { display: block; font-style: normal; color: #5c6b78; }

/* ---------- Fenêtres ---------- */
dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); padding: 0; border: 0; border-radius: 16px;
  background: var(--surface); color: var(--encre); overflow: auto;
}
dialog::backdrop { background: rgba(8, 12, 16, 0.6); }
dialog .dedans { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { font-size: 19px; font-weight: 800; }
dialog.plein { width: 100%; max-width: 100%; height: 100%; max-height: 100%; border-radius: 0; background: #0a0f13; color: #fff; }
dialog.plein .dedans { height: 100%; padding: 12px; }
.visionneuse { flex: 1; min-height: 0; display: grid; place-items: center; }
.visionneuse .cadre { width: auto; max-width: 100%; max-height: 100%; cursor: crosshair; background: none; }
.visionneuse img { max-width: 100%; max-height: calc(100vh - 190px); width: auto; }
dialog.plein .btn { background: #1c2731; border-color: #2f3d49; color: #fff; }
ol.etapes { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; }

#annonce {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px); transform: translateX(-50%); z-index: 20;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: var(--encre); color: var(--surface); font-weight: 600; font-size: 14.5px; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#annonce.visible { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
