/* ============================================================
   V9 Home — "The Vault". Your collection in 3D obsidian space: top cards fan at
   depth, the deck parallaxes to the pointer, and the focused card lifts forward,
   faces you, holo-foils live, while its neighbours spread aside. Card = position
   (animated); .inner = pointer tilt (instant) so the two don't fight. Card art
   is the only colour; yellow rationed to rank + the HUD's "today". Heavy foil is
   display:none until a card is focused (only one composites it). Scoped .v9-vault.
   ============================================================ */

.v9-vault { display: grid; gap: var(--v9-space-6); padding: var(--v9-space-5) 0 var(--v9-space-9); }

/* ---- top: greeting + HUD ---- */
.v9-vault-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--v9-space-6); flex-wrap: wrap; }
.v9-vault-greet { display: grid; gap: var(--v9-space-1); }
.v9-vault-greet-date { color: var(--v9-text-mute); }
.v9-vault-greet-title { margin: 0; font: var(--v9-weight-display) var(--v9-text-xl)/1.02 var(--v9-font-ui); letter-spacing: var(--v9-track-display); color: var(--v9-text); }
.v9-vault-greet-title .accent { color: var(--v9-accent); }

.v9-vault-hud { display: flex; gap: var(--v9-space-6); align-items: flex-start; }
.v9-vault-stat { display: flex; flex-direction: column; gap: 4px; min-width: 5.5rem; }
.v9-vault-stat .t-eyebrow { color: var(--v9-text-faint); white-space: nowrap; }
.v9-vault-stat-fig { font: 300 var(--v9-text-lg)/1 var(--v9-font-mono); color: var(--v9-text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.v9-vault-stat.is-accent .v9-vault-stat-fig { color: var(--v9-accent); }

/* ---- 3D stage ---- */
.v9-vault-stage-wrap { position: relative; display: grid; place-items: center; min-height: 32rem; }
.v9-vault-stage { position: relative; width: 100%; max-width: 64rem; height: 30rem; perspective: 1700px; }
.v9-vault-deck {
  position: absolute; inset: 0; transform-style: preserve-3d;
  /* --deck-scale fits the fan to the container width (set by JS); parallax tips it */
  transform: scale(var(--deck-scale, 1)) rotateX(calc(var(--par-y, 0) * -4deg)) rotateY(calc(var(--par-x, 0) * 7deg));
  transition: transform 260ms var(--v9-ease);
}

/* ---- a card (position only — animated) ---- */
.v9-vault-card {
  position: absolute; top: 50%; left: 50%;
  width: 15.5rem; aspect-ratio: 5 / 7; margin: -10.85rem 0 0 -7.75rem;
  transform-style: preserve-3d; cursor: pointer;
  transform:
    translate3d(calc(var(--tx, 0px) + var(--spread, 0px)), var(--ty, 0px), var(--tz, 0px))
    rotateY(var(--card-ry, 0deg)) rotateZ(var(--card-rot, 0deg))
    scale(var(--bloom, 1));
  transition: transform 320ms var(--v9-ease), filter 320ms var(--v9-ease);
  filter: saturate(0.82) brightness(0.86);
  z-index: 1;
}
.v9-vault-card.is-focus { filter: none; z-index: 10; }
/* carousel neighbours: dimmed + edge-blurred so the active card pops forward */
.v9-vault-card.is-peek { filter: blur(2.4px) brightness(0.6) saturate(0.7); }

/* ---- inner (pointer tilt) ---- the tilt is eased toward the cursor by a rAF lerp
   in home.js (smooth on re-focus, tight while tracking, eases back on leave). No
   CSS transition here on purpose — it would double-smooth and lag the lerp. */
.v9-vault-inner {
  position: absolute; inset: 0; border-radius: var(--v9-r-md);
  transform: rotateX(var(--tilt-y, 0deg)) rotateY(var(--tilt-x, 0deg));
  transform-style: preserve-3d;
}
.v9-vault-art { position: absolute; inset: 0; border-radius: var(--v9-r-md); overflow: hidden; background: var(--v9-raised); box-shadow: 0 0 0 1px rgba(255,255,255,0.05); }
.v9-vault-art img { width: 100%; height: 100%; object-fit: cover; display: block; }
.v9-vault-art .ph { width: 100%; height: 100%; display: grid; place-items: center; color: var(--v9-text-faint); font-size: var(--v9-text-xs); }

/* rank badge — only on the focused card */
.v9-vault-rank {
  /* translateZ forward (like the plinth) so the tilting art can't z-sort over it;
     rotateX/Y flexes it with the card so it doesn't read as a rigid sticker */
  position: absolute; top: -0.55rem; left: -0.55rem; z-index: 6;
  transform: translateZ(70px) rotateX(calc(var(--tilt-y, 0deg) * 0.5)) rotateY(calc(var(--tilt-x, 0deg) * 0.5));
  display: inline-flex; align-items: center; padding: 0.14rem 0.55rem;
  border-radius: var(--v9-r-pill); background: var(--v9-accent); color: var(--v9-accent-ink);
  font: 600 var(--v9-text-xs) var(--v9-font-mono); letter-spacing: 0.04em;
  opacity: 0; transition: opacity 200ms var(--v9-ease);
}
.v9-vault-card.is-focus .v9-vault-rank { opacity: 1; }

/* ---- holo foil (display:none until focused → only one card composites it) ---- */
.v9-vault-foil { position: absolute; inset: 0; border-radius: var(--v9-r-md); pointer-events: none; overflow: hidden; display: none; }
.v9-vault-card.is-focus .v9-vault-foil { display: block; }
.v9-vault-foil .glare {
  position: absolute; inset: -20%;
  background: radial-gradient(circle at var(--px, 50%) var(--py, 50%), rgba(255,255,255,0.6), rgba(255,255,255,0.12) 24%, transparent 50%);
  mix-blend-mode: soft-light; opacity: calc(0.35 + var(--pfc, 0) * 0.65);
}
.v9-vault-foil .rainbow {
  position: absolute; inset: -40%;
  background: repeating-linear-gradient(115deg,
    hsla(0,100%,66%,0.6) 0%, hsla(48,100%,66%,0.6) 7%, hsla(120,100%,62%,0.6) 14%,
    hsla(190,100%,62%,0.6) 21%, hsla(280,100%,70%,0.6) 28%, hsla(330,100%,66%,0.6) 35%, hsla(0,100%,66%,0.6) 42%);
  background-size: 220% 220%;
  background-position: calc(var(--px, 50%) * 1.5) calc(var(--py, 50%) * 1.5);
  mix-blend-mode: color-dodge; filter: brightness(0.9) contrast(1.25);
  opacity: calc(0.22 + var(--pfc, 0) * 0.55);
}
.v9-vault-foil .sparkle {
  position: absolute; inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.95) 0.5px, transparent 1.4px);
  background-size: 7px 7px; background-position: calc(var(--px, 50%) * 0.3) calc(var(--py, 50%) * 0.3);
  mix-blend-mode: color-dodge; opacity: calc(var(--pfc, 0) * 0.4);
}

