/* ============================================================================
 * Circuits Paris Ouest — Design System
 *
 * Source de verite : UX wireframes §2 (typo, palette, spacing, composants).
 *
 * NOTE polices (story 1.5) : GT America n'est pas encore licenciee.
 * Strategie de fallback graduel :
 *   1. GT America (sera servie depuis /assets/fonts/ quand .woff2 livres)
 *   2. Söhne (fallback equivalent qualitatif)
 *   3. system-ui / -apple-system / "Helvetica Neue" (fallback final propre)
 * JAMAIS Inter / Geist / Space Grotesk (anti-pattern v0/Vercel).
 *
 * Mono : JetBrains Mono (open source, sera servie depuis /assets/fonts/).
 * En attendant : ui-monospace / Menlo / Consolas.
 * ========================================================================= */

/* ============================================================================
 * 1. Reset minimal
 * ========================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html,
body {
  height: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  cursor: pointer;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}

/* ============================================================================
 * 2. @font-face — self-hosted, font-display: swap
 *    Les fichiers .woff2 seront ajoutes a public/assets/fonts/ quand livres.
 *    En attendant, les fallbacks system-ui prennent le relais sans FOIT.
 * ========================================================================= */
/* @font-face {
  font-family: 'GT America';
  src: url('/assets/fonts/gt-america-regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'GT America';
  src: url('/assets/fonts/gt-america-medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/assets/fonts/jetbrains-mono-medium.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
} */

/* ============================================================================
 * 3. Tokens — :root custom properties (UX §2)
 * ========================================================================= */
:root {
  /* --- Couleurs : neutres (UX §2.2) --- */
  --bg: #fafaf7;
  --bg-elevated: #ffffff;
  --bg-subtle: #f2f1ec;
  --fg: #1a1a1a;
  --fg-secondary: #525252;
  --fg-muted: #595959; /* WCAG AA : 5.96:1 sur #f2f1ec (vs #737373 = 4.19:1, insuffisant) */
  --border: #e5e4df;
  --border-strong: #a3a29c;

  /* --- Couleurs : accent (1 seul, fort) --- */
  --accent: #c2410c;
  --accent-hover: #9a330a;
  --accent-subtle: #fbe9dc;
  --accent-fg: #7c2d0c;

  /* --- Couleurs : etats fonctionnels --- */
  --success: #15803d;
  --warning: #a16207;
  --danger: #b91c1c;

  /* --- Spacing (UX §2.3) --- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
  --space-24: 96px;
  --space-32: 128px;
  --space-40: 160px;

  /* --- Typo : familles --- */
  --font-display:
    'GT America', 'Söhne', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial,
    sans-serif;
  --font-body:
    'GT America', 'Söhne', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial,
    sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  /* --- Typo : tailles (rem, base 16) --- */
  --text-display-xl: 5rem; /* 80 */
  --text-display-md: 3rem; /* 48 */
  --text-heading-lg: 1.75rem; /* 28 */
  --text-heading-md: 1.375rem; /* 22 */
  --text-body-lg: 1.0625rem; /* 17 */
  --text-body: 1rem; /* 16 */
  --text-body-sm: 0.875rem; /* 14 */
  --text-eyebrow: 0.75rem; /* 12 */

  /* --- Typo : line heights --- */
  --lh-display: 1.05;
  --lh-heading: 1.25;
  --lh-body: 1.65;
  --lh-tight: 1.2;

  /* --- Typo : letter-spacings --- */
  --tracking-display: -0.02em;
  --tracking-heading: -0.008em;
  --tracking-body: 0;
  --tracking-eyebrow: 0.08em;

  /* --- Layout --- */
  --container-max: 1200px;
  --container-padding-mobile: 24px;
  --container-padding-desktop: 48px;

  /* --- Radius --- */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 24px;

  /* --- Breakpoints (commentaires) ---
   * mobile  < 640px
   * tablet  640px – 1023px
   * desktop ≥ 1024px
   */
}

/* ============================================================================
 * 4. Base — html, body, headings, paragraphs, links
 * ========================================================================= */
html {
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  font-size: 16px;
  line-height: var(--lh-body);
}

body {
  font-family: var(--font-body);
  color: var(--fg);
  background: var(--bg);
  font-size: var(--text-body-lg);
  line-height: var(--lh-body);
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 500;
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-heading);
  color: var(--fg);
}

h1 {
  font-size: var(--text-display-xl);
  line-height: var(--lh-display);
  letter-spacing: var(--tracking-display);
}

h2 {
  font-size: var(--text-display-md);
  letter-spacing: var(--tracking-display);
}

h3 {
  font-size: var(--text-heading-lg);
}

h4 {
  font-size: var(--text-heading-md);
}

