/* ============================================================================
   BULLE — Design system « Écume » (identité 2026-11)
   ----------------------------------------------------------------------------
   SOURCE UNIQUE des jetons de l'interface. Chargé EN DERNIER dans index.html.

   L'idée : tout est membrane. Les surfaces sont nacrées, leur bord capte un
   reflet irisé (violet → rose → lagon), les formes ont la tension d'une bulle
   de savon. Une seule animation signature : la pression « pop » (l'objet
   s'enfonce puis rebondit) et, pour les moments forts, l'éclatement.

   Règles :
   • Toutes les couleurs dérivent des 18 jetons du moteur de thèmes (theme.js :
     --violet, --fond, --panneau, --texte…). Les thèmes personnalisés et Bulle+
     continuent donc de fonctionner : ils réécrivent ces jetons en ligne sur <html>.
   • Aucun composant ne doit écrire une couleur en dur : utiliser les jetons.
   • Nouveaux composants : préfixe .e- (voir section 5).
   • Polices : Unbounded (titres, avatars) + Onest (texte), auto-hébergées.

   Retour arrière : retirer <link ecume.css> d'index.html et remettre la
   sauvegarde de bulle.css (les jetons y étaient en sections 0 et 1).
   ========================================================================== */

/* ---------------------------------------------------------------------------
   0. Couleurs par défaut (premier affichage, pages sans theme.js).
   Le moteur de thèmes écrit ses variables en ligne sur <html> : elles priment.
   ------------------------------------------------------------------------- */
:root {
  --violet: #6B4BFF; --accent-2: #F2559F; --accent-3: #1FA9CF; --btn-bg: #6B4BFF; --btn-texte: #fff; --notif: #6B4BFF;
  --fond: #F5F2FC; --panneau: #FFFFFF; --panneau-2: #EFEAFB; --rail: #EDE7FA;
  --texte: #1B1033; --texte-2: #52476E; --texte-3: #857BA2; --texte-msg: #261A40;
  --ligne: #E7E1F5; --ligne-2: #D4CBEC; --vert: #17895A; --rouge: #DE3D59; --or: #B07A0C;
  --shadow-rgb: 27, 16, 51;
}
:root[data-theme="dark"] {
  --violet: #A08CFF; --accent-2: #FF85C4; --accent-3: #6CD6F0; --btn-bg: #7657FF; --btn-texte: #fff; --notif: #A08CFF;
  --fond: #0F0A1E; --panneau: #171128; --panneau-2: #201836; --rail: #0B0716;
  --texte: #F1ECFF; --texte-2: #B8ADD8; --texte-3: #7F759B; --texte-msg: #E6DFFA;
  --ligne: #2A2142; --ligne-2: #3A2F58; --vert: #3FD08E; --rouge: #FF6680; --or: #F0C056;
  --shadow-rgb: 0, 0, 0;
}

/* ---------------------------------------------------------------------------
   1. Jetons
   ------------------------------------------------------------------------- */
