/* ============================================================
   Reely Links — Design System « Indigo & Sage »
   Tokens issus de inspiration/indigo_sage/DESIGN.md
   ============================================================ */

:root {
  /* --- Couleurs de base (thème par défaut) --- */
  --surface: #f9f9ff;
  --surface-dim: #cfdaf2;
  --surface-lowest: #ffffff;
  --surface-low: #f0f3ff;
  --surface-container: #e7eeff;
  --surface-high: #dee8ff;
  --surface-highest: #d8e3fb;
  --on-surface: #111c2d;
  --on-surface-variant: #464554;
  --inverse-surface: #263143;
  --inverse-on-surface: #ecf1ff;
  --outline: #767586;
  --outline-variant: #c7c4d7;

  --primary: #4648d4;
  --primary-hover: #494bd6;
  --on-primary: #ffffff;
  --primary-container: #6063ee;
  --primary-fixed: #e1e0ff;

  --secondary: #52625c;
  --secondary-container: #d3e3dc;
  --on-secondary-container: #566660;

  --tertiary: #595c5e;
  --error: #ba1a1a;
  --error-container: #ffdad6;
  --on-error-container: #93000a;
  --success: #2e7d54;
  --success-container: #d3e3dc;

  /* --- Typographie --- */
  --font-display: 'Montserrat', ui-sans-serif, system-ui, sans-serif;
  --font-body: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;

  /* --- Rayons --- */
  --r-sm: 0.25rem;
  --r: 0.5rem;
  --r-md: 0.75rem;
  --r-lg: 1rem;
  --r-xl: 1.5rem;
  --r-2xl: 1.75rem;
  --r-full: 9999px;

  /* --- Espacement (base 8px) --- */
  --base: 8px;
  --stack-sm: 12px;
  --stack-md: 24px;
  --stack-lg: 48px;
  --gutter: 16px;
  --margin-mobile: 20px;
  --container-max: 640px;

  /* --- Élévation --- */
  --e1: 0 4px 20px rgba(30, 41, 59, .05);
  --e2: 0 8px 30px rgba(30, 41, 59, .08);
  --e3: 0 20px 40px rgba(70, 72, 212, .12);

  --ring: 0 0 0 4px color-mix(in srgb, var(--primary) 12%, transparent);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

/* --- Mode sombre (activé par [data-mode="dark"]) --- */
[data-mode="dark"] {
  --surface: #0e1220;
  --surface-dim: #0a0d18;
  --surface-lowest: #171c2e;
  --surface-low: #141928;
  --surface-container: #1c2236;
  --surface-high: #232a41;
  --surface-highest: #2a3350;
  --on-surface: #e8ecff;
  --on-surface-variant: #b3b7cc;
  --inverse-surface: #e8ecff;
  --inverse-on-surface: #1c2236;
  --outline: #6c7590;
  --outline-variant: #333a52;
  --primary-fixed: #262a63;
  --secondary-container: #24382f;
  --on-secondary-container: #a9cfbd;
  --tertiary: #9aa0b4;
  --error-container: #4d1414;
  --on-error-container: #ffb4ab;
  --e1: 0 4px 20px rgba(0, 0, 0, .35);
  --e2: 0 8px 30px rgba(0, 0, 0, .45);
  --e3: 0 20px 40px rgba(0, 0, 0, .5);
}

/* ============================================================
   Reset
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--on-surface);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p, figure { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: var(--r); }
::selection { background: var(--primary); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ============================================================
   Typographie
   ============================================================ */
.t-display   { font-family: var(--font-display); font-size: clamp(30px, 7vw, 44px); font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.t-head-lg   { font-family: var(--font-display); font-size: 32px; font-weight: 700; line-height: 1.2; letter-spacing: -.01em; }
.t-head-md   { font-family: var(--font-display); font-size: 20px; font-weight: 600; line-height: 1.4; }
.t-head-sm   { font-family: var(--font-display); font-size: 16px; font-weight: 600; line-height: 1.35; }
.t-body-lg   { font-size: 18px; line-height: 1.6; }
.t-body      { font-size: 16px; line-height: 1.5; }
.t-label     { font-size: 14px; font-weight: 500; line-height: 1.4; letter-spacing: .01em; }
.t-label-sm  { font-size: 12px; font-weight: 600; line-height: 1.2; }
.muted       { color: var(--tertiary); }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-1     { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.clamp-2     { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-only     { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ============================================================
   Primitives
   ============================================================ */
[hidden] { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 20px;
  border-radius: var(--r-xl);
  font-family: var(--font-body); font-size: 15px; font-weight: 600;
  transition: background .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease), color .2s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn svg { width: 20px; height: 20px; flex: none; }

.btn-primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--e1); }
.btn-primary:hover { background: var(--primary-container); transform: translateY(-1px); box-shadow: var(--e2); }

.btn-ghost { background: var(--surface-lowest); color: var(--on-surface); box-shadow: var(--e1); }
.btn-ghost:hover { background: var(--surface-high); }

.btn-quiet { background: transparent; color: var(--on-surface-variant); }
.btn-quiet:hover { background: var(--surface-container); color: var(--on-surface); }

.btn-danger { background: var(--error-container); color: var(--on-error-container); }
.btn-danger:hover { filter: brightness(.96); }

.btn-sm { height: 38px; padding: 0 14px; font-size: 14px; border-radius: var(--r-md); }
.btn-icon { width: 40px; height: 40px; padding: 0; border-radius: var(--r-md); color: var(--tertiary); }
.btn-icon:hover { background: var(--surface-container); color: var(--on-surface); }
.btn-block { width: 100%; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--r-full);
  background: var(--secondary-container); color: var(--on-secondary-container);
  font-size: 12px; font-weight: 600; letter-spacing: .01em;
}
.chip-primary { background: var(--primary-fixed); color: var(--primary); }
.chip-outline { background: transparent; border: 1px solid var(--outline-variant); color: var(--on-surface-variant); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--on-surface-variant); }
.input, .textarea, .select {
  width: 100%; min-height: 48px; padding: 12px 14px;
  background: var(--surface-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--r-md);
  color: var(--on-surface);
  transition: border-color .2s, box-shadow .2s;
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--outline); }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.hint { font-size: 12px; color: var(--tertiary); }

.switch { position: relative; display: inline-flex; width: 44px; height: 26px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: var(--r-full);
  background: var(--outline-variant); transition: background .2s var(--ease);
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .22s var(--ease);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { box-shadow: var(--ring); }

.card {
  background: var(--surface-lowest);
  border-radius: var(--r-2xl);
  box-shadow: var(--e1);
}
.divider { height: 1px; background: var(--outline-variant); opacity: .6; border: 0; margin: 0; }

.avatar-fallback {
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
  color: #fff; font-family: var(--font-display); font-weight: 700;
}

/* Toasts */
.toast-host {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px; border-radius: var(--r-full);
  background: var(--inverse-surface); color: var(--inverse-on-surface);
  font-size: 14px; font-weight: 500; box-shadow: var(--e2);
  animation: toast-in .35s var(--ease);
}
.toast svg { width: 18px; height: 18px; }
.toast.is-out { animation: toast-out .25s var(--ease) forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px) scale(.97); } }
