/* Calika - pages de compte : inscription, connexion, clé de récupération, mot de passe oublié, paramètres.
   Chargée par templates/comptes/*.html, après components.css. */

/* 1. Mise en page : une carte de formulaire ; à partir de 1024px, la mascotte à droite, posée sur son ombre */

.ck-auth {
  display: grid;
  justify-content: center;
  grid-template-columns: minmax(0, 480px);
  padding: var(--space-6) 0 var(--space-8);
}
.ck-auth__carte { display: flex; flex-direction: column; gap: var(--space-4); }
.ck-auth__carte .ck-h1 { margin: 0; }
.ck-auth__intro { margin: -4px 0 0; color: var(--ink-muted); }
.ck-auth__bas { margin: 0; text-align: center; font-size: 14px; color: var(--ink-muted); }
.ck-auth__perso { display: none; }

@media (min-width: 1024px) {
  .ck-auth {
    grid-template-columns: minmax(0, 480px) 300px;
    gap: 56px;
    align-items: end;
    padding: var(--space-8) 0 48px;
  }
  .ck-auth__perso { display: block; position: relative; align-self: end; padding-bottom: 8px; }
  .ck-auth__perso img { position: relative; z-index: 1; width: auto; height: 440px; margin: 0 auto; }
  /* Ombre au sol, sous les pieds */
  .ck-auth__perso::after {
    content: ""; position: absolute; z-index: 0;
    left: 18%; right: 18%; bottom: 6px; height: 18px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(43, 37, 53, .28), rgba(43, 37, 53, 0));
  }
}

/* 2. Formulaires */

.ck-form { display: flex; flex-direction: column; gap: var(--space-4); }
.ck-form .ck-help, .ck-form .ck-error { margin: 0; }
.ck-form__envoi { width: 100%; }
.ck-form__ligne { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.ck-form__ligne .ck-small { color: var(--violet); }
.ck-auth__age { margin-top: calc(-1 * var(--space-2)); }
.ck-input { height: var(--touch-target); } /* champs de compte à 44px : plus confortables au doigt */
.ck-field--erreur .ck-label { color: var(--danger); }
.ck-field--erreur .ck-input { border-color: var(--danger); }
.ck-field--erreur .ck-input:focus { outline-color: var(--danger); }

/* Règles du mot de passe, cochées au fil de la frappe */
.ck-regles { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: var(--type-small-size); line-height: var(--type-small-line); color: var(--ink-muted); }
.ck-regles li::before { content: "○"; display: inline-block; width: 1.2em; }
.ck-regles li.ck-regles__ok { color: var(--success); }
.ck-regles li.ck-regles__ok::before { content: "✓"; font-weight: 700; }

/* Case à cocher : native, à la couleur de la marque, zone cliquable étendue au libellé */
.ck-check {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: var(--touch-target);
  cursor: pointer;
  font-size: 15px;
}
.ck-check input {
  width: 20px; height: 20px; margin: 0; flex: none;
  accent-color: var(--violet);
  cursor: pointer;
}

/* Mot de passe : bouton œil à droite du champ pour afficher ou masquer la saisie */
.ck-mdp { position: relative; }
.ck-mdp .ck-input { padding-right: 48px; }
.ck-mdp__voir {
  position: absolute; top: 0; right: 0;
  width: var(--touch-target); height: var(--touch-target);
  display: grid; place-items: center;
  border: 0; background: none; padding: 0;
  color: var(--ink-muted); cursor: pointer;
  border-radius: var(--radius-sm);
}
.ck-mdp__voir:hover { color: var(--violet); }
.ck-mdp__voir svg { grid-area: 1 / 1; }
.ck-mdp__barre { opacity: 0; transition: opacity .15s; }
.ck-mdp__voir[aria-pressed="true"] .ck-mdp__barre { opacity: 1; }

/* Pot de miel : hors de l'écran (pas display:none, que certains robots savent repérer) */
.ck-piege { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }

/* Séparateur « ou » entre deux façons de faire */
.ck-separateur { display: flex; align-items: center; gap: var(--space-4); color: var(--ink-muted); font-size: 13px; }
.ck-separateur::before, .ck-separateur::after { content: ""; flex: 1; height: 1px; background: var(--line); }

div.ck-panel { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); }
div.ck-panel p { margin: 0; }

