/* ============================================
   GAME VIEW — full-screen playable portfolio
   Layered on top of the classic page; style.css
   still owns the .jm-* card styles reused in the log drawer.
   ============================================ */

:root {
  --hud-bg:     rgba(4, 8, 14, 0.72);
  --hud-border: rgba(0, 255, 163, 0.22);
  --hud-blur:   blur(14px);
}

body.mode-game {
  overflow: hidden;
  height: 100%;
}

body.mode-game #bg-canvas { display: none; }

#game-root[hidden],
#classic-root[hidden] { display: none; }

#game-root {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: #04060a;
  overflow: hidden;
  font-family: var(--font-mono);
}

#game-root #journey-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* Nothing but the canvas (and its own buttons) while the title screen is up. */
#game-root.is-intro .hud-top,
#game-root.is-intro .hud-rail,
#game-root.is-intro .hud-drawer,
#game-root.is-intro .hud-controls {
  display: none;
}

/* ── TOP BAR ─────────────────────────────────── */
.hud-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.1rem;
  background: linear-gradient(180deg, rgba(4,8,14,0.88), rgba(4,8,14,0));
  pointer-events: none;
  z-index: 3;
}

.hud-top > * { pointer-events: auto; }

.hud-logo {
  font-family: var(--font-display, var(--font-mono));
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--neon);
  letter-spacing: 1px;
  flex-shrink: 0;
}

.hud-zone {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.hud-zone-idx {
  font-size: 0.62rem;
  letter-spacing: 2px;
  color: rgba(136, 146, 164, 0.75);
}

.hud-zone-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--zone-accent, var(--neon));
  text-shadow: 0 0 14px rgba(0, 255, 163, 0.35);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.5s;
}

.hud-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.hud-stat {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--hud-bg);
  border: 1px solid rgba(136, 146, 164, 0.22);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  backdrop-filter: var(--hud-blur);
  white-space: nowrap;
}

.hud-stat b { color: var(--neon); font-weight: 700; }
.hud-stat.pop { animation: hudPop 0.45s ease; }

@keyframes hudPop {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(0,255,163,0.5); }
  40%  { transform: scale(1.18); box-shadow: 0 0 0 8px rgba(0,255,163,0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(0,255,163,0); }
}

.hud-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--hud-bg);
  border: 1px solid rgba(136, 146, 164, 0.28);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  backdrop-filter: var(--hud-blur);
  transition: color 0.2s, border-color 0.2s, transform 0.15s;
  white-space: nowrap;
}

.hud-btn:hover {
  color: var(--neon);
  border-color: var(--hud-border);
  transform: translateY(-1px);
}

.hud-btn-exit {
  color: var(--neon);
  border-color: var(--hud-border);
}

/* ── TIMELINE RAIL ───────────────────────────── */
.hud-rail {
  position: absolute;
  top: 3.4rem;
  left: 1.1rem;
  right: 1.1rem;
  height: 18px;
  z-index: 3;
  pointer-events: none;
}

.hud-rail-track {
  position: absolute;
  inset: 0 0 auto 0;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.hud-rail-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #00ffa3, #00d4ff);
  box-shadow: 0 0 12px rgba(0, 255, 163, 0.6);
  transition: width 0.12s linear;
}

.hud-rail-ticks { position: absolute; inset: 0; }

.hud-rail-tick {
  position: absolute;
  top: -2px;
  width: 2px;
  height: 9px;
  border-radius: 1px;
  background: rgba(136, 146, 164, 0.4);
  transform: translateX(-1px);
  transition: background 0.3s, box-shadow 0.3s;
}

.hud-rail-tick.reached {
  background: var(--neon);
  box-shadow: 0 0 8px rgba(0, 255, 163, 0.8);
}

.hud-rail-cap {
  position: absolute;
  top: 8px;
  font-size: 0.6rem;
  color: rgba(136, 146, 164, 0.6);
}

.hud-rail-cap.left  { left: 0; }
.hud-rail-cap.right { right: 0; }