/* ---- focused card stat plinth ---- */
.v9-vault-plinth {
  /* translateZ pulls the plinth forward in the card's 3D space so the focused
     card's tilting art (which projects toward the viewer at steep angles) can't
     z-sort in front of it and clip the details. The rotateX/Y flexes the plinth
     at ~half the card's tilt so it feels attached to the card, not rigid. */
  position: absolute; left: 50%; bottom: -2.6rem;
  transform: translateX(-50%) translateZ(70px)
    rotateX(calc(var(--tilt-y, 0deg) * 0.5)) rotateY(calc(var(--tilt-x, 0deg) * 0.5));
  display: grid; gap: 1px; justify-items: center; text-align: center; white-space: nowrap;
  padding: var(--v9-space-2) var(--v9-space-4); min-width: 11rem;
  border: 1px solid var(--v9-line); border-radius: var(--v9-r-md); background: var(--v9-surface);
  opacity: 0; transition: opacity 220ms var(--v9-ease);
}
.v9-vault-card.is-focus .v9-vault-plinth { opacity: 1; }
.v9-vault-plinth strong { color: var(--v9-text); font: 500 var(--v9-text-md) var(--v9-font-ui); }
.v9-vault-plinth span { color: var(--v9-accent); font: 400 var(--v9-text-sm) var(--v9-font-mono); }
.v9-vault-plinth small { color: var(--v9-text-faint); font: 400 var(--v9-text-xs) var(--v9-font-ui); }

.v9-vault-hint { text-align: center; color: var(--v9-text-faint); font-size: var(--v9-text-xs); }

