/* =====================================================================
   style.css — proxyz custom styles
   Bootstrap gives us the layout, grid, buttons, modals and dark mode.
   This file only adds the "proxyz look" on top:
     1. Theme colors and fonts (CSS variables)
     2. Navbar and footer
     3. Pages (views) and the hero on Home
     4. Reusable bits: tag, chip, stat box, panel box
     5. Game cards
     6. Animations (page transitions, glitch, reveal, tilt, skeletons)
     7. Card picture picker (in the Add/Edit form)
   ===================================================================== */


/* ---------- 1. THEME: colors + fonts ----------
   Change a value here and it updates everywhere that uses var(--name). */
:root {
  --px-bg: #0a0a0b;        /* page background (near black) */
  --px-panel: #141416;     /* card / box background */
  --px-line: #2a2a2e;      /* borders */
  --px-ink: #f2f2f3;       /* main text */
  --px-muted: #9c9ca3;     /* secondary text */
  --px-accent: #e5182b;    /* red: buttons, highlights */
  --px-accent-2: #ff5a66;  /* light red: tags, chips */
  --px-font-display: "Chakra Petch", "Segoe UI", sans-serif;
  --px-font-body: "Barlow", "Segoe UI", Roboto, sans-serif;

  /* Tell Bootstrap to use our colors/fonts for its own components */
  --bs-body-bg: var(--px-bg);
  --bs-body-color: var(--px-ink);
  --bs-body-font-family: var(--px-font-body);
  --bs-border-color: var(--px-line);
  --bs-secondary-color: var(--px-muted);
  --bs-link-color: var(--px-accent);
  --bs-link-hover-color: #ff4b5a;
}

body { font-size: 17px; line-height: 1.6; }

/* All headings use the display font */
h1, h2, h3, h4, h5, .navbar-brand {
  font-family: var(--px-font-display);
  letter-spacing: .01em;
  text-wrap: balance;
}

/* Visible keyboard focus (accessibility) */
:focus-visible { outline: 2px solid var(--px-accent); outline-offset: 3px; }

.text-accent { color: var(--px-accent) !important; }


/* ---------- Custom button colors ----------
   Bootstrap has .btn-primary etc. We add .btn-accent (filled red)
   and .btn-outline-accent (red border) by setting Bootstrap's
   button variables. */
.btn-accent {
  --bs-btn-bg: var(--px-accent);
  --bs-btn-border-color: var(--px-accent);
  --bs-btn-color: #ffffff;
  --bs-btn-hover-bg: #ff2e40;
  --bs-btn-hover-border-color: #ff2e40;
  --bs-btn-hover-color: #ffffff;
  --bs-btn-active-bg: #b80f1f;
  --bs-btn-active-border-color: #b80f1f;
  --bs-btn-disabled-bg: var(--px-accent);
  --bs-btn-disabled-border-color: var(--px-accent);
  font-family: var(--px-font-display);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.btn-outline-accent {
  --bs-btn-color: var(--px-accent);
  --bs-btn-border-color: var(--px-accent);
  --bs-btn-hover-bg: var(--px-accent);
  --bs-btn-hover-color: #ffffff;
  --bs-btn-hover-border-color: var(--px-accent);
  font-family: var(--px-font-display);
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
}


/* ---------- 2. NAVBAR + FOOTER ---------- */
.site-nav {
  background: rgba(10, 10, 11, .92);
  backdrop-filter: blur(8px);           /* frosted-glass effect when scrolling */
  border-bottom: 1px solid var(--px-line);
}
.logo { font-weight: 700; font-size: 22px; color: var(--px-ink); }
.logo span { color: var(--px-accent); }  /* the red "z" */

.site-nav .nav-link {
  font-family: var(--px-font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--px-muted);
  border-radius: 6px;
  padding: 8px 14px !important;
}
.site-nav .nav-link:hover { color: var(--px-ink); }
/* The current page's link (app.js adds .active) gets a red pill */
.site-nav .nav-link.active { background: var(--px-accent); color: #ffffff; }

.site-footer {
  border-top: 1px solid var(--px-line);
  padding: 24px 0 40px;
  color: var(--px-muted);
  font-size: 14px;
}


/* ---------- 3. PAGES (views) + HERO ---------- */
/* Every page is hidden by default; app.js adds .active to show one */
.view { display: none; }
.view.active { display: block; }

.hero { position: relative; padding: 72px 0 56px; overflow: hidden; }
/* The canvas fills the hero behind the text */
.hero canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  opacity: .5; pointer-events: none;
}
.hero-title {
  font-size: clamp(56px, 12vw, 124px);  /* grows with screen width, between 56px and 124px */
  line-height: .95;
  font-weight: 700;
  margin: 18px 0 12px;
}
.hero-title span { color: var(--px-accent); }
.hero-lead { max-width: 52ch; color: var(--px-muted); font-size: 19px; margin-bottom: 28px; }

.page-title { font-size: clamp(34px, 6vw, 52px); font-weight: 700; }


/* ---------- 4. REUSABLE BITS ---------- */
/* Small outlined label, e.g. "Player online", "Library · 4 games" */
.tag {
  display: inline-block;
  font-family: var(--px-font-display);
  font-size: 13px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--px-accent-2);
  border: 1px solid var(--px-accent-2);
  padding: 4px 10px;
  border-radius: 4px;
}

