/* Playoff 2.5D avatar — tier flourishes & tile chrome
 * ───────────────────────────────────────────────────────────────────────────
 * Drop this stylesheet next to avatar-renderer.js. All selectors are scoped
 * with the `.pa-` (Playoff Avatar) prefix so they won't collide with your app.
 *
 * Token defaults are listed at the top — override them in your app's root
 * (or a parent of `.pa-tile`) to re-skin without forking this file.
 *
 *   --pa-paper       warm card background (default #F4F1E8)
 *   --pa-paper-edge  inner stroke on the card
 *   --pa-radius      tile radius
 *   --pa-tilt-perspective  perspective for the parallax tilt
 *
 * The five tier classes are: pa-tier-{base|common|rare|legendary|mythic}.
 * They escalate visual richness:
 *   base       clean card, idle bob only
 *   common     soft blue halo
 *   rare       warm halo + shimmer sweep
 *   legendary  warm bg + dual halo + shimmer
 *   mythic     orbital rings + sparkles + tinted bg
 */

/* ─── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --pa-paper:        #F4F1E8;
  --pa-paper-warm:   #F4E8D8;
  --pa-paper-violet: #E8DCF4;
  --pa-paper-edge:   rgba(26, 28, 38, 0.06);
  --pa-radius:       20px;
  --pa-ink:          #1A1C26;
  --pa-tilt-perspective: 800px;

  /* tier accents */
  --pa-base:        #9BA0AE;
  --pa-common:      #5B8DEF;
  --pa-rare:        #FFB23D;
  --pa-legendary-1: #C03A2E;
  --pa-legendary-2: #FFB23D;
  --pa-mythic-1:    #C77DFF;
  --pa-mythic-2:    #FFD93D;
  --pa-mythic-3:    #5B8DEF;
}

/* ─── Card base ──────────────────────────────────────────────────────────── */
.pa-tile {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--pa-paper);
  border-radius: var(--pa-radius);
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px var(--pa-paper-edge),
    0 6px 14px rgba(0, 0, 0, 0.35),
    0 1px 2px rgba(0, 0, 0, 0.4);
  isolation: isolate;
  cursor: pointer;
  perspective: var(--pa-tilt-perspective);
  transform-style: preserve-3d;
  transition: box-shadow 0.24s ease;
  outline: none;
}
.pa-tile:hover,
.pa-tile:focus-visible {
  box-shadow:
    inset 0 0 0 1px rgba(26, 28, 38, 0.10),
    0 14px 28px rgba(0, 0, 0, 0.45),
    0 2px 4px rgba(0, 0, 0, 0.4);
}
.pa-tile:focus-visible { outline: 2px solid #FF3D6B; outline-offset: 3px; }

/* Subtle hand-made paper texture */
.pa-tile::before {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.15  0 0 0 0 0.12  0 0 0 0 0.08  0 0 0 0.4 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.18;
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: 2;
}
/* Soft vignette */
.pa-tile::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 35%, transparent 58%, rgba(60, 40, 20, 0.14) 100%);
  pointer-events: none;
  z-index: 3;
}

/* ─── The art group ──────────────────────────────────────────────────────── */
.pa-art {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  transform-style: preserve-3d;
  will-change: transform;
}
.pa-art svg {
  width: 88%;
  height: 88%;
  display: block;
  overflow: visible;
}

/* Idle bob — gentle vertical breath when not interacting */
@keyframes pa-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}
.pa-tile:not(.is-locked) .pa-art {
  animation: pa-bob 4.8s cubic-bezier(0.45, 0, 0.55, 1) infinite;
  /* Stagger across the grid by setting --pa-bob-delay per tile in JS */
  animation-delay: var(--pa-bob-delay, 0s);
}
.pa-tile:hover .pa-art,
.pa-tile:focus-visible .pa-art { animation-play-state: paused; }

