/* =====================================================================
   PROFILE-MODAL.CSS — Fenêtre de profil du joueur
   S'ouvre en cliquant sur l'avatar ou le nom, dans la carte joueur.
   3 onglets : Statistiques, Avatar, Cadre.

   Structure HTML attendue : voir le bloc <div class="profile-modal">
   dans index.html. Piloté par js/profile-modal.js.
   ===================================================================== */


/* ---------------------------------------------------------------------
   1. FOND SOMBRE + CONTENEUR
   --------------------------------------------------------------------- */
.profile-modal {
  position: absolute;
  inset: 0;
  z-index: 90;              /* au-dessus de tout le reste du jeu */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Cache complètement la fenêtre tant qu'elle n'est pas ouverte
   (display:none via [hidden], plus fiable que juste de l'opacité) */
.profile-modal[hidden] {
  display: none;
}

/* Fond sombre semi-transparent derrière la fenêtre : cliquer dessus la ferme */
.profile-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 10, 0.78);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  animation: pm-fade-in 0.2s ease;
}


/* ---------------------------------------------------------------------
   2. LE PANNEAU
   --------------------------------------------------------------------- */
.profile-modal-panel {
  position: relative;
  z-index: 1;
  width: 620px;
  max-height: 780px;
  background: linear-gradient(160deg, rgba(28, 16, 52, 0.98) 0%, rgba(9, 7, 18, 0.99) 100%);
  border: 1.5px solid var(--gold, #d8a83e);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.7), 0 0 40px rgba(156, 90, 197, 0.25), inset 0 0 30px rgba(140, 80, 255, 0.08);
  clip-path: polygon(18px 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%, 0 18px);
  display: flex;
  flex-direction: column;
  animation: pm-pop-in 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Fine bordure intérieure (double cadre, comme la bulle de dialogue) */
.profile-modal-panel::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(216, 168, 62, 0.28);
  clip-path: polygon(15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%, 0 15px);
  pointer-events: none;
}

@keyframes pm-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes pm-pop-in {
  from { opacity: 0; transform: scale(0.94) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- Bouton fermer (croix dorée, coin supérieur droit) --- */
.profile-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 30px;
  height: 30px;
  padding: 6px;
  display: grid;
  place-items: center;
  color: var(--gold-light, #ffe18a);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(216, 168, 62, 0.5);
  border-radius: 50%;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.profile-modal-close svg {
  width: 100%;
  height: 100%;
}

.profile-modal-close:hover {
  transform: rotate(90deg) scale(1.08);
  border-color: var(--gold-light, #ffe18a);
  color: #fff;
}


/* ---------------------------------------------------------------------
   3. EN-TÊTE : grand avatar, nom, niveau, XP, rang
   --------------------------------------------------------------------- */
.pm-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 30px 34px 22px;
}

/* Grand avatar hexagonal (même construction que celui de la carte joueur,
   en plus grand) + bouton crayon pour changer */
.pm-avatar {
  --hex: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  position: relative;
  flex: none;
  width: 108px;
  height: 124px;
  filter: drop-shadow(0 0 10px rgba(216, 168, 62, 0.4));
}

.pm-avatar-hex {
  position: absolute;
  inset: 0;
  clip-path: var(--hex);
  /* Même variable que la carte joueur : les deux cadres restent synchronisés */
  background: var(--frame-bg, linear-gradient(160deg, #fff1b8 0%, var(--gold, #d8a83e) 40%, var(--purple-bright, #9c5ac5) 100%));
}

.pm-avatar-hex::before {
  content: "";
  position: absolute;
  inset: 4px;
  clip-path: var(--hex);
  background: var(--void, #090811);
}

.pm-avatar-face {
  position: absolute;
  inset: 8px;
  clip-path: var(--hex);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #fff;
  font-family: "Cinzel", serif;
  font-size: 42px;
  font-weight: 700;
  background: var(--avatar-bg, radial-gradient(circle at 35% 25%, #b9b4ff, #44345d 45%, #15101e 70%));
}

.pm-avatar-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Bouton crayon, en bas à droite du grand avatar : ouvre l'onglet Avatar */
.pm-avatar-edit {
  position: absolute;
  right: -6px;
  bottom: -2px;
  width: 32px;
  height: 32px;
  padding: 6px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff1b8, var(--gold, #d8a83e));
  border: 2px solid var(--void, #090811);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  transition: transform 0.15s ease;
}

.pm-avatar-edit svg {
  width: 100%;
  height: 100%;
}

.pm-avatar-edit:hover {
  transform: scale(1.12);
}

/* Infos à droite du grand avatar */
.pm-identity {
  flex: 1;
  min-width: 0;
}

.pm-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.pm-name {
  font-family: "Cinzel", serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--cream, #f5ead5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pm-level-pill {
  flex: none;
  padding: 2px 12px;
  font-family: "Cinzel", serif;
  font-size: 13px;
  font-weight: 800;
  color: #2a1a00;
  background: linear-gradient(180deg, #fff3a8 0%, var(--banana, #f5cf4c) 50%, #d99a1e 100%);
  clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
}

.pm-rank-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 12px 0 8px;
  margin-bottom: 12px;
  border-radius: 12px;
  font-family: "Cinzel", serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--rank-color, var(--gold-light));
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--rank-color, var(--gold-light));
  box-shadow: 0 0 8px var(--rank-glow, rgba(216, 168, 62, 0.4));
}

.pm-rank-pill svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

/* Barre d'XP (même style que la carte joueur, en un peu plus large) */
.pm-xp-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pm-xp-bar {
  position: relative;
  flex: 1;
  height: 11px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(216, 168, 62, 0.55);
}

.pm-xp-bar span {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #8e4eb3, var(--purple-bright, #9c5ac5) 40%, var(--gold-light, #ffe18a));
  box-shadow: 0 0 10px rgba(216, 168, 62, 0.45);
}

.pm-xp-text {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #b8aabf);
}


/* ---------------------------------------------------------------------
   4. ONGLETS
   --------------------------------------------------------------------- */
.pm-tabs {
  flex: none;
  display: flex;
  gap: 6px;
  padding: 0 34px;
  border-bottom: 1px solid rgba(216, 168, 62, 0.25);
}

.pm-tab {
  position: relative;
  padding: 10px 6px 14px;
  font-family: "Cinzel", serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--muted, #b8aabf);
  background: transparent;
  border: 0;
  transition: color 0.15s ease;
}

.pm-tab + .pm-tab {
  margin-left: 20px;
}

.pm-tab:hover {
  color: var(--cream, #f5ead5);
}

.pm-tab.active {
  color: var(--gold-light, #ffe18a);
}

/* Soulignement doré sous l'onglet actif */
.pm-tab.active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--gold, #d8a83e), var(--gold-light, #ffe18a));
  box-shadow: 0 0 8px rgba(216, 168, 62, 0.6);
}


/* ---------------------------------------------------------------------
   5. CONTENU DES ONGLETS (zone défilable)
   --------------------------------------------------------------------- */
.pm-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 34px 30px;
}

.pm-panel[hidden] {
  display: none;
}

/* --- Onglet Statistiques : grille de pastilles --- */
.pm-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.pm-stat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(216, 168, 62, 0.25);
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
}

.pm-stat-icon {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #3a2a72 0%, #180f3c 60%, #0a0620 100%);
  box-shadow: 0 0 0 2px var(--gold-light, #ffe18a), 0 0 0 4px rgba(9, 8, 17, 0.9);
}

.pm-stat-icon svg {
  width: 22px;
  height: 22px;
}

.pm-stat-icon svg .ol {
  stroke: var(--void, #090811);
  stroke-width: 1.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.pm-stat-text {
  min-width: 0;
}

.pm-stat-label {
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted, #b8aabf);
  margin-bottom: 2px;
}

.pm-stat-value {
  font-family: "Cinzel", serif;
  font-size: 17px;
  font-weight: 800;
  color: var(--cream, #f5ead5);
}

/* --- Onglets Avatar / Cadre : grille de vignettes sélectionnables --- */
.pm-picker-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.pm-swatch {
  --hex: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
  position: relative;
  aspect-ratio: 0.866;
  clip-path: var(--hex);
  background: linear-gradient(160deg, #fff1b8 0%, var(--gold, #d8a83e) 40%, var(--purple-bright, #9c5ac5) 100%);
  border: 0;
  padding: 3px;
  transition: transform 0.15s ease;
}

.pm-swatch-inner {
  position: absolute;
  inset: 3px;
  clip-path: var(--hex);
  display: grid;
  place-items: center;
}

/* Le fond de la vignette (avatar ou cadre) : réglé via une variable inline,
   voir index.html (style="--swatch-bg: ...") */
.pm-swatch.is-avatar .pm-swatch-inner {
  background: var(--swatch-bg, radial-gradient(circle at 35% 25%, #b9b4ff, #44345d 45%, #15101e 70%));
}

/* Vignette "cadre" : montre juste l'anneau (le centre reste neutre) */
.pm-swatch.is-frame {
  background: var(--swatch-bg, linear-gradient(160deg, #fff1b8, var(--gold), var(--purple-bright)));
}

.pm-swatch.is-frame .pm-swatch-inner {
  background: radial-gradient(circle at 35% 25%, #4a3a72, #180f3c 70%);
}

.pm-swatch:hover:not(.is-locked) {
  transform: translateY(-3px);
}

/* Sélection actuelle : halo doré */
.pm-swatch.is-selected {
  filter: drop-shadow(0 0 10px rgba(255, 225, 138, 0.8));
}

.pm-swatch.is-selected::after {
  content: "";
  position: absolute;
  inset: -4px;
  clip-path: var(--hex);
  background: var(--gold-light, #ffe18a);
  z-index: -1;
}

/* Option verrouillée : assombrie, cadenas au centre, non cliquable */
.pm-swatch.is-locked {
  cursor: default;
  filter: grayscale(0.6) brightness(0.55);
}

.pm-swatch.is-locked .pm-swatch-inner {
  background: #100a1e;
}

.pm-lock-icon {
  width: 26px;
  height: 26px;
}

.pm-lock-icon .ol {
  stroke: var(--void, #090811);
  stroke-width: 1.4;
}


/* ---------------------------------------------------------------------
   6. ACCESSIBILITÉ
   --------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .profile-modal-backdrop,
  .profile-modal-panel,
  .pm-avatar-edit,
  .pm-swatch {
    animation: none;
    transition: none;
  }
}