/*
 * FLOWAYZ — COMPOSANTS REFONTE (Sprint 1.2, refonte 2026-04-26)
 *
 * Composants core spec'd dans handoff/02-components-spec.md, utilisant les
 * tokens unifiés via tokens/handoff_aliases.css (--bg-canvas, --r-md,
 * --density-y, --motion-mult, etc.).
 *
 * Naming convention : BEM-like (.btn / .btn--primary / .btn__icon).
 * Coexistence avec composants existants (.btn-primary, .card, .form-input)
 * dans components/* — ces fichiers restent inchangés. Migration progressive
 * sprint après sprint.
 *
 * Red lines (cf. handoff/01-design-system.md §10) :
 * - Aucun #hex hardcodé (tout via var)
 * - Aucun text-white sur bg-accent (--accent-contrast est auto)
 * - Aucun transform: scale au hover sur cards/lists/sections
 * - Aucun bounce easing
 */

/* =============================================================================
   BUTTON — handoff §02 Button
   ============================================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--density-y) calc(var(--density-x) + 4px);
  font-family: var(--font-body, var(--font-primary));
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.005em;
  white-space: nowrap;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  transition:
    background var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow-accent);
}
.btn--primary:hover { filter: brightness(0.96); }

[data-gradient="on"] .btn--primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong, var(--accent-hover)) 100%);
}

.btn--secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default, var(--border-handoff));
}
.btn--secondary:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong, var(--border-strong-handoff));
}

.btn--ghost {
  background: transparent;
  color: var(--text-primary);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--bg-hover); }

.btn--soft {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn--soft:hover { filter: brightness(0.97); }

.btn--danger {
  background: var(--danger, #EF4444);
  color: var(--text-inverse, #FFFFFF);
}
.btn--danger:hover { filter: brightness(0.95); }

.btn--link {
  background: transparent;
  color: var(--accent);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 0;
}

/* Sizes */
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--lg { padding: 14px 22px; font-size: 15px; border-radius: var(--r-md); }
.btn--xl { padding: 18px 28px; font-size: 16px; border-radius: var(--r-md); }
.btn--icon { padding: 8px; width: 36px; height: 36px; }

.btn__icon { width: 18px; height: 18px; flex-shrink: 0; }
.btn[aria-busy="true"] .btn__label { opacity: 0.5; }

/* Loading shimmer at the bottom edge — Sprint 1 polish 2026-05-06.
   Plays while the button is in flight (aria-busy or .btn-loading). */
.btn[aria-busy="true"],
.btn-loading {
  position: relative;
  overflow: hidden;
  cursor: progress;
  pointer-events: none;
}
.btn[aria-busy="true"]::after,
.btn-loading::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  width: 30%;
  background: linear-gradient(90deg, transparent, currentColor, transparent);
  opacity: 0.85;
  animation: fz-btn-loading-shimmer 1.2s linear infinite;
  pointer-events: none;
}
@keyframes fz-btn-loading-shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(330%); }
}
@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy="true"]::after,
  .btn-loading::after { animation: none !important; opacity: 0.4; width: 100%; }
}
[data-animations="off"] .btn[aria-busy="true"]::after,
[data-animations="off"] .btn-loading::after { animation: none !important; }

/* =============================================================================
   CARD — handoff §02 Card
   ============================================================================= */
.fz-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default, var(--border-handoff));
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}
.fz-card:hover {
  border-color: var(--border-strong, var(--border-strong-handoff));
  box-shadow: var(--shadow-md);
  /* PAS de transform: scale — red line handoff */
}

.fz-card--flat     { box-shadow: none; }
.fz-card--elevated { box-shadow: var(--shadow-md); }
.fz-card--glow     { box-shadow: 0 0 0 1px var(--accent), 0 12px 24px -12px var(--accent); }
.fz-card--accent   { background: var(--accent-soft); border-color: var(--accent); }

.fz-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 0 16px;
}
.fz-card__title { font-weight: 600; font-size: 16px; color: var(--text-primary); margin: 0; }
.fz-card__meta  { font-size: 12px; color: var(--text-muted, var(--text-muted-handoff)); }
.fz-card__body  { padding: 16px; }
.fz-card__foot  { padding: 0 16px 16px 16px; display: flex; gap: 8px; justify-content: flex-end; }

