/* ═══════════════════════════════════════════════════════════════
   PlayVolt — visual layer
   Atmosphere, page transitions, the home showcase, ranked shelves,
   genre portals, card effects, game-page ambient glow, podium.
   Loaded after app.css. Everything here respects reduced motion.
   ═══════════════════════════════════════════════════════════════ */

@property --spin { syntax: '<angle>'; inherits: false; initial-value: 0deg; }

/* ── Atmosphere: drifting aurora + film grain ───────────────── */
.atmos { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; }
.atmos i {
  position: absolute; width: 70vmax; height: 70vmax; border-radius: 50%;
  background: radial-gradient(circle, var(--c) 0, transparent 60%);
  animation: aurora 48s ease-in-out infinite alternate;
  will-change: transform;
}
.atmos i:nth-child(1) { --c: rgba(255, 62, 154, .20); top: -32vmax; left: -22vmax; }
.atmos i:nth-child(2) { --c: rgba(46, 230, 246, .13); top: 8vh; right: -34vmax; animation-duration: 62s; animation-delay: -14s; }
.atmos i:nth-child(3) { --c: rgba(124, 92, 255, .22); bottom: -42vmax; left: 12vw; animation-duration: 70s; animation-delay: -33s; }
.atmos::after {
  content: ''; position: absolute; inset: -50%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .035;
}
@keyframes aurora {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(9vw, 7vh) scale(1.18); }
  100% { transform: translate(-7vw, -5vh) scale(.92); }
}
[data-theme="light"] .atmos i:nth-child(1) { --c: rgba(255, 62, 154, .13); }
[data-theme="light"] .atmos i:nth-child(2) { --c: rgba(10, 167, 184, .10); }
[data-theme="light"] .atmos i:nth-child(3) { --c: rgba(124, 92, 255, .14); }
[data-theme="light"] .atmos::after { opacity: .03; }

/* ── Glass header with a neon hairline ──────────────────────── */
.topbar {
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-bottom-color: transparent;
  view-transition-name: topbar;
}
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--zap) 20%, var(--volt) 50%, var(--arc) 80%, transparent);
  opacity: .55;
}
.logo span { letter-spacing: .02em; }

/* ── Page transitions (View Transitions API) ────────────────── */
::view-transition-old(root) { animation: vt-out .16s ease-in both; }
::view-transition-new(root) { animation: vt-in .32s cubic-bezier(.2, .8, .2, 1) both; }
::view-transition-group(topbar) { animation: none; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-6px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(12px) scale(.996); } }

/* ── Loading skeletons ──────────────────────────────────────── */
.skel-page { padding-top: 34px; display: grid; gap: 22px; }
.skel { border-radius: var(--r-lg); background: var(--panel); position: relative; overflow: hidden; }
.skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, color-mix(in srgb, var(--ink) 7%, transparent) 50%, transparent 80%);
  transform: translateX(-100%); animation: shimmer 1.3s ease-in-out infinite;
}
.skel--hero { height: clamp(260px, 42vw, 520px); border-radius: var(--r-xl); }
.skel-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; }
.skel--card { aspect-ratio: 16 / 12; }
.skel--line { height: 34px; width: min(420px, 70%); border-radius: 12px; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ── Keycaps get a light sweep ──────────────────────────────── */
.btn { position: relative; isolation: isolate; overflow: hidden; }
.btn::after {
  content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .5) 50%, transparent 65%);
  transform: translateX(-120%); transition: transform .6s ease;
}
.btn:hover::after { transform: translateX(120%); }
.btn--ghost::after { background: linear-gradient(105deg, transparent 35%, color-mix(in srgb, var(--ink) 14%, transparent) 50%, transparent 65%); }

