.risk-pulse {
  --risk-color: #2f855a;
  --risk-color-light: #86d99b;
  --risk-warm: #f3c969;

  width: min(500px, 100%);
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

/* Used when the card is embedded flush inside another card (no surrounding
   padding/margin) rather than floating on its own — it should fill whatever
   box its parent gives it instead of sizing itself off its own aspect-ratio,
   and only round the corners that land on the outer card's own corners. */
.risk-pulse--flush {
  width: 100%;
}

.risk-pulse--flush .risk-pulse__card {
  /* Mobile: stacked below the info panel, flush along the bottom edge. */
  border-radius: 0 0 28px 28px;
}

@media (min-width: 768px) {
  .risk-pulse--flush {
    width: min(460px, 100%);
  }

  .risk-pulse--flush .risk-pulse__flip {
    /* Desktop: side-by-side, flush along the right edge. */
    height: 100%;
    aspect-ratio: auto;
  }

  .risk-pulse--flush .risk-pulse__card {
    border-radius: 0 28px 28px 0;
  }
}

/* Smaller variant for component/mini score cards — shrinks the big score
   number to ~30% of its normal size (since bumped up 15% from there) and
   drops the status pill entirely. */
.risk-pulse--sm .risk-pulse__score {
  font-size: clamp(1.932rem, 6.9vw, 3.036rem);
  margin-top: calc(.23em + 25px);
}

.risk-pulse--sm .risk-pulse__status {
  display: none;
}

/* Example score states */

/* No data, rather than a bad score — deliberately desaturated so it reads as
   absent instead of alarming. */
.risk-pulse__card--unknown {
  --risk-color: #64748b;
  --risk-color-light: #cbd5e1;
  --risk-warm: #e2e8f0;
}

.risk-pulse__card--bad {
  --risk-color: #c2413b;
  --risk-color-light: #ef9a92;
  --risk-warm: #f5c96b;
}

.risk-pulse__card--medium {
  --risk-color: #b7791f;
  --risk-color-light: #efd27b;
  --risk-warm: #f2b866;
}

.risk-pulse__card--good {
  --risk-color: #27744c;
  --risk-color-light: #83d99c;
  --risk-warm: #f2ca67;
}

/* A quick at-a-glance color cue for the row's score: a solid bar along the
   cell's right edge, using the same tier colors as .risk-pulse__card. */
.risk-cell {
  position: relative;
}

.risk-cell::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;

  width: 20px;

  pointer-events: none;
}

.risk-cell--bad {
  color: #c2413b;
}

.risk-cell--bad::after {
  background: #c2413b;
}

.risk-cell--medium {
  color: #b7791f;
}

.risk-cell--medium::after {
  background: #b7791f;
}

.risk-cell--good {
  color: #27744c;
}

.risk-cell--good::after {
  background: #27744c;
}

/* Flip mechanics — .risk-pulse__flip owns the box's size (what
   .risk-pulse__card used to own directly) so the front/back faces can be
   absolutely positioned on top of each other and rotated in 3D. */
.risk-pulse__flip {
  position: relative;
  isolation: isolate;

  width: 100%;
  aspect-ratio: 1.55 / 1;

  cursor: pointer;
  perspective: 1400px;
}

.risk-pulse__flip-inner {
  position: absolute;
  inset: 0;

  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}

.risk-pulse__flip--active .risk-pulse__flip-inner {
  transform: rotateY(180deg);
}

.risk-pulse__card {
  position: absolute;
  inset: 0;

  overflow: hidden;
  backface-visibility: hidden;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;

  background:
    radial-gradient(
      circle at 90% 10%,
      color-mix(in srgb, var(--risk-color-light) 45%, transparent),
      transparent 40%
    ),
    radial-gradient(
      circle at 0% 100%,
      color-mix(in srgb, var(--risk-warm) 40%, transparent),
      transparent 38%
    ),
    linear-gradient(
      135deg,
      #ffffff 0%,
      color-mix(in srgb, var(--risk-color-light) 12%, white) 100%
    );

  box-shadow:
    0 24px 50px -24px rgba(15, 23, 42, 0.28),
    inset 0 0 0 1px rgba(148, 163, 184, 0.18);

  color: var(--risk-color);
}

