/* =========================================================
   Coeur Analytique — identité visuelle
   Palette : papier clinique pâle, encre teal profonde,
   accent "sain" (teal) / accent "à risque" (brique).
   ========================================================= */

:root {
  --bg: #EEF2F0;
  --surface: #FFFFFF;
  --ink: #142B28;
  --ink-muted: #5C726E;
  --line: #D4DEDA;
  --teal: #2F6F64;
  --teal-dark: #1F4F47;
  --brick: #B3402F;
  --brick-dark: #8F3325;

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: inherit; }

html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: var(--teal-dark); }

/* ---------- header ---------- */

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 22px 24px;
}

.wordmark {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.tagline {
  color: var(--ink-muted);
  font-size: 0.875rem;
}

/* ---------- layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 48px;
  padding-top: 40px;
  padding-bottom: 56px;
  align-items: start;
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

/* ---------- intake form ---------- */

.intake h1 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 1.9rem;
  margin: 0 0 8px;
  max-width: 24ch;
}

.lede {
  color: var(--ink-muted);
  max-width: 54ch;
  margin: 0 0 32px;
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 32px;
}

legend {
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0 0 12px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  margin-bottom: 20px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px 20px;
}

@media (max-width: 520px) {
  .field-grid { grid-template-columns: 1fr; }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

.field span {
  color: var(--ink-muted);
}

.field input,
.field select {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
}

.field input:focus-visible,
.field select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

#submit-btn {
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  background: var(--teal);
  border: none;
  border-radius: 4px;
  padding: 14px 28px;
  cursor: pointer;
  transition: background 0.15s ease;
}

#submit-btn:hover { background: var(--teal-dark); }
#submit-btn:disabled { opacity: 0.6; cursor: wait; }

.error-msg {
  color: var(--brick-dark);
  margin-top: 14px;
  font-size: 0.9rem;
}

/* ---------- monitor panel ---------- */

.monitor {
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

@media (max-width: 860px) {
  .monitor { position: static; max-height: none; overflow: visible; }
}

.monitor-bezel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(20, 43, 40, 0.06);
}

.pulse {
  display: block;
  width: 100%;
  height: 72px;
  background: var(--teal-dark);
}

#pulse-idle {
  stroke: rgba(255, 255, 255, 0.28);
}

#pulse-result {
  stroke: #9FE3C7;
  stroke-dasharray: 700;
  stroke-dashoffset: 700;
}

#pulse-result.draw {
  animation: draw-pulse 1.1s ease-out forwards;
}

@keyframes draw-pulse {
  to { stroke-dashoffset: 0; }
}

.monitor-body {
  padding: 28px 26px 26px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.monitor-placeholder p {
  margin: 0 0 6px;
}

.muted { color: var(--ink-muted); font-size: 0.9rem; }

.monitor-loading p {
  font-family: 'IBM Plex Mono', monospace;
  color: var(--ink-muted);
}

.verdict-badge {
  display: inline-block;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 999px;
  margin-bottom: 20px;
}

.verdict-badge.sain {
  background: rgba(47, 111, 100, 0.12);
  color: var(--teal-dark);
}

.verdict-badge.moyen {
  background: rgba(154, 106, 18, 0.14);
  color: #7A5410;
}

.verdict-badge.malade {
  background: rgba(179, 64, 47, 0.12);
  color: var(--brick-dark);
}

.readout {
  margin-bottom: 20px;
}

.readout-value {
  display: block;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 2.6rem;
  font-weight: 500;
  line-height: 1.1;
}

.readout-label {
  color: var(--ink-muted);
  font-size: 0.85rem;
}

.flags-list {
  list-style: none;
  margin: 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flags-list li {
  font-size: 0.85rem;
  color: var(--ink);
  padding-left: 16px;
  position: relative;
}

.flags-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brick);
}

.flags-list.empty li::before { background: var(--teal); }

.disclaimer {
  color: var(--ink-muted);
  font-size: 0.8rem;
  margin-top: 14px;
  line-height: 1.5;
}

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 40px;
}

.site-footer .wrap {
  color: var(--ink-muted);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
}

/* ---------- reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  #pulse-result.draw {
    animation: none;
    stroke-dashoffset: 0;
  }
}

/* ---------- champs dérivés, avertissements, facteurs ---------- */

.derived {
  margin: 14px 0 0;
  font-size: 0.9rem;
  color: var(--ink-muted);
}
.derived strong { font-family: 'IBM Plex Mono', monospace; color: var(--ink); font-weight: 500; }

.mono { font-family: 'IBM Plex Mono', monospace; color: var(--ink-muted); }
.small { font-size: 0.8rem; margin: 0 0 12px; }

.warning {
  font-size: 0.85rem;
  color: #7A5410;
  background: rgba(154, 106, 18, 0.1);
  border-radius: 4px;
  padding: 10px 12px;
  margin: 0 0 20px;
}

.factors h2, .indicators h2 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 1.05rem;
  margin: 0 0 4px;
}
.indicators h2 { margin-bottom: 12px; }
.indicators { margin-top: 22px; }

.factor-group h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 14px 0 8px;
}

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.bars li { display: grid; gap: 4px; font-size: 0.85rem; }
.bars li.empty { color: var(--ink-muted); }
.track { display: block; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.fill { display: block; height: 100%; border-radius: 3px; }
#factors-up .fill { background: var(--brick); }
#factors-down .fill { background: var(--teal); }

.flags-list { border-top: 0; padding-top: 0; }

.model-info {
  margin: 22px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.74rem;
  color: var(--ink-muted);
  line-height: 1.5;
}
