/* Einrosen — composants. Classes préfixées er-. Toutes les valeurs viennent de tokens.css. */

.er, .er * { box-sizing: border-box; }
.er { font-family: var(--font-sans); color: var(--ink); -webkit-font-smoothing: antialiased; }
.er-num { font-variant-numeric: tabular-nums; }
.er-icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Bouton ---------- */
.er-btn {
  appearance: none; border: 0; margin: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--button-md); padding: 0 var(--space-6);
  border-radius: var(--radius-full);
  font: 600 16px/1 var(--font-sans); letter-spacing: -0.01em; white-space: nowrap;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.er-btn:active { transform: scale(0.97); }
.er-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.er-btn .er-icon { width: 20px; height: 20px; }
.er-btn--primary { background: var(--accent); color: var(--on-accent); }
.er-btn--primary:active { background: var(--accent-press); }
.er-btn--dark { background: var(--ink); color: var(--on-ink); }
.er-btn--soft { background: var(--surface-2); color: var(--ink); }
.er-btn--soft:active { background: var(--surface-3); }
.er-btn--ghost { background: transparent; color: var(--accent-ink); padding: 0 var(--space-3); }
.er-btn--lg { height: var(--button-lg); padding: 0 var(--space-8); font-size: 17px; }
.er-btn--sm { height: var(--button-sm); padding: 0 var(--space-4); font-size: 14px; }
.er-btn--block { display: flex; width: 100%; }
.er-btn:disabled, .er-btn[aria-disabled="true"] { background: var(--surface-2); color: var(--disabled); cursor: not-allowed; transform: none; }
.er-btn[aria-busy="true"] { pointer-events: none; }

