/* client/hub/styles.css
 *
 * Playful but polished styling for the launcher hub. Friendly, rounded, and
 * colorful — but with consistent spacing, soft shadows, and a tidy layout so it
 * doesn't look amateur. Kept readable with comments for the boys to learn from.
 */

:root {
  /* Brand + accents. We start green (Paseo "Verde") and add lively accents. */
  --green: #10b981;
  --green-deep: #059669;
  --teal: #06b6d4;
  --indigo: #6366f1;

  /* Surfaces + text */
  --bg: #f3f5fb;
  --card: #ffffff;
  --text: #16233a;
  --muted: #6b7a90;
  --line: #e9edf5;

  --hero-gradient: linear-gradient(120deg, #10b981 0%, #06b6d4 50%, #6366f1 100%);
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(22, 35, 58, 0.08);
  --shadow-hover: 0 16px 40px rgba(22, 35, 58, 0.14);
  --font-head: "Poppins", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must always win over our display rules below. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* --- Header / hero ---------------------------------------------------------- */

.hub-header {
  position: relative;
  background: var(--hero-gradient);
  color: white;
  padding: 18px 20px 56px;
  border-radius: 0 0 28px 28px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Soft glow accents in the banner background. */
.hub-header::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(420px circle at 88% -10%, rgba(255, 255, 255, 0.25), transparent 60%),
    radial-gradient(360px circle at 5% 120%, rgba(255, 255, 255, 0.18), transparent 60%);
  pointer-events: none;
}

.hub-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1000px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-head);
  font-weight: 800;
}

.brand-mark {
  font-size: 1.6rem;
}

.brand-name {
  font-size: 1.25rem;
  letter-spacing: 0.2px;
}

.hero {
  position: relative;
  z-index: 1;
  max-width: 1000px;
  margin: 28px auto 0;
  text-align: center;
}

.hero-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(1.8rem, 5vw, 3rem);
  margin: 0 0 8px;
  letter-spacing: -0.5px;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.12);
}

.hero-sub {
  margin: 0;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  opacity: 0.92;
}

/* --- Auth corner ------------------------------------------------------------ */

.auth-corner-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.welcome-msg {
  font-weight: 700;
}

/* Small round avatar shown next to "Welcome <name>" (image or colored initial). */
.corner-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.welcome-link {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.welcome-link:hover {
  opacity: 0.85;
}

.inline-login {
  display: flex;
  gap: 6px;
  align-items: center;
}

.inline-login input {
  padding: 8px 11px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-size: 0.85rem;
  width: 132px;
  font-family: var(--font-body);
}

.inline-login input::placeholder {
  color: rgba(255, 255, 255, 0.8);
}

.inline-login input:focus {
  outline: none;
  border-color: white;
  background: rgba(255, 255, 255, 0.26);
}

/* Login error sits on its own line under the form so nothing jumps around. */
.login-error {
  flex-basis: 100%;
  color: #fff0f0;
  font-size: 0.8rem;
  text-align: right;
  font-weight: 700;
}

.login-error:empty {
  display: none;
}

/* --- Buttons ---------------------------------------------------------------- */

.btn {
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-block {
  width: 100%;
}

/* Solid white pill — used on the colored header. */
.btn-light {
  background: white;
  color: var(--green-deep);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.btn-light:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

/* Outlined pill that reads on the colored header. */
.btn-ghost {
  background: rgba(255, 255, 255, 0.14);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* Primary brand button (gradient) — used in the signup modal. */
.btn-green {
  background: var(--hero-gradient);
  color: white;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.35);
}

.btn-green:hover {
  box-shadow: 0 8px 22px rgba(16, 185, 129, 0.45);
}

/* On narrow screens the auth corner drops below the brand and centers. */
@media (max-width: 640px) {
  .inline-login input {
    width: 120px;
  }
  .auth-corner {
    width: 100%;
  }
  .auth-corner-group {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* --- Main layout ------------------------------------------------------------ */

.hub-main {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 20px;
  max-width: 1000px;
  margin: -28px auto 32px; /* pull the panels up to overlap the hero */
  padding: 0 20px;
  position: relative;
  z-index: 2;
}

@media (max-width: 760px) {
  .hub-main {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.panel-head h2 {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.15rem;
  margin: 0;
}

.panel-tag {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--bg);
  border-radius: 999px;
  padding: 4px 10px;
}

.loading {
  color: var(--muted);
  list-style: none;
}

/* --- Game cards ------------------------------------------------------------- */

.games-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 480px) {
  .games-list {
    grid-template-columns: 1fr;
  }
}

.game-card {
  --accent: var(--green); /* app.js overrides this per game */
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
}

.game-icon {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  border-radius: 14px;
  /* Soft tinted square using the game's accent color. */
  background: color-mix(in srgb, var(--accent) 16%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

.game-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.game-name {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1rem;
}

.game-desc {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.game-players {
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent);
}

.game-go {
  margin-left: auto;
  align-self: center;
  color: var(--accent);
  font-size: 1.2rem;
  font-weight: 800;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.game-card:hover .game-go {
  opacity: 1;
  transform: translateX(0);
}

/* --- Leaderboard ------------------------------------------------------------ */

.leaderboard {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.lb-row.top {
  background: color-mix(in srgb, var(--green) 10%, white);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--green) 25%, transparent);
}

.lb-rank {
  width: 26px;
  text-align: center;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--muted);
}

.lb-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  font-size: 0.9rem;
  background-size: cover;
  background-position: center;
}

.lb-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
}

.lb-name:hover {
  color: var(--green-deep);
  text-decoration: underline;
}

.lb-pts {
  margin-left: auto;
  font-weight: 800;
  color: var(--green-deep);
  white-space: nowrap;
}

/* --- Modal ------------------------------------------------------------------ */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(16, 24, 40, 0.55);
  backdrop-filter: blur(3px);
}

.modal {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 28px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  animation: pop 0.16s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-title {
  font-family: var(--font-head);
  margin: 0 0 18px;
  font-size: 1.3rem;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.6rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--muted);
}

.auth-form input {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 1rem;
  font-family: var(--font-body);
  background: #fbfcfe;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.auth-message {
  margin: 12px 0 0;
  min-height: 1.2em;
  font-size: 0.88rem;
  color: #d6336c;
  text-align: center;
  font-weight: 700;
}

/* --- Footer ----------------------------------------------------------------- */

.hub-footer {
  text-align: center;
  color: var(--muted);
  padding: 8px 16px 28px;
  font-size: 0.85rem;
}