/* ─── Tier badge ────────────────────────────────────────────────────────── */
.pa-tier-badge {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 5;
  font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(26, 28, 38, 0.88);
  color: var(--pa-paper);
  line-height: 1;
}
.pa-tier-badge.pa-tier-base       { background: var(--pa-base);     color: #0A0B10; }
.pa-tier-badge.pa-tier-common     { background: var(--pa-common);   color: var(--pa-paper); }
.pa-tier-badge.pa-tier-rare       { background: var(--pa-rare);     color: var(--pa-ink); }
.pa-tier-badge.pa-tier-legendary  { background: linear-gradient(90deg, var(--pa-legendary-1), var(--pa-legendary-2)); color: var(--pa-ink); }
.pa-tier-badge.pa-tier-mythic     { background: linear-gradient(90deg, var(--pa-mythic-1), var(--pa-mythic-2), var(--pa-mythic-3)); color: var(--pa-ink); }

/* ─── Lock state ────────────────────────────────────────────────────────── */
.pa-tile.is-locked .pa-art { filter: grayscale(1) brightness(0.55); }
.pa-tile.is-locked { cursor: not-allowed; }
.pa-tile.is-locked .pa-halo,
.pa-tile.is-locked .pa-shimmer,
.pa-tile.is-locked .pa-orbital,
.pa-tile.is-locked .pa-sparks { display: none; }
.pa-lock {
  position: absolute; top: 10px; left: 10px;
  z-index: 5; width: 18px; height: 18px;
}
.pa-lock svg { width: 100%; height: 100%; display: block; }

/* ─── Halos (per-tier soft glow) ────────────────────────────────────────── */
.pa-halo {
  position: absolute; inset: -10%;
  pointer-events: none; z-index: 1;
}
.pa-tier-common .pa-halo {
  background: radial-gradient(ellipse at 50% 45%, rgba(91, 141, 239, 0.14), transparent 55%);
}
.pa-tier-rare .pa-halo {
  background: radial-gradient(ellipse at 50% 45%, rgba(255, 178, 61, 0.28), transparent 55%);
}
.pa-tier-legendary .pa-halo {
  inset: -12%;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(255, 178, 61, 0.40), transparent 50%),
    radial-gradient(ellipse at 50% 45%, rgba(192,  58, 46, 0.18), transparent 70%);
}
.pa-tier-mythic .pa-halo {
  inset: -14%;
  background:
    radial-gradient(ellipse at 50% 45%, rgba(199, 125, 255, 0.45), transparent 55%),
    radial-gradient(ellipse at 50% 45%, rgba(255, 217,  61, 0.25), transparent 70%);
}

/* ─── Shimmer sweep (rare / legendary / mythic) ────────────────────────── */
@keyframes pa-shimmer-sweep {
  0%   { transform: translateX(-140%) skewX(-18deg); opacity: 0; }
  10%  { opacity: 0.55; }
  60%  { opacity: 0.55; }
  100% { transform: translateX( 140%) skewX(-18deg); opacity: 0; }
}
.pa-shimmer {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
}
.pa-shimmer i {
  position: absolute;
  top: -20%; left: 0;
  width: 55%; height: 140%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  mix-blend-mode: screen;
  animation: pa-shimmer-sweep 3.6s ease-in-out infinite;
  /* Stagger per-tile by overriding --pa-shimmer-delay if you want */
  animation-delay: var(--pa-shimmer-delay, 0s);
}

/* ─── Legendary card (warmer paper + tighter shadow) ───────────────────── */
.pa-tile.pa-tier-legendary {
  background: linear-gradient(180deg, #FFFDF4 0%, var(--pa-paper-warm) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(192, 58, 46, 0.18),
    0 8px 18px rgba(192, 58, 46, 0.18),
    0 1px 2px rgba(0, 0, 0, 0.4);
}
.pa-tile.pa-tier-legendary::before { opacity: 0.12; }

/* ─── Mythic — orbital rings + sparkles + violet paper ─────────────────── */
.pa-tile.pa-tier-mythic {
  background: linear-gradient(180deg, #FFFDF4 0%, var(--pa-paper-violet) 100%);
  box-shadow:
    inset 0 0 0 1.5px rgba(199, 125, 255, 0.35),
    0 0 30px rgba(199, 125, 255, 0.30),
    0 8px 18px rgba(0, 0, 0, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.4);
}
.pa-tile.pa-tier-mythic::before { opacity: 0.10; }

@keyframes pa-orbital-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.pa-orbital {
  position: absolute; inset: 6%;
  pointer-events: none;
  z-index: 4;
  animation: pa-orbital-spin 22s linear infinite;
}
.pa-orbital svg { width: 100%; height: 100%; }

@keyframes pa-sparkle-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1.2); }
}
.pa-sparks { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
.pa-sparks i {
  position: absolute;
  width: 6px; height: 6px;
  background: radial-gradient(circle, #FFD93D 0%, transparent 60%);
  border-radius: 50%;
  animation: pa-sparkle-pulse 2.4s ease-in-out infinite;
}
.pa-sparks i:nth-child(1) { top: 12%;    left:  20%;  animation-delay: 0.0s; }
.pa-sparks i:nth-child(2) { top: 18%;    right: 14%;  animation-delay: 0.6s; }
.pa-sparks i:nth-child(3) { bottom: 22%; left:  16%;  animation-delay: 1.2s; }
.pa-sparks i:nth-child(4) { bottom: 18%; right: 18%;  animation-delay: 1.8s; }
.pa-sparks i:nth-child(5) { top: 50%;    left:   8%;  animation-delay: 0.3s; }
.pa-sparks i:nth-child(6) { top: 50%;    right:  8%;  animation-delay: 1.5s; }

/* ─── Press feedback (any tier) ────────────────────────────────────────── */
.pa-tile:active .pa-art {
  animation: none;
  transform: scale(1.03, 0.94);
  transform-origin: center bottom;
  transition: transform 80ms ease-out;
}

/* ─── Reduced motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .pa-art,
  .pa-shimmer i,
  .pa-orbital,
  .pa-sparks i { animation: none !important; }
  .pa-tile { transition: none !important; }
}

/* ─── Optional missing-art fallback ────────────────────────────────────── */
.pa-tile.pa-missing {
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace;
  color: #C03A2E;
  font-size: 11px;
  background: #FFE9E5;
  border: 1px dashed #C03A2E;
}