/* Rounded pill, e.g. "MMORPG" under the biography */
.chip {
  font-size: 14px; font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(229, 24, 43, .12);
  color: var(--px-accent-2);
  border: 1px solid rgba(229, 24, 43, .35);
}

/* Number boxes on Home */
.stat-box, .panel-box {
  background: var(--px-panel);
  border: 1px solid var(--px-line);
  border-radius: 14px;
  padding: 20px 24px;
  height: 100%;
}
.stat-k { font-size: 13px; color: var(--px-muted); text-transform: uppercase; letter-spacing: .1em; }
.stat-v { font-family: var(--px-font-display); font-size: 26px; font-weight: 700; margin-top: 4px; }

/* Red "P" square on the profile card */
.badge-avatar {
  width: 96px; height: 96px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--px-accent), #6e0a14);
  display: grid; place-items: center;
  font-family: var(--px-font-display);
  font-weight: 700; font-size: 40px;
  color: var(--px-bg);
}

/* Label/value list on the profile card (Location, Main genre...) */
.player-info { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 15px; }
.player-info dt { color: var(--px-muted); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; padding-top: 3px; }
.player-info dd { margin: 0; font-weight: 500; }

.panel-box p { max-width: 65ch; }


/* ---------- 5. GAME CARDS ----------
   Each card sets its own --c (card color) from the database, in app.js.
   --rx / --ry = tilt angles and --mx / --my = light spot position,
   set by addTilt() in app.js while the mouse moves over the card. */
.game-card {
  --rx: 0deg; --ry: 0deg; --lift: 0px;
  background: var(--px-panel);
  border: 1px solid var(--px-line);
  border-radius: 14px;
  overflow: hidden;
  height: 100%;
  transform: perspective(900px) rotateX(var(--rx)) rotateY(var(--ry)) translateY(var(--lift));
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
  will-change: transform;
}
.game-card:hover {
  --lift: -6px;
  border-color: var(--c);
  /* colored glow under the card in its own color */
  box-shadow: 0 18px 40px -18px var(--c), 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent);
}
/* Light spot that follows the mouse (only visible on hover) */
.game-card::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 0%), rgba(255,255,255,.09), transparent 60%);
  opacity: 0;
  transition: opacity .25s ease;
}
.game-card:hover::after { opacity: 1; }

/* Top picture area of the card */
.game-art { height: 150px; position: relative; background: var(--c); overflow: hidden; }
.game-art canvas { position: absolute; inset: 0; width: 100%; height: 100%; }

/* Uploaded picture: covers the pattern, fades in when loaded, zooms on hover */
.game-img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;               /* fill the box, crop the edges if needed */
  opacity: 0;
  transform: scale(1.02);
  transition: opacity .5s ease, transform .6s ease;
}
.game-img.loaded { opacity: 1; }
.game-card:hover .game-img { transform: scale(1.08); }
/* Dark gradient at the bottom so the genre label is readable on any picture */
.game-art::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,.55), transparent 55%);
  pointer-events: none;
}
.game-art .num, .game-art .genre {
  z-index: 1;                      /* above the picture and the gradient */
  position: absolute; left: 14px;
  font-size: 12px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  padding: 3px 9px; border-radius: 4px;
}
.game-art .num { top: 12px; font-family: var(--px-font-display); }
.game-art .genre { bottom: 12px; }

