/* ── CardioFusion — Styles v2 ─────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg-deep: #050810;
  --bg-primary: #0a0e1a;
  --bg-card: rgba(15, 20, 35, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-light: rgba(255, 255, 255, 0.12);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;

  --accent-rppg: #06b6d4;
  --accent-rbcg: #a78bfa;
  --accent-fused: #f43f5e;
  --accent-green: #22c55e;
  --accent-amber: #f59e0b;
  --accent-rose-soft: rgba(244, 63, 94, 0.15);

  --radius: 16px;
  --radius-sm: 10px;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
}

/* ═══════ SCREENS ═══════ */

.app {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: all;
}

/* ═══════ LANDING SCREEN ═══════ */

.screen-landing {
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(244, 63, 94, 0.06) 0%, transparent 70%),
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(6, 182, 212, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 60% 60% at 80% 20%, rgba(167, 139, 250, 0.04) 0%, transparent 60%),
    var(--bg-deep);
}

.landing-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 440px;
  padding: 40px;
}

.landing-icon {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-heart {
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 0 12px rgba(244, 63, 94, 0.4)) drop-shadow(0 0 24px rgba(167, 139, 250, 0.2));
  animation: heartGlow 2.5s ease-in-out infinite;
}

@keyframes heartGlow {

  0%,
  100% {
    filter: drop-shadow(0 0 8px rgba(244, 63, 94, 0.3)) drop-shadow(0 0 20px rgba(167, 139, 250, 0.15));
    transform: scale(1);
  }

  50% {
    filter: drop-shadow(0 0 16px rgba(244, 63, 94, 0.5)) drop-shadow(0 0 32px rgba(167, 139, 250, 0.3));
    transform: scale(1.05);
  }
}

.landing-pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(244, 63, 94, 0.3);
  animation: landingPulse 2.5s ease-in-out infinite;
}

.landing-pulse-ring.delay {
  animation-delay: 1.25s;
}

@keyframes landingPulse {
  0% {
    transform: scale(0.8);
    opacity: 1;
  }

  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.landing-title {
  font-size: 2.5rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--text-primary);
}

.landing-title span {
  background: linear-gradient(135deg, var(--accent-fused), var(--accent-rppg));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.5;
}

.landing-method {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.method-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.method-selector {
  display: flex;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.method-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  transition: all 0.2s ease;
}

.method-btn.active {
  background: var(--accent-fused);
  color: white;
  box-shadow: 0 2px 12px rgba(244, 63, 94, 0.35);
}

.method-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.btn-start {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 16px 40px;
  border: none;
  border-radius: 60px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent-fused), #e11d48);
  color: white;
  box-shadow: 0 8px 32px rgba(244, 63, 94, 0.35);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: all 0.3s ease;
  margin-top: 8px;
}

.btn-start:hover {
  box-shadow: 0 12px 40px rgba(244, 63, 94, 0.5);
  transform: translateY(-2px);
}

.btn-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-start-icon {
  font-size: 1.1rem;
}

.landing-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ═══════ MEASUREMENT SCREEN ═══════ */

.screen-measure {
  overflow: hidden;
}

#videoElement {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  z-index: 1;
}

#overlayCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
  z-index: 2;
  pointer-events: none;
}

/* Vignette */
.screen-measure::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 70% at 50% 50%, transparent 30%, rgba(5, 8, 16, 0.7) 100%);
}

.measure-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
}

.measure-status {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.active {
  background: var(--accent-green);
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
  animation: dotPulse 2s infinite;
}

@keyframes dotPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.measure-status span {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.measure-fps {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.4);
  padding: 6px 12px;
  border-radius: 16px;
}

/* ── Timer Ring ─────── */

.timer-display {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timer-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.timer-ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 3;
}

.timer-ring-progress {
  fill: none;
  stroke: var(--accent-fused);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s linear;
  filter: drop-shadow(0 0 6px rgba(244, 63, 94, 0.5));
}

.timer-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 16px rgba(244, 63, 94, 0.4);
}

/* ── Center Prompt ─────── */

.measure-center {
  position: absolute;
  bottom: 140px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.scanning-text {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
  padding: 10px 20px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.scan-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-fused);
  animation: scanPulse 1.2s ease-in-out infinite;
}

@keyframes scanPulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.3;
    transform: scale(0.6);
  }
}

/* ── Bottom Bar ─────── */
/* ── Mask Selector ─────────────────────────────────────────────────── */
.mask-selector {
  position: absolute;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(10, 14, 26, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.mask-thumb {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.mask-thumb:hover {
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.1);
}

.mask-thumb.active {
  border-color: var(--accent-fused);
  background: rgba(244, 63, 94, 0.15);
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.3);
}

.mask-thumb-icon {
  font-size: 18px;
  line-height: 1;
}

.measure-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 20px 32px;
  display: flex;
  align-items: flex-end;
  gap: 24px;
}

.signal-bar-container {
  flex: 0 0 200px;
}

.signal-bar-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 6px;
}

.signal-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}

.signal-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-amber), var(--accent-green));
  transition: width 0.5s ease;
}

.mini-wave-container {
  flex: 1;
  height: 60px;
  /* canvas fills this */
}

#miniWaveChart {
  width: 100% !important;
  height: 60px !important;
}


/* ═══════ RESULTS SCREEN ═══════ */

