/* The games hub on /games/ (assets/hub.js): the End City behind the heading, and the HUD you see
   while walking it. Without WebGL it's the still scene and the heading, and the game list below. */

.hub {
  --hub-r: 28px;
  position: relative; isolation: isolate; overflow: hidden;
  width: min(1280px, calc(100% - 24px)); height: clamp(520px, 82vh, 860px); margin: 18px auto 8px;
  border-radius: var(--hub-r); border: 1px solid var(--line);
  background: #0b0614 url('/assets/brand/scene-games.webp') center / cover no-repeat;
  box-shadow: 0 40px 120px -40px rgba(124, 77, 255, .45);
}
.hub-stage { position: absolute; inset: 0; z-index: 0; }
.hub-gl { display: block; width: 100%; height: 100%; opacity: 0; transition: opacity 900ms var(--ease-out); touch-action: none; }
.hub-ready .hub-gl { opacity: 1; }

/* The heading, over a scrim so it reads against the city. */
.hub-intro {
  position: absolute; z-index: 2; left: 0; right: 0; bottom: 0;
  padding: 120px clamp(20px, 5vw, 64px) clamp(28px, 5vw, 56px);
  background: linear-gradient(to top, rgba(13, 7, 21, .94) 0%, rgba(13, 7, 21, .72) 45%, rgba(13, 7, 21, 0) 100%);
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
}
.hub-intro h1 { font-family: var(--display); font-size: clamp(34px, 5.4vw, 64px); line-height: 1.03; margin: 0 0 14px; max-width: 13ch; text-wrap: balance; }
.hub-intro .cmp-lede { margin: 0 0 22px; max-width: 600px; text-align: left; }
.hub-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hub-actions .btn { padding: 13px 22px; font-size: 15px; }
.hub-actions .ic { width: 18px; height: 18px; }
.hub-hint { margin: 14px 0 0; font-size: 13px; color: var(--dimmer); }
.hub:not(.hub-ready) .hub-hint { visibility: hidden; }

/* Walking: the city takes the whole window. */
html.hub-lock, html.hub-lock body { overflow: hidden; }
.hub.hub-live { position: fixed; inset: 0; width: auto; height: auto; margin: 0; border: 0; border-radius: 0; z-index: 100; box-shadow: none; }
.hub.hub-live .hub-intro { opacity: 0; transform: translateY(12px); pointer-events: none; }

.hub-hud { position: absolute; inset: 0; z-index: 3; pointer-events: none; font-family: var(--sans); color: var(--text); }
.hub-hud > * { pointer-events: auto; }
.hub-hud[hidden] { display: none; }
.hub-leave { position: absolute; top: 16px; left: 16px; backdrop-filter: blur(10px); }
.hub-leave .ic { width: 16px; height: 16px; }
.hub-keys {
  position: absolute; left: 16px; bottom: 16px; margin: 0; pointer-events: none;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; color: var(--dim);
}
.hub-keys kbd {
  font-family: var(--mono); font-size: 11px; color: var(--text); min-width: 22px; text-align: center;
  padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px;
  background: color-mix(in srgb, var(--panel) 80%, transparent);
}
.hub-keys kbd + kbd { margin-left: -2px; }

/* The card for the portal you're standing at. */
.hub-prompt {
  --c: var(--accent);
  position: absolute; left: 50%; bottom: 28px; translate: -50% 0;
  display: grid; gap: 3px; min-width: min(360px, calc(100vw - 32px)); padding: 14px 18px 14px 20px;
  border-radius: 16px; border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line));
  background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: blur(14px);
  box-shadow: 0 18px 50px -18px color-mix(in srgb, var(--c) 70%, transparent), inset 3px 0 0 var(--c);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(8px) scale(.98); }
}
.hub-prompt[hidden] { display: none; }
.hub-prompt b { font-family: var(--display); font-size: 18px; color: var(--c); }
.hub-prompt span { font-size: 14px; color: var(--text); }
.hub-prompt small { font-size: 12px; color: var(--dimmer); }
.hub-prompt a { color: var(--dim); }

.hub-pause {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  background: rgba(13, 7, 21, .62); backdrop-filter: blur(6px);
  transition: opacity 180ms var(--ease-out);
  @starting-style { opacity: 0; }
}
.hub-pause[hidden] { display: none; }
.hub-pause h2 { font-family: var(--display); font-size: 30px; margin: 0 0 6px; }
.hub-pause .btn { min-width: 220px; }

