/* ==========================================================================
   VaultLens — styles communs : jetons, base, en-tête, pied de page, pages secondaires
   Aucune ressource externe : polices du système, aucun CDN, aucun traqueur.
   ========================================================================== */

/* ---------- 1. Jetons de design ---------- */

:root {
  color-scheme: light dark;

  /* Thème clair */
  --bg: #f7f7f4;
  --surface: #ffffff;
  --surface-sunken: #efefea;
  --text: #15171b;
  --text-muted: #464b53;
  --text-subtle: #5b6068;
  --rule: #d9d9d1;
  --rule-strong: #15171b;
  --accent: #0b5c63;
  --accent-hover: #08474d;
  --accent-ink: #ffffff;
  --accent-soft: #e1ecec;
  --fail: #a4271f;
  --focus: #0b5c63;
  --todo-bg: #fff0a8;
  --todo-ink: #3b2f00;
  --shadow: 0 1px 0 rgb(21 23 27 / 0.03), 0 24px 48px -28px rgb(21 23 27 / 0.35);

  /* Encre de la marque : bandeau du logo de la référence client (identique dans les deux thèmes) */
  --brand-ink: #14161a;

  /* Bandeau inversé (sécurité) */
  --band-bg: #15171b;
  --band-text: #ecece6;
  --band-muted: #aeb2b9;
  --band-rule: #343840;
  --band-accent: #7cc7cc;

  /* Code et terminal : sombres dans les deux thèmes */
  --code-bg: #121417;
  --code-text: #d8dbe0;
  --code-muted: #8d949e;
  --code-key: #8fc8cd;
  --code-num: #e3c27c;
  --code-str: #b9d38f;
  --code-fail: #f2897e;
  --code-hit: rgb(242 137 126 / 0.14);

  /* Typographie : polices système, choisies pour ne rien charger */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --step--2: 0.75rem;
  --step--1: 0.875rem;
  --step-0: 1.0625rem;
  --step-1: 1.25rem;
  --step-2: clamp(1.375rem, 1.2rem + 0.8vw, 1.75rem);
  --step-3: clamp(1.875rem, 1.35rem + 2.2vw, 3rem);
  --step-4: clamp(2rem, 1.45rem + 2.4vw, 3.25rem); /* gros titre de l’accroche : volontairement mesuré */

  /* Espacements et formes */
  --gutter: clamp(1rem, 0.5rem + 2.5vw, 2.5rem);
  --space-section: clamp(4rem, 2.5rem + 5vw, 7rem);
  --radius: 4px;
  --radius-lg: 8px;
  --max: 75rem;
  --header-h: 4rem;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --dur: 160ms;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1113;
    --surface: #16191c;
    --surface-sunken: #1c2024;
    --text: #ecece6;
    --text-muted: #b8bcc2;
    --text-subtle: #9a9fa7;
    --rule: #2c3137;
    --rule-strong: #ecece6;
    --accent: #7cc7cc;
    --accent-hover: #a0dade;
    --accent-ink: #0a1a1c;
    --accent-soft: #142a2c;
    --fail: #f2897e;
    --focus: #7cc7cc;
    --todo-bg: #4d3f00;
    --todo-ink: #ffeaa3;
    --shadow: 0 0 0 1px rgb(255 255 255 / 0.02), 0 24px 48px -28px rgb(0 0 0 / 0.8);
    --band-bg: #181b1f;
    --band-rule: #30353b;
    --code-bg: #0a0c0e;
  }
}

/* ---------- 2. Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: -0.02em;
  font-weight: 650;
  text-wrap: balance;
}

p, ul, ol, dl, dd, figure { margin: 0; }
p { text-wrap: pretty; }
ul, ol { padding: 0; }

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color var(--dur) var(--ease);
}
a:hover { color: var(--accent); }

code, pre { font-family: var(--font-mono); }

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

::selection { background: var(--accent); color: var(--accent-ink); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--text);
  color: var(--bg);
  font-weight: 600;
  border-radius: var(--radius);
}
.skip-link:focus { top: 0.75rem; color: var(--bg); }

.container {
  width: min(100% - 2 * var(--gutter), var(--max));
  margin-inline: auto;
}

/* Emplacement à remplir : visible à l’aperçu pour ne rien oublier */
.todo {
  background: var(--todo-bg);
  color: var(--todo-ink);
  padding: 0 0.25em;
  border-radius: 2px;
  outline: 1px dashed currentColor;
  outline-offset: 1px;
}