.screen-results {
  background:
    radial-gradient(ellipse 50% 40% at 50% 30%, rgba(244, 63, 94, 0.08) 0%, transparent 70%),
    var(--bg-deep);
  overflow-y: auto;
  align-items: flex-start;
  justify-content: flex-start;
}

.results-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 48px 24px 120px;
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  animation: resultsIn 0.8s ease forwards;
}

@keyframes resultsIn {
  from {
    opacity: 0;
    transform: translateY(30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.results-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.results-icon {
  position: relative;
  width: 70px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.results-icon .logo-heart {
  animation: heartGlow 1.5s ease-in-out infinite;
}

.results-pulse-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(244, 63, 94, 0.4);
  animation: resultPulse 1.5s ease-in-out infinite;
}

@keyframes resultPulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 0.6;
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
  }
}

.results-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ── Hero BPM ─────── */

.result-hero {
  text-align: center;
  margin: 16px 0 32px;
  animation: bpmReveal 1s ease forwards;
  animation-delay: 0.3s;
  opacity: 0;
}

@keyframes bpmReveal {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }

  60% {
    transform: scale(1.05);
  }

  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.result-bpm-value {
  font-size: 7rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  background: linear-gradient(135deg, var(--accent-fused), #fb7185, var(--accent-rppg));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 30px rgba(244, 63, 94, 0.3));
}

.result-bpm-label {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.2em;
  margin-top: 4px;
}

/* ── HRV Grid ─────── */

.results-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  width: 100%;
  animation: gridIn 0.6s ease forwards;
  animation-delay: 0.7s;
  opacity: 0;
}

@keyframes gridIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  backdrop-filter: blur(8px);
}

.result-card-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-rppg);
  margin-bottom: 8px;
}

.result-card-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
}

.result-card-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Sub estimates ─────── */

.results-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  padding: 16px 24px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  width: 100%;
  animation: gridIn 0.6s ease forwards;
  animation-delay: 1s;
  opacity: 0;
}

.result-sub-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.result-sub-divider {
  width: 1px;
  height: 20px;
  background: var(--border-glass);
}

.sub-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sub-label.rppg {
  color: var(--accent-rppg);
}

.sub-label.rbcg {
  color: var(--accent-rbcg);
}

.sub-label.snr-label {
  color: var(--accent-amber);
}

.sub-label.method-label-sm {
  color: var(--accent-fused);
}

.sub-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.sub-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ── Result Charts ─────── */

.results-charts {
  width: 100%;
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: gridIn 0.6s ease forwards;
  animation-delay: 1.2s;
  opacity: 0;
}

.results-chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.results-chart {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 12px;
  height: 100px;
}

.results-chart.full {
  height: 120px;
}

.results-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

.chart-tag {
  position: absolute;
  top: 8px;
  left: 12px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.rppg-tag {
  color: var(--accent-rppg);
}

.rbcg-tag {
  color: var(--accent-rbcg);
}

.fused-tag {
  color: var(--accent-fused);
}

.spectrum-tag {
  color: var(--accent-amber);
}


/* ═══════ FACE MESH PULSING (driven by JS) ═══════ */
/* The canvas overlay handles the pulsing face mesh via app.js */


/* ═══════ Responsive ═══════ */

@media (max-width: 640px) {
  .results-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .results-chart-row {
    grid-template-columns: 1fr;
  }

  .result-bpm-value {
    font-size: 5rem;
  }

  .results-sub {
    flex-wrap: wrap;
  }

  .landing-title {
    font-size: 2rem;
  }
}

/* ── Physiologic Assessment Panel ───────────────────────────────────── */
.physio-panel {
  margin-top: 28px;
  padding: 24px;
  background: rgba(15, 20, 35, 0.8);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  text-align: left;
}

.physio-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.physio-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

.physio-confidence {
  padding: 4px 12px;
  border-radius: 100px;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.physio-confidence.high {
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.physio-confidence.moderate {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.physio-confidence.low {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.physio-domains {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.physio-domain-row {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  align-items: center;
  gap: 12px;
}

.physio-domain-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.physio-domain-bar {
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.physio-domain-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.physio-domain-zone {
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
}

.physio-domain-suppressed {
  opacity: 0.3;
}

.physio-suppressed {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.12);
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.72rem;
  color: #f59e0b;
  line-height: 1.5;
}

.physio-suppressed svg {
  flex-shrink: 0;
  margin-top: 1px;
  color: #f59e0b;
}

.physio-narrative {
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
  border-left: 3px solid rgba(99, 102, 241, 0.3);
}

.physio-safety {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.65rem;
  color: var(--text-muted);
  font-style: italic;
}

.physio-safety svg {
  flex-shrink: 0;
  opacity: 0.5;
}

/* Collapsible info card */
.physio-info-card {
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.3s;
}

.physio-info-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

.physio-info-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.physio-info-header svg:first-child {
  color: var(--accent-rppg);
  flex-shrink: 0;
}

.physio-info-header span {
  flex: 1;
}

.physio-chevron {
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.physio-info-card.expanded .physio-chevron {
  transform: rotate(180deg);
}

.physio-info-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease, padding 0.3s ease;
  padding: 0 16px;
}

.physio-info-card.expanded .physio-info-body {
  max-height: 600px;
  padding: 0 16px 16px;
}