:root {
  --font-ui: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-titre: 'Unbounded', 'Onest', system-ui, sans-serif;

  /* Échelle typographique (rem) */
  --fs-xs: .75rem; --fs-sm: .8125rem; --fs-md: .9375rem; --fs-lg: 1.0625rem;
  --fs-xl: 1.3125rem; --fs-2xl: 1.75rem; --fs-3xl: 2.375rem;

  /* Espacement (4 px) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px; --s-12: 48px;

  /* Arrondis : plus généreux que l'ancien système, formes de membrane */
  --r-xs: 8px; --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --r-xl: 28px; --r-full: 999px;

  /* Surfaces dérivées */
  --surface-0: var(--fond);
  --surface-1: var(--panneau);
  --surface-2: var(--panneau-2);
  --surface-hover: color-mix(in srgb, var(--violet) 7%, transparent);
  --surface-press: color-mix(in srgb, var(--violet) 13%, transparent);
  --survol: var(--surface-hover);
  --accent: var(--violet);
  --accent-soft: color-mix(in srgb, var(--violet) 11%, var(--panneau));
  --accent-soft-2: color-mix(in srgb, var(--violet) 19%, var(--panneau));
  --accent-ink: color-mix(in srgb, var(--violet) 82%, var(--texte));
  --violet-clair: var(--accent-soft);
  --violet-clair-2: var(--accent-soft-2);
  --hairline: color-mix(in srgb, var(--violet) 12%, color-mix(in srgb, var(--texte) 6%, transparent));
  --hairline-strong: color-mix(in srgb, var(--violet) 18%, color-mix(in srgb, var(--texte) 10%, transparent));

  /* Signature irisée */
  --iris: linear-gradient(135deg, var(--violet) 0%, var(--accent-2) 52%, var(--accent-3) 100%);
  --iris-ring: conic-gradient(from 210deg, var(--violet), var(--accent-2), var(--accent-3), var(--violet));
  --sheen: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .55) 0 10%, rgba(255, 255, 255, 0) 42%);
  --rim: inset 0 0 0 1px var(--hairline), inset 0 1px 0 rgba(255, 255, 255, .7);
  --nacre: radial-gradient(120% 80% at 0% 0%, color-mix(in srgb, var(--violet) 9%, transparent), transparent 60%),
           radial-gradient(100% 70% at 100% 100%, color-mix(in srgb, var(--accent-3) 7%, transparent), transparent 60%);
  --gold: linear-gradient(135deg, #F7D774, #E2A93B);
  --focus-ring: 0 0 0 2px var(--panneau), 0 0 0 4px color-mix(in srgb, var(--violet) 55%, transparent);

  /* Élévation : ombres teintées d'encre violette */
  --e-1: 0 1px 2px rgba(var(--shadow-rgb, 27, 16, 51), .06);
  --e-2: 0 1px 2px rgba(var(--shadow-rgb, 27, 16, 51), .05), 0 6px 18px -6px rgba(var(--shadow-rgb, 27, 16, 51), .14);
  --e-3: 0 2px 6px rgba(var(--shadow-rgb, 27, 16, 51), .06), 0 20px 48px -14px rgba(var(--shadow-rgb, 27, 16, 51), .26);
  --e-4: 0 4px 12px rgba(var(--shadow-rgb, 27, 16, 51), .08), 0 36px 90px -22px rgba(var(--shadow-rgb, 27, 16, 51), .38);
  --ombre: var(--e-3);
  --voile: color-mix(in srgb, #12091F 50%, transparent);

  /* Mouvement */
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.3, 1.3, .5, 1);
  --ease-pop: cubic-bezier(.34, 1.56, .64, 1);
  --d-1: 120ms; --d-2: 200ms; --d-3: 320ms; --d-pop: 420ms;

  /* Zones de sécurité */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);

  /* Mobile : hauteur de la barre de navigation */
  --tabbar-h: 60px;
}
:root[data-theme="dark"] {
  --surface-hover: color-mix(in srgb, var(--violet) 10%, transparent);
  --surface-press: color-mix(in srgb, var(--violet) 17%, transparent);
  --accent-soft: color-mix(in srgb, var(--violet) 16%, var(--panneau));
  --accent-soft-2: color-mix(in srgb, var(--violet) 27%, var(--panneau));
  --accent-ink: color-mix(in srgb, var(--violet) 74%, #fff);
  --hairline: color-mix(in srgb, var(--violet) 14%, color-mix(in srgb, var(--texte) 5%, transparent));
  --hairline-strong: color-mix(in srgb, var(--violet) 22%, color-mix(in srgb, var(--texte) 8%, transparent));
  --rim: inset 0 0 0 1px var(--hairline), inset 0 1px 0 rgba(255, 255, 255, .06);
  --sheen: radial-gradient(circle at 30% 24%, rgba(255, 255, 255, .32) 0 9%, rgba(255, 255, 255, 0) 40%);
  --voile: color-mix(in srgb, #000 62%, transparent);
  --e-2: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px -6px rgba(0, 0, 0, .45);
  --e-3: 0 2px 6px rgba(0, 0, 0, .35), 0 20px 48px -12px rgba(0, 0, 0, .6);
  --e-4: 0 4px 12px rgba(0, 0, 0, .4), 0 36px 90px -20px rgba(0, 0, 0, .7);
}
:root[data-motion="off"] { --d-1: 0ms; --d-2: 0ms; --d-3: 0ms; --d-pop: 0ms; }
@media (prefers-reduced-motion: reduce) { :root { --d-1: 0ms; --d-2: 0ms; --d-3: 0ms; --d-pop: 0ms; } }

/* ---------------------------------------------------------------------------
   2. Base
   ------------------------------------------------------------------------- */
body { background-color: var(--fond); background-image: var(--nacre); } /* pas de background-attachment: fixed (redessin à chaque défilement) */
h1, h2, h3, h4, .brand { letter-spacing: -.035em; font-weight: var(--fw-titre, 650); }
h1 { font-weight: 700; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); }
::selection { background: color-mix(in srgb, var(--accent-2) 28%, transparent); }

/* ---------------------------------------------------------------------------
   3. Signature : la pression « pop »
   Sur tout ce qui se presse, l'objet s'enfonce puis rebondit au relâchement.
   ------------------------------------------------------------------------- */
.btn, .icon-btn, .e-btn, .e-chip, .e-orb[role="button"], .e-orb[href] {
  transition: transform var(--d-pop) var(--ease-pop), background-color var(--d-1) var(--ease-out),
              color var(--d-1) var(--ease-out), box-shadow var(--d-2) var(--ease-out);
}
.btn:active, .icon-btn:active, .e-btn:active, .e-chip:active { transform: scale(.94); transition-duration: 90ms; }

@keyframes e-burst {
  0%   { transform: scale(1); opacity: 1; }
  45%  { transform: scale(1.12); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}
/* Respiration de la bulle : uniquement la propriété « scale », traitée par le
   compositeur (aucun redessin). Ne jamais animer border-radius en boucle. */
@keyframes e-wobble {
  0%, 100% { scale: 1 1; }
  33% { scale: 1.025 .978; }
  66% { scale: .982 1.02; }
}
@keyframes e-rise {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

/* ---------------------------------------------------------------------------
   4. Composants existants à l'image d'Écume
   ------------------------------------------------------------------------- */
/* Bouton principal : membrane pleine avec reflet sur le bord supérieur */
.btn-primary, :root[data-theme="dark"] .btn-primary {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32), inset 0 0 0 1px rgba(255, 255, 255, .12),
              0 8px 20px -10px color-mix(in srgb, var(--btn-bg, var(--violet)) 80%, transparent);
}
.btn-primary:hover { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32), inset 0 0 0 1px rgba(255, 255, 255, .16),
              0 10px 26px -10px color-mix(in srgb, var(--btn-bg, var(--violet)) 90%, transparent); }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--hairline); }
