/*
  Card 03 — Live Analytics Card — standalone HTML/CSS/JS implementation.
  No build step, no framework, no external dependency: copy index.html,
  this file, and script.js into any project as-is.
*/

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

:root {
  --card-fg: oklch(0.145 0 0);
  --card-muted: oklch(0.5 0 0);
  --card-success: oklch(0.5 0.14 155);
  --card-success-bg: oklch(0.96 0.03 155);
  --card-error: oklch(0.55 0.19 20);
  --card-error-bg: oklch(0.97 0.02 20);
}

.metric-card {
  display: flex;
  width: 100%;
  align-items: stretch;
  overflow: hidden;
  border-radius: 1rem;
  background-color: #ffffff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 10px -4px rgba(0, 0, 0, 0.08);
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji";
}

.metric-card__main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem;
}

.metric-card__label {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--card-muted);
}

.metric-card__value {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--card-fg);
  font-variant-numeric: tabular-nums;
  animation: metric-value-enter 450ms ease-out both;
}

.metric-card__trend-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  animation: metric-fade-in 400ms 220ms ease-out both;
}

.metric-card__trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: 9999px;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.metric-card__trend svg {
  height: 0.75rem;
  width: 0.75rem;
}

.metric-card__trend--up {
  color: var(--card-success);
  background-color: var(--card-success-bg);
}

.metric-card__trend--down {
  color: var(--card-error);
  background-color: var(--card-error-bg);
}

.metric-card__trend--neutral {
  color: var(--card-muted);
  background-color: oklch(0.96 0 0);
}

.metric-card__comparison {
  font-size: 0.75rem;
  color: var(--card-muted);
}

/* A subtly recessed "data surface" for the sparkline — distinct from the
   plain value/trend side without a border between them. */
.metric-card__data-surface {
  display: flex;
  width: 38%;
  flex-shrink: 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1rem;
  background-image: radial-gradient(circle at 70% 30%, color-mix(in oklab, var(--card-fg) 4%, transparent), transparent 70%),
    oklch(0.975 0 0);
  box-shadow: inset 1px 0 0 oklch(0.92 0 0);
  color: var(--card-fg);
}

.metric-card__sparkline-path {
  stroke-dasharray: 300;
  stroke-dashoffset: 300;
  animation: metric-draw 900ms 150ms ease-out forwards;
}

.metric-card__sparkline-dot {
  opacity: 0;
  animation: metric-fade-in 300ms 1000ms ease-out forwards;
}

.metric-card__secondary {
  text-align: center;
  animation: metric-fade-in 400ms 220ms ease-out both;
}

.metric-card__secondary-label {
  margin: 0;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--card-muted);
  text-transform: uppercase;
}

.metric-card__secondary-value {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--card-fg);
}

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

@keyframes metric-value-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes metric-fade-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .metric-card__sparkline-path,
  .metric-card__sparkline-dot,
  .metric-card__value,
  .metric-card__trend-row,
  .metric-card__secondary {
    animation: none;
    opacity: 1;
    transform: none;
    stroke-dashoffset: 0;
  }
}

/*
  Page layout — the canvas this resource is presented on. Adjust or drop it
  when placing the resource inside your own layout.
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom, #fafafa, #f4f4f5);
}
.card03-layout {
  display: flex;
  min-height: 24rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 2rem 2.5rem;
}
.card03-layout__panel {
  width: 100%;
  max-width: 24rem;
}
.card03-layout__button {
  border-radius: 9999px;
  border: 1px solid oklch(0.87 0 0);
  background-color: #ffffff;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: oklch(0.145 0 0);
  cursor: pointer;
  transition: border-color 150ms ease;
}
.card03-layout__button:hover {
  border-color: oklch(0.72 0 0);
}