/* ── LOG DRAWER ──────────────────────────────── */
.hud-drawer {
  position: absolute;
  top: 5.2rem;
  right: 0.9rem;
  bottom: 1rem;
  width: min(380px, 34vw);
  display: flex;
  flex-direction: column;
  z-index: 4;
  pointer-events: none;
}

.hud-drawer-handle {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--hud-bg);
  border: 1px solid rgba(136, 146, 164, 0.22);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  margin-bottom: 0.45rem;
  cursor: pointer;
  pointer-events: auto;
  backdrop-filter: var(--hud-blur);
}

.hud-drawer-handle:hover { color: var(--neon); }

.hdh-caret { transition: transform 0.25s; }
.hud-drawer.collapsed .hdh-caret { transform: rotate(-90deg); }

.hud-drawer-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.35rem;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 255, 163, 0.35) transparent;
}

.hud-drawer.collapsed { pointer-events: none; }
.hud-drawer.collapsed .hud-drawer-handle { pointer-events: auto; }
.hud-drawer.collapsed .hud-drawer-body { display: none; }

.hud-drawer-body::-webkit-scrollbar { width: 6px; }
.hud-drawer-body::-webkit-scrollbar-thumb {
  background: rgba(0, 255, 163, 0.3);
  border-radius: 3px;
}

/* Reuse the .jm-* cards from style.css, but stacked for the narrow drawer. */
.hud-drawer-body .jm-card {
  grid-template-columns: 1fr;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  background: rgba(8, 13, 22, 0.86);
  backdrop-filter: var(--hud-blur);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.hud-drawer-body .jm-desc { align-self: auto; font-size: 0.82rem; line-height: 1.6; }
.hud-drawer-body .jm-title { font-size: 1rem; }
.hud-drawer-body .jm-game-img { max-height: 130px; }
.hud-drawer-body .jm-collected-list { gap: 0.7rem; }

.hud-drawer-empty {
  background: rgba(8, 13, 22, 0.8);
  border: 1px dashed rgba(136, 146, 164, 0.28);
  border-radius: 12px;
  padding: 1rem;
  font-size: 0.78rem;
  line-height: 1.9;
  color: var(--text-muted);
  backdrop-filter: var(--hud-blur);
}

.hud-drawer-empty kbd {
  background: rgba(0, 255, 163, 0.1);
  border: 1px solid rgba(0, 255, 163, 0.3);
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  color: var(--neon);
  font-size: 0.72rem;
}

/* ── SKILL TOTEM CARD ────────────────────────── */
.jm-meter {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.jm-meter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.6rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.jm-meter-bar {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.jm-meter-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--mc, var(--neon));
  box-shadow: 0 0 10px var(--mc, var(--neon));
  width: 0;
  animation: meterFill 0.8s ease forwards;
}

@keyframes meterFill { to { width: var(--pct, 0%); } }

button.jm-link {
  cursor: pointer;
  font-weight: 600;
}

.hud-drawer-body .jm-card.jm-wip { border-style: dashed; }

.jm-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  border: 1px dashed rgba(136, 146, 164, 0.35);
  border-radius: 6px;
  padding: 0.3rem 0.7rem;
  letter-spacing: 0.4px;
}

.jm-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.jm-pills span {
  font-size: 0.72rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(136, 146, 164, 0.22);
  color: var(--text-muted);
}

/* ── TOASTS ──────────────────────────────────── */
.hud-toast-stack {
  position: absolute;
  left: 50%;
  bottom: 6.5rem;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  z-index: 5;
  pointer-events: none;
}

.hud-toast {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(8, 13, 22, 0.92);
  border: 1px solid var(--tc, var(--neon));
  border-left-width: 4px;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  box-shadow: 0 0 26px rgba(0, 0, 0, 0.5);
  backdrop-filter: var(--hud-blur);
  animation: toastIn 0.35s ease, toastOut 0.4s ease 3.1s forwards;
}

