/* ═══════════════════════════════════════════════════════════════════
   Jarvis Playground v3 — Cards
   ─────────────────────────────────────────────────────────────────
   The v3 card library. Base card + four variants. Every value routes
   through tokens.css.

   Variants:
     .v3-card            base (surface, border, radius, padding,
                         hover lift)
     .v3-card--app       app tile: icon + name + description +
                         status dot (the homepage app grid)
     .v3-card--news      news entry: media header + kicker + title
                         + excerpt + meta row
     .v3-card--stat      stat tile: big number + label + delta
     .v3-card--media     media tile: full-bleed 16:9 visual with a
                         caption bar (gallery / video wall)

   Modifiers:
     .is-featured        larger padding + glow border + elevated
                         shadow (hero cards)
     .is-clickable       pointer + stronger hover lift (wraps an <a>
                         or has a JS click handler)

   Structure convention (BEM-lite):
     .v3-card          block
     .v3-card__*       element (media, body, title, meta, …)
     .v3-card--app     variant

   Usage:
     <article class="v3-card v3-card--app is-clickable">
       <div class="v3-card__icon" aria-hidden="true">◆</div>
       <div class="v3-card__body">
         <h3 class="v3-card__title">Stem Separator</h3>
         <p class="v3-card__desc">Isolate vocals, drums, bass…</p>
       </div>
       <span class="v3-card__status" data-state="online"></span>
     </article>
   ═══════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────
   1. BASE CARD
   ───────────────────────────────────────────────────────────────── */
.v3-card {
  position: relative;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;

  background:
    var(--v3-grad-surface),
    var(--v3-bg-surface);
  border: var(--v3-border-w) solid var(--v3-border);
  border-radius: var(--v3-radius-md);
  padding: var(--v3-space-5);
  color: var(--v3-text);

  box-shadow: var(--v3-shadow-1);

  transition:
    transform var(--v3-dur-3) var(--v3-ease-out),
    box-shadow var(--v3-dur-3) var(--v3-ease-out),
    border-color var(--v3-dur-2) var(--v3-ease-out),
    background-color var(--v3-dur-2) var(--v3-ease-out);

  will-change: transform;
}

/* hover — lift + accent border (only when interactive) */
.v3-card.is-clickable {
  cursor: pointer;
}
.v3-card.is-clickable:hover,
.v3-card.is-clickable:focus-within {
  transform: translateY(-4px);
  border-color: var(--v3-border-hover);
  box-shadow: var(--v3-shadow-3), var(--v3-glow-sm);
}
.v3-card.is-clickable:active {
  transform: translateY(-1px) scale(0.995);
}

/* keyboard focus ring on the card itself (when it's focusable) */
.v3-card:focus-visible {
  outline: var(--v3-border-w-thick) solid var(--v3-border-focus);
  outline-offset: 2px;
}

/* ─────────────────────────────────────────────────────────────────
   2. FEATURED MODIFIER
   ───────────────────────────────────────────────────────────────── */
.v3-card.is-featured {
  padding: var(--v3-space-8);
  border-color: var(--v3-border-hover);
  box-shadow: var(--v3-shadow-2), var(--v3-glow-ring);
}
.v3-card.is-featured.is-clickable:hover {
  box-shadow: var(--v3-shadow-4), var(--v3-glow-md);
}

/* ─────────────────────────────────────────────────────────────────
   3. SHARED ELEMENTS
   ───────────────────────────────────────────────────────────────── */
.v3-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--v3-space-2);
  flex: 1 1 auto;
  min-width: 0;
}
.v3-card__title {
  margin: 0;
  font-family: var(--v3-font-sans);
  font-size: var(--v3-text-lg);
  font-weight: var(--v3-weight-semibold);
  line-height: var(--v3-leading-snug);
  color: var(--v3-text);
}
.v3-card__desc {
  margin: 0;
  font-size: var(--v3-text-sm);
  line-height: var(--v3-leading-base);
  color: var(--v3-text-secondary);
}
.v3-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--v3-space-2);
  margin-top: auto;
  padding-top: var(--v3-space-3);
  font-family: var(--v3-font-mono);
  font-size: var(--v3-text-xs);
  letter-spacing: var(--v3-tracking-wide);
  color: var(--v3-text-muted);
}
.v3-card__meta .v3-card__meta-dot {
  width: 3px;
  height: 3px;
  border-radius: var(--v3-radius-full);
  background: var(--v3-text-muted);
}