/* ── Home showcase ──────────────────────────────────────────── */
.showcase { --accent: var(--volt); position: relative; isolation: isolate; padding: 30px 0 8px; }
.showcase__ambient {
  position: absolute; z-index: -1; left: 50%; top: -80px; width: 100vw; height: calc(100% + 140px);
  transform: translateX(-50%); overflow: hidden; pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 55%, transparent); mask-image: linear-gradient(#000 55%, transparent);
}
/* The glow is a 32×18 canvas stretched to fill the area (see ambientGlow in ui.js) */
.ambient-canvas { position: absolute; inset: -6%; width: 112%; height: 112%; opacity: 0; transition: opacity .8s ease; }
.is-lit .ambient-canvas { opacity: .5; }
[data-theme="light"] .is-lit .ambient-canvas { opacity: .32; }
.showcase__grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: center; }
.showcase .cabinet { transition: box-shadow .5s; }
.showcase .cabinet__screen video, .showcase .cabinet__screen img { transition: opacity .45s ease; }
.showcase.is-swapping .cabinet__screen video, .showcase.is-swapping .cabinet__screen img,
.showcase.is-swapping .showcase__info > * { opacity: 0; }
.showcase__info { display: grid; gap: 16px; justify-items: start; }
.showcase__info > * { transition: opacity .35s ease, transform .35s ease; }
.showcase.is-swapping .showcase__info > * { transform: translateY(8px); }
.showcase__title {
  font-family: var(--font-display); font-weight: 400; line-height: .92;
  font-size: clamp(2.4rem, 5.8vw, 4.9rem); color: var(--ink);
  text-shadow: 0 4px 0 color-mix(in srgb, var(--accent) 60%, transparent), 0 0 42px color-mix(in srgb, var(--accent) 45%, transparent);
}
.showcase__count { font-weight: 750; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.showcase__count b { color: var(--ink); }

.rail { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-top: 28px; }
.rail button {
  --accent: var(--volt);
  position: relative; display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: center; text-align: left;
  padding: 8px; border-radius: 18px; border: 2px solid var(--line); cursor: pointer; color: var(--ink-2);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  transition: border-color .2s, transform .25s var(--ease-pop), color .2s, background .2s; overflow: hidden;
}
.rail button:hover { transform: translateY(-3px); color: var(--ink); }
.rail button[aria-pressed="true"] { border-color: var(--accent); color: var(--ink); background: color-mix(in srgb, var(--accent) 12%, var(--panel)); }
.rail img { width: 54px; height: 54px; border-radius: 12px; object-fit: cover; }
.rail b { display: block; font-size: .92rem; line-height: 1.15; }
.rail small { display: block; font-size: .76rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail .bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--accent); transform-origin: left; transform: scaleX(0); }
.rail button[aria-pressed="true"] .bar { animation: railbar var(--rail-ms, 8000ms) linear forwards; }
.showcase.is-paused .rail .bar { animation-play-state: paused; }
@keyframes railbar { to { transform: scaleX(1); } }
@media (max-width: 900px) {
  .showcase__grid { grid-template-columns: 1fr; }
  .rail { grid-template-columns: repeat(5, 72%); overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 6px; }
  .rail button { scroll-snap-align: start; }
}

/* ── Section headings get a neon underline ───────────────────── */
.section__title { position: relative; }
.section__head .section__title::after {
  content: ''; display: block; width: 56px; height: 5px; border-radius: 5px; margin-top: 10px;
  background: linear-gradient(90deg, var(--zap), var(--volt));
}

