/* ============================================================
   /games — the hub.

   One cover per world, drawn in that world's colours and lettered in its
   face. The page is the site's own chrome (style-test.css) plus this file;
   both themes come from the covers carrying two palettes and the light
   theme swapping which one is live.
   ============================================================ */

:root{
  --hub-radius: 18px;
  --hub-line: var(--line);
  --hub-glow: rgba(216,177,90,.14);
}

body.hub{ overflow-x: hidden; }

/* ---------- top bar ---------- */
.hubTop{ display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 6px; }
.hubTopRight{ display: flex; align-items: center; gap: 10px; }
.hubSearch{ position: relative; display: flex; align-items: center; gap: 8px; }
.hubSearch input{
  width: min(260px, 46vw);
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--card) 80%, transparent);
  color: var(--text);
  font: 600 14px/1 var(--font-ui);
  outline: none;
}
.hubSearch input:focus{ border-color: var(--gold); box-shadow: 0 0 0 3px rgba(216,177,90,.18); }
.countPill{
  min-width: 34px; height: 30px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--muted);
  font: 800 13px/1 var(--font-ui);
}

/* ---------- hero ---------- */
.hubHero{
  position: relative;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 24px;
  align-items: center;
  margin: 10px 0 18px;
  padding: 26px 26px 24px;
  border-radius: 24px;
  border: 1px solid var(--line);
  background:
    radial-gradient(70% 80% at 85% 20%, rgba(216,177,90,.16), transparent 60%),
    radial-gradient(50% 60% at 10% 90%, rgba(74,160,255,.14), transparent 60%),
    var(--card);
  overflow: hidden;
}
.hubKicker{ font: 800 12px/1 var(--font-ui); letter-spacing: .22em; text-transform: uppercase; color: var(--gold); }
.hubTitle{ margin: 10px 0 8px; font: 900 clamp(30px, 5.2vw, 52px)/1.02 var(--font-ui); letter-spacing: -.01em; }
.hubTitle span{ display: block; color: var(--muted); font-weight: 700; font-size: .6em; margin-top: 6px; letter-spacing: 0; }
.hubSub{ margin: 0 0 16px; color: var(--muted); font-size: 16px; max-width: 46ch; }
.hubCtas{ display: flex; gap: 10px; flex-wrap: wrap; }
.btnPrimary, .btnGhost{
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px;
  font: 800 14px/1 var(--font-ui);
  text-decoration: none;
  border: 1px solid var(--line);
  transition: transform .12s ease, box-shadow .2s ease, filter .2s;
}
.btnPrimary{
  color: #1a1200;
  background: linear-gradient(180deg, #ffe08a, #d9a441 60%, #c08f2e);
  border-color: #7a5514;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 10px 26px rgba(0,0,0,.25);
}
.btnGhost{ color: var(--text); background: color-mix(in srgb, var(--card) 70%, transparent); }
.btnPrimary:hover, .btnGhost:hover{ transform: translateY(-2px); filter: brightness(1.05); }

.hubHeroArt{ position: relative; min-height: 220px; }
.heroStack{ position: relative; height: 240px; }
.heroCard{
  position: absolute; left: 50%; top: 50%;
  width: min(300px, 78%); aspect-ratio: 16 / 10;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: radial-gradient(80% 60% at 50% 0%, color-mix(in srgb, var(--c1) 22%, transparent), transparent 70%), linear-gradient(180deg, var(--b1), var(--b0));
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  overflow: hidden;
  transform-origin: 50% 50%;
  animation: heroFloat 7s ease-in-out infinite;
}
.heroCard svg{ width: 100%; height: 100%; display: block; }
.heroCard:nth-child(1){ transform: translate(-50%, -50%) rotate(-10deg) translateX(-120px) translateY(14px) scale(.92); animation-delay: -1s; z-index: 1; }
.heroCard:nth-child(2){ transform: translate(-50%, -50%) rotate(9deg) translateX(120px) translateY(-10px) scale(.92); animation-delay: -3s; z-index: 2; }
.heroCard:nth-child(3){ transform: translate(-50%, -50%) rotate(-2deg) translateY(4px); animation-delay: -5s; z-index: 3; }
@keyframes heroFloat{ 0%,100%{ margin-top: 0 } 50%{ margin-top: -8px } }

/* ---------- mode row ---------- */
.modeRow{ display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 18px; }
.modeCard{
  position: relative;
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 14px 12px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--card);
  text-decoration: none; color: var(--text);
  overflow: hidden;
  transition: transform .14s ease, box-shadow .2s ease;
}
.modeCard::before{ content: ""; position: absolute; left: 0; right: 0; top: 0; height: 5px; background: var(--mc); }
.modeCard.daily{ --mc: #4aa0ff; } .modeCard.quick{ --mc: #2ec88c; } .modeCard.skills{ --mc: #ff7a85; } .modeCard.brain{ --mc: #a07cff; }
.modeCard:hover{ transform: translateY(-3px); box-shadow: 0 14px 30px rgba(0,0,0,.25); }
.modeName{ font: 900 17px/1.1 var(--font-ui); }
.modeSub{ font-size: 12.5px; color: var(--muted); }

/* ---------- dock: jump between worlds ---------- */
.dock{ margin: 0 -16px 14px; padding: 0 16px; }
.dockTrack{
  display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x proximity;
  padding: 6px 2px 10px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.dockItem{
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--b1), var(--b0));
  color: var(--c3);
  font: 700 12px/1 var(--f);
  letter-spacing: .02em;
  text-decoration: none;
  scroll-snap-align: start;
  white-space: nowrap;
  transition: transform .12s ease, box-shadow .2s ease, opacity .2s;
}
.dockItem img{ width: 22px; height: 22px; border-radius: 50%; background: var(--c4); padding: 2px; }
.dockItem:hover, .dockItem.active{ transform: translateY(-2px); box-shadow: 0 0 0 2px var(--c1), 0 8px 18px rgba(0,0,0,.25); }
.dockItem.dim{ opacity: .35; }

