/* ==========================================================================
   Calculateur de percentile — Score calcique coronaire (MESA)
   Style clinique, clair, utilisable en consultation.
   ========================================================================== */

:root {
  --ink: #15202b;
  --ink-soft: #3d4f5f;
  --muted: #6b7c8a;
  --paper: #f3f6f8;
  --panel: rgba(255, 255, 255, 0.92);
  --line: #d5dee6;
  --accent: #0d6e6e;
  --accent-deep: #0a5252;
  --accent-soft: #d8efef;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(21, 32, 43, 0.08);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", "Segoe UI", sans-serif;

  /* Jauge */
  --g-green: #2f9e6b;
  --g-lime: #8fbf3f;
  --g-yellow: #e2b93b;
  --g-orange: #e07a2f;
  --g-red: #c43c2c;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  position: relative;
}

/* Atmosphère : dégradé + motif léger (pas de fond plat) */
.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(1200px 600px at 10% -10%, #c9e8e6 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #dbe7f2 0%, transparent 50%),
    linear-gradient(165deg, #eef3f6 0%, #f7f9fb 45%, #e8eef2 100%);
}

.page-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(13, 110, 110, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(13, 110, 110, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   En-tête / marque
   -------------------------------------------------------------------------- */

.app-header {
  max-width: 42rem;
  animation: fade-up 0.55s ease both;
}

.brand-kicker {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.brand-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: clamp(2rem, 4.5vw, 3.1rem);
  line-height: 1.1;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.brand-subtitle {
  margin: 0.45rem 0 0;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--ink-soft);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Panneaux
   -------------------------------------------------------------------------- */

.panel {
  background: var(--panel);
  border: 1px solid rgba(213, 222, 230, 0.9);
  border-radius: var(--radius);
  padding: 1.5rem 1.4rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: fade-up 0.6s ease 0.08s both;
}

.panel-placeholder {
  min-height: 280px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 650;
  margin: 0 0 0.35rem;
}

.panel-hint,
.placeholder-text {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
}

.form-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.form-control,
.form-select {
  border-radius: 10px;
  border-color: var(--line);
  padding: 0.65rem 0.85rem;
  background: #fff;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 110, 0.15);
}

.btn-calc {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-deep);
  --bs-btn-hover-border-color: var(--accent-deep);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-bg: var(--accent-deep);
  --bs-btn-active-border-color: var(--accent-deep);
  --bs-btn-active-color: #fff;
  border-radius: 12px;
  font-weight: 600;
  padding: 0.75rem 1rem;
  letter-spacing: 0.01em;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.btn-calc:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(13, 110, 110, 0.28);
}

.btn-calc:disabled {
  opacity: 0.75;
}

/* --------------------------------------------------------------------------
   Carte résultat
   -------------------------------------------------------------------------- */

.result-card {
  border: 1px solid rgba(213, 222, 230, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: #fff;
  overflow: hidden;
}

.result-enter {
  animation: card-in 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.result-top {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--line);
}

.result-label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.result-score {
  margin: 0.15rem 0 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 650;
  color: var(--ink);
}

.result-percentile {
  margin: 0.1rem 0 0;
  font-family: var(--font-display);
  font-size: clamp(2.8rem, 6vw, 3.6rem);
  font-weight: 650;
  line-height: 1;
  color: var(--accent-deep);
}

.result-percentile-block {
  text-align: right;
}

.result-text {
  margin: 0;
  padding: 1rem 1.1rem;
  background: var(--accent-soft);
  border-radius: 12px;
  color: var(--ink);
  font-size: 1.02rem;
  line-height: 1.45;
  border-left: 4px solid var(--accent);
}

/* Badges catégorie */
.category-badge {
  display: inline-block;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.35rem 0.85rem;
  border-radius: 8px;
  background: #eef2f5;
  color: var(--ink);
}

.cat-low { background: #d8f3e5; color: #1b6b45; }
.cat-mild { background: #e8f3c8; color: #4f6b16; }
.cat-mid { background: #f7efc4; color: #7a6410; }
.cat-high { background: #fde0c8; color: #9a4a12; }
.cat-very-high,
.cat-extreme { background: #f8d4d0; color: #8f2418; }

/* --------------------------------------------------------------------------
   Jauge colorée
   -------------------------------------------------------------------------- */

.gauge-track {
  position: relative;
  height: 18px;
  border-radius: 999px;
  overflow: visible;
}

.gauge-segments {
  display: flex;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.seg {
  flex: 1;
  height: 100%;
}

.seg-green { background: var(--g-green); }
.seg-lime { background: var(--g-lime); }
.seg-yellow { background: var(--g-yellow); }
.seg-orange { background: var(--g-orange); }
.seg-red { background: var(--g-red); }

.gauge-marker {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  transition: left 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 2;
}

.gauge-scale,
.needle-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

/* --------------------------------------------------------------------------
   Graphique horizontal + aiguille rouge
   -------------------------------------------------------------------------- */

.needle-track {
  position: relative;
  height: 28px;
  border-radius: 8px;
  background:
    linear-gradient(
      90deg,
      var(--g-green) 0%,
      var(--g-lime) 25%,
      var(--g-yellow) 50%,
      var(--g-orange) 75%,
      var(--g-red) 100%
    );
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  overflow: visible;
}

.needle-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 8px 0 0 8px;
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.needle {
  position: absolute;
  top: -10px;
  bottom: -10px;
  width: 3px;
  margin-left: -1.5px;
  background: #c62828;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.5);
  transition: left 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 3;
}

.needle-tip {
  position: absolute;
  top: -6px;
  left: 50%;
  width: 0;
  height: 0;
  margin-left: -7px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid #c62828;
}

/* --------------------------------------------------------------------------
   Pied de page
   -------------------------------------------------------------------------- */

.app-footer {
  max-width: 48rem;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
  animation: fade-up 0.7s ease 0.15s both;
}

.app-footer p {
  margin: 0;
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 575.98px) {
  .panel {
    padding: 1.2rem 1rem;
  }

  .result-percentile-block {
    text-align: left;
  }

  .result-top {
    flex-direction: column;
    align-items: flex-start;
  }
}

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