/* Captcha ALTCHA aux couleurs de Calika (les variables sont lues par le composant) */
.ck-altcha altcha-widget {
  display: block;
  --altcha-max-width: 100%;
  --altcha-border-width: 1px;
  --altcha-border-radius: var(--radius-sm);
  --altcha-border-color: var(--field-border);
  --altcha-color-base: var(--page);
  --altcha-color-base-content: var(--ink);
  --altcha-color-neutral: var(--surface-100);
  --altcha-color-neutral-content: var(--ink-muted);
  --altcha-color-primary: var(--violet);
  --altcha-color-primary-content: var(--on-violet);
  --altcha-color-success: var(--success);
  --altcha-color-success-content: #ffffff;
  --altcha-color-error: var(--danger);
  --altcha-color-error-content: #ffffff;
  --altcha-checkbox-border-color: var(--field-border);
  --altcha-checkbox-border-radius: 4px;
  --altcha-spinner-color: var(--violet);
  --altcha-shadow: none;
  font-family: var(--font-text);
}

/* 3. Clé de récupération */

/* La mascotte « pointe vers le bas » se tient derrière l'encadré, en haut à droite :
   seuls la tête et les bras dépassent, le bout des doigts arrive sur le bord de l'encadré.
   Dans l'image, le bout des doigts est à 54,4 % de la hauteur. */
.ck-cle-zone { position: relative; --perso-h: 190px; }
.ck-cle__perso {
  position: absolute; z-index: 0;
  right: 10px;
  top: calc(-0.544 * var(--perso-h) - 1px);
  height: var(--perso-h); width: auto;
  pointer-events: none;
}
.ck-cle-zone .ck-cle { position: relative; z-index: 1; }
.ck-cle__intro { padding-right: 104px; }
@media (min-width: 640px) {
  .ck-cle-zone { --perso-h: 220px; }
  .ck-cle__intro { padding-right: 124px; }
}
/* Page de la clé : la carte seule, centrée (la mascotte est dans la carte) */
@media (min-width: 1024px) {
  .ck-auth--seule { grid-template-columns: minmax(0, 480px); }
}

.ck-cle {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-4);
  padding: var(--space-6) var(--space-4);
  background: var(--surface-100);
  border: 1.5px dashed var(--lavender);
  border-radius: var(--radius-md);
  text-align: center;
}
.ck-cle__valeur {
  margin: 0;
  font-family: var(--font-text);
  font-size: 18px; font-weight: 800; letter-spacing: 1px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  user-select: all;
}
@media (min-width: 640px) { .ck-cle__valeur { font-size: 24px; letter-spacing: 2px; } }
.ck-cle__actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.ck-cle__retour { margin: 0; color: var(--success); }
.ck-cle__retour:empty { display: none; }

.ck-btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* 4. Messages après une action, en haut de page */

.ck-messages { display: flex; flex-direction: column; gap: var(--space-2); padding-top: var(--space-4); }
.ck-messages .ck-alert { margin: 0; font-size: 14px; }
.ck-messages + .ck-auth { padding-top: var(--space-4); }

/* 5. Pancarte « Confirme ton adresse mail » (mon compte, tableau de bord) */

.ck-bandeau {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2);
  padding: 12px 16px;
  background: var(--warning-bg);
  color: var(--warning);
  border-radius: var(--radius-md);
  font-size: 14px;
}
.ck-bandeau__texte { margin: 0; }
.ck-bandeau .ck-btn { border-color: currentColor; color: var(--warning); background: transparent; }
.ck-bandeau .ck-btn:hover { background: color-mix(in srgb, var(--warning) 10%, transparent); }
@media (min-width: 640px) {
  .ck-bandeau { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--space-4); }
  .ck-bandeau form { flex: none; }
}

/* 6. Pages simples : mon compte, tableau de bord provisoire */

.ck-page { display: flex; flex-direction: column; gap: var(--space-4); width: 100%; max-width: 760px; margin: 0 auto; padding: var(--space-6) 0 var(--space-8); }
.ck-page > .ck-h1 { margin: 0; }
.ck-compte .ck-h2 { margin: 0 0 var(--space-4); }
.ck-compte .ck-help { margin: var(--space-4) 0 0; }
.ck-compte__sortie { margin: 0; }