.btn-soft:hover { background: var(--accent-soft-2); }
.icon-btn { border-radius: var(--r-full); }

/* Champs : capsule claire, reflet violet au focus */
.input, .auth-form input, textarea.input, select.input, .field input {
  background: color-mix(in srgb, var(--panneau) 92%, var(--violet));
  border-color: var(--hairline-strong); box-shadow: none;
}
.input:focus, .auth-form input:focus, textarea.input:focus, select.input:focus {
  background: var(--panneau); box-shadow: 0 0 0 4px color-mix(in srgb, var(--violet) 16%, transparent);
}

/* Avatars : de petites bulles, avec un reflet en haut à gauche */
.avatar { position: relative; }
.avatar::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: var(--sheen); box-shadow: inset 0 -3px 8px rgba(var(--shadow-rgb, 27, 16, 51), .12);
}

/* Cartes et fenêtres : membranes */
.card { border-color: var(--hairline); box-shadow: var(--rim), var(--e-1); }
.modal { border-radius: var(--r-xl); box-shadow: var(--rim), var(--e-4); }
.ctx-menu { border-radius: var(--r-lg); border-color: var(--hairline); box-shadow: var(--rim), var(--e-3); }
.toast { border-radius: var(--r-full); }

/* Pastilles de notification : pastille irisée */
.item .count { background: var(--iris); }

/* ---------------------------------------------------------------------------
   5. Composants Écume (.e-) — à utiliser pour tout nouvel écran
   ------------------------------------------------------------------------- */
/* Bouton */
.e-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px;
  border: 0; border-radius: var(--r-full); font: 650 var(--fs-md)/1 var(--font-ui); letter-spacing: -.01em;
  background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 1px var(--hairline);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.e-btn:hover { background: var(--accent-soft-2); }