/* ─────────────────────────────────────────────────────────────────
   4. VARIANT: APP CARD
   ─────────────────────────────────────────────────────────────────
   Icon tile + name + description + status dot. Used in the
   homepage app grid. */
.v3-card--app {
  gap: var(--v3-space-4);
}
.v3-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  flex: none;
  border-radius: var(--v3-radius);
  font-size: var(--v3-text-2xl);
  background: var(--v3-accent-16);
  border: var(--v3-border-w) solid var(--v3-accent-32);
  color: var(--v3-accent);
  box-shadow: var(--v3-glow-ring);
}
.v3-card--app .v3-card__title {
  font-size: var(--v3-text-base);
  font-weight: var(--v3-weight-semibold);
}
.v3-card--app .v3-card__desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* status dot — data-state drives color via semantic tokens */
.v3-card__status {
  position: absolute;
  top: var(--v3-space-4);
  inset-inline-end: var(--v3-space-4);
  width: 10px;
  height: 10px;
  border-radius: var(--v3-radius-full);
  background: var(--v3-text-muted);
}
.v3-card__status[data-state="online"] {
  background: var(--v3-success);
  box-shadow: 0 0 8px 0 color-mix(in srgb, var(--v3-success) 60%, transparent);
}
.v3-card__status[data-state="busy"] {
  background: var(--v3-warning);
  box-shadow: 0 0 8px 0 color-mix(in srgb, var(--v3-warning) 60%, transparent);
}
.v3-card__status[data-state="offline"] {
  background: var(--v3-error);
  box-shadow: 0 0 8px 0 color-mix(in srgb, var(--v3-error) 60%, transparent);
}

/* ─────────────────────────────────────────────────────────────────
   5. VARIANT: NEWS CARD
   ─────────────────────────────────────────────────────────────────
   Media header (optional) + kicker + title + excerpt + meta. */