.ck-infos { margin: 0; display: flex; flex-direction: column; }
.ck-infos__ligne { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-top: 1px solid var(--line); }
.ck-infos__ligne:first-child { border-top: 0; padding-top: 0; }
.ck-infos dt { font-size: var(--type-small-size); color: var(--ink-muted); }
.ck-infos dd { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; overflow-wrap: anywhere; }
@media (min-width: 640px) {
  .ck-infos__ligne { flex-direction: row; align-items: baseline; }
  .ck-infos dt { flex: 0 0 160px; }
}
.ck-casse { overflow-wrap: anywhere; }

.ck-pastille { display: inline-block; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 12.5px; font-weight: 700; }
.ck-pastille--ok { background: var(--success-bg); color: var(--success); }
.ck-pastille--attente { background: var(--warning-bg); color: var(--warning); }

.ck-bientot { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); text-align: center; }
.ck-bientot .ck-h1 { margin: 0 0 var(--space-2); }
.ck-bientot p { margin: 0 0 var(--space-4); color: var(--ink-muted); }
.ck-bientot__perso { width: auto; height: 200px; }
@media (min-width: 640px) {
  .ck-bientot { flex-direction: row; text-align: left; gap: var(--space-8); }
  .ck-bientot__perso { height: 260px; }
}

/* Bloc repliable (« Adresse mal saisie ? Corrige-la ») */
.ck-replie { padding: 0; }
.ck-replie__titre {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  min-height: var(--touch-target);
  padding: var(--space-2) var(--space-4);
  font-weight: 700; cursor: pointer; list-style: none;
}
.ck-replie__titre::-webkit-details-marker { display: none; }
.ck-replie__titre::after {
  content: ""; width: 8px; height: 8px; flex: none;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-2px); transition: transform .15s;
}
.ck-replie[open] .ck-replie__titre::after { transform: rotate(-135deg) translateY(-2px); }
.ck-replie__corps { padding: 0 var(--space-4) var(--space-4); }
@media (min-width: 640px) {
  .ck-replie__titre { padding: var(--space-2) var(--space-6); }
  .ck-replie__corps { padding: 0 var(--space-6) var(--space-6); }
}
p.ck-panel { margin: 0; }

/* 7. Paramètres : sommaire à gauche sur ordinateur, une carte par section */

.ck-reglages { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-8); padding: var(--space-6) 0 var(--space-8); }
.ck-reglages__corps { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; width: 100%; max-width: 760px; margin: 0 auto; }
.ck-reglages__corps > .ck-h1 { margin: 0; }
.ck-reglages__corps > .ck-messages { padding-top: 0; }

.ck-sommaire { display: none; }
@media (min-width: 1024px) {
  .ck-reglages { grid-template-columns: 220px minmax(0, 760px); justify-content: center; }
  .ck-reglages__corps { margin: 0; }
  .ck-sommaire {
    display: flex; flex-direction: column; gap: 2px;
    position: sticky; top: 96px; align-self: start;
    padding-top: 52px; /* aligné sous le titre de la page */
  }
  .ck-sommaire a {
    display: block; padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--ink-muted); font-size: 14.5px; font-weight: 600; text-decoration: none; white-space: nowrap;
  }
  .ck-sommaire a:hover { background: var(--surface-100); color: var(--violet); }
  .ck-sommaire a[href="#suppression"] { margin-top: var(--space-2); color: var(--danger); }
  .ck-sommaire a[href="#suppression"]:hover { background: var(--danger-bg); color: var(--danger); }
}

/* Une section : l'ancre arrive sous le header fixe */
.ck-reglage { display: flex; flex-direction: column; gap: var(--space-4); scroll-margin-top: 88px; }
.ck-reglage > .ck-h2, .ck-reglage__tete .ck-h2 { margin: 0; }
.ck-reglage > form, .ck-reglage > .ck-form { margin: 0; }
.ck-reglage__tete { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); }
.ck-reglage__texte { margin: 0; color: var(--ink-muted); }
.ck-reglage__pied { margin: 0; }
.ck-reglage .ck-messages { padding-top: 0; }
.ck-reglage--doux { background: var(--surface-100); box-shadow: none; }
.ck-reglage--danger { border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent); box-shadow: none; }
.ck-reglage--danger > .ck-h2 { color: var(--danger); }
.ck-sans-marge { margin: 0; }

