/*
 * Boutik Terrain — styles.
 * Couleurs issues de @boutik/design-tokens (design/DESIGN.md).
 *
 * Contraintes de terrain qui dictent ces choix :
 * - usage debout, à une main → cibles tactiles ≥ 48px, actions en bas d'écran ;
 * - plein soleil → contrastes élevés, thème clair par défaut ;
 * - téléphones bas de gamme → pas de framework, pas d'animation coûteuse.
 */

:root {
  --primary: #118f9c;
  --primary-dark: #0d7280;
  --primary-light: #e0f4f6;
  --accent: #c85a4a;
  --accent-light: #faeae8;
  --success: #059669;
  --warning: #d97706;
  --info: #2563eb;
  --bg: #e6e6e6;
  --surface: #ffffff;
  --surface-variant: #f0f4f5;
  --border: #d0d8da;
  --text: #0b2730;
  --text-secondary: #4d7c87;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --header-h: 56px;
  --footer-h: 76px;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overscroll-behavior-y: contain;
}

/* ---------- Structure ---------- */
.app {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

header .title { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
header .sub { font-size: 12px; opacity: 0.85; }

main {
  flex: 1;
  padding: 16px 16px 24px;
}

footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
}

/* ---------- Barre de progression ---------- */
.progress {
  height: 4px;
  background: var(--primary-light);
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--primary);
  transition: width 0.2s ease;
}

/* ---------- Blocs & cartes ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.block-brief {
  background: var(--primary-light);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #0b3c49;
}
.block-brief strong { display: block; margin-bottom: 4px; }

.block-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}
.block-meta { color: var(--text-secondary); font-size: 13px; margin-bottom: 16px; }

/* ---------- Questions ---------- */
.q-label {
  display: block;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.35;
}
.q-label .req { color: var(--accent); margin-left: 2px; }

.q-hint {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface-variant);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 12px;
}

.q-pillar {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 8px;
}

/* Choix : grande cible tactile, état sélectionné très lisible au soleil */
.choices { display: flex; flex-direction: column; gap: 8px; }

.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  text-align: left;
  width: 100%;
  color: var(--text);
}
.choice:active { transform: scale(0.995); }
.choice[aria-pressed="true"],
.choice.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}
.choice .mark {
  flex: 0 0 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 13px;
  color: #fff;
}
.choice.selected .mark { background: var(--primary); border-color: var(--primary); }
.choice.multi .mark { border-radius: 6px; }

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  min-height: 52px;
  padding: 14px;
  font-size: 16px; /* < 16px déclenche un zoom automatique sur iOS */
  font-family: inherit;
  color: var(--text);
  background: var(--surface-variant);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, .choice:focus-visible, button:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-color: var(--primary);
}

.unit { font-size: 13px; color: var(--text-secondary); margin-top: 6px; }

/* ---------- Boutons ---------- */
button {
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  min-height: 52px;
  padding: 12px 18px;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; flex: 1; }
.btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { background: #9dc4c9; cursor: not-allowed; }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border); }
.btn-danger { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-sm { min-height: 40px; font-size: 14px; padding: 8px 14px; }

/* ---------- Accueil / liste ---------- */
.home-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }

.stat-row { display: flex; gap: 10px; margin-bottom: 16px; }
.stat {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  text-align: center;
}
.stat .v { font-size: 26px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat .k { font-size: 12px; color: var(--text-secondary); }

.visit-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.visit-item .name { font-weight: 600; }
.visit-item .meta { font-size: 13px; color: var(--text-secondary); }
.visit-item .grow { flex: 1; min-width: 0; }
.visit-item .name, .visit-item .meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge.draft { background: var(--accent-light); color: var(--accent); }
.badge.done { background: #e6f6f1; color: var(--success); }
.badge.pain { background: var(--accent); color: #fff; }
.badge.ok { background: var(--success); color: #fff; }
.badge.neutral { background: var(--surface-variant); color: var(--text-secondary); }

/* ---------- Synthèse ---------- */
.bar-row { margin-bottom: 12px; }
.bar-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; }
.bar-head .val { font-weight: 700; }
.bar {
  height: 12px;
  background: var(--surface-variant);
  border-radius: 999px;
  overflow: hidden;
}
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.bar > i.hot { background: var(--accent); }
.bar > i.warm { background: var(--warning); }

.empty {
  text-align: center;
  color: var(--text-secondary);
  padding: 32px 16px;
  font-size: 15px;
}

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.photo-grid figure { margin: 0; position: relative; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); }
.photo-grid button {
  position: absolute; top: 4px; right: 4px;
  min-height: 28px; width: 28px; padding: 0;
  border-radius: 50%; background: rgba(0,0,0,0.6); color: #fff; font-size: 16px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-h) + 16px);
  transform: translateX(-50%);
  background: #0b2730;
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  z-index: 50;
  max-width: 90vw;
  text-align: center;
}

.offline-pill {
  font-size: 11px;
  font-weight: 700;
  background: var(--warning);
  color: #fff;
  padding: 3px 8px;
  border-radius: 999px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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