.e-btn--primary { background: var(--btn-bg, var(--violet)); color: var(--btn-texte, #fff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .32), inset 0 0 0 1px rgba(255, 255, 255, .12),
              0 8px 20px -10px color-mix(in srgb, var(--btn-bg, var(--violet)) 80%, transparent); }
.e-btn--primary:hover { background: color-mix(in srgb, var(--btn-bg, var(--violet)) 90%, #000); }
.e-btn--iris { background: var(--iris); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 10px 24px -12px var(--accent-2); }
.e-btn--ghost { background: transparent; box-shadow: none; color: var(--texte-2); }
.e-btn--ghost:hover { background: var(--surface-hover); color: var(--texte); }
.e-btn--danger { background: color-mix(in srgb, var(--rouge) 12%, transparent); color: var(--rouge); box-shadow: none; }
.e-btn--sm { min-height: 34px; padding: 0 14px; font-size: var(--fs-sm); }
.e-btn--icon { width: 44px; padding: 0; }
.e-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* Pastille de choix (filtres, intérêts) */
.e-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px; border-radius: var(--r-full);
  border: 0; background: var(--panneau); color: var(--texte-2); box-shadow: inset 0 0 0 1px var(--hairline-strong);
  font: 600 var(--fs-sm)/1 var(--font-ui); cursor: pointer;
}
.e-chip[aria-pressed="true"], .e-chip[aria-checked="true"], .e-chip.on {
  background: var(--texte); color: var(--panneau); box-shadow: none;
}

/* Membrane : la surface de base d'Écume */
.e-card {
  background: var(--panneau); border-radius: var(--r-lg); box-shadow: var(--rim), var(--e-1);
  padding: var(--s-4); min-width: 0;
}
.e-card--nacre { background: var(--panneau); background-image: var(--nacre); }
.e-card--float { box-shadow: var(--rim), var(--e-3); }

/* Bulle d'avatar : bulle avec reflet, anneau irisé optionnel */
.e-orb {
  --size: 44px; position: relative; flex: none; width: var(--size); height: var(--size); border-radius: 50%;
  display: grid; place-items: center; overflow: hidden; background: var(--accent-soft-2); color: var(--texte);
  font: 700 calc(var(--size) * .36)/1 var(--font-titre); letter-spacing: -.02em;
}
.e-orb > img { width: 100%; height: 100%; object-fit: cover; }
.e-orb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: var(--sheen); pointer-events: none;
  box-shadow: inset 0 -4px 10px rgba(var(--shadow-rgb, 27, 16, 51), .14); }
.e-orb--ring { overflow: visible; }
.e-orb--ring::before { content: ""; position: absolute; inset: -3px; border-radius: 50%; background: var(--iris-ring); z-index: -1; }
.e-orb--live { animation: e-wobble 5s ease-in-out infinite; }
:root[data-motion="off"] .e-orb--live { animation: none; }
@media (prefers-reduced-motion: reduce) { .e-orb--live { animation: none; } }

/* Titres de section */
.e-title { font: 700 var(--fs-xl)/1.15 var(--font-titre); letter-spacing: -.035em; margin: 0; color: var(--texte); text-wrap: balance; }
.e-eyebrow { font: 700 var(--fs-xs)/1 var(--font-ui); letter-spacing: .1em; text-transform: uppercase; color: var(--texte-3); }

/* Segment (onglets compacts) */
.e-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r-full); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--hairline); }
.e-seg > button { border: 0; background: transparent; color: var(--texte-2); min-height: 32px; padding: 0 14px; border-radius: var(--r-full); font: 600 var(--fs-sm)/1 var(--font-ui); cursor: pointer; }
.e-seg > button[aria-selected="true"] { background: var(--panneau); color: var(--texte); box-shadow: var(--e-2); }

/* État vide */
.e-empty { display: grid; justify-items: center; gap: var(--s-2); text-align: center; padding: var(--s-8) var(--s-4); color: var(--texte-2); }
.e-empty::before { content: ""; width: 56px; height: 56px; border-radius: 50%; background: var(--sheen), var(--iris); opacity: .85;
  box-shadow: inset 0 -6px 14px rgba(var(--shadow-rgb, 27, 16, 51), .18); margin-bottom: var(--s-2); }
.e-empty b { color: var(--texte); font: 700 var(--fs-lg)/1.2 var(--font-titre); letter-spacing: -.03em; }

/* Apparition douce des éléments d'une liste */
.e-rise { animation: e-rise var(--d-3) var(--ease-out) both; }
:root[data-motion="off"] .e-rise { animation: none; }

/* ---------------------------------------------------------------------------
   6. Garde-fous pour la police de titre (Unbounded est large)
   Dans les en-têtes compacts, le titre se réduit et s'abrège au lieu de
   pousser les boutons hors de l'écran.
   ------------------------------------------------------------------------- */
.smh-title > span { font-size: 1.3rem !important; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.smh-title { min-width: 0; }
.main-head h1 { min-width: 0; }
.side-title h2 { font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Titres : un mot long ne doit jamais élargir sa colonne */
h1, h2, h3 { overflow-wrap: break-word; }
.lp-hero-copy { min-width: 0; }
.lp-title { letter-spacing: -.045em; }
@media (max-width: 760px) { .lp-title { font-size: clamp(27px, 8.4vw, 40px); } }