.game-card .card-title { font-size: 21px; }
.game-card .card-text { color: var(--px-muted); font-size: 15px; }
.game-meta {
  font-size: 13px; color: var(--px-muted);
  border-top: 1px solid var(--px-line);
  padding-top: 10px;
}
.game-meta b { color: var(--px-ink); font-weight: 600; }

/* Message shown when the library is empty */
.empty-box {
  text-align: center; color: var(--px-muted);
  padding: 48px 0;
  border: 1px dashed var(--px-line);
  border-radius: 14px;
}


/* ---------- 6. ANIMATIONS ---------- */

/* Moving colored glow behind the whole site (the <div class="bg-fx"> in index.html) */
.bg-fx {
  position: fixed; inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(40% 35% at 20% 25%, rgba(229,24,43,.12), transparent 70%),
    radial-gradient(35% 30% at 80% 70%, rgba(140,10,22,.14), transparent 70%);
  animation: bgDrift 24s ease-in-out infinite alternate;
}
@keyframes bgDrift {
  from { transform: translate(0, 0) rotate(0deg); }
  to   { transform: translate(4%, -3%) rotate(6deg); }
}

/* Page switch: the new page fades + slides up a little.
   (An animation restarts every time .view goes from hidden to shown.) */
.view.active { animation: viewIn .45s cubic-bezier(.2,.7,.2,1); }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Navbar links: smooth color change + a thin red line growing on hover */
.site-nav .nav-link { position: relative; transition: color .2s ease, background-color .25s ease; }
.site-nav .nav-link:not(.active)::after {
  content: "";
  position: absolute; left: 14px; right: 14px; bottom: 4px;
  height: 2px; background: var(--px-accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform .25s ease;
}
.site-nav .nav-link:not(.active):hover::after { transform: scaleX(1); }

/* Buttons: lift + glow on hover */
.btn-accent, .btn-outline-accent { transition: transform .15s ease, box-shadow .2s ease, background-color .2s ease; }
.btn-accent:hover, .btn-outline-accent:hover { transform: translateY(-2px); box-shadow: 0 8px 26px -8px rgba(229,24,43,.8); }
.btn-accent:active, .btn-outline-accent:active { transform: translateY(0); }

/* "Player online" tag: blinking red "LIVE" dot in front */
.tag-live::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #ff2e40;
  box-shadow: 0 0 0 0 rgba(255,46,64,.7);
  vertical-align: 1px;
  animation: livePulse 1.8s ease-out infinite;
}
@keyframes livePulse {
  0%   { box-shadow: 0 0 0 0 rgba(255,46,64,.7); }
  100% { box-shadow: 0 0 0 9px rgba(255,46,64,0); }
}

/* Hero title: short "glitch" (RGB split + slices) every ~5 seconds.
   ::before (bright red) and ::after (dark red) are copies of the text from data-text. */
.glitch { position: relative; }
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute; inset: 0;
  opacity: 0;
  pointer-events: none;
}
.glitch::before { color: #ff3b4b; animation: glitchA 5s infinite steps(1); }
.glitch::after  { color: #7a0a15;   animation: glitchB 5s infinite steps(1); }
@keyframes glitchA {
  0%, 89%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
  90% { opacity: .8; transform: translate(-4px, 1px); clip-path: inset(10% 0 55% 0); }
  92% { opacity: .8; transform: translate(3px, -2px); clip-path: inset(60% 0 8% 0); }
  94% { opacity: .8; transform: translate(-2px, 0);  clip-path: inset(35% 0 35% 0); }
  96% { opacity: 0; }
}
@keyframes glitchB {
  0%, 90%, 100% { opacity: 0; transform: none; clip-path: inset(0 0 0 0); }
  91% { opacity: .8; transform: translate(4px, -1px); clip-path: inset(50% 0 20% 0); }
  93% { opacity: .8; transform: translate(-3px, 2px); clip-path: inset(5% 0 70% 0); }
  95% { opacity: 0; }
}

/* Hero text slides in one line after another when Home opens */
.view.active .hero .tag,
.view.active .hero-title,
.view.active .hero-lead,
.view.active .hero .d-flex { animation: riseIn .6s cubic-bezier(.2,.7,.2,1) backwards; }
.view.active .hero-title { animation-delay: .08s; }
.view.active .hero-lead  { animation-delay: .16s; }
.view.active .hero .d-flex { animation-delay: .24s; }
@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: none; }
}