/* =============================================================================
   FIELD / INPUT / TEXTAREA — handoff §02 Input
   ============================================================================= */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary, var(--text-secondary-handoff));
  letter-spacing: -0.005em;
}
.field__input,
.field__textarea,
.field__select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-default, var(--border-handoff));
  border-radius: var(--r-md);
  font: 400 15px var(--font-body, var(--font-primary));
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.field__textarea { min-height: 96px; resize: vertical; }
.field__input:focus,
.field__textarea:focus,
.field__select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field__input::placeholder,
.field__textarea::placeholder { color: var(--text-muted, var(--text-muted-handoff)); }
.field__hint  { font-size: 12px; color: var(--text-muted, var(--text-muted-handoff)); }
.field__error { font-size: 12px; color: var(--danger, #EF4444); }

/* =============================================================================
   PILL / BADGE — handoff §02 Pill
   ============================================================================= */
.fz-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border-radius: var(--r-pill);
  background: var(--bg-muted);
  color: var(--text-secondary, var(--text-secondary-handoff));
  border: 1px solid var(--border-faint);
  white-space: nowrap;
}
.fz-pill--neutral { /* default */ }
.fz-pill--accent  { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.fz-pill--success { background: var(--success-soft, rgba(34,197,94,0.14)); color: var(--success, #16A34A); border-color: transparent; }
.fz-pill--warning { background: var(--warning-soft, rgba(245,158,11,0.14)); color: var(--warning, #F59E0B); border-color: transparent; }
.fz-pill--danger  { background: var(--danger-soft, rgba(239,68,68,0.14)); color: var(--danger, #EF4444); border-color: transparent; }
.fz-pill--solid   { background: var(--accent); color: var(--accent-contrast); border-color: transparent; }
.fz-pill--outline { background: transparent; border-color: var(--border-strong, var(--border-strong-handoff)); }

.fz-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; background: currentColor; }

/* =============================================================================
   SIDEBAR — handoff §02 Sidebar
   ============================================================================= */
.fz-sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-faint);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  transition: width var(--dur) var(--ease-out);
}
[data-density="compact"] .fz-sidebar { width: 220px; }
.fz-sidebar[data-collapsed="true"] { width: 64px; }
.fz-sidebar[data-collapsed="true"] .fz-sidebar__label,
.fz-sidebar[data-collapsed="true"] .fz-sidebar__brand-name { display: none; }

[data-gradient="on"] .fz-sidebar {
  background: linear-gradient(180deg,
    var(--bg-sidebar) 0%,
    var(--bg-sidebar) 50%,
    color-mix(in oklch, var(--accent) 8%, var(--bg-sidebar)) 100%);
}

.fz-sidebar__brand {
  padding: 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-faint);
}
.fz-sidebar__nav {
  display: flex; flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  flex: 1; overflow-y: auto;
}
.fz-sidebar__link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: var(--text-secondary, var(--text-secondary-handoff));
  font-size: 14px; font-weight: 500;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
  position: relative;
}
.fz-sidebar__link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  /* PAS de transform: scale — red line handoff */
}
.fz-sidebar__link[aria-current="page"],
.fz-sidebar__link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}
.fz-sidebar__link[aria-current="page"]::before,
.fz-sidebar__link.is-active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}
.fz-sidebar__icon { width: 20px; height: 20px; flex-shrink: 0; }
.fz-sidebar__bottom {
  padding: 12px 16px;
  border-top: 1px solid var(--border-faint);
  display: flex; flex-direction: column; gap: 8px;
}

/* =============================================================================
   TOPBAR — handoff §02 Topbar
   ============================================================================= */
.fz-topbar {
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border-faint);
  backdrop-filter: blur(12px);
  background: color-mix(in oklch, var(--bg-canvas) 80%, transparent);
}
.fz-topbar__left,
.fz-topbar__right { display: flex; align-items: center; gap: 12px; }
.fz-topbar__center { flex: 1; max-width: 480px; }

/* =============================================================================
   MODAL — handoff §02 Modal
   ============================================================================= */
.fz-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.fz-modal {
  background: var(--bg-elev);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  border: 1px solid var(--border-faint);
}
.fz-modal--lg { max-width: 720px; }
.fz-modal--xl { max-width: 920px; }
.fz-modal__head {
  padding: 20px 24px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border-faint);
}
.fz-modal__title { font-weight: 600; font-size: 18px; color: var(--text-primary); margin: 0; }
.fz-modal__body { padding: 24px; }
.fz-modal__foot {
  padding: 16px 24px;
  display: flex; gap: 8px; justify-content: flex-end;
  border-top: 1px solid var(--border-faint);
}