/* ---------- filters ---------- */
.hubFilters{
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin: 0 -16px 14px; padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.chipRow{ display: flex; gap: 6px; flex-wrap: wrap; }
.chipRow + .chipRow{ padding-left: 10px; border-left: 1px solid var(--line); }
.chipBtn{
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card); color: var(--muted);
  font: 800 13px/1 var(--font-ui);
  cursor: pointer;
  transition: transform .1s ease, background .15s, color .15s;
}
.chipBtn:hover{ color: var(--text); }
.chipBtn[data-active]{ background: var(--text); color: var(--bg); border-color: var(--text); }
.chipBtn:active{ transform: scale(.96); }

/* ---------- grid + cards ---------- */
.hubGrid{ display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.gameTile{
  --tile-c: var(--c1);
  position: relative;
  display: flex; flex-direction: column;
  border-radius: var(--hub-radius);
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(0,0,0,.18);
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease, border-color .2s;
  animation: tileIn .55s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
@keyframes tileIn{ from{ opacity: 0; transform: translateY(14px) } to{ opacity: 1; transform: none } }
.gameTile:hover, .gameTile:focus-visible{
  transform: translateY(-6px);
  border-color: var(--c1);
  box-shadow: 0 22px 44px rgba(0,0,0,.3), 0 0 0 1px var(--c1), 0 0 30px color-mix(in srgb, var(--c1) 30%, transparent);
  outline: none;
}
.gameTile.hit{ box-shadow: 0 0 0 3px var(--c1); }

.cover{
  position: relative;
  aspect-ratio: 16 / 10;
  background:
    radial-gradient(80% 60% at 50% 0%, color-mix(in srgb, var(--c1) 22%, transparent), transparent 70%),
    linear-gradient(180deg, var(--b1), var(--b0));
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}
.coverArt{ width: 100%; height: 100%; display: block; transition: transform .5s cubic-bezier(.2,.8,.2,1); }
.gameTile:hover .coverArt{ transform: scale(1.06) rotate(-.6deg); }
.worldName{
  position: absolute; left: 10px; bottom: 10px;
  padding: 5px 10px 4px;
  border-radius: 999px;
  font: 700 11px/1 var(--f);
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--c2);
  background: color-mix(in srgb, var(--b0) 78%, transparent);
  border: 1px solid color-mix(in srgb, var(--c1) 45%, transparent);
  backdrop-filter: blur(4px);
}

.tileBody{ display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; }
.tileHead{ display: flex; align-items: center; gap: 8px; }
.tileLogo{ width: 22px; height: 22px; }
.tileName{ margin: 0; font: 900 17px/1.1 var(--font-ui); flex: 1 1 auto; }
.tileMode{ font: 800 10px/1 var(--font-ui); letter-spacing: .12em; text-transform: uppercase; padding: 5px 8px 4px; border-radius: 999px; color: #fff; }
.tileMode.daily{ background: #2f6fd6; } .tileMode.quick{ background: #1d9a67; } .tileMode.skills{ background: #c8404f; }
.tileDesc{ margin: 0; color: var(--muted); font-size: 13.5px; line-height: 1.4; min-height: 2.8em; }
.tileFoot{ display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.tag{ font: 700 11px/1 var(--font-ui); padding: 5px 9px 4px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.play{ font: 800 13px/1 var(--font-ui); color: var(--c1); transition: transform .15s; }
.gameTile:hover .play{ transform: translateX(3px); }
.hubEmpty{ text-align: center; color: var(--muted); padding: 30px 0; }

/* ---------- light theme ---------- */
/* Covers are posters and keep their night palette; only the page around them changes. */
:root[data-theme="light"] .gameTile{ box-shadow: 0 10px 26px rgba(24,42,74,.10); }
:root[data-theme="light"] .gameTile:hover{ box-shadow: 0 22px 44px rgba(24,42,74,.16), 0 0 0 1px var(--c1); }
:root[data-theme="light"] .heroCard{ border-color: rgba(24,42,74,.14); box-shadow: 0 24px 60px rgba(24,42,74,.18); }
:root[data-theme="light"] .worldName{ background: color-mix(in srgb, var(--b1) 82%, transparent); }
:root[data-theme="light"] .hubFilters{ background: color-mix(in srgb, var(--bg) 86%, transparent); }
:root[data-theme="light"] .btnPrimary{ box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 10px 26px rgba(24,42,74,.14); }
:root[data-theme="light"] .modeCard:hover{ box-shadow: 0 14px 30px rgba(24,42,74,.12); }

/* ---------- phones ---------- */
@media (max-width: 860px){
  .hubHero{ grid-template-columns: 1fr; padding: 20px 18px; }
  .hubHeroArt{ min-height: 200px; }
  .heroStack{ height: 200px; }
  .modeRow{ grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px){
  /* On a phone the top is one line and a button: people came to pick a
     game, and the cards should be visible without scrolling far. */
  .hubHero{ padding: 12px 14px 12px; margin: 4px 0 10px; gap: 8px; }
  .hubHeroArt{ display: none; }
  .hubKicker{ display: none; }
  .hubTitle{ font-size: 22px; margin: 0 0 8px; }
  .hubTitle span{ display: none; }
  .hubSub{ display: none; }
  .hubCtas{ gap: 8px; }
  .hubCtas .btnPrimary{ padding: 9px 14px; font-size: 14px; }
  .hubCtas .btnGhost{ display: none; }
  .modeRow{ grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px; }
  .modeCard{ padding: 8px 6px 7px; text-align: center; }
  .modeName{ font-size: 12px; line-height: 1.15; }
  .modeSub{ display: none; }
  .hubTop{ flex-wrap: wrap; }
  .hubSearch input{ width: min(220px, 56vw); }
  .hubGrid{ grid-template-columns: 1fr; gap: 14px; }
  .heroCard{ width: 70%; }
  .chipRow + .chipRow{ padding-left: 0; border-left: 0; }
}

@media (prefers-reduced-motion: reduce){
  .gameTile{ animation: none; }
  .heroCard{ animation: none; }
  .coverArt, .gameTile, .play{ transition: none; }
}

/* ---------- tilt + glare (gv-tilt.js) ---------- */
.gameTile.tilting{ transition: box-shadow .25s ease, border-color .2s; }
.cover::after{
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.16), transparent 60%);
  opacity: 0; transition: opacity .25s;
}
.gameTile:hover .cover::after{ opacity: 1; }

/* ---------- theme-aware covers ---------- */
/* gen-hub puts both palettes on each cover (the d set for night, the l set
   for day); the theme decides which one the c and b variables resolve to. */
[style*="--d1:"]{ --c1: var(--d1); --c2: var(--d2); --c3: var(--d3); --c4: var(--d4); --b0: var(--db0); --b1: var(--db1); }
:root[data-theme="light"] [style*="--d1:"]{ --c1: var(--l1); --c2: var(--l2); --c3: var(--l3); --c4: var(--l4); --b0: var(--lb0); --b1: var(--lb1); }
:root[data-theme="light"] .worldName{ color: var(--c1); border-color: color-mix(in srgb, var(--c1) 55%, transparent); }
:root[data-theme="light"] .cover{ box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c1) 18%, transparent); }
