/* VERSION = "1.0.0" */

/* ─── FONTS ──────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Porsche Next';
  src: url('../assets/fonts/PorscheNext-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Porsche Next';
  src: url('../assets/fonts/PorscheNext-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ─── DESIGN TOKENS ──────────────────────────────────────────────────────── */
:root {
  /* Colors */
  --c-black:       #0a0a0a;
  --c-surface:     #141414;
  --c-surface-2:   #1e1e1e;
  --c-surface-3:   #282828;
  --c-border:      rgba(255,255,255,0.10);
  --c-border-2:    rgba(255,255,255,0.18);
  --c-red:         #d5001c;
  --c-red-hover:   #b80018;
  --c-gold:        #ab7f4c;
  --c-green:       #005f2e;
  --c-white:       #ffffff;
  --c-white-80:    rgba(255,255,255,0.80);
  --c-white-60:    rgba(255,255,255,0.60);
  --c-white-40:    rgba(255,255,255,0.62); /* WCAG AA 1.4.3 — contraste 4.5:1 sur #0a0a0a */
  --c-white-20:    rgba(255,255,255,0.20);
  --c-white-08:    rgba(255,255,255,0.08);

  /* Typography */
  --font:          'Porsche Next', 'Helvetica Neue', Arial, sans-serif;
  --fw-regular:    400;
  --fw-bold:       700;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radius */
  --r-sm: 4px;
  --r-md: 8px;
  --r-lg: 12px;

  /* Transitions */
  --t-fast: 150ms ease;
  --t-base: 250ms ease;
  --t-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  font-weight: var(--fw-regular);
  background: var(--c-black);
  color: var(--c-white);
  line-height: 1.6;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font-family: inherit; }
a { color: inherit; text-decoration: none; }

/* ─── FOCUS VISIBLE GLOBAL (WCAG 2.4.7 + 1.4.11) ─────────────────────────── */
/* Anneau doré sur tous les éléments interactifs au focus clavier (pas à la souris) */
:where(button, [role="button"], a[href], input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
/* Cas spécial : checkbox / radio — outline-offset négatif pour suivre le contour natif */
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 3px;
}
/* Skip link visible uniquement au focus */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  z-index: 9999;
  padding: 12px 18px;
  background: var(--c-black);
  color: var(--c-gold);
  font-weight: var(--fw-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 13px;
  border: 2px solid var(--c-gold);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  transition: top var(--t-fast);
}
.skip-link:focus,
.skip-link:focus-visible {
  top: 0;
  outline: none;
}

/* ─── TYPOGRAPHY ─────────────────────────────────────────────────────────── */
.t-label {
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--c-white-60);
}
.t-body-sm { font-size: 13px; line-height: 1.5; color: var(--c-white-80); }
.t-body    { font-size: 15px; line-height: 1.6; }
.t-lead    { font-size: 17px; line-height: 1.5; }
.t-h3      { font-size: 20px; font-weight: var(--fw-bold); letter-spacing: 0.02em; }
.t-h2      { font-size: 26px; font-weight: var(--fw-bold); letter-spacing: 0.01em; }
.t-h1      { font-size: 32px; font-weight: var(--fw-bold); letter-spacing: -0.01em; }

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 13px var(--sp-6);
  font-family: var(--font);
  font-size: 13px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast), opacity var(--t-fast), transform var(--t-fast);
  white-space: nowrap;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-primary  { background: var(--c-red); color: var(--c-white); }
.btn-primary:hover:not(:disabled) { background: var(--c-red-hover); }

.btn-secondary { background: var(--c-white); color: var(--c-black); }
.btn-secondary:hover:not(:disabled) { background: var(--c-white-80); }

.btn-ghost {
  background: transparent;
  color: var(--c-white-60);
  border: 1px solid var(--c-border-2);
}
.btn-ghost:hover:not(:disabled) { color: var(--c-white); border-color: var(--c-white-40); }

