/* Lynxo — style « clay » doux et tactile (UI/UX Pro Max : claymorphism mobile, Nunito + DM Sans). */

:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F1F4F9;
  --ink: #0F172A;
  --muted: #475569;
  --line: #D5DBE5;
  --primary: #2563EB;
  --primary-press: #1D4ED8;
  --primary-soft: #E3ECFF;
  --fur: #F97316;
  --fur-soft: #FFEAD8;
  --ok: #15803D;
  --ok-soft: #DCF5E4;
  --warn: #B45309;
  --warn-soft: #FFF1D6;
  --bad: #B91C1C;
  --bad-soft: #FEE7E7;
  --clay: 0 1px 2px rgba(15, 23, 42, .06), 0 0 0 1px var(--line);
  --clay-press: 0 0 0 1px var(--line);
  --plein-bleu: #2563EB;
  --plein-bleu-press: #1D4ED8;
  --plein-vert: #15803D;
  --plein-rouge: #B91C1C;
  --r-xl: 32px;
  --r-lg: 24px;
  --r-md: 18px;
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --font-title: 'Nunito', system-ui, sans-serif;
  --font-body: 'DM Sans', system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.55 var(--font-body);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.blobs { display: none; }

#app { max-width: 560px; margin: 0 auto; min-height: 100%; padding: 0 16px calc(120px + env(safe-area-inset-bottom)); }

h1, h2, h3 { font-family: var(--font-title); font-weight: 900; letter-spacing: -.01em; margin: 0; line-height: 1.15; }
h1 { font-size: 30px; }
h2 { font-size: 24px; }
h3 { font-size: 18px; font-weight: 800; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* ---------- Cartes et boutons clay */
.card {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--clay);
  padding: 18px; margin: 14px 0;
}
.card.soft { background: var(--surface-2); box-shadow: none; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 0 24px; border-radius: 20px;
  font: 800 18px/1 var(--font-title); letter-spacing: .01em;
  background: var(--surface); box-shadow: var(--clay);
  transition: transform .25s var(--spring), box-shadow .2s, background .2s;
}
.btn:active { transform: scale(.94); box-shadow: var(--clay-press); }
/* Fonds pleins sous texte blanc : mêmes teintes foncées dans les deux thèmes (contraste ≥ 4,5:1). */
.btn.primary { background: var(--plein-bleu); color: #fff; }
.btn.primary:active { background: var(--plein-bleu-press); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; box-shadow: none; color: var(--primary); min-height: 44px; padding: 0 12px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn svg { width: 22px; height: 22px; flex: none; }

:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 12px; }

/* ---------- Champs */
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 14px; font-weight: 700; color: var(--muted); margin: 0 0 6px 6px; }
.input {
  width: 100%; min-height: 54px; padding: 0 18px; border-radius: var(--r-md);
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
  font: 500 17px var(--font-body); transition: border-color .2s, box-shadow .2s;
}
textarea.input { padding: 14px 18px; min-height: 96px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.row > .narrow { flex: 0 0 34%; }

/* ---------- Puces de choix (gros boutons tactiles) */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.chip {
  min-height: 48px; padding: 0 18px; border-radius: 16px;
  background: var(--surface); box-shadow: var(--clay);
  font: 700 16px var(--font-body); display: inline-flex; align-items: center; gap: 8px;
  transition: transform .3s var(--spring), background .2s, color .2s;
}
.chip:active { transform: scale(.92); }
.chip[aria-pressed="true"] { background: var(--plein-bleu); color: #fff; animation: pop .35s var(--spring); }
.chip.yes[aria-pressed="true"] { background: var(--plein-vert); }
.chip.no[aria-pressed="true"] { background: var(--plein-rouge); }
.chips.stack { flex-direction: column; }
.chips.stack .chip { justify-content: flex-start; text-align: left; padding: 12px 18px; line-height: 1.3; }
@keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }

.question { margin: 18px 0 6px; }
.question h3 { margin-bottom: 4px; }
.question .muted { font-size: 14px; }
.reveal { animation: reveal .45s var(--ease-out) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(10px); } }