/* Champ et bouton sur une ligne (prénom) ; l'un sous l'autre sur smartphone */
.ck-en-ligne { display: flex; flex-direction: column; gap: var(--space-2); }
.ck-en-ligne .ck-field { flex: 1; min-width: 0; }
.ck-en-ligne > .ck-btn { align-self: flex-end; }
@media (min-width: 640px) {
  .ck-en-ligne { flex-direction: row; align-items: flex-start; gap: var(--space-4); }
  /* Le bouton s'aligne sur le champ (le libellé fait 18px + 6px d'écart au-dessus) */
  .ck-en-ligne > .ck-btn { align-self: flex-start; margin-top: 26px; min-height: var(--touch-target); }
}

.ck-adresse { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ck-attente { display: flex; flex-direction: column; gap: var(--space-2); }
.ck-attente p { margin: 0; }
.ck-attente .ck-actions { justify-content: flex-start; }
.ck-attente form { margin: 0; }

/* Blocs repliables dans une carte : un filet au-dessus, sans fond ni ombre */
.ck-replie--dans-carte { border-top: 1px solid var(--line); margin: 0 calc(-1 * var(--space-4)); }
.ck-replie--dans-carte:last-child { margin-bottom: calc(-1 * var(--space-4)); }
@media (min-width: 640px) {
  .ck-replie--dans-carte { margin: 0 calc(-1 * var(--space-6)); }
  .ck-replie--dans-carte:last-child { margin-bottom: calc(-1 * var(--space-6)); }
}
.ck-reglage > .ck-h2 + .ck-replie--dans-carte, .ck-reglage > .ck-messages + .ck-replie--dans-carte { border-top: 0; margin-top: calc(-1 * var(--space-2)); }
.ck-replie__titre:hover { color: var(--violet); }

/* Mesures côte à côte : taille et poids, kcal et protéines */
.ck-mesures { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--space-4); align-items: end; }
.ck-mesures .ck-input--num { width: 100%; max-width: 160px; }
.ck-unite { display: inline-flex; align-items: center; gap: var(--space-2); }
.ck-unite .ck-input--num { width: 112px; }
.ck-field .ck-weight { min-height: var(--touch-target); }
.ck-field .ck-weight__delta { min-width: 0; text-align: left; }
.ck-field .ck-weight__box { height: var(--touch-target); }
.ck-field .ck-weight__input { height: calc(var(--touch-target) - 2px); font-size: 16px; }
.ck-field--erreur .ck-weight__box { border-color: var(--danger); }

.ck-imc { display: flex; flex-direction: column; gap: 4px; padding: 12px 14px; background: var(--surface-100); border-radius: 12px; }
.ck-imc p { margin: 0; }
.ck-imc__valeur { display: flex; align-items: baseline; gap: 10px; }
.ck-imc__valeur .ck-strong { font-family: var(--font-display); font-size: var(--type-metric-mobile-size); line-height: var(--type-metric-mobile-line); color: var(--ink); }

.ck-consentement { display: flex; flex-direction: column; gap: var(--space-2); }
.ck-consentement p { margin: 0; }
.ck-check span { line-height: 1.35; }

.ck-pastille--bientot { background: var(--surface-200); color: var(--violet-deep); }
.ck-actions--fin { justify-content: flex-end; }
.ck-modal .ck-form { gap: var(--space-4); }
.ck-modal .ck-alert { margin: 0; }

/* Bouton qui ouvre la suppression : contour rouge, le rouge plein est réservé à la confirmation */
.ck-btn--rouge { border-color: var(--danger); color: var(--danger); background: transparent; }
.ck-btn--rouge:hover { background: var(--danger-bg); }

/* Champs grisés (objectifs désactivés) : lisibles, mais on voit qu'ils ne servent pas */
.ck-mesures.ck-dimmed { opacity: .5; }

/* Sessions ouvertes : une ligne par appareil, case à cocher à gauche (sauf « Cet appareil ») */
.ck-sessions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ck-session { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.ck-session:first-child { border-top: 0; padding-top: 0; }
.ck-session__case { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--violet); cursor: pointer; }
span.ck-session__case { cursor: default; }
.ck-session__infos { display: flex; flex-direction: column; gap: 2px; min-width: 0; cursor: pointer; }
.ck-session--actuelle .ck-session__infos { cursor: default; }
.ck-session__appareil { font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.ck-session__reseau { font-size: 14px; color: var(--ink); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ck-session__dates { font-size: var(--type-small-size); line-height: var(--type-small-line); color: var(--ink-muted); }
.ck-oubli a { color: var(--violet); font-weight: 600; }