p {
  font-size: var(--text-body-lg);
  line-height: var(--lh-body);
  color: var(--fg-secondary);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================================================
 * 5. Composants
 * ========================================================================= */

/* --- Container --- */
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding-left: var(--container-padding-mobile);
  padding-right: var(--container-padding-mobile);
}

/* --- Eyebrow --- */
.eyebrow {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--text-eyebrow);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--fg-muted);
}

.eyebrow--accent {
  color: var(--accent);
}

/* --- Button --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-body);
  line-height: 1;
  letter-spacing: 0;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-5);
  transition:
    background-color 150ms ease,
    color 150ms ease,
    border-color 150ms ease,
    transform 150ms ease;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: #ffffff;
}

.btn--primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
}

.btn--secondary {
  background: var(--bg-elevated);
  color: var(--fg);
  border: 1px solid var(--border-strong);
}

.btn--secondary:hover {
  background: var(--bg-subtle);
  border-color: var(--fg);
  text-decoration: none;
}

.btn--tertiary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
}

.btn--tertiary:hover {
  background: var(--bg-subtle);
  text-decoration: none;
}

.btn--ghost {
  background: transparent;
  color: var(--accent);
  padding-left: var(--space-2);
  padding-right: var(--space-2);
}

.btn--ghost:hover {
  background: var(--accent-subtle);
  text-decoration: none;
}

.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-body-sm);
}

.btn--md {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-body);
}

.btn--lg {
  padding: var(--space-4) var(--space-6);
  font-size: var(--text-body-lg);
}

/* --- Input / Select / Textarea --- */
.input,
.select,
.textarea {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.4;
  color: var(--fg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--fg-muted);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-subtle);
}

.input--error,
.select--error,
.textarea--error {
  border-color: var(--danger);
}

.textarea {
  min-height: 120px;
  resize: vertical;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.field__label {
  font-size: var(--text-body-sm);
  font-weight: 500;
  color: var(--fg);
}

.field__hint {
  font-size: var(--text-body-sm);
  color: var(--fg-muted);
}

.field__error {
  font-size: var(--text-body-sm);
  color: var(--danger);
}

/* --- Card --- */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition:
    border-color 150ms ease,
    transform 150ms ease;
}

.card--accent {
  border-color: var(--accent);
}

.card--hover:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

/* --- Badge --- */
.badge {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-eyebrow);
  line-height: var(--lh-tight);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--fg-secondary);
}

.badge--accent {
  background: var(--accent-subtle);
  color: var(--accent-fg);
}

.badge--success {
  background: #dcfce7;
  color: var(--success);
}

/* --- Avatar --- */
.avatar {
  display: inline-block;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-subtle);
  object-fit: cover;
  overflow: hidden;
}

.avatar--lg {
  width: 64px;
  height: 64px;
}

.avatar--square {
  border-radius: var(--radius-md);
}

/* --- Accordion FAQ --- */
.accordion__item {
  border-bottom: 1px solid var(--border);
}

.accordion__item:first-child {
  border-top: 1px solid var(--border);
}

.accordion__question {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-body-lg);
  color: var(--fg);
  text-align: left;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.accordion__question::after {
  content: '+';
  font-size: 1.5rem;
  color: var(--fg-muted);
  transition: transform 200ms ease;
}

.accordion__item[open] .accordion__question::after {
  content: '−';
}

.accordion__answer {
  padding-bottom: var(--space-5);
  color: var(--fg-secondary);
  font-size: var(--text-body-lg);
  line-height: var(--lh-body);
}

/* ============================================================================
 * 6. Utilities
 * ========================================================================= */
.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;
}

/* Skip-to-content link (a11y WCAG 2.4.1) — hors viewport, visible au focus clavier */
.skip-to-content {
  position: absolute;
  top: 0;
  left: 0;
  transform: translateY(-100%);
  z-index: 1000;
  padding: var(--space-3) var(--space-4);
  background: var(--accent);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--text-body-sm);
  border-radius: 0 0 var(--radius-md) 0;
  text-decoration: none;
  transition: transform 150ms ease;
}

.skip-to-content:focus,
.skip-to-content:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--fg);
  outline-offset: 2px;
  text-decoration: none;
}

.text-balance {
  text-wrap: balance;
}

.flex {
  display: flex;
}

.grid {
  display: grid;
}

.gap-2 {
  gap: var(--space-2);
}

.gap-4 {
  gap: var(--space-4);
}

.gap-6 {
  gap: var(--space-6);
}

/* ============================================================================
 * 7. Media queries — mobile first
 * ========================================================================= */
@media (min-width: 640px) {
  .container {
    padding-left: var(--container-padding-desktop);
    padding-right: var(--container-padding-desktop);
  }
}

@media (min-width: 1024px) {
  h1 {
    font-size: var(--text-display-xl);
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