/* Touch: the stick appears under your left thumb; the jump button sits bottom right. */
.hub-stick {
  position: fixed; width: 110px; height: 110px; margin: -55px 0 0 -55px; border-radius: 50%; pointer-events: none;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, transparent); background: rgba(23, 16, 42, .35);
}
.hub-stick[hidden] { display: none; }
.hub-stick span { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 70%, transparent); }
.hub-jump {
  display: none; position: absolute; right: 22px; bottom: 26px; width: 68px; height: 68px; border-radius: 50%;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 70%, transparent); color: var(--text);
  transition: transform 120ms var(--ease-out);
}
.hub-jump:active { transform: scale(.94); }
.hub-jump .ic { width: 28px; height: 28px; }
@media (pointer: coarse) {
  .hub-jump { display: grid; place-items: center; }
  .hub-keys { display: none; }
  .hub-prompt { bottom: 112px; }
  .hub-chat-btn { display: grid; place-items: center; }
  .hub-chat { bottom: 112px; width: min(440px, calc(100% - 120px)); }
  .hub-card { top: 120px; }
}

/* Who else is here, top right. */
.hub-online {
  position: absolute; top: 16px; right: 16px; margin: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 700; color: var(--text);
  border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 72%, transparent); backdrop-filter: blur(10px);
}
.hub-online[hidden] { display: none; }
.hub-dot { width: 8px; height: 8px; border-radius: 50%; background: #5AD6A4; box-shadow: 0 0 0 0 rgba(90, 214, 164, .6); animation: hub-ping 2.4s var(--ease-out) infinite; }
.hub-online.off .hub-dot { background: var(--dimmer); animation: none; }
@keyframes hub-ping { 0% { box-shadow: 0 0 0 0 rgba(90, 214, 164, .55); } 70%, 100% { box-shadow: 0 0 0 8px rgba(90, 214, 164, 0); } }

/* Chat, bottom left: the last lines fade after a while unless the box is open. */
.hub-chat { position: absolute; left: 16px; bottom: 48px; width: min(440px, calc(100% - 32px)); pointer-events: none; display: grid; gap: 8px; }
.hub-chat[hidden] { display: none; }
.hub-log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; align-content: end; max-height: 40vh; overflow: hidden; }
.hub-log li {
  justify-self: start; max-width: 100%; padding: 5px 10px; border-radius: 10px; font-size: 14px; line-height: 1.35; overflow-wrap: anywhere;
  background: rgba(13, 7, 21, .62); backdrop-filter: blur(6px); color: var(--text);
  transition: opacity 600ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(4px); }
}
.hub-log li.old { opacity: 0; }
.hub-chat.open .hub-log li.old { opacity: 1; }
.hub-chat.open .hub-log { overflow-y: auto; pointer-events: auto; }
.hub-log b { color: var(--accent-2, #C9B2FF); font-weight: 700; margin-right: 6px; }
.hub-log button.who { all: unset; cursor: pointer; color: var(--accent-2, #C9B2FF); font-weight: 700; margin-right: 6px; pointer-events: auto; }
.hub-log button.who:hover { text-decoration: underline; }
.hub-log li.me b, .hub-log li.me .who { color: #5AD6A4; }
.hub-log li.note { color: var(--dim); font-style: italic; }
.hub-say { display: flex; gap: 8px; pointer-events: auto; }
.hub-say[hidden] { display: none; }
.hub-say input {
  flex: 1; min-width: 0; padding: 10px 14px; border-radius: 12px; font: inherit; font-size: 14px; color: var(--text);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); background: rgba(13, 7, 21, .8); outline: none;
}
.hub-say input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.hub-why { margin: 0; justify-self: start; padding: 8px 12px; border-radius: 10px; font-size: 13px; color: var(--dim); background: rgba(13, 7, 21, .7); pointer-events: auto; }
.hub-why[hidden] { display: none; }
.hub-why a { color: var(--accent-2, #C9B2FF); }
.hub-chat-btn {
  display: none; position: absolute; top: 64px; right: 16px; width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 70%, transparent); color: var(--text);
}
.hub-chat-btn .ic { width: 20px; height: 20px; }

/* A player's card: who they are and what they're wearing. */
.hub-card {
  position: absolute; top: 64px; right: 16px; width: min(320px, calc(100% - 32px)); padding: 18px; border-radius: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
  background: color-mix(in srgb, var(--panel) 88%, transparent); backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -24px rgba(124, 77, 255, .6);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  @starting-style { opacity: 0; transform: translateY(-6px) scale(.98); }
}
.hub-card[hidden] { display: none; }
.hub-card header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.hub-card .head { width: 48px; height: 48px; border-radius: 10px; image-rendering: pixelated; background: #1a1030; flex: none; }
.hub-card h3 { margin: 0; font-family: var(--display); font-size: 20px; overflow-wrap: anywhere; }
.hub-card .sub { margin: 2px 0 0; font-size: 12px; color: var(--dimmer); }
.hub-card .x { all: unset; cursor: pointer; margin-left: auto; align-self: start; padding: 4px 8px; border-radius: 8px; color: var(--dim); font-size: 18px; line-height: 1; }
.hub-card .x:hover, .hub-card .x:focus-visible { background: rgba(255, 255, 255, .08); color: var(--text); }
.hub-card ul { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 8px; }
.hub-card li { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.hub-card li .tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--dimmer); min-width: 64px; }
.hub-card li img { width: 40px; height: 40px; object-fit: contain; }
.hub-card li .cape { width: 30px; height: 48px; image-rendering: pixelated; object-fit: none; object-position: -2px -2px; }
.hub-card .gold { color: #FFC46B; font-weight: 700; }
.hub-card .none { color: var(--dimmer); font-size: 13px; }
.hub-card .btn { width: 100%; justify-content: center; }

/* Through a portal: the screen fills with its colour, then the game loads. */
.hub-flash {
  --flash: var(--accent);
  position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0;
  background: radial-gradient(circle at 50% 55%, #fff 0%, var(--flash) 35%, #0D0715 100%);
  transition: opacity 320ms var(--ease-out);
}
.hub-flash.on { opacity: 1; transition: opacity 380ms var(--ease-in-out); }

/* F5: which view you're in now, for a moment. */
.hub-view {
  position: absolute; left: 50%; top: 18px; translate: -50% 0; margin: 0; padding: 6px 14px; pointer-events: none;
  border-radius: 999px; border: 1px solid var(--line); background: color-mix(in srgb, var(--panel) 80%, transparent);
  font-size: 13px; font-weight: 700; color: var(--text); backdrop-filter: blur(10px);
}
.hub-view[hidden] { display: none; }

/* A game, open over the city (assets/hub-play.js): the city's last frame behind, dimmed, and the
   game in a card in the portal's colour. The colour flash covers it opening and closing. */
.hub.hub-gaming .hub-hud { display: none; }
.hub-play {
  --c: var(--accent);
  position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 16%, rgba(13, 7, 21, .5)) 0%, rgba(13, 7, 21, .82) 75%);
  backdrop-filter: blur(5px);
}
.hub-play-card {
  --c-accent: var(--c);
  width: min(1040px, 100%, calc((100dvh - 150px) * 1.6667 + 34px)); max-height: 100%; overflow: auto;
  border-radius: 20px; border: 1px solid color-mix(in srgb, var(--c) 38%, var(--line));
  background: rgba(20, 10, 32, .94); color: #F2E8FF; font-family: 'Manrope', system-ui, sans-serif;
  box-shadow: 0 30px 90px -30px color-mix(in srgb, var(--c) 60%, transparent), 0 20px 60px rgba(0, 0, 0, .55);
}
.hub-play-card.duel { width: min(720px, 100%); }
.hub-play-top { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.hub-play-chip { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--c); color: #140a20; }
.hub-play-name { display: grid; min-width: 0; }
.hub-play-name b { font-family: 'Sora', sans-serif; font-size: 16px; }
.hub-play-name small { font-size: 12px; color: #A995C4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hub-play-back {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; flex: none; cursor: pointer;
  border: 0; border-radius: 10px; padding: 8px 12px; background: rgba(255, 255, 255, .07); color: #fff; font: inherit; font-size: 13px; font-weight: 700;
  transition: background-color 150ms ease, transform 120ms var(--ease-out);
}
.hub-play-back:hover { background: rgba(255, 255, 255, .12); }
.hub-play-back:active { transform: scale(.97); }
.hub-play-back kbd { font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .2); color: #CDBBE8; }
.hub-play-body { padding: 16px; }
.hub-play-body .hub-arena { min-height: 300px; padding: 0; border: 0; border-radius: 0; background: none; box-shadow: none; }
.hub-board { width: min(420px, 100%); margin: 4px 0 0; text-align: left; }
@media (max-width: 700px) {
  .hub-play { padding: 8px; }
  .hub-play-back kbd { display: none; }
}

@media (max-width: 700px) {
  .hub { width: calc(100% - 16px); height: clamp(520px, 86svh, 760px); --hub-r: 22px; margin-top: 12px; }
  .hub-intro { padding-top: 140px; background: linear-gradient(to top, rgba(13, 7, 21, .97) 0%, rgba(13, 7, 21, .9) 62%, rgba(13, 7, 21, 0) 100%); }
  .hub-hint { display: none; }
  .hub-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .hub-gl, .hub-intro, .hub-prompt, .hub-log li, .hub-card, .hub-flash, .hub-flash.on { transition-duration: 1ms; }
  .hub-dot { animation: none; }
}