/* Reveal on scroll (app.js adds .in). Hidden only when JS runs (.js on <html>),
   so without JavaScript nothing stays invisible. */
.js .reveal { opacity: 0; transform: translateY(22px); }
.js .reveal.in {
  opacity: 1; transform: none;
  transition: opacity .6s ease, transform .6s cubic-bezier(.2,.7,.2,1);
  transition-delay: calc(var(--i, 0) * 90ms);
}

/* Stat boxes and panels: glow a little on hover */
.stat-box, .panel-box { transition: border-color .25s ease, box-shadow .25s ease, transform .25s ease; }
.stat-box:hover { border-color: rgba(229,24,43,.55); transform: translateY(-3px); box-shadow: 0 12px 30px -16px var(--px-accent); }
.panel-box:hover { border-color: rgba(229,24,43,.35); }

/* Profile avatar: slow shine sweeping across */
.badge-avatar { position: relative; overflow: hidden; }
.badge-avatar::after {
  content: "";
  position: absolute; inset: -50%;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,.35) 50%, transparent 60%);
  animation: shine 4s ease-in-out infinite;
}
@keyframes shine {
  0%, 60% { transform: translateX(-60%); }
  100%    { transform: translateX(60%); }
}

/* Game cards pop in one after another (--i = card number, set in app.js).
   "backwards" = only the start state is held before playing, so the
   hover tilt still works after the animation ends. */
#grid > .col { animation: cardIn .5s cubic-bezier(.2,.7,.2,1) backwards; animation-delay: calc(var(--i, 0) * 70ms); }
@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

/* Loading placeholders with a moving shine (renderSkeletons in app.js) */
.skeleton { padding-bottom: 18px; }
.skeleton .sk-art { height: 150px; }
.skeleton .sk-line { height: 14px; margin: 16px 20px 0; border-radius: 6px; }
.skeleton .sk-line.short { width: 55%; }
.skeleton .sk-art, .skeleton .sk-line {
  background: linear-gradient(90deg, #1a1a1d 0%, #26262a 40%, #1a1a1d 80%);
  background-size: 300% 100%;
  animation: skShimmer 1.3s linear infinite;
}
@keyframes skShimmer {
  from { background-position: 100% 0; }
  to   { background-position: 0 0; }
}

/* Pop-up windows: grow in slightly instead of only sliding */
.modal.fade .modal-dialog { transform: scale(.94) translateY(10px); transition: transform .25s cubic-bezier(.2,.7,.2,1); }
.modal.show .modal-dialog { transform: none; }
.modal-content { background: var(--px-panel); border: 1px solid var(--px-line); border-radius: 14px; }


/* ---------- 7. CARD PICTURE PICKER ---------- */
.pic-picker { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; }
.pic-preview {
  width: 220px; height: 120px;     /* same shape as the card art, smaller */
  flex: none;
  border: 1px dashed var(--px-line);
  border-radius: 10px;
  overflow: hidden;
  display: grid; place-items: center;
  text-align: center;
  font-size: 13px; color: var(--px-muted);
  padding: 0;
  background: #111113;
  transition: opacity .2s ease;
}
.pic-preview span { padding: 0 12px; }
.pic-preview img { width: 100%; height: 100%; object-fit: cover; animation: viewIn .35s ease; }
.pic-preview.busy { opacity: .5; }   /* while the picture is being resized */


/* Less motion for people who ask for it in their system settings:
   switch off every animation and movement above. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .game-card, .game-card:hover { transform: none; }
  .js .reveal { opacity: 1; transform: none; }
  .glitch::before, .glitch::after { display: none; }
}