/* =============================================================================
   TOAST — handoff §02 Toast
   ============================================================================= */
.fz-toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg-elev);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-faint);
  display: flex; align-items: center; gap: 10px;
  z-index: 200;
  max-width: 420px;
  animation: fz-toast-in calc(200ms * var(--motion-mult)) var(--ease-out);
}
.fz-toast--info    { border-left: 3px solid var(--info, #3B82F6); }
.fz-toast--success { border-left: 3px solid var(--success, #16A34A); }
.fz-toast--warning { border-left: 3px solid var(--warning, #F59E0B); }
.fz-toast--danger  { border-left: 3px solid var(--danger, #EF4444); }
@keyframes fz-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 640px) {
  .fz-toast { left: 24px; right: 24px; bottom: 80px; max-width: none; }
}

/* =============================================================================
   SKELETON — handoff §02 Skeleton + handoff/code/base.css .skel
   ============================================================================= */
.fz-skeleton {
  background: linear-gradient(90deg,
    var(--bg-muted) 0%,
    color-mix(in oklch, var(--bg-muted) 60%, white) 50%,
    var(--bg-muted) 100%);
  background-size: 200% 100%;
  animation: fz-shimmer calc(1.5s / max(var(--motion-mult), 0.001)) linear infinite;
  border-radius: var(--r-sm);
}
.fz-skeleton--text  { height: 1em; margin: 4px 0; }
.fz-skeleton--block { width: 100%; }
@keyframes fz-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* =============================================================================
   STREAMING CURSOR — handoff §base.css
   ============================================================================= */
.fz-cursor-blink::after {
  content: "▌";
  display: inline-block;
  margin-left: 2px;
  color: var(--accent);
  animation: fz-blink 1.2s step-end infinite;
}
@keyframes fz-blink { 50% { opacity: 0; } }

/* =============================================================================
   STAGGER REVEAL — fadeUp depuis handoff/code/base.css .reveal
   ============================================================================= */
.fz-reveal {
  animation: fz-fade-up calc(450ms * var(--motion-mult)) var(--ease-out) both;
}
.fz-reveal[data-i] { animation-delay: calc(var(--i, 0) * 50ms); }
@keyframes fz-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =============================================================================
   EMPTY STATE — handoff §02 Empty
   ============================================================================= */
.fz-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 64px 24px;
  text-align: center;
  gap: 16px;
}
.fz-empty__icon {
  width: 48px; height: 48px;
  color: var(--text-muted, var(--text-muted-handoff));
  margin-bottom: 8px;
}
.fz-empty__title {
  font-size: 18px; font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.fz-empty__sub {
  font-size: 14px;
  color: var(--text-secondary, var(--text-secondary-handoff));
  max-width: 320px;
  margin: 0;
}

/* =============================================================================
   TYPOGRAPHY HELPERS — handoff §base.css
   ============================================================================= */
.fz-h-display {
  font-family: var(--font-display, 'Fraunces', serif);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.fz-h-display--italic { font-style: italic; }
.fz-h-display-md {
  font-family: var(--font-display, 'Fraunces', serif);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.fz-h-mono {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-weight: 500;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* =============================================================================
   LAYOUT PRIMITIVES — handoff §01-design-system §9
   ============================================================================= */
.fz-container        { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.fz-container--wide  { max-width: 1400px; }
.fz-container--narrow{ max-width: 720px; }

.fz-grid    { display: grid; gap: 24px; }
.fz-grid--3 { grid-template-columns: repeat(3, 1fr); }
.fz-grid--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 768px) {
  .fz-grid--3, .fz-grid--4 { grid-template-columns: 1fr; }
}

.fz-stack > * + * { margin-top: var(--gap, 16px); }
.fz-stack--sm { --gap: 8px; }
.fz-stack--md { --gap: 16px; }
.fz-stack--lg { --gap: 32px; }

/* =============================================================================
   UTILITY FOCUS RING — handoff §01-design-system
   ============================================================================= */
.fz-focusable:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* =============================================================================
   ACCESSIBILITY — prefers-reduced-motion handled via --motion-mult in aliases
   Additional safety: hard-disable transform animations when reduced-motion is on
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
  .fz-reveal,
  .fz-toast,
  .fz-cursor-blink::after { animation: none !important; }
}