.v3-card--news {
  padding: 0;
  overflow: hidden;
}
.v3-card--news .v3-card__media {
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  background: var(--v3-bg-raised);
}
.v3-card--news .v3-card__media img,
.v3-card--news .v3-card__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--v3-dur-4) var(--v3-ease-out);
}
.v3-card--news.is-clickable:hover .v3-card__media img,
.v3-card--news.is-clickable:hover .v3-card__media video {
  transform: scale(1.04);
}
.v3-card--news .v3-card__body {
  padding: var(--v3-space-5);
}
.v3-card__kicker {
  font-family: var(--v3-font-mono);
  font-size: var(--v3-text-xs);
  letter-spacing: var(--v3-tracking-wider);
  text-transform: uppercase;
  color: var(--v3-accent);
}
.v3-card--news .v3-card__title {
  font-size: var(--v3-text-xl);
  font-weight: var(--v3-weight-bold);
  line-height: var(--v3-leading-snug);
}
.v3-card--news .v3-card__desc {
  font-size: var(--v3-text-sm);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─────────────────────────────────────────────────────────────────
   6. VARIANT: STAT CARD
   ─────────────────────────────────────────────────────────────────
   Big number + label + delta. Container-query aware: reads
   --v3-cq-step (set by layout.css @container rules) to scale the
   number when the card is rendered in a wide arena. */
.v3-card--stat {
  gap: var(--v3-space-2);
}
.v3-card__stat-value {
  font-family: var(--v3-font-display);
  font-size: var(--v3-text-3xl);
  font-weight: var(--v3-weight-bold);
  line-height: var(--v3-leading-tight);
  letter-spacing: -0.01em;
  color: var(--v3-text);
  font-variant-numeric: tabular-nums;
}
/* grow the number in a wide container (layout.css sets the step) */
@container v3-arena (min-width: 480px) {
  .v3-card__stat-value { font-size: var(--v3-text-4xl); }
}
@container v3-arena (min-width: 720px) {
  .v3-card__stat-value { font-size: var(--v3-text-5xl); }
}
.v3-card__stat-label {
  font-size: var(--v3-text-sm);
  color: var(--v3-text-secondary);
}
.v3-card__stat-delta {
  display: inline-flex;
  align-items: center;
  gap: var(--v3-space-1);
  font-family: var(--v3-font-mono);
  font-size: var(--v3-text-xs);
  font-weight: var(--v3-weight-semibold);
  padding: var(--v3-space-1) var(--v3-space-2);
  border-radius: var(--v3-radius-full);
}
.v3-card__stat-delta[data-dir="up"] {
  color: var(--v3-success);
  background: var(--v3-success-16);
}
.v3-card__stat-delta[data-dir="down"] {
  color: var(--v3-error);
  background: var(--v3-error-16);
}
.v3-card__stat-delta[data-dir="flat"] {
  color: var(--v3-text-muted);
  background: var(--v3-text-08);
}

/* ─────────────────────────────────────────────────────────────────
   7. VARIANT: MEDIA CARD
   ─────────────────────────────────────────────────────────────────
   Full-bleed visual with a caption bar. Gallery / video wall. */
.v3-card--media {
  padding: 0;
  overflow: hidden;
}
.v3-card--media .v3-card__media {
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  background: var(--v3-bg-raised);
}
.v3-card--media .v3-card__media img,
.v3-card--media .v3-card__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--v3-dur-4) var(--v3-ease-out),
              filter var(--v3-dur-3) var(--v3-ease-out);
}
.v3-card--media.is-clickable:hover .v3-card__media img,
.v3-card--media.is-clickable:hover .v3-card__media video {
  transform: scale(1.05);
  filter: brightness(1.08);
}
/* caption bar overlays the bottom of the visual */
.v3-card__caption {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: var(--v3-space-4) var(--v3-space-5) var(--v3-space-3);
  background: linear-gradient(0deg,
      color-mix(in srgb, var(--v3-bg) 85%, transparent),
      transparent);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--v3-space-2);
}
.v3-card__caption-title {
  margin: 0;
  font-size: var(--v3-text-sm);
  font-weight: var(--v3-weight-semibold);
  color: var(--v3-text);
}
.v3-card__caption-meta {
  font-family: var(--v3-font-mono);
  font-size: var(--v3-text-xs);
  color: var(--v3-text-secondary);
}

/* ─────────────────────────────────────────────────────────────────
   8. RESPONSIVE BEHAVIOR PER BREAKPOINT
   ─────────────────────────────────────────────────────────────────
   Cards are intrinsically fluid (they fill their grid track). The
   breakpoint rules below tune internal density as width grows:
   more padding + larger type on desktop. */
@media (min-width: 640px) {
  .v3-card { padding: var(--v3-space-6); }
  .v3-card--news .v3-card__body { padding: var(--v3-space-6); }
  .v3-card--news .v3-card__title { font-size: var(--v3-text-xl); }
}
@media (min-width: 1024px) {
  .v3-card { padding: var(--v3-space-6); }
  .v3-card.is-featured { padding: var(--v3-space-10); }
  .v3-card--app .v3-card__icon { width: 64px; height: 64px; }
}
@media (min-width: 1280px) {
  .v3-card--news .v3-card__title { font-size: var(--v3-text-2xl); }
  .v3-card--stat .v3-card__stat-value { font-size: var(--v3-text-4xl); }
}

/* ─────────────────────────────────────────────────────────────────
   9. REDUCED MOTION
   ─────────────────────────────────────────────────────────────────
   Hover lift + media zoom are decorative → dropped. The global
   kill switch in tokens.css handles durations. */
@media (prefers-reduced-motion: reduce) {
  .v3-card,
  .v3-card.is-clickable:hover,
  .v3-card.is-clickable:active {
    transform: none;
  }
  .v3-card--news .v3-card__media img,
  .v3-card--news .v3-card__media video,
  .v3-card--media .v3-card__media img,
  .v3-card--media .v3-card__media video {
    transform: none;
    transition: none;
  }
}
