/* ===========================================================
   Page d'accueil — plateforme de jeux entre amis
   =========================================================== */

:root {
  --bg-1: #f4f2fb;
  --bg-2: #e9e4fb;
  --surface: #ffffff;
  --text: #211b3a;
  --text-dim: #6a6380;
  --primary: #5b3fd6;
  --border: #e4e0f5;
  --shadow: 0 8px 24px rgba(80, 60, 160, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-1: #16132a; --bg-2: #1e1a38; --surface: #241f42;
    --text: #f1eefc; --text-dim: #b3aacf; --primary: #a08bff; --border: #362e5c;
    --shadow: 0 8px 28px rgba(0,0,0,.45);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% -10%, var(--bg-2), var(--bg-1) 60%);
  -webkit-font-smoothing: antialiased;
  touch-action: manipulation;
}

.page {
  max-width: 640px; margin: 0 auto;
  padding: calc(32px + var(--safe-top)) 18px calc(32px + var(--safe-bottom));
  min-height: 100dvh; display: flex; flex-direction: column;
}

.brand { text-align: center; margin-bottom: 28px; }
.brand-emoji { font-size: 52px; line-height: 1; }
.brand h1 { margin: 8px 0 6px; font-size: 32px; letter-spacing: -0.02em; }
.subtitle { margin: 0; color: var(--text-dim); font-size: 15px; max-width: 420px; margin-inline: auto; line-height: 1.5; }

.game-grid { display: flex; flex-direction: column; gap: 14px; flex: 1; }

.section-title {
  margin: 8px 0 -2px; font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-dim);
}
.section-title:first-child { margin-top: 0; }

.game-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 16px; box-shadow: var(--shadow); text-decoration: none; color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.game-card:active { transform: scale(0.98); }

.game-emoji {
  flex-shrink: 0; width: 56px; height: 56px; border-radius: 16px;
  display: flex; align-items: center; justify-content: center; font-size: 28px;
  box-shadow: 0 6px 14px rgba(0,0,0,.18);
}

.game-info { flex: 1; min-width: 0; }
.game-info h2 { margin: 0 0 4px; font-size: 18px; }
.game-info p { margin: 0 0 6px; font-size: 13px; color: var(--text-dim); line-height: 1.45; }
.game-meta { font-size: 11px; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: .03em; }

.game-arrow { flex-shrink: 0; font-size: 20px; color: var(--text-dim); }

.page-footer { text-align: center; margin-top: 28px; }
.page-footer p { margin: 0; color: var(--text-dim); font-size: 13px; }

@media (min-width: 640px) {
  .brand h1 { font-size: 38px; }
  .game-grid { gap: 16px; }
}

/* ===========================================================
   Porte pseudo, groupe d'amis, boutons/champs communs
   =========================================================== */

.hidden { display: none !important; }

/* Bascule Mode Bénéficiaire AAH, accessible en permanence sur le hub (pas
   seulement sur la porte pseudo, qui ne se réaffiche plus une fois le
   pseudo mémorisé) — voir public/shared/AAH_MODE.md. */
.aah-toggle-btn {
  position: fixed; top: calc(14px + var(--safe-top)); right: 14px; z-index: 20;
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--surface);
  font-size: 20px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.aah-toggle-btn[aria-pressed="true"] {
  background: var(--primary); border-color: var(--primary);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 12px; padding: 12px 18px;
  font-size: 15px; font-weight: 700; cursor: pointer;
  text-decoration: none; color: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-small { padding: 9px 14px; font-size: 13px; border-radius: 10px; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 16px 0; text-align: left; }
.field span { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.field input {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
  font-size: 16px; background: var(--surface); color: var(--text);
}

/* Case à cocher inline (ex. Mode Bénéficiaire AAH) — même motif que
   games/petit-bac/public/style.css, dupliqué ici volontairement (chaque
   page de cette plateforme est autonome pour son CSS). */
.field-inline { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-dim); margin: 14px 0; text-align: left; }
.field-inline input { width: 20px; height: 20px; flex-shrink: 0; }

.pseudo-gate {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: radial-gradient(circle at 20% -10%, var(--bg-2), var(--bg-1) 60%);
}
.pseudo-gate-box {
  max-width: 360px; width: 100%; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 28px 22px; box-shadow: var(--shadow);
}
.pseudo-gate-box .btn-primary { width: 100%; }

.group-section { margin-bottom: 4px; }
.group-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.group-hint { margin: 0 0 10px; font-size: 13px; color: var(--text-dim); line-height: 1.4; }
.group-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.join-group-panel { display: flex; gap: 8px; margin-top: 10px; }
.join-group-panel input {
  flex: 1; min-width: 0; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface); color: var(--text);
}

.group-box-active { padding: 0; overflow: hidden; }
.group-badge {
  width: 100%; display: flex; align-items: center; justify-content: center;
  gap: 8px; border: none; background: transparent; color: var(--text);
  font-size: 14px; font-weight: 700; padding: 14px 16px; cursor: pointer;
}
.group-panel-body { padding: 0 16px 16px; }
.group-members { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.group-members li {
  background: var(--bg-2); border-radius: 999px; padding: 5px 12px; font-size: 13px;
}
.group-members li.disconnected { opacity: 0.5; }
.group-panel-body .group-hint { margin-top: 0; }
.group-panel-body .btn-primary { width: 100%; margin-bottom: 10px; }

.game-card.disabled {
  opacity: 0.45; pointer-events: none;
  cursor: not-allowed;
}

.toast {
  position: fixed; top: calc(14px + var(--safe-top)); left: 50%; z-index: 40;
  transform: translateX(-50%) translateY(-140%);
  background: #c0392b; color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: 0 8px 20px rgba(0,0,0,.25);
  transition: transform .25s ease;
  max-width: 88vw; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