.btn-danger  { background: var(--c-red); color: var(--c-white); }
.btn-danger:hover:not(:disabled) { background: #aa0016; }

.btn-gold    { background: var(--c-gold); color: var(--c-black); }
.btn-gold:hover:not(:disabled) { background: #946c3f; }

.btn-sm { padding: 8px var(--sp-4); font-size: 11px; }
.btn-lg { padding: 16px var(--sp-8); font-size: 14px; }
.btn-full { width: 100%; }
.btn-icon { padding: 10px; width: 40px; height: 40px; }

/* ─── FORM ELEMENTS ──────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.form-label {
  font-size: 10px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--c-white-60);
}
.form-label .required { color: var(--c-red); margin-left: 2px; }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 13px var(--sp-4);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-white);
  font-family: var(--font);
  font-size: 15px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  appearance: none;
  -webkit-appearance: none;
}
.form-input::placeholder { color: var(--c-white-40); }
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--c-red);
  box-shadow: 0 0 0 3px rgba(213, 0, 28, 0.15);
}
.form-input:focus-visible,
.form-select:focus-visible,
.form-textarea:focus-visible {
  outline: 2px solid var(--c-gold);
  outline-offset: 2px;
  border-color: var(--c-red);
}
.form-input.valid   { border-color: var(--c-green); }
.form-input.invalid { border-color: var(--c-red); }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(255,255,255,0.4)' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}
.form-select option { background: var(--c-surface-2); color: var(--c-white); }

.form-textarea { resize: vertical; min-height: 80px; line-height: 1.5; }

.form-hint { font-size: 12px; color: var(--c-white-40); }
.form-error {
  font-size: 12px;
  color: var(--c-red);
  display: flex;
  align-items: center;
  gap: 4px;
}
.form-error::before { content: '✕'; font-size: 10px; }

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
@media (max-width: 480px) { .form-grid-2 { grid-template-columns: 1fr; } }

/* ─── VIN FIELD ──────────────────────────────────────────────────────────── */
.vin-wrapper { position: relative; }
.vin-counter {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.05em;
  color: var(--c-white-40);
  pointer-events: none;
  transition: color var(--t-fast);
}
/* Pattern badge (fond couleur + texte blanc) plutôt que texte vert/rouge sur
   fond noir — ce dernier ratio 2.1:1 (vert) et 4.0:1 (rouge) ne passait pas
   WCAG AA pour du texte 11px. Le badge préserve les couleurs brand Porsche
   exactes et atteint 7.6:1 (blanc/vert) / 4.9:1 (blanc/rouge). */
.vin-counter.valid,
.vin-counter.invalid {
  color: #fff;
  padding: 2px 6px;
  border-radius: 3px;
}
.vin-counter.valid   { background: var(--c-green); }
.vin-counter.invalid { background: var(--c-red); }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-4);
  opacity: 0;
  transition: opacity var(--t-base);
  backdrop-filter: blur(4px);
  overflow: hidden;
}
.modal-overlay.visible { opacity: 1; }
.modal {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-lg);
  padding: var(--sp-8);
  max-width: 480px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  width: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform var(--t-base);
}
.modal-overlay.visible .modal { transform: translateY(0); }
.modal-title {
  font-size: 18px;
  font-weight: var(--fw-bold);
  margin-bottom: var(--sp-3);
  letter-spacing: 0.02em;
}
.modal-message { color: var(--c-white-80); font-size: 14px; line-height: 1.6; margin-bottom: var(--sp-6); }
.modal-actions { display: flex; gap: var(--sp-3); justify-content: flex-end; }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
/* Live regions permanentes invisibles — l'AT lit le textContent ajouté */
.toast-region {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 2000;
}
.toast {
  position: fixed;
  bottom: var(--sp-6);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: var(--fw-bold);
  z-index: 2000;
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-success { background: var(--c-green); color: var(--c-white); }
.toast-error   { background: var(--c-red); color: var(--c-white); }
.toast-info    { background: var(--c-surface-3); color: var(--c-white); border: 1px solid var(--c-border-2); }

/* ─── LOADER ─────────────────────────────────────────────────────────────── */
.pf-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  padding: var(--sp-12);
  color: var(--c-white-60);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.loader-ring {
  width: 36px;
  height: 36px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── BADGE / STATUS ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ─── CARD ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  padding: var(--sp-6);
}

/* ─── DIVIDER ────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--c-border);
  margin: var(--sp-6) 0;
}

/* ─── PORSCHE LOGO HEADER ────────────────────────────────────────────────── */
.pf-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-6) var(--sp-4) var(--sp-4);
  flex-direction: column;
  gap: var(--sp-3);
}
.pf-header-crest {
  width: 64px;
  height: auto;
}
.pf-header-title {
  font-size: 11px;
  font-weight: var(--fw-bold);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--c-gold);
  text-align: center;
}
.pf-header-subtitle {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--c-white-40);
  text-align: center;
  text-transform: uppercase;
}

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--c-surface); }
::-webkit-scrollbar-thumb { background: var(--c-surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c-white-20); }

/* ─── SELECTION ──────────────────────────────────────────────────────────── */
::selection { background: rgba(213, 0, 28, 0.3); }

/* ─── UTILS ──────────────────────────────────────────────────────────────── */
.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; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mt-8 { margin-top: var(--sp-8); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.opacity-60 { opacity: 0.6; }