/* ---------- En-tête de progression avec le lynx qui avance */
.topbar {
  position: sticky; top: 0; z-index: 10; margin: 0 -16px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.topbar .line { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.topbar .title { flex: 1; font: 800 15px var(--font-title); color: var(--muted); text-align: center; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--clay); transition: transform .25s var(--spring);
}
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 22px; height: 22px; }
.track { position: relative; height: 54px; margin-top: 4px; }
.track .rail { position: absolute; left: 0; right: 0; bottom: 8px; height: 10px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 2px 3px rgba(0,0,0,.08); }
.track .fill { position: absolute; left: 0; bottom: 8px; height: 10px; border-radius: 10px; background: linear-gradient(90deg, #FDBA74, var(--fur)); transition: width .7s var(--spring); }
.track .runner { position: absolute; bottom: 2px; width: 46px; height: 46px; transform: translateX(-50%); transition: left .7s var(--spring); }
.track .runner.hop { animation: hop .55s var(--ease-out); }
@keyframes hop { 30% { transform: translate(-50%, -14px) rotate(-6deg); } 60% { transform: translate(-50%, 0) rotate(3deg); } }

/* Bulle du lynx */
.bubble {
  position: relative; background: var(--surface); box-shadow: var(--clay); border-radius: 20px;
  padding: 12px 16px; font-size: 15px; margin: 6px 0 4px; min-height: 46px;
}
.bubble::before {
  content: ''; position: absolute; top: -8px; left: var(--tail, 30px); width: 16px; height: 16px;
  background: var(--surface); transform: rotate(45deg); border-radius: 3px;
}
.bubble .caret { display: inline-block; width: 2px; height: 1em; background: var(--fur); vertical-align: -2px; margin-left: 2px; animation: clign 1s steps(2) infinite; }
@keyframes clign { 50% { opacity: 0; } }

/* ---------- Barre d'action collée en bas */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.actionbar .inner { max-width: 528px; margin: 0 auto; display: flex; gap: 10px; }
.actionbar .btn.primary { flex: 1; }

/* ---------- Écran de connexion */
.login { min-height: 100svh; display: flex; flex-direction: column; justify-content: center; padding: 24px 4px 40px; }
.login .mascotte { width: 210px; height: 210px; margin: 0 auto -18px; position: relative; z-index: 1; }
.brand { text-align: center; margin: 12px 0 6px; }
.brand h1 { font-size: 40px; }
.brand h1 b { color: var(--fur); }
.tag { display: inline-block; font-size: 13px; font-weight: 700; padding: 4px 12px; border-radius: 99px; background: var(--fur-soft); color: var(--warn); }

/* ---------- Accueil */
.hello { display: flex; align-items: center; gap: 14px; padding: 22px 0 6px; }
.hello .mascotte { width: 86px; height: 86px; flex: none; }
.big-cta { display: flex; align-items: center; gap: 16px; width: 100%; text-align: left; padding: 20px; border-radius: var(--r-xl);
  background: var(--plein-bleu); color: #fff; box-shadow: var(--clay); transition: transform .3s var(--spring); }
.big-cta:active { transform: scale(.96); }
.big-cta .plus { width: 56px; height: 56px; border-radius: 18px; background: rgba(255,255,255,.18); display: grid; place-items: center; flex: none; }
.big-cta .plus svg { width: 30px; height: 30px; }
.big-cta strong { display: block; font: 900 21px var(--font-title); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .grow b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { font-size: 13px; font-weight: 800; padding: 5px 10px; border-radius: 99px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.draft { background: var(--primary-soft); color: var(--primary); }

/* ---------- Mesures */
.scan-cta { display: grid; place-items: center; gap: 10px; text-align: center; padding: 26px 18px; border-radius: var(--r-xl);
  background: var(--surface); box-shadow: var(--clay); width: 100%; transition: transform .3s var(--spring); }
.scan-cta:active { transform: scale(.96); }
.scan-cta .qr-ico { width: 74px; height: 74px; border-radius: 22px; display: grid; place-items: center; background: var(--fur-soft); color: var(--fur); }
.scan-cta .qr-ico svg { width: 40px; height: 40px; }
.scan-cta strong { font: 900 20px var(--font-title); }
.mesures { display: grid; gap: 10px; }
.mesure { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface); box-shadow: var(--clay);
  animation: reveal .5s var(--ease-out) both; }
.mesure .lbl { flex: 1; }
.mesure .lbl small { display: block; color: var(--muted); font-size: 13px; }
.mesure .val { font: 900 22px var(--font-title); font-variant-numeric: tabular-nums; }
.mesure .unit { font-size: 13px; color: var(--muted); margin-left: 2px; }
.verdict { width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.verdict svg { width: 20px; height: 20px; }
.verdict.ok { background: var(--ok-soft); color: var(--ok); }
.verdict.bad { background: var(--bad-soft); color: var(--bad); }
.verdict.na { background: var(--surface-2); color: var(--muted); }
.verdict.ok svg path, .verdict.bad svg path { stroke-dasharray: 30; stroke-dashoffset: 30; animation: trace .5s .25s var(--ease-out) forwards; }
@keyframes trace { to { stroke-dashoffset: 0; } }

.banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); margin: 12px 0; font-size: 15px; animation: reveal .4s var(--ease-out) both; }
.banner svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.info { background: var(--primary-soft); color: var(--primary); }
.banner b { display: block; }

/* Stepper température */
.stepper { display: flex; align-items: center; gap: 12px; }
.stepper .input { text-align: center; font: 900 26px var(--font-title); }
.stepper .icon-btn { width: 56px; height: 56px; border-radius: 18px; font: 900 26px var(--font-title); }

/* ---------- Résultat */
.result { text-align: center; padding: 26px 18px; border-radius: var(--r-xl); box-shadow: var(--clay); margin: 14px 0; animation: pop .6s var(--spring); }
.result.ok { background: var(--ok-soft); color: var(--ok); }
.result.bad { background: var(--bad-soft); color: var(--bad); }
.result h2 { font-size: 28px; }
.result ul { text-align: left; margin: 12px 0 0; padding-left: 20px; color: var(--ink); }
.dates { display: grid; gap: 8px; }
.dates div { display: flex; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); font-size: 15px; }
.dates b { font-family: var(--font-title); font-weight: 900; white-space: nowrap; }

/* ---------- Signatures */
.pad { position: relative; height: 170px; border-radius: var(--r-md); background: var(--surface); border: 2px dashed var(--line); touch-action: none; overflow: hidden; }
.pad canvas { width: 100%; height: 100%; display: block; }
.pad .hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); pointer-events: none; font-weight: 700; }
.pad.signed .hint { display: none; }
.pad.signed { border-style: solid; border-color: var(--ok); }