.hud-toast-icon { font-size: 1.15rem; }
.hud-toast-label {
  font-size: 0.6rem;
  letter-spacing: 2px;
  color: var(--tc, var(--neon));
  text-transform: uppercase;
}
.hud-toast-title { font-size: 0.85rem; color: var(--text); font-weight: 600; }

@keyframes toastIn  { from { opacity: 0; transform: translateY(14px); } }
@keyframes toastOut { to   { opacity: 0; transform: translateY(-10px); } }

/* ── TOUCH CONTROLS ──────────────────────────── */
.hud-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 1rem;
  display: none;
  justify-content: center;
  gap: 0.6rem;
  z-index: 4;
  padding: 0 1rem;
}

body.mode-game.touch .hud-controls { display: flex; }

/* ── PLAY INVITE (classic page) ──────────────── */
.play-invite {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 2rem;
  align-items: center;
  max-width: 820px;
  margin: 2.5rem auto 0;
  padding: 2rem;
  border: 1px solid rgba(0, 255, 163, 0.25);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(0, 255, 163, 0.06), rgba(0, 212, 255, 0.04));
}

.play-invite-art {
  position: relative;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.pi-gem {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #00ffa3, #00d4ff);
  transform: rotate(45deg);
  border-radius: 4px;
  box-shadow: 0 0 22px rgba(0, 255, 163, 0.55);
  animation: piBob 2.4s ease-in-out infinite;
}

.pi-gem:nth-child(2) { animation-delay: 0.35s; background: linear-gradient(135deg, #00d4ff, #a855f7); }
.pi-gem:nth-child(3) { animation-delay: 0.7s;  background: linear-gradient(135deg, #a855f7, #ff6b9d); }

@keyframes piBob {
  0%, 100% { transform: rotate(45deg) translateY(0); }
  50%      { transform: rotate(45deg) translateY(-12px); }
}

.play-invite-body h3 {
  font-size: 1.5rem;
  margin-bottom: 0.6rem;
  color: var(--text);
}

.play-invite-body p {
  color: var(--text-muted);
  line-height: 1.75;
  margin-bottom: 1rem;
}

.play-invite-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  list-style: none;
  margin-bottom: 1.4rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.play-invite-keys kbd {
  background: rgba(0, 255, 163, 0.1);
  border: 1px solid rgba(0, 255, 163, 0.3);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  color: var(--neon);
}

/* ── FLOATING PLAY BUTTON (classic page) ─────── */
.play-fab {
  position: fixed;
  right: 1.2rem;
  bottom: 1.2rem;
  z-index: 120;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: #04060a;
  background: linear-gradient(135deg, #00ffa3, #00d4ff);
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.2rem;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(0, 255, 163, 0.3);
  transition: transform 0.18s, box-shadow 0.18s;
}

.play-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 255, 163, 0.45);
}

.play-fab-icon { font-size: 0.9rem; }

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 900px) {
  .hud-drawer {
    top: auto;
    left: 0.6rem;
    right: 0.6rem;
    bottom: 5.6rem;
    width: auto;
    max-height: 46vh;
  }
  .hud-drawer-body { max-height: 40vh; }
  .hud-toast-stack { bottom: auto; top: 5.4rem; }
}

@media (max-width: 640px) {
  .hud-top { flex-wrap: wrap; gap: 0.5rem 0.7rem; padding: 0.6rem 0.7rem; }
  .hud-actions { width: 100%; margin-left: 0; justify-content: flex-start; flex-wrap: wrap; }
  .hud-rail { top: 5.6rem; }
  .hud-drawer { top: auto; bottom: 6.2rem; max-height: 40vh; }
  .hud-btn-exit { margin-left: auto; }
  .play-invite { grid-template-columns: 1fr; padding: 1.4rem; gap: 1rem; }
  .play-invite-art { height: 80px; }
  .play-fab-text { display: none; }
  .play-fab { padding: 0.85rem; }
}

@media (prefers-reduced-motion: reduce) {
  .pi-gem, .hud-toast, .jm-meter-fill { animation: none !important; }
  .jm-meter-fill { width: var(--pct, 0%); }
}