/* ── Genre portals ──────────────────────────────────────────── */
.portals { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.portal {
  --g1: #FF3E9A; --g2: #7C5CFF;
  position: relative; isolation: isolate; overflow: hidden; display: grid; align-content: end; gap: 2px;
  min-height: 150px; padding: 16px; border-radius: var(--r-lg); border: 0; cursor: pointer; text-align: left; color: #fff;
  background: linear-gradient(140deg, var(--g1), var(--g2));
  box-shadow: 0 6px 0 color-mix(in srgb, var(--g2) 55%, #000), 0 16px 30px color-mix(in srgb, var(--g1) 25%, transparent);
  transition: transform .25s var(--ease-pop), box-shadow .25s;
}
.portal::before { /* LED dots */
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .35;
  background-image: radial-gradient(rgba(255, 255, 255, .45) 1.2px, transparent 1.3px); background-size: 12px 12px;
}
.portal:hover { transform: translateY(-5px) rotate(-1deg); }
.portal:active { transform: translateY(2px); box-shadow: 0 2px 0 color-mix(in srgb, var(--g2) 55%, #000); }
.portal[aria-pressed="true"] { outline: 4px solid var(--ink); outline-offset: 3px; }
.portal b { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; line-height: 1; text-shadow: 0 2px 0 rgba(0, 0, 0, .25); }
.portal small { font-weight: 700; opacity: .9; }
.portal__fan { position: absolute; top: 14px; right: 10px; display: flex; }
.portal__fan img {
  width: 46px; height: 46px; border-radius: 13px; border: 3px solid rgba(255, 255, 255, .9); object-fit: cover;
  box-shadow: 0 6px 14px rgba(0, 0, 0, .3); margin-left: -18px; transition: transform .35s var(--ease-pop);
}
.portal__fan img:nth-child(1) { transform: rotate(-12deg); }
.portal__fan img:nth-child(2) { transform: rotate(4deg) translateY(6px); }
.portal__fan img:nth-child(3) { transform: rotate(14deg); }
.portal:hover .portal__fan img:nth-child(1) { transform: rotate(-20deg) translateX(-10px); }
.portal:hover .portal__fan img:nth-child(3) { transform: rotate(22deg) translateX(8px); }
.portal--all { --g1: #1D2C5C; --g2: #0A1124; }
@media (max-width: 1100px) { .portals { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .portals { grid-template-columns: repeat(2, minmax(0, 1fr)); } .portal { min-height: 128px; } }

/* ── Ranked shelf (Top 10 style) ─────────────────────────────── */
.shelf__track--ranked { grid-auto-columns: minmax(330px, 28%); }
.ranked { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; }
.ranked__n {
  font-family: var(--font-display); font-size: clamp(6rem, 11vw, 9.5rem); line-height: .78; margin-right: -26px; z-index: 0;
  color: transparent; -webkit-text-stroke: 3px var(--line); user-select: none; transition: -webkit-text-stroke-color .25s, color .25s;
}
.ranked .card { z-index: 1; }
.ranked:hover .ranked__n { -webkit-text-stroke-color: var(--volt); color: color-mix(in srgb, var(--volt) 12%, transparent); }
@media (max-width: 1100px) { .shelf__track--ranked { grid-auto-columns: minmax(300px, 42%); } }
@media (max-width: 720px) { .shelf__track--ranked { grid-auto-columns: 86%; } .ranked__n { margin-right: -18px; } }

/* Fade the edges of horizontal shelves */
.shelf__track { -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent); }

/* ── Cards: 3D tilt, glare, spinning neon ring, popped icon ──── */
.card {
  transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift, 0px));
  transition: transform .35s var(--ease-pop), border-color .2s, box-shadow .3s;
}
.card:hover, .card:focus-visible { --lift: -8px; transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(var(--lift)); }
.card.is-tilting { transition: transform .08s linear, border-color .2s, box-shadow .3s; }
.card::before { /* neon ring */
  content: ''; position: absolute; inset: 0; z-index: 4; border-radius: inherit; padding: 3px; pointer-events: none;
  background: conic-gradient(from var(--spin), var(--accent), var(--zap), var(--arc), var(--volt), var(--accent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  opacity: 0; transition: opacity .3s; animation: spin 3.2s linear infinite paused;
}
.card:hover::before, .card:focus-visible::before { opacity: 1; animation-play-state: running; }
.card::after { /* glare that follows the pointer */
  content: ''; position: absolute; inset: 0; z-index: 3; pointer-events: none; border-radius: inherit;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 0%), rgba(255, 255, 255, .14), transparent 45%);
  opacity: 0; transition: opacity .3s;
}
.card:hover::after { opacity: 1; }
@keyframes spin { to { --spin: 360deg; } }
.card__media::after { /* subtle bottom shade so the popped icon sits nicely */
  content: ''; position: absolute; inset: auto 0 0 0; height: 40%; z-index: 1;
  background: linear-gradient(transparent, color-mix(in srgb, var(--panel) 75%, transparent));
}
.card__icon { position: relative; z-index: 2; margin-top: -30px; border: 3px solid var(--panel); box-shadow: 0 8px 18px rgba(0, 0, 0, .35); transition: transform .35s var(--ease-pop); }
.card:hover .card__icon { transform: translateY(-4px) rotate(-6deg) scale(1.06); }
.card__body { align-items: start; padding-top: 10px; }
.card__title { padding-top: 4px; }

/* ── Game page: ambient glow from the art ───────────────────── */
.gp { position: relative; isolation: isolate; }
.gp__ambient {
  position: absolute; z-index: -1; left: 50%; top: -40px; width: 100vw; height: 820px; transform: translateX(-50%);
  pointer-events: none; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 35%, transparent); mask-image: linear-gradient(#000 35%, transparent);
}

.gp__title { font-size: clamp(1.9rem, 3.4vw, 2.7rem); text-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 55%, transparent); }
.gp__id img { box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 35%, transparent); border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.fact { background: color-mix(in srgb, var(--panel) 86%, transparent); }
.gp__side .panel, .gp__body .panel { background: color-mix(in srgb, var(--panel) 90%, transparent); }
.gallery button { box-shadow: 0 10px 24px rgba(0, 0, 0, .25); }

/* ── Leaderboard podium ─────────────────────────────────────── */
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 14px; max-width: 760px; margin: 18px auto 30px; }
.podium__spot { display: grid; justify-items: center; gap: 8px; text-align: center; min-width: 0; }
.podium__spot:nth-child(1) { order: 2; } .podium__spot:nth-child(2) { order: 1; } .podium__spot:nth-child(3) { order: 3; }
.podium__who { display: grid; justify-items: center; gap: 6px; text-decoration: none; min-width: 0; max-width: 100%; }
.podium__who b { font-size: 1.05rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium__who .avatar--lg { width: 82px; height: 82px; font-size: 2rem; border-radius: 26px; }
.podium__spot:nth-child(1) .avatar--lg { width: 104px; height: 104px; font-size: 2.6rem; box-shadow: 0 0 0 4px #FFD54A, 0 0 40px rgba(255, 213, 74, .6); }
.podium__spot:nth-child(2) .avatar--lg { box-shadow: 0 0 0 4px #CFD8E6, 0 0 30px rgba(207, 216, 230, .4); }
.podium__spot:nth-child(3) .avatar--lg { box-shadow: 0 0 0 4px #E39B5B, 0 0 30px rgba(227, 155, 91, .4); }
.podium__score { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.podium__block {
  width: 100%; display: grid; place-items: center; border-radius: 18px 18px 8px 8px; color: #1A1033;
  font-family: var(--font-display); font-size: 2.4rem;
}
.podium__spot:nth-child(1) .podium__block { height: 150px; background: linear-gradient(#FFE58A, #E8B21E); box-shadow: 0 8px 0 #A97F07, 0 20px 50px rgba(255, 213, 74, .35); }
.podium__spot:nth-child(2) .podium__block { height: 110px; background: linear-gradient(#EEF2F8, #AEB9CB); box-shadow: 0 8px 0 #7D879A; }
.podium__spot:nth-child(3) .podium__block { height: 82px; background: linear-gradient(#F3BE8C, #C77B3F); box-shadow: 0 8px 0 #8C4F22; }
.podium__crown { width: 34px; height: 34px; color: #FFD54A; filter: drop-shadow(0 0 10px rgba(255, 213, 74, .8)); animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-5px); } }
@media (max-width: 560px) { .podium__block { font-size: 1.8rem; } .podium__spot:nth-child(1) .podium__block { height: 120px; } .podium__spot:nth-child(2) .podium__block { height: 88px; } .podium__spot:nth-child(3) .podium__block { height: 64px; } }

/* ── Profile banner ─────────────────────────────────────────── */
.profile-banner {
  position: relative; isolation: isolate; overflow: hidden; margin-top: 30px; padding: 28px clamp(18px, 3vw, 32px);
  border-radius: var(--r-xl); border: 3px solid var(--line);
  background: radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--a1, var(--zap)) 45%, transparent), transparent 55%),
              radial-gradient(120% 140% at 100% 100%, color-mix(in srgb, var(--a2, var(--arc)) 35%, transparent), transparent 55%), var(--panel);
}
.profile-banner::before { content: ''; position: absolute; inset: 0; z-index: -1; opacity: .25; background-image: radial-gradient(rgba(255, 255, 255, .5) 1.2px, transparent 1.3px); background-size: 14px 14px; }
.profile-banner .profile-head { padding-top: 0; }
.profile-banner .avatar--lg { box-shadow: 0 0 0 4px var(--panel), 0 0 0 7px var(--volt), 0 14px 30px rgba(0, 0, 0, .35); }

/* ── Footer wordmark ────────────────────────────────────────── */
.footer { position: relative; overflow: hidden; background: color-mix(in srgb, var(--bg-2) 85%, transparent); }
.footer__mark {
  display: block; font-family: var(--font-display); font-size: clamp(3.6rem, 15vw, 13rem); line-height: 1; text-align: center;
  color: transparent; -webkit-text-stroke: 2px color-mix(in srgb, var(--ink) 16%, transparent); letter-spacing: .02em;
  margin: .1em 0 .12em; user-select: none; white-space: nowrap; pointer-events: none;
  background: linear-gradient(90deg, var(--zap), var(--volt), var(--arc)); -webkit-background-clip: text; background-clip: text;
  background-size: 0% 100%; background-repeat: no-repeat; transition: background-size 1.2s cubic-bezier(.2, .8, .2, 1);
}
.footer:hover .footer__mark { background-size: 100% 100%; }

/* ── Scrollbars ─────────────────────────────────────────────── */
html { scrollbar-color: var(--line) var(--bg); }
::-webkit-scrollbar { width: 12px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--zap); }

/* ── Reduced motion: keep it calm ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .atmos i, .card::before, .podium__crown { animation: none !important; }
  .card, .card:hover { transform: none !important; }
  .rail .bar { display: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; }
}

/* ── Player poster: dim the art, glass label, lift on hover ──── */
.player__poster img { filter: brightness(.62) saturate(1.15); transform: scale(1.02); transition: filter .4s, transform .6s cubic-bezier(.2, .8, .2, 1); }
.player__poster:hover img { filter: brightness(.78) saturate(1.2); transform: scale(1.05); }
.player__poster::before { background: radial-gradient(ellipse at center, rgba(4, 8, 22, .1), rgba(4, 8, 22, .7)); }
.player__go { padding: 22px 30px 20px; border-radius: 26px; background: rgba(8, 14, 34, .42); backdrop-filter: blur(10px) saturate(1.3); -webkit-backdrop-filter: blur(10px) saturate(1.3); border: 1px solid rgba(255, 255, 255, .12); }
.player__go strong { text-shadow: 0 3px 0 color-mix(in srgb, var(--accent) 70%, #000); }

/* ── Log in / sign up: tilted wall of game art behind a glass panel ── */
.auth-scene { position: relative; isolation: isolate; padding-bottom: 40px; }
.auth-wall {
  position: absolute; z-index: -1; left: 50%; top: -30px; width: min(1500px, 120vw); transform: translateX(-50%) rotate(-8deg);
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; opacity: .45; pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%); mask-image: radial-gradient(ellipse at center, #000 20%, transparent 70%);
}
.auth-wall img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 16px; border: 2px solid rgba(255, 255, 255, .08); }
.auth-wall img:nth-child(odd) { transform: translateY(26px); }
.auth.panel { background: color-mix(in srgb, var(--panel) 78%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); box-shadow: 0 30px 80px rgba(2, 5, 16, .5); }

/* Full-bleed decorations (art wall, glows) never cause sideways scrolling */
main { overflow-x: clip; }