.inline-code,
.prose code {
  font-size: 0.88em;
  padding: 0.08em 0.35em;
  background: var(--surface-sunken);
  border: 1px solid var(--rule);
  border-radius: 3px;
  overflow-wrap: anywhere;
}

/* ---------- 3. Boutons et liens ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 2.875rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--accent-hover); color: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn-sm { min-height: 2.5rem; padding: 0.5rem 0.9rem; font-size: 0.9375rem; white-space: nowrap; }

.btn .arrow { transition: transform var(--dur) var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--rule-strong);
  padding-block: 0.2rem;
}
.link-arrow:hover { border-color: var(--accent); }

/* ---------- 4. En-tête ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { color: var(--text); }

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.3;
  letter-spacing: 0.04em;
  padding: 0.05rem 0.4rem;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}

/* Logo VaultLens : le symbole compact seul, suivi du nom écrit en texte.
   Deux sources dans le <picture> : le clair et le sombre suivent prefers-color-scheme.
   Le canevas SVG (32 × 32) a une marge vide de 2 unités ; la marge gauche négative aligne
   le bord visible du dessin sur la colonne de texte. */
.brand-logo { display: block; flex: none; width: 2.25rem; margin-left: -0.1rem; }
.brand-logo img { display: block; width: 100%; height: auto; }

.brand-name {
  font-size: 1.1875rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

/* La ligne descriptive passe après la navigation visible, pour que l’en-tête tienne sur
   une ligne entre 64 rem et 72 rem. */
@media (max-width: 72rem) {
  .brand-tag { display: none; }
}

/* Page 404 : le logo et le nom, au-dessus du message, alignés sur la colonne de texte de la page */
.page-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: clamp(2rem, 1.5rem + 2vw, 3rem);
}
.page-logo .brand-logo { width: 3rem; margin-left: -0.15rem; }
.page-logo .brand-name { font-size: 1.5rem; }

.brand-tag { margin-left: 0.5rem; font-size: var(--step--1); color: var(--text-subtle); white-space: nowrap; }

.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: 1.5rem; list-style: none; }
.site-nav a {
  display: block;
  padding-block: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9375rem;
  text-decoration: none;
  background: linear-gradient(var(--accent), var(--accent)) left bottom / 0 1.5px no-repeat;
  transition: color var(--dur) var(--ease), background-size var(--dur) var(--ease);
}
.site-nav a:hover { color: var(--text); background-size: 100% 1.5px; }

.nav-toggle {
  flex: none;
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 1.125rem;
  height: 1.5px;
  background: currentColor;
  transition: transform var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.nav-toggle-bars { position: relative; }
.nav-toggle-bars::before,
.nav-toggle-bars::after { content: ""; position: absolute; left: 0; }
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bars::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 64rem) {
  .brand-tag { display: none; }
  .header-cta { margin-left: auto; }
  .nav-toggle:not([hidden]) { display: inline-flex; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--rule);
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0; padding: 0.25rem var(--gutter) 1rem; }
  .site-nav li + li { border-top: 1px solid var(--rule); }
  .site-nav a { padding-block: 0.9rem; font-size: 1rem; background: none; }
}

/* Petits téléphones : symbole, nom, bouton « Parlons de votre code » et menu doivent tenir sur une ligne */
@media (max-width: 30rem) {
  .header-inner { gap: 0.75rem; }
  .header-cta { padding-inline: 0.7rem; font-size: 0.875rem; }
}