/* Bouton rond d'action (carte de solde) */
.er-action { appearance: none; border: 0; background: none; padding: 0; display: inline-flex; flex-direction: column; align-items: center; gap: var(--space-2); font: 500 13px/18px var(--font-sans); color: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.er-action__icon { width: var(--icon-round); height: var(--icon-round); border-radius: var(--radius-full); background: var(--surface-2); display: grid; place-items: center; transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.er-action:active .er-action__icon { transform: scale(0.94); background: var(--surface-3); }
.er-action--primary .er-action__icon { background: var(--accent); color: var(--on-accent); }
.er-action--primary:active .er-action__icon { background: var(--accent-press); }
.er-action:focus-visible { outline: none; }
.er-action:focus-visible .er-action__icon { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* ---------- Chargements ---------- */
.er-spinner { width: 18px; height: 18px; flex: none; display: inline-block; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; opacity: 0.9; animation: er-spin calc(var(--dur-loop) / 2) linear infinite; }
@keyframes er-spin { to { transform: rotate(360deg); } }

/* Portail (trou de ver) : les anneaux naissent au point de sortie (décalé à droite) et s'ouvrent vers l'extérieur */
.er-portal { width: 56px; height: 56px; flex: none; display: inline-block; overflow: visible; }
.er-portal circle { transform-box: view-box; }
.er-portal .er-portal__rim { fill: none; stroke: var(--ink); }
.er-portal .er-portal__core { fill: var(--accent); }
.er-portal .er-portal__ring { fill: none; stroke: var(--accent); opacity: 0; transform-origin: 67.94px 50px; animation: er-emerge calc(var(--dur-loop) * 1.5) var(--ease-out) infinite; }
.er-portal .er-portal__ring:nth-of-type(3) { animation-delay: calc(var(--dur-loop) * -0.5); }
.er-portal .er-portal__ring:nth-of-type(4) { animation-delay: calc(var(--dur-loop) * -1); }
@keyframes er-emerge { 0% { transform: scale(0.15); opacity: 0; } 20% { opacity: 1; } 100% { transform: scale(1); opacity: 0; } }

/* Squelette (contenu qui charge) */
.er-skeleton { display: block; border-radius: var(--radius-sm); background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: er-shimmer var(--dur-loop) var(--ease-soft) infinite; }
@keyframes er-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* Coche qui apparaît */
.er-check { width: 28px; height: 28px; flex: none; border-radius: var(--radius-full); background: var(--success); color: var(--on-ink); display: inline-grid; place-items: center; }
.er-check svg { width: 62%; height: 62%; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.er-check path { stroke-dasharray: 24; stroke-dashoffset: 0; }
.er-check.is-in { animation: er-pop var(--dur-base) var(--ease-pop) both; }
.er-check.is-in path { animation: er-draw var(--dur-slow) var(--ease-out) calc(var(--dur-fast) / 2) both; }
@keyframes er-pop { from { transform: scale(0.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes er-draw { from { stroke-dashoffset: 24; } to { stroke-dashoffset: 0; } }

/* ---------- Badge ---------- */
.er-badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: var(--radius-full); font: 600 12px/1 var(--font-sans); letter-spacing: 0.01em; white-space: nowrap; }
.er-badge .er-icon { width: 14px; height: 14px; stroke-width: 2.2; }
.er-badge .er-spinner { width: 11px; height: 11px; border-width: 1.75px; }
.er-badge--pending { background: var(--pending-soft); color: var(--pending); }
.er-badge--success { background: var(--success-soft); color: var(--success); }
.er-badge--secure { background: var(--ink); color: var(--on-ink); }
.er-badge--error { background: var(--error-soft); color: var(--error); }
.er-badge--neutral { background: var(--surface-2); color: var(--ink-2); }
.er-badge--sm { height: 22px; padding: 0 8px; font-size: 11px; }
.er-badge.is-in { animation: er-fade-up var(--dur-base) var(--ease-out) both; }
@keyframes er-fade-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Champ de montant ---------- */
.er-amount { background: var(--surface-2); border-radius: var(--radius-md); padding: var(--space-4); display: grid; gap: var(--space-2); transition: box-shadow var(--dur-fast) var(--ease-out); }
.er-amount:focus-within { box-shadow: inset 0 0 0 2px var(--ink); }
.er-amount__top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); font: 500 13px/18px var(--font-sans); color: var(--muted); }
.er-amount__row { display: flex; align-items: center; gap: var(--space-3); }
.er-amount__currency { display: inline-flex; align-items: center; gap: 6px; height: var(--button-sm); padding: 0 10px 0 6px; border: 0; border-radius: var(--radius-full); background: var(--surface); color: var(--ink); font: 600 15px/1 var(--font-sans); cursor: pointer; flex: none; }
.er-amount__currency .er-cur-dot { width: 24px; height: 24px; border-radius: var(--radius-full); background: var(--ink); color: var(--on-ink); display: grid; place-items: center; font: 700 13px/1 var(--font-sans); }
.er-amount__currency .er-icon { width: 16px; height: 16px; color: var(--muted); }
.er-amount__input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; text-align: right; color: var(--ink); caret-color: var(--accent); font: 700 34px/40px var(--font-sans); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; padding: 0; }
.er-amount__input::placeholder { color: var(--muted); }
.er-amount__hint { font: 400 13px/18px var(--font-sans); color: var(--muted); min-height: 18px; }
.er-amount.is-error { box-shadow: inset 0 0 0 2px var(--error); }
.er-amount.is-error .er-amount__hint { color: var(--error); }
.er-chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.er-chip { appearance: none; border: 0; height: 32px; padding: 0 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); font: 600 13px/1 var(--font-sans); font-variant-numeric: tabular-nums; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out); }
.er-chip:active { background: var(--surface-3); }
.er-chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- Carte de solde ---------- */
.er-balance { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-6); display: grid; gap: var(--space-2); }
.er-balance__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font: 500 13px/18px var(--font-sans); color: var(--muted); }
.er-balance__amount { font: 700 44px/48px var(--font-sans); letter-spacing: -0.035em; font-variant-numeric: tabular-nums; color: var(--ink); margin-top: var(--space-1); }
.er-balance__amount small { font-size: 0.55em; letter-spacing: -0.02em; color: var(--ink); }
.er-balance__delta { font: 500 13px/18px var(--font-sans); color: var(--muted); }
.er-balance__delta b { color: var(--success); font-weight: 600; }
.er-balance__actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-2); margin-top: var(--space-6); justify-items: center; }

