/* Mini app iglook. Les couleurs viennent de Telegram quand il les fournit ;
   les valeurs de repli permettent d'ouvrir la page dans un navigateur normal
   pendant le developpement. */
:root {
  --fond:        var(--tg-theme-secondary-bg-color, #f2f3f5);
  --carte:       var(--tg-theme-bg-color, #ffffff);
  --texte:       var(--tg-theme-text-color, #16181c);
  --discret:     var(--tg-theme-hint-color, #8a8f98);
  --lien:        var(--tg-theme-link-color, #2f80ed);
  --bouton:      var(--tg-theme-button-color, #2f80ed);
  --bouton-texte:var(--tg-theme-button-text-color, #ffffff);
  --danger:      #d64545;
  --succes:      #2f9e5f;
  --bord:        color-mix(in srgb, var(--discret) 22%, transparent);
  --rayon: 14px;
  --gouttiere: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 400px;
  margin: 0 auto;
  padding: 10px var(--gouttiere) calc(24px + env(safe-area-inset-bottom, 0px));
}

/* --- blocs --------------------------------------------------------------- */
.carte {
  background: var(--carte);
  border-radius: var(--rayon);
  padding: 18px 16px;
  margin-bottom: 14px;
}

/* Composition reprise de la page des nouveautes : un sur-titre discret, puis
   un titre large et serre. Aligne a gauche, comme un texte qu'on lit, et non
   centre comme un formulaire qu'on remplit. */
.entete {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 4px 0 20px;
}
.entete .sur-titre {
  margin: 0;
  font-size: 11.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--discret);
}
.entete h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.entete .sous-titre {
  margin: 0;
  color: var(--discret);
  font-size: 14.5px;
  word-break: break-word;
}

h2 {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--discret);
}
.sous { color: var(--texte); opacity: .78; font-size: 15px; line-height: 1.5; margin: 0 0 16px; }

/* --- formulaires --------------------------------------------------------- */
label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--discret);
  margin: 0 0 6px;
}

input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 16px;            /* en dessous de 16px, iOS zoome a la saisie */
  font-family: inherit;
  color: var(--texte);
  background: var(--fond);
  border: 1px solid var(--bord);
  border-radius: 10px;
  outline: none;
  transition: border-color .15s;
}
input:focus { border-color: var(--lien); }
input[aria-invalid="true"] { border-color: var(--danger); }

.champ { margin-bottom: 11px; }
.champ .aide { font-size: 12px; color: var(--discret); margin: 5px 0 0; }

.case {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin: 2px 0 13px;
  cursor: pointer;
  font-size: 13px;
}
.case input { margin: 2px 0 0; flex: none; width: 18px; height: 18px; accent-color: var(--bouton); }
.case span { color: var(--discret); }
.case b { color: var(--texte); font-weight: 550; display: block; }

button {
  width: 100%;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  color: var(--bouton-texte);
  background: var(--bouton);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity .15s;
}
button:disabled { opacity: .55; cursor: default; }
button.secondaire {
  background: transparent;
  color: var(--lien);
  font-weight: 550;
  padding: 10px;
}

/* --- messages ------------------------------------------------------------ */
.message {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 14px;
}
.message.erreur { background: color-mix(in srgb, var(--danger) 12%, transparent); color: var(--danger); }
.message.ok     { background: color-mix(in srgb, var(--succes) 12%, transparent); color: var(--succes); }
.message.info   { background: color-mix(in srgb, var(--lien) 10%, transparent); color: var(--lien); }

/* --- etat du compte ------------------------------------------------------ */
.ligne {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--bord);
}
.ligne:last-child { border-bottom: 0; padding-bottom: 0; }
.ligne .icone { font-size: 22px; flex: none; width: 28px; text-align: center; }
.ligne .corps { flex: 1; min-width: 0; }
.ligne .titre { font-weight: 600; font-size: 15.5px; letter-spacing: -.01em; }
.ligne .detail {
  color: var(--discret);
  font-size: 13.5px;
  word-break: break-word;
  /* Chiffres de meme largeur : deux comptes se comparent d'un regard. */
  font-variant-numeric: tabular-nums;
}
.ligne .etat { font-size: 13px; font-weight: 600; flex: none; }
.etat.vert { color: var(--succes); }
.etat.rouge { color: var(--danger); }

/* --- barre du haut ------------------------------------------------------- */
/* Le lien de bascule a gauche, le drapeau a droite : la main du pouce tombe
   naturellement sur le second, qu'on utilise une fois, et pas sur le premier,
   qui change d'ecran. */
.barre {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  margin-bottom: 2px;
}

.lien {
  width: auto;
  padding: 6px 2px;
  background: none;
  border: 0;
  color: var(--lien);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}

.drapeau {
  width: auto;
  padding: 4px 8px;
  background: none;
  border: 0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
  transition: background .15s;
}
.drapeau:hover { background: color-mix(in srgb, var(--discret) 14%, transparent); }
.drapeau:active { transform: scale(0.92); }

/* --- divers -------------------------------------------------------------- */
.chargement { text-align: center; padding: 60px 0; color: var(--discret); }
.pied { color: var(--discret); font-size: 12.5px; margin-top: 16px; line-height: 1.6; }
.pied code { font-size: 12px; }

.masque { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* --- listes cliquables et panneau ----------------------------------------- */
.ligne.cliquable { cursor: pointer; }
.ligne.cliquable:active { opacity: .6; }
.ligne .chevron { color: var(--discret); font-size: 22px; flex: none; }
.ligne .detail.faible { color: var(--discret); opacity: .75; font-size: 12.5px; }
.ligne .detail.alerte { color: var(--danger); }

.menu .ligne:first-child { padding-top: 0; }

/* Bouton discret en bout de ligne : il ne doit pas concurrencer la ligne. */
button.mini {
  width: auto;
  flex: none;
  padding: 7px 10px;
  font-size: 15px;
  background: color-mix(in srgb, var(--discret) 14%, transparent);
  color: var(--texte);
  border-radius: 9px;
}

/* Le mot de passe provisoire sera recopie a la main : espace fixe, gros. */
.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 21px;
  letter-spacing: .06em;
  text-align: center;
  padding: 16px 10px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: var(--fond);
  user-select: all;
  word-break: break-all;
}

/* Pastille de nouveaute : une forme, pas une couleur en plus. */
.pastille {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-left: 6px;
  vertical-align: 2px;
  border-radius: 50%;
  background: currentColor;
}

/* La section Nouveautes apporte sa propre feuille : on lui rend la gouttiere
   que #app impose deja, sans quoi elle serait deux fois en retrait. */
.wn { background: transparent; }
.wn__inner { padding-left: 0; padding-right: 0; }

/* --- avertissement modal --------------------------------------------------- */
/* Le fond est floute plutot qu'assombri : l'arriere-plan reste reconnaissable
   -- on voit qu'on n'a pas change de page -- tout en devenant illisible, ce qui
   empeche de continuer a remplir le formulaire sans avoir lu. */
body.floute > #app {
  filter: blur(7px) saturate(.7);
  pointer-events: none;
  user-select: none;
}