/* ---------- Scanner caméra */
.sheet { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; animation: reveal .3s var(--ease-out); }
.sheet video { flex: 1; width: 100%; object-fit: cover; }
.sheet .frame { position: absolute; left: 50%; top: 45%; width: 68vmin; height: 68vmin; transform: translate(-50%, -50%);
  border-radius: 28px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
.sheet .frame::after { content: ''; position: absolute; left: 8%; right: 8%; height: 3px; top: 10%; background: var(--fur); border-radius: 3px;
  box-shadow: 0 0 16px var(--fur); animation: balaye 1.8s ease-in-out infinite alternate; }
@keyframes balaye { to { top: 88%; } }
.sheet .bar { position: absolute; left: 16px; right: 16px; bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; gap: 10px; }
.sheet .bar .btn { flex: 1; }
.sheet .msg { position: absolute; top: calc(24px + env(safe-area-inset-top)); left: 16px; right: 16px; text-align: center; color: #fff; font-weight: 700; }

/* ---------- Transitions d'écran et confettis */
.screen { animation: entre .5s var(--ease-out) both; }
.screen.retour { animation-name: entreRetour; }
@keyframes entre { from { opacity: 0; transform: translateX(28px); } }
@keyframes entreRetour { from { opacity: 0; transform: translateX(-28px); } }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-weight: 700; font-size: 15px; animation: reveal .3s var(--ease-out); max-width: 90vw; }

/* Feuille d'actions qui monte du bas de l'écran */
.feuille-fond { position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-end; justify-content: center; animation: fondu .25s ease-out; }
.feuille { width: 100%; max-width: 560px; max-height: 92svh; overflow: auto; background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 40px rgba(0,0,0,.2); animation: monte .45s var(--spring); }
.feuille .poignee { width: 44px; height: 5px; border-radius: 5px; background: var(--line); margin: 0 auto 14px; }
@keyframes monte { from { transform: translateY(100%); } }
@keyframes fondu { from { opacity: 0; } }
button.list-item { border-bottom: 1px solid var(--line); border-radius: 0; }
button.list-item:last-child { border-bottom: 0; }

.doc { background: #fff; color: #1E293B; border-radius: 18px; box-shadow: var(--clay); padding: 20px; font-size: 14px; }
.doc h3 { font-size: 16px; margin: 14px 0 6px; color: #1B3A6B; }
.doc table { width: 100%; border-collapse: collapse; }
.doc td { padding: 5px 0; border-bottom: 1px solid #EEE; vertical-align: top; }
.doc td:last-child { text-align: right; font-weight: 700; }
.doc img.sig { height: 60px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