/* ---------- Ligne de transaction ---------- */
.er-list { list-style: none; margin: 0; padding: 0; }
.er-tx { display: flex; align-items: center; gap: var(--space-3); min-height: 72px; padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.er-list > .er-tx:last-child { border-bottom: 0; }
.er-tx__icon { width: var(--icon-round); height: var(--icon-round); flex: none; border-radius: var(--radius-full); background: var(--surface-2); color: var(--ink); display: grid; place-items: center; font: 600 15px/1 var(--font-sans); }
.er-tx__icon .er-icon { width: 20px; height: 20px; }
.er-tx__main { flex: 1; min-width: 0; }
.er-tx__title { font: 600 16px/22px var(--font-sans); letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.er-tx__sub { font: 500 13px/18px var(--font-sans); color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.er-tx__end { display: grid; justify-items: end; gap: 4px; flex: none; }
.er-tx__amount { font: 600 16px/22px var(--font-sans); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; color: var(--ink); }
.er-tx__amount--in { color: var(--success); }
.er-tx__amount--void { color: var(--muted); text-decoration: line-through; }

/* ---------- Étapes ---------- */
.er-steps { list-style: none; margin: 0; padding: 0; display: grid; }
.er-step { position: relative; display: grid; grid-template-columns: 28px 1fr; column-gap: var(--space-4); padding-bottom: var(--space-6); }
.er-step:last-child { padding-bottom: 0; }
.er-step::before { content: ""; position: absolute; left: 13px; top: 32px; bottom: 4px; width: 2px; border-radius: 2px; background: var(--line); transition: background-color var(--dur-slow) var(--ease-out); }
.er-step:last-child::before { display: none; }
.er-step.is-done::before { background: var(--success); }
.er-step__mark { width: 28px; height: 28px; display: grid; place-items: center; }
.er-step__dot { width: 28px; height: 28px; border-radius: var(--radius-full); box-shadow: inset 0 0 0 2px var(--line-strong); }
.er-step.is-active .er-step__mark { color: var(--pending); }
.er-step.is-active .er-spinner { width: 22px; height: 22px; border-width: 2.5px; }
.er-step__title { font: 600 16px/22px var(--font-sans); letter-spacing: -0.01em; color: var(--ink); padding-top: 3px; transition: color var(--dur-base) var(--ease-out); }
.er-step__sub { font: 500 13px/18px var(--font-sans); color: var(--muted); margin-top: 2px; }
.er-step__sub code { font: 450 12px/18px var(--font-mono); }
.er-step:not(.is-done):not(.is-active) .er-step__title { color: var(--muted); }
.er-step.is-error .er-step__dot { box-shadow: none; background: var(--error); }

/* ---------- Notification ---------- */
.er-toast { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-md); }
.er-toast.is-in { animation: er-drop var(--dur-base) var(--ease-out) both; }
@keyframes er-drop { from { opacity: 0; transform: translateY(-12px) scale(0.98); } to { opacity: 1; transform: none; } }
.er-toast__icon { width: 36px; height: 36px; flex: none; border-radius: var(--radius-full); display: grid; place-items: center; }
.er-toast__icon .er-icon { width: 18px; height: 18px; stroke-width: 2.2; }
.er-toast__icon .er-spinner { width: 16px; height: 16px; }
.er-toast__icon--success { background: var(--success-soft); color: var(--success); }
.er-toast__icon--pending { background: var(--pending-soft); color: var(--pending); }
.er-toast__icon--error { background: var(--error-soft); color: var(--error); }
.er-toast__icon--brand { background: var(--accent); color: var(--on-accent); }
.er-toast__body { flex: 1; min-width: 0; }
.er-toast__title { font: 600 15px/20px var(--font-sans); letter-spacing: -0.01em; }
.er-toast__text { font: 400 14px/20px var(--font-sans); color: var(--muted); margin-top: 2px; }
.er-toast__time { font: 500 12px/20px var(--font-sans); color: var(--muted); flex: none; }

/* ---------- Barre de navigation du bas ---------- */
.er-tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; height: var(--tabbar); background: var(--surface); border-top: 1px solid var(--line); padding: 0 var(--space-2); }
.er-tab { position: relative; appearance: none; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--muted); font: 600 11px/14px var(--font-sans); letter-spacing: 0.01em; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent; transition: color var(--dur-fast) var(--ease-out); }
.er-tab .er-icon { transition: transform var(--dur-fast) var(--ease-out); }
.er-tab:active .er-icon { transform: scale(0.9); }
.er-tab[aria-current="page"] { color: var(--ink); }
.er-tab[aria-current="page"]::before { content: ""; position: absolute; top: 6px; width: 4px; height: 4px; border-radius: var(--radius-full); background: var(--accent); animation: er-pop var(--dur-base) var(--ease-pop) both; }
.er-tab:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -4px; border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  .er-spinner, .er-portal .er-portal__ring, .er-skeleton { animation-duration: calc(var(--dur-loop) * 3); }
  .er-check.is-in, .er-check.is-in path, .er-toast.is-in, .er-badge.is-in { animation: none; }
}
