/* ── Google Fonts — import unique, chargé une seule fois via tokens.css ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;900&family=DM+Sans:wght@300;400;500;600&display=swap');

/*
 * ╔══════════════════════════════════════════════════════════════════════╗
 * ║         FABELLA DESIGN TOKENS — Source unique de vérité (Web)        ║
 * ║                                                                      ║
 * ║  Parfaitement alignés avec le système iOS :                          ║
 * ║    • FabellaColors.swift     (couleurs)                              ║
 * ║    • FabellaTypography.swift (typographie)                           ║
 * ║    • DesignTokens.swift      (spacing, radius, shadows…)             ║
 * ║                                                                      ║
 * ║  Utilisation : importer ce fichier EN PREMIER dans chaque page.      ║
 * ║  Toujours utiliser var(--token) — jamais une valeur hex brute.       ║
 * ╚══════════════════════════════════════════════════════════════════════╝
 */

/* ─────────────────────────────────────────────────────────────────────────
   RESET
   ───────────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─────────────────────────────────────────────────────────────────────────
   CUSTOM PROPERTIES (dark mode — default, matches OLED app)
   ───────────────────────────────────────────────────────────────────────── */
:root {

  /* ── Backgrounds ─────────────────────────────────────────────────────── */
  /* FabellaColors.backgroundPrimary   → dark: #0A0A0A */
  --bg-primary:          #0A0A0A;
  /* FabellaColors.backgroundSecondary → dark: #111111 */
  --bg-secondary:        #111111;
  /* Viewer / full-screen immersive (always dark) */
  --bg-viewer:           #000000;

  /* ── Surfaces ────────────────────────────────────────────────────────── */
  /* FabellaColors.surfaceCard         → dark: #161616 */
  --surface-card:        #161616;
  /* FabellaColors.surfaceElevated     → dark: #1C1C1C */
  --surface-elevated:    #1C1C1C;
  /* FabellaColors.surfaceHighlight    → dark: #242424 */
  --surface-highlight:   #242424;
  /* FabellaColors.surfaceSheet        → dark: #0F0F0F */
  --surface-sheet:       #0F0F0F;

  /* ── Labels / Text ───────────────────────────────────────────────────── */
  /* FabellaColors.labelPrimary        → dark: #F5F5F5 */
  --text-primary:        #F5F5F5;
  /* FabellaColors.labelSecondary      → system .secondary (~60% white) */
  --text-secondary:      rgba(245, 245, 245, 0.60);
  /* FabellaColors.labelTertiary       → system .tertiaryLabel (~35%) */
  --text-tertiary:       rgba(245, 245, 245, 0.35);
  /* Alias pratiques */
  --text-muted:          rgba(245, 245, 245, 0.45);
  --text-heading:        #F5F5F5;

  /* ── Borders ─────────────────────────────────────────────────────────── */
  /* FabellaColors.borderSubtle        → white 7% */
  --border-subtle:       rgba(255, 255, 255, 0.07);
  /* FabellaColors.borderMedium        → white 12% */
  --border-medium:       rgba(255, 255, 255, 0.12);

  /* ── Brand Gradient ──────────────────────────────────────────────────── */
  /* FabellaColors.brandStart          → #BE123C (Crimson) */
  --brand-start:         #BE123C;
  /* FabellaColors.brandEnd            → #6366F1 (Indigo) */
  --brand-end:           #6366F1;
  /* FabellaColors.brandGradient (horizontal) */
  --brand-gradient:      linear-gradient(90deg, #BE123C, #6366F1);
  /* FabellaColors.brandGradientDiagonal */
  --brand-gradient-diag: linear-gradient(135deg, #BE123C, #6366F1);

  /* ── Tint / Accent ───────────────────────────────────────────────────── */
  /* FabellaColors.tintAccent          → #6366F1 (Indigo, identique dark+light) */
  --accent:              #6366F1;
  --accent-soft:         rgba(99, 102, 241, 0.75);
  --accent-glow:         rgba(99, 102, 241, 0.18);

  /* ── Reactions ───────────────────────────────────────────────────────── */
  /* FabellaColors.reactionAmazing     → #BE123C */
  --reaction-amazing:    #BE123C;
  --reaction-amazing-glow: rgba(190, 18, 60, 0.18);
  /* FabellaColors.reactionLivedIt     → #7C3AED */
  --reaction-lived-it:   #7C3AED;
  --reaction-lived-it-glow: rgba(124, 58, 237, 0.18);
  /* FabellaColors.reactionWasThere    → #F97316 */
  --reaction-was-there:  #F97316;
  --reaction-was-there-glow: rgba(249, 115, 22, 0.18);

  /* ── Status ──────────────────────────────────────────────────────────── */
  /* FabellaColors.statusSuccess       → #10B981 */
  --status-success:      #10B981;
  --status-success-bg:   rgba(16, 185, 129, 0.12);
  /* FabellaColors.statusDanger        → #E53E3E */
  --status-danger:       #E53E3E;
  --status-danger-bg:    rgba(229, 62, 62, 0.12);
  /* FabellaColors.statusWarning       → #F59E0B */
  --status-warning:      #F59E0B;
  --status-warning-bg:   rgba(245, 158, 11, 0.12);
  /* FabellaColors.statusInfo          → #0EA5E9 */
  --status-info:         #0EA5E9;
  --status-info-bg:      rgba(14, 165, 233, 0.12);

  /* ─────────────────────────────────────────────────────────────────────
     TYPOGRAPHY
     FabellaTypography.swift → SF Pro Rounded (iOS) = Inter (web, closest match)
     Fallback stack: Inter → DM Sans → system-ui → sans-serif
     ───────────────────────────────────────────────────────────────────── */
  --font-sans:    'Inter', 'DM Sans', -apple-system, BlinkMacSystemFont,
                  'Segoe UI', system-ui, sans-serif;
  --font-serif:   'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* Échelle typographique (DesignTokens.swift → FabellaFontStyle) */
  --text-display:  28px;   /* FabellaFontStyle.display  — section headers */
  --text-title1:   22px;   /* FabellaFontStyle.title1   — screen titles   */
  --text-title2:   18px;   /* FabellaFontStyle.title2   — card titles     */
  --text-body:     15px;   /* FabellaFontStyle.body     — readable text   */
  --text-label:    13px;   /* FabellaFontStyle.label    — metadata        */
  --text-caption:  11px;   /* FabellaFontStyle.caption  — timestamps      */

  /* Graisses */
  --weight-regular:   400;
  --weight-medium:    500;
  --weight-semibold:  600;
  --weight-bold:      700;
  --weight-heavy:     800;
  --weight-black:     900;

  /* Hauteurs de ligne */
  --leading-tight:    1.2;
  --leading-snug:     1.4;
  --leading-normal:   1.55;
  --leading-relaxed:  1.7;

  /* ─────────────────────────────────────────────────────────────────────
     SPACING (DesignTokens.swift → FabellaSpacing)
     Base 4-pt grid
     ───────────────────────────────────────────────────────────────────── */
  --space-micro: 2px;
  --space-xs:    4px;
  --space-sm:    8px;
  --space-md:    12px;
  --space-base:  16px;
  --space-lg:    20px;
  --space-xl:    24px;
  --space-xxl:   32px;
  --space-xxxl:  40px;
  --space-jumbo: 48px;
  --space-giant: 64px;

  /* ─────────────────────────────────────────────────────────────────────
     BORDER RADIUS (DesignTokens.swift → FabellaRadius)
     ───────────────────────────────────────────────────────────────────── */
  --radius-xs:   4px;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;    /* cartes principales — valeur par défaut */
  --radius-xl:   20px;    /* modales, bottom sheets */
  --radius-xxl:  24px;    /* feature tiles */
  --radius-full: 999px;   /* pilules, avatars */

  /* ─────────────────────────────────────────────────────────────────────
     SHADOWS (DesignTokens.swift → ShadowElevation)
     ───────────────────────────────────────────────────────────────────── */
  --shadow-none:   none;
  /* ShadowElevation.low    → radius 6, y 3, opacity 6% */
  --shadow-low:    0 3px 6px rgba(0, 0, 0, 0.06);
  /* ShadowElevation.medium → radius 10, y 5, opacity 12% */
  --shadow-md:     0 5px 10px rgba(0, 0, 0, 0.12);
  /* ShadowElevation.high   → radius 16, y 8, opacity 20% */
  --shadow-high:   0 8px 16px rgba(0, 0, 0, 0.20);
  /* Extra (web-only) — pour les modales flottantes */
  --shadow-modal:  0 24px 48px rgba(0, 0, 0, 0.40);
  /* Brand glow (bouton CTA principal) */
  --shadow-brand:  0 8px 24px rgba(99, 102, 241, 0.30);

  /* ─────────────────────────────────────────────────────────────────────
     BLURS (DesignTokens.swift → FabellaBlur)
     ───────────────────────────────────────────────────────────────────── */
  --blur-sm:  blur(6px);
  --blur-md:  blur(12px);
  --blur-lg:  blur(20px);
  --blur-xl:  blur(40px);

  /* ─────────────────────────────────────────────────────────────────────
     LAYOUT CONSTANTS (DesignTokens.swift → FabellaLayout)
     ───────────────────────────────────────────────────────────────────── */
  --nav-height:       64px;
  --card-max-width:   600px;
  --input-max-width:  480px;
  --content-padding:  var(--space-base);   /* 16px */
  --section-spacing:  var(--space-xl);     /* 24px */
  --button-height:    48px;
  --button-height-sm: 36px;
  --button-radius:    var(--radius-full);

  /* ─────────────────────────────────────────────────────────────────────
     TRANSITIONS (DesignTokens.swift → FabellaAnimation)
     ───────────────────────────────────────────────────────────────────── */
  --transition-fast:     0.15s ease-out;
  --transition-standard: 0.25s ease-in-out;
  --transition-slow:     0.35s ease-in-out;
  --transition-spring:   0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ─────────────────────────────────────────────────────────────────────
     OPACITY (DesignTokens.swift → FabellaOpacity)
     ───────────────────────────────────────────────────────────────────── */
  --opacity-border:   0.07;
  --opacity-border-md:0.12;
  --opacity-glow:     0.18;
  --opacity-disabled: 0.35;
  --opacity-muted:    0.45;
  --opacity-semi:     0.75;
  --opacity-nav:      0.85;

  /* ─────────────────────────────────────────────────────────────────────
     Z-INDEX (DesignTokens.swift → FabellaZIndex)
     ───────────────────────────────────────────────────────────────────── */
  --z-base:    0;
  --z-card:    1;
  --z-sticky:  10;
  --z-overlay: 50;
  --z-toast:   90;
  --z-modal:   100;
  --z-nav:     200;
}

/* ─────────────────────────────────────────────────────────────────────────
   LIGHT MODE OVERRIDES
   Correspond aux valeurs `.light` de FabellaColors.adaptive()
   ───────────────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: light) {
  :root {
    --bg-primary:        #FFFFFF;
    --bg-secondary:      #F2F2F7;
    --surface-card:      #FFFFFF;
    --surface-elevated:  #F7F7F7;
    --surface-highlight: #EFEFEF;
    --surface-sheet:     #F9F9F9;
    --text-primary:      #0D0D0D;
    --text-secondary:    rgba(13, 13, 13, 0.60);
    --text-tertiary:     rgba(13, 13, 13, 0.35);
    --text-muted:        rgba(13, 13, 13, 0.45);
    --text-heading:      #0D0D0D;
    --border-subtle:     rgba(0, 0, 0, 0.07);
    --border-medium:     rgba(0, 0, 0, 0.12);
    --shadow-low:        0 3px 6px rgba(0, 0, 0, 0.04);
    --shadow-md:         0 5px 10px rgba(0, 0, 0, 0.08);
    --shadow-high:       0 8px 16px rgba(0, 0, 0, 0.12);
  }
}

/* ─────────────────────────────────────────────────────────────────────────
   BASE STYLES (à appliquer globalement)
   ───────────────────────────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-body);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────────────────────────────────────
   UTILITY CLASSES (optionnelles — déclenche-les si besoin)
   ───────────────────────────────────────────────────────────────────────── */

/* Gradient de marque en texte */
.text-brand {
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Gradient de marque diagonal en texte */
.text-brand-diag {
  background: var(--brand-gradient-diag);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Carte standard */
.card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-md);
}

/* Bouton primaire (gradient de marque) */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--button-height);
  padding: 0 var(--space-xl);
  border-radius: var(--button-radius);
  background: var(--brand-gradient);
  color: #fff;
  font-family: var(--font-sans);
  font-size: var(--text-label);
  font-weight: var(--weight-bold);
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition-fast), transform var(--transition-fast),
              box-shadow var(--transition-fast);
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover  { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active { opacity: 1;   transform: translateY(0);    }

/* Bouton secondaire (bordure) */
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--button-height);
  padding: 0 var(--space-xl);
  border-radius: var(--button-radius);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-label);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  border: 1px solid var(--border-medium);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
.btn-secondary:hover { background: var(--surface-highlight); }

/* Statut badges */
.badge-success { color: var(--status-success); background: var(--status-success-bg); }
.badge-danger  { color: var(--status-danger);  background: var(--status-danger-bg);  }
.badge-warning { color: var(--status-warning); background: var(--status-warning-bg); }
.badge-info    { color: var(--status-info);    background: var(--status-info-bg);    }

/* Reactions */
.reaction-amazing   { color: var(--reaction-amazing);   }
.reaction-lived-it  { color: var(--reaction-lived-it);  }
.reaction-was-there { color: var(--reaction-was-there); }
