/*
 * Compte et profil (/profil, refonte 2026, phase 5, maquettes compte/Compte
 * et compte/Badges) : carte d'identite, compteurs, badges et reglages.
 * Mobile : une colonne ; ordinateur : profil a gauche, reglages a droite.
 */

.profile-page > .form-screen__step {
  flex-grow: 0;
  max-width: 520px;
}

.profile-page > .form-screen__step .form-screen__actions {
  margin-top: 0;
}

.profile {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.profile__grid {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.profile__side,
.profile__main {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  min-width: 0;
}

.profile__title {
  margin: 0;
  font-size: 1.75rem;
}

/* --- Carte d'identite -------------------------------------------------------- */
.profile-card {
  display: flex;
  flex-direction: column;
  padding: var(--sp-4);
  background: var(--surface);
  gap: var(--sp-3);
  border-radius: var(--r-xl);
}

.profile-card__who {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-card__who .avatar {
  width: 72px;
  height: 72px;
  border: 3px solid var(--flame);
  font-size: 1.875rem;
}

.profile-card__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  overflow-wrap: anywhere;
  font-size: 1.625rem;
  line-height: 1;
}

.profile-card__meta {
  margin: var(--sp-1) 0 0;
  color: var(--muted);
  margin-top: var(--sp-1);
  font-weight: 800;
  font-size: 0.8125rem;
}

.profile-card__actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: var(--sp-2);
}

.profile-card__actions .button,
.profile-pseudo > summary {
  gap: var(--sp-2);
  width: 100%;
  --button-edge-size: 0px;
  min-height: 46px;
  padding: 0 var(--sp-4);
  border-radius: var(--r-md);
  background: var(--soft);
  color: var(--text);
  font-size: 0.9375rem;
}

.profile-pseudo > summary {
  list-style: none;
}

.profile-pseudo > summary::-webkit-details-marker { display: none; }

.profile-pseudo[open] {
  grid-column: 1 / -1;
}

.profile-pseudo form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.profile-card .form-status:empty { display: none; }

/* --- Compteurs ------------------------------------------------------------------ */
.profile-stats {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--sp-2);
}

.profile-stats[hidden] { display: none; }

.profile-stats__item {
  flex-direction: column;
  align-items: center;
  gap: 2px;
  box-sizing: border-box;
  background: var(--surface);
  font-weight: 800;
  font-size: 0.75rem;
  text-decoration: none;
  display: grid;
  grid-template-columns: auto auto;
  align-content: center;
  justify-content: center;
  column-gap: var(--sp-1);
  row-gap: 2px;
  height: 84px;
  padding: 0 var(--sp-1);
  border-radius: 20px;
  color: var(--text);
}

.profile-stats__item strong {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.375rem;
  line-height: 1.2;
}

/* --- Badges ------------------------------------------------------------------------ */
.profile-badges {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-badges[hidden] { display: none; }

.profile-badges__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.profile-badge {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: var(--radius-card);
  background: var(--surface);
}

.profile-badge[data-next="true"] {
  border: 2px solid var(--violet-light);
}

.profile-badge__blason {
  flex-shrink: 0;
  width: 68px;
  height: auto;
}

.profile-badge[data-earned="false"] .profile-badge__blason {
  filter: grayscale(1);
  opacity: 0.6;
}

.profile-badge__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--sp-1);
  min-width: 0;
}

.profile-badge__text h3 {
  margin: 0;
  font-size: 1.1875rem;
}

.profile-badge__text p,
.profile-badge__text small {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8125rem;
}

.profile-badge__level {
  color: var(--muted);
  font-weight: 900;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.profile-badge progress {
  width: 100%;
  height: 8px;
  accent-color: var(--error-accent);
}

/* --- Reglages --------------------------------------------------------------------- */
.profile-row,
.profile__main > .card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: 0;
  padding: 14px var(--sp-4);
  border: 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}

.profile__main > .card[hidden] { display: none; }

.profile-row--link {
  flex-direction: row;
  align-items: center;
}

.profile-row__summary {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0;
  font-weight: 800;
  list-style: none;
  cursor: pointer;
}