/* ---- recent activity (ledger rows: kind chip · count/age · amount) ---- */
.v9-vault-activity-head { margin-bottom: var(--v9-space-2); }
.v9-vault-activity { display: grid; }
.v9-vault-act-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center;
  gap: var(--v9-space-4); padding: var(--v9-space-3) var(--v9-space-2);
  border-top: 1px solid var(--v9-line); cursor: pointer; border-radius: var(--v9-r-sm);
  transition: background-color var(--v9-t-micro) var(--v9-ease);
}
.v9-vault-act-row:first-child { border-top: 0; }
.v9-vault-act-row:hover { background: var(--v9-hover); }
/* kind chip — scan Sale vs Trade at a glance; stays neutral (accent is rationed) */
.v9-vault-act-kind {
  justify-self: start; min-width: 3.6rem; padding: 0.22rem 0.5rem; text-align: center;
  border: 1px solid var(--v9-line); border-radius: var(--v9-r-pill); background: var(--v9-raised);
  color: var(--v9-text-mute); font: 500 var(--v9-text-2xs, var(--v9-text-xs))/1 var(--v9-font-mono);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.v9-vault-act-kind.is-trade { color: var(--v9-text-faint); }
.v9-vault-act-main { display: grid; gap: 2px; min-width: 0; }
.v9-vault-act-title { color: var(--v9-text); font: 500 var(--v9-text-sm)/1.1 var(--v9-font-ui); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v9-vault-act-meta { color: var(--v9-text-faint); font: 400 var(--v9-text-xs)/1 var(--v9-font-ui); }
.v9-vault-act-amt { color: var(--v9-text); font: 500 var(--v9-text-md)/1 var(--v9-font-mono); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.v9-vault-empty { color: var(--v9-text-mute); font-size: var(--v9-text-sm); padding: var(--v9-space-3) var(--v9-space-2); }

/* ---- mobile carousel chrome (arrows + dots) — mounted by JS only ≤820px ---- */
.v9-vault-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 20;
  width: 2.6rem; height: 2.6rem; display: grid; place-items: center;
  border: 1px solid var(--v9-line-strong); border-radius: 50%;
  background: color-mix(in srgb, var(--v9-surface) 82%, transparent);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  color: var(--v9-text); font: 400 1.5rem/1 var(--v9-font-ui); cursor: pointer; padding: 0;
  transition: background-color var(--v9-t-micro) var(--v9-ease), opacity var(--v9-t-micro) var(--v9-ease);
}
.v9-vault-arrow.is-prev { left: 0.25rem; }
.v9-vault-arrow.is-next { right: 0.25rem; }
.v9-vault-arrow:hover { background: var(--v9-raised); }
.v9-vault-arrow:disabled { opacity: 0.25; cursor: default; }
.v9-vault-dots { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); display: flex; gap: var(--v9-space-2); z-index: 20; }
.v9-vault-dot {
  width: 7px; height: 7px; padding: 0; border: 0; border-radius: 50%; cursor: pointer; background: var(--v9-line-strong);
  transition: background-color var(--v9-t-micro) var(--v9-ease), transform var(--v9-t-micro) var(--v9-ease);
}
.v9-vault-dot[aria-current="true"] { background: var(--v9-accent); transform: scale(1.35); }

/* ---- deal-in ---- */
@keyframes v9-vault-deal { from { opacity: 0; transform: translate3d(0,46px,-320px) rotateZ(8deg); } to { opacity: 1; } }
.v9-vault-card.dealing { animation: v9-vault-deal 640ms var(--v9-ease) backwards; }

@media (prefers-reduced-motion: reduce) {
  .v9-vault-deck, .v9-vault-card { transition: none; transform: none; }
  .v9-vault-card.dealing { animation: none; }
  .v9-vault-foil { display: none !important; }
}

@media (max-width: 820px) {
  .v9-vault-top { flex-direction: column; gap: var(--v9-space-2); }
  /* Phones show only the headline Vault value — Today / Sold·traded are dropped
     so the top doesn't stack into a scrambled column. */
  .v9-vault-stat-soft { display: none; }
  .v9-vault-hud { gap: var(--v9-space-4); }
  .v9-vault-stat { min-width: 0; }
  .v9-vault-stat-fig { font-size: var(--v9-text-xl); }
  /* Carousel: one card forward, neighbours peek; room below for the dots. */
  .v9-vault-stage-wrap { min-height: 23rem; padding-bottom: 1.75rem; }
  .v9-vault-stage { height: 17rem; }
  .v9-vault-card { width: 12rem; margin: -8.4rem 0 0 -6rem; }
  .v9-vault-hint { display: none; } /* no hover on touch — arrows/dots are self-evident */
}