/* Très petits écrans (jusqu’à 26 rem, soit 416 px) : le bouton passe sur deux lignes pour que le nom reste visible */
@media (max-width: 26rem) {
  .header-inner { gap: 0.5rem; }
  .brand { gap: 0.5rem; }
  .brand-logo { width: 2rem; }
  .brand-name { font-size: 1.0625rem; }
  .header-cta { padding-inline: 0.6rem; font-size: 0.8125rem; line-height: 1.15; text-align: center; white-space: normal; }
}

/* ---------- 5. Sections : structure commune ---------- */

.section { padding-block: var(--space-section); }

.section-head {
  display: grid;
  gap: 1rem 2rem;
  padding-top: 1.25rem;
  margin-bottom: clamp(2.5rem, 2rem + 2vw, 4rem);
  border-top: 2px solid var(--rule-strong);
}

.section-num {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--text-subtle);
  letter-spacing: 0.02em;
}

.section-title { font-size: var(--step-3); max-width: 22ch; }

.section-lead {
  margin-top: 1.25rem;
  max-width: 60ch;
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--text-muted);
}

@media (min-width: 52rem) {
  .section-head { grid-template-columns: minmax(0, 3fr) minmax(0, 9fr); }
}

.note {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--text-subtle);
}

.kicker {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

/* ---------- 6. Niveaux de confiance (pastilles) ---------- */

.level,
.badge-input {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.22rem 0.55rem;
  border: 1px solid transparent;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.level::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}
.level--repro { background: var(--accent); color: var(--accent-ink); }
.level--suspect { border-color: var(--text-subtle); color: var(--text); }
.level--suspect::before { background: transparent; border: 1.5px solid currentColor; }
.level--review { border: 1px dashed var(--text-subtle); color: var(--text-muted); }
.level--review::before { background: transparent; border: 1.5px dashed currentColor; }

.badge-input { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.badge-input::before { content: "↳"; font-weight: 700; }

/* ---------- 16. Pied de page ---------- */

.site-footer { padding-block: 3.5rem 2rem; border-top: 1px solid var(--rule); font-size: 0.9375rem; }
.footer-grid { display: grid; gap: 2rem; }
@media (min-width: 52rem) { .footer-grid { grid-template-columns: 1.2fr 1fr 1.2fr; } }
.footer-made { margin-top: 0.9rem; font-weight: 600; }
.footer-links { list-style: none; display: grid; gap: 0.5rem; }
.footer-links a { color: var(--text-muted); }
.footer-links a:hover { color: var(--accent); }
.footer-privacy { color: var(--text-muted); }
.footer-base { margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--rule); color: var(--text-subtle); font-size: var(--step--1); }

/* ---------- 17. Pages secondaires (mentions, confidentialité, 404) ---------- */

.page { padding-block: clamp(3rem, 2rem + 4vw, 6rem) var(--space-section); }
.page-title { margin-top: 1rem; font-size: var(--step-3); }
.prose { max-width: 68ch; margin-top: 2.5rem; }
.prose h2 { margin-top: 2.5rem; font-size: var(--step-2); }
.prose h2:first-child { margin-top: 0; }
.prose p,
.prose ul { margin-top: 0.9rem; color: var(--text-muted); }
.prose ul { padding-left: 1.25rem; }
.prose li + li { margin-top: 0.35rem; }
.prose dl { margin-top: 0.9rem; display: grid; gap: 0.5rem; }
.prose dl > div { display: grid; gap: 0.15rem; }
.prose dt { font-weight: 600; }
.prose dd { color: var(--text-muted); }
.prose .updated { margin-top: 3rem; font-size: var(--step--1); color: var(--text-subtle); }

/* ---------- 18. Préférences utilisateur ---------- */

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

@media (forced-colors: active) {
  .level, .badge-input, .btn { border: 1px solid CanvasText; }
  .todo { outline: 2px dashed CanvasText; }
}

@media print {
  .site-header, .nav-toggle, .form, .skip-link { display: none !important; }
  .band { background: none; color: #000; --band-text: #000; --band-muted: #333; --band-rule: #bbb; }
  .code, .term { white-space: pre-wrap; }
}