.risk-pulse__card--back {
  transform: rotateY(180deg);

  padding: 28px;
  text-align: center;
}

.risk-pulse__description {
  margin-top: 10px;

  font-size: 0.75rem;
  line-height: 1.2;

  color: var(--risk-color);
  opacity: 0.85;
}

.risk-pulse__card::after {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: -1;

  pointer-events: none;

  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 20px;

  box-shadow: inset 0 0 0 1px rgba(100, 116, 139, 0.08);
}

/* Title */

.risk-pulse__title {
  position: relative;
  z-index: 2;

  margin-top: 4px;

  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-align: center;

  color: var(--risk-color);
  opacity: 0.65;
}

.risk-pulse__subtitle {
  position: relative;
  z-index: 2;

  margin-top: 2px;

  font-size: 0.6rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;

  color: var(--risk-color);
  opacity: 0.45;
}

/* Shield */

.risk-pulse__icon {
  position: absolute;
  top: 24px;
  left: 50%;
  z-index: 3;

  width: 34px;
  height: 38px;

  transform: translateX(-50%);

  color: var(--risk-color);
  opacity: 0.95;
}

.risk-pulse__icon svg {
  width: 100%;
  height: 100%;
}

/* EKG */

.risk-pulse__trace {
  position: absolute;
  top: 50%;
  left: 4%;
  z-index: 0;

  width: 92%;
  height: 42%;

  transform: translateY(-50%);

  color: var(--risk-color-light);
  opacity: 0.52;

  pointer-events: none;
}

.risk-pulse__ecg {
  width: 100%;
  height: 100%;
}

.risk-pulse__ecg-ghost {
  opacity: 0.32;
}

.risk-pulse__ecg-line {
  stroke-dasharray: 2400;
  stroke-dashoffset: 2400;

  animation: risk-pulse-draw 4s linear infinite;

  filter: drop-shadow(
    0 0 4px color-mix(in srgb, var(--risk-color) 25%, transparent)
  );
}

@keyframes risk-pulse-draw {
  from {
    stroke-dashoffset: 2400;
  }

  to {
    stroke-dashoffset: 0;
  }
}

/* Score */

.risk-pulse__score {
  position: relative;
  z-index: 2;
  font-size: clamp(7rem, 25vw, 11rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: -0.02em;
  margin-top: .23em;
  text-align: center;
  color: var(--risk-color);

  text-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4),
    0 8px 24px color-mix(in srgb, var(--risk-color) 12%, transparent);
}

/* Status */

.risk-pulse__status {
  position: relative;
  z-index: 3;

  display: flex;
  align-items: center;
  gap: 12px;

  margin-top: 8px;
  padding: 8px 22px 8px 9px;

  border: 1px solid
    color-mix(in srgb, var(--risk-color-light) 50%, transparent);
  border-radius: 999px;

  background: rgba(255, 255, 255, 0.34);
  backdrop-filter: blur(6px);

  box-shadow:
    inset 0 0 12px rgba(255, 255, 255, 0.35),
    0 4px 12px rgba(15, 23, 42, 0.05);

  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

.risk-pulse__check {
  display: grid;
  place-items: center;

  width: 30px;
  height: 30px;

  border-radius: 50%;

  background: var(--risk-color-light);
  color: white;

  font-size: 1rem;
  letter-spacing: 0;
}

/* Decorative dots */

.risk-pulse__dots {
  position: absolute;
  bottom: 22px;

  width: 48px;
  height: 48px;

  opacity: 0.65;

  background-image: radial-gradient(
    circle,
    currentColor 2px,
    transparent 2.5px
  );
  background-size: 12px 12px;

  mask-image: linear-gradient(
    135deg,
    black,
    transparent 75%
  );
}

.risk-pulse__dots--left {
  left: 20px;
  color: var(--risk-warm);
}

.risk-pulse__dots--right {
  right: 20px;
  color: var(--risk-color-light);
  transform: scaleX(-1);
}

.risk-pulse__label {
  margin-top: 24px;

  text-align: center;

  font-size: 2rem;
  font-weight: 650;
  letter-spacing: -0.035em;

  color: #263238;
}

@media (prefers-reduced-motion: reduce) {
  .risk-pulse__ecg-line {
    animation: none;
    stroke-dashoffset: 0;
  }
}