.voile {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: color-mix(in srgb, var(--fond) 55%, transparent);
  animation: voile-entre .16s ease-out;
}

.avert {
  width: 100%;
  max-width: 340px;
  background: var(--carte);
  border-radius: 16px;
  padding: 22px 20px 18px;
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  animation: avert-entre .2s cubic-bezier(.2, .9, .3, 1.1);
}

.avert-icone { font-size: 34px; line-height: 1; margin-bottom: 10px; }

.avert-titre {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.01em;
  text-transform: none;
  color: var(--texte);
}

.avert-corps {
  margin: 0 0 14px;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--discret);
}

.avert-points {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: 13.5px;
  line-height: 1.5;
}
.avert-points li { padding: 5px 0 5px 20px; position: relative; color: var(--texte); }
.avert-points li::before {
  content: '\2713';
  position: absolute;
  left: 0;
  color: var(--discret);
}

.avert button + button { margin-top: 2px; }

@keyframes voile-entre { from { opacity: 0; } to { opacity: 1; } }
@keyframes avert-entre { from { opacity: 0; transform: translateY(10px) scale(.97); }
                         to   { opacity: 1; transform: none; } }

/* --- annonces -------------------------------------------------------------- */
.annonce-date {
  margin: 0 0 6px;
  font-size: 11.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--discret);
}
.annonce-titre {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.01em;
  text-transform: none;
  color: var(--texte);
}
.annonce-corps { margin: 0 0 10px; font-size: 15px; line-height: 1.55; white-space: pre-wrap; }
.annonce-corps:last-of-type { margin-bottom: 0; }

textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--texte);
  background: var(--fond);
  border: 1px solid var(--bord);
  border-radius: 10px;
  outline: none;
  resize: vertical;
  min-height: 90px;
}
textarea:focus { border-color: var(--lien); }

/* --- retour ---------------------------------------------------------------- */
/* La fleche est dessinee, pas ecrite : un caractere fleche change de forme et
   d'alignement selon la police, et Telegram n'impose pas la meme partout. */
.lien.retour {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: -4px;
}

.fleche {
  width: 17px;
  height: 17px;
  flex: none;
}

/* --- version ---------------------------------------------------------------- */
/* Assez discret pour ne pas distraire, assez lisible pour repondre a
   « tu es sur quelle version ? » sans ouvrir un terminal. */
#version {
  max-width: 400px;
  margin: 0 auto;
  padding: 0 var(--gouttiere) calc(18px + env(safe-area-inset-bottom, 0px));
  font-size: 11.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--discret);
  opacity: .65;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Le voile d'avertissement floute #app : le pied doit suivre, sinon il reste
   net au milieu d'une page brouillee. */
body.floute > #version { filter: blur(7px); }