.profile-row__summary::-webkit-details-marker { display: none; }

legend.profile-row__summary {
  float: left;
  width: 100%;
  cursor: default;
  gap: 10px;
  margin-bottom: var(--sp-2);
  font-family: var(--font-display);
  font-size: 1rem;
}

.profile-row--choice .segmented {
  clear: both;
  height: 44px;
  padding: var(--sp-1);
  border-radius: 16px;
  background: var(--soft);
}

.profile-row__text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.profile-row__text span {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.8125rem;
  line-height: 1.38;
}

.profile-row__action {
  color: var(--accent-text);
  font-weight: 800;
  font-size: 0.875rem;
  font-family: var(--font-display);
}

.profile-row__body {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin: var(--sp-3) 0 0;
}

.profile-prefs {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

/* Choix en ligne : objectif quotidien, theme */
.segmented {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  gap: var(--sp-1);
  padding: var(--sp-1);
  border-radius: var(--radius-md);
  background: var(--bg);
}

.segmented__item {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 800;
  font-size: 0.9375rem;
  cursor: pointer;
}

.segmented__item:has(input:checked) {
  border-bottom: var(--relief) solid var(--flame-button-edge);
  background: var(--flame);
  color: var(--on-flame);
}

.segmented__item:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.profile-logout {
  --button-edge-size: 0px;
  border: 2px solid var(--border);
  background: transparent;
  min-height: 52px;
  box-shadow: none;
  border-radius: var(--r-md);
  color: var(--red-strong);
  font-size: 1rem;
}

/* Visiteur (refonte v2, phase 4, maquette auth/CompteChoixMobile) : creer un
   compte, se connecter, ou entrer un code de jeu ou de classe. */
.account-guest {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  width: 100%;
  max-width: 440px;
  margin: 22px auto 0;
  text-align: center;
}

.account-guest[hidden] {
  display: none;
}

.account-guest__icon {
  display: grid;
  place-items: center;
  align-self: center;
  width: 80px;
  height: 80px;
  border-radius: 24px;
  background: var(--violet);
  box-shadow: 0 4px 0 var(--violet-edge);
}

.account-guest__icon .site-icon {
  width: 40px;
  height: 40px;
}

.account-guest__title {
  margin: -2px 0 0;
  font-size: 2.125rem;
  line-height: 1;
}

.account-guest__lead {
  margin: -10px 0 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.4;
}

.account-guest__actions {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.account-guest__actions .button--flame {
  min-height: 64px;
  font-size: 1.3125rem;
  text-transform: uppercase;
}

.account-guest__actions .button--ghost {
  box-sizing: border-box;
  min-height: 58px;
  border-radius: var(--r-md);
}

.account-guest__code {
  min-height: var(--touch-min);
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 0.9375rem;
}

/* --- Refonte v2, phase 6 (maquettes compte/Compte*, compte/Badges*) ------------- */
.profile,
.profile__grid,
.profile__side,
.profile__main { gap: var(--sp-5); }

.profile-stats:has(> [data-role="profile-exams"]:not([hidden])) { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.profile-stats li[hidden] { display: none; }

/* Icone et nombre sur une ligne, libelle dessous */

.profile-stats__item .site-icon { align-self: center; }

.profile-stats__item > span {
  grid-column: 1 / -1;
  justify-self: center;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.75rem;
}

.profile-row,
.profile__main > .profile-row--switch {
  gap: var(--sp-2);
  padding: var(--sp-3) 14px;
  border-radius: var(--r-md);
}

.profile-row--switch[hidden] { display: none; }

.profile-row__summary,
.profile-row--link,
.profile-row--switch .switch-row { gap: var(--sp-3); }

.profile-row__text strong {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.15;
}

.profile-row--switch .switch-row { justify-content: flex-start; }

.profile-row--switch .form-status:empty { display: none; }

.profile-row--choice .segmented__item {
  min-height: 36px;
  border-radius: 12px;
  font-family: var(--font-display);
  font-size: 0.9375rem;
}

.profile-row--choice .segmented__item:has(input:checked) {
  border-bottom: 0;
  box-shadow: 0 3px 0 var(--flame-edge);
}

/* Suppression du compte : discrete, sous la deconnexion (absente des maquettes) */
.profile__main .student-danger > summary {
  --button-edge-size: 0px;
  box-shadow: none;
  min-height: var(--touch-min);
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: underline;
}

/* Sur mobile, « Réglages » reste pour les lecteurs d'ecran : la maquette l'omet */
@media (max-width: 959px) {
  .profile__title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (min-width: 960px) {
  .profile__grid { display: grid; align-items: start; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: var(--space-6); }
  .profile__side { gap: var(--sp-4); }
  .profile__main { gap: 10px; }
  .profile__title { font-size: 1.75rem; line-height: 1.05; }
}

/* Mes badges (/profil#badges) */
.badges-view {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.badges-view[hidden] { display: none; }

.badges-hero {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: var(--sp-5);
  border-radius: 30px;
  background: var(--hero);
}

.badges-hero__who {
  display: flex;
  align-items: center;
  gap: 14px;
}

.badges-hero__avatar {
  width: 64px;
  height: 64px;
  border: 3px solid var(--flame);
  font-size: 1.625rem;
}

.badges-hero__text {
  display: flex;
  flex-direction: column;
}

.badges-hero__kicker {
  color: var(--muted);
  font-weight: 900;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badges-hero__title {
  margin: 0;
  font-size: 2.5rem;
  line-height: 1;
}

.badges-hero__value { color: var(--flame); }

.badges-hero__total {
  color: var(--muted);
  font-size: 0.5em;
}

.badges-hero__bar {
  display: flex;
  gap: var(--sp-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.badges-hero__bar li {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-1);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 0.75rem;
}

.badges-hero__bar li::before {
  content: '';
  width: 100%;
  height: 10px;
  border-radius: var(--r-pill);
  background: var(--soft);
}

.badges-hero__bar li[data-earned="true"]::before { background: var(--badge-glow); }

.badges-hero__bar li[data-earned="false"] { color: var(--muted); }

.badges-hero__lead {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.875rem;
}

.badges-view .profile-badge {
  padding: 14px;
  border-radius: var(--r-lg);
}

.badges-view .profile-badge[data-next="true"] { border: 2px solid var(--sel-border); }

.badges-view .profile-badge__level { font-size: 0.6875rem; }

.badges-view .profile-badge__text h3 { font-size: 1.1875rem; line-height: 1.1; }

.badges-view .profile-badge__text > p { font-size: 0.8125rem; }

.badges-view .profile-badge__text small {
  font-weight: 800;
  font-size: 0.75rem;
}

.badges-view .profile-badge progress {
  width: 100%;
  height: 8px;
  margin-top: var(--sp-1);
  border: 0;
  border-radius: var(--r-pill);
  background: var(--soft);
  appearance: none;
}

.badges-view .profile-badge progress::-webkit-progress-bar {
  border-radius: var(--r-pill);
  background: var(--soft);
}

.badges-view .profile-badge progress::-webkit-progress-value {
  border-radius: var(--r-pill);
  background: var(--badge-glow);
}

.badges-view .profile-badge progress::-moz-progress-bar {
  border-radius: var(--r-pill);
  background: var(--badge-glow);
}

@media (min-width: 960px) {
  .badges-view { gap: var(--sp-6); }
  .badges-hero { padding: var(--sp-6); gap: var(--sp-4); }
  .badges-hero__avatar { width: 80px; height: 80px; font-size: 2rem; }
  .badges-hero__title { font-size: 3rem; }
  .badges-view .profile-badges__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-3);
  }
}

/* Le pied de page suit le contenu, comme dans la maquette */
[data-page="profil"] .app { min-height: 0; }

@media (max-width: 767px) {
  [data-page="profil"] .app-content { padding-bottom: var(--sp-5); }
}

/* Un <details> ferme garde sa zone de contenu vide dans le flex : pas d'ecart */
details.profile-row:not([open]) { gap: 0; }
