/* ============================================================
   CV — Jean Laurain
   Feuille de style : thème (clair/sombre/système), mise en page,
   et rendu d'impression (PDF). Aucune dépendance externe.
   ============================================================ */

/* ----- Reset léger ----- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
img { max-width: 100%; display: block; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
p, li { overflow-wrap: break-word; }

/* ============================================================
   Thème — variables de couleur
   Défaut = clair. « dark » forcé, ou « system » qui suit l'OS.
   ============================================================ */
:root {
  color-scheme: light;
  --bg: #eef1f6;
  --bg-grad: radial-gradient(1100px 560px at 50% -8%, #e6ecff 0%, #eef1f6 58%);
  --card: #ffffff;
  --text: #1f2733;
  --muted: #6b7480;
  --border: #e6e9f1;
  --accent: #2f5bea;
  --accent-strong: #2646c9;
  --tag-bg: #eef2ff;
  --tag-text: #3346b8;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 10px 26px rgba(16, 24, 40, .06);
  --radius: 16px;
}

/* Sombre forcé */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1220;
  --bg-grad: radial-gradient(1100px 560px at 50% -8%, #17213c 0%, #0d1220 58%);
  --card: #151c2c;
  --text: #e7ebf3;
  --muted: #99a4b5;
  --border: #253049;
  --accent: #6f8dff;
  --accent-strong: #8ba3ff;
  --tag-bg: #1c2740;
  --tag-text: #aabaff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px rgba(0, 0, 0, .38);
}

/* Système : applique le sombre uniquement si l'OS est en sombre */
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #0d1220;
    --bg-grad: radial-gradient(1100px 560px at 50% -8%, #17213c 0%, #0d1220 58%);
    --card: #151c2c;
    --text: #e7ebf3;
    --muted: #99a4b5;
    --border: #253049;
    --accent: #6f8dff;
    --accent-strong: #8ba3ff;
    --tag-bg: #1c2740;
    --tag-text: #aabaff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 30px rgba(0, 0, 0, .38);
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ============================================================
   Barre d'outils
   ============================================================ */
.toolbar {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 50;
  display: flex;
  gap: 8px;
}
.tool-btn {
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .08s ease, border-color .15s ease, background .15s ease;
}
.tool-btn:hover { border-color: var(--accent); }
.tool-btn:active { transform: translateY(1px); }
.tool-btn--primary { background: var(--accent); color: #fff; border-color: transparent; }
.tool-btn--primary:hover { background: var(--accent-strong); }

/* ============================================================
   Mise en page générale
   ============================================================ */
.cv {
  max-width: 860px;
  margin: 0 auto;
  padding: 84px 20px 48px;
  display: grid;
  gap: 20px;
}
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 28px;
}
.section-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}
.sub-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin: 18px 0 8px;
}

/* ----- Tags ----- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--tag-text);
  background: var(--tag-bg);
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ============================================================
   En-tête (héros)
   ============================================================ */
.hero { display: flex; gap: 24px; align-items: center; }
.hero__photo {
  width: 108px;
  height: 108px;
  border-radius: 50%;
  object-fit: cover;
  flex: none;
  border: 3px solid var(--card);
  box-shadow: 0 0 0 1px var(--border), var(--shadow);
  background: var(--tag-bg);
}
.hero__info { min-width: 0; }
.hero__name { font-size: 29px; font-weight: 800; letter-spacing: -.01em; }
.hero__title { font-size: 17px; color: var(--accent); font-weight: 600; margin: 3px 0 10px; }
.hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}
.hero__meta a { text-decoration: none; word-break: break-word; }
.hero__meta a:hover { color: var(--accent); }

/* Avatar / logo de repli (initiales) */
.avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}
.hero__photo.avatar-fallback { font-size: 34px; }

/* ============================================================
   À propos
   ============================================================ */
.about__desc { color: var(--text); }
.langs { display: grid; gap: 8px; }
.lang-row { display: flex; gap: 12px; font-size: 14.5px; flex-wrap: wrap; }
.lang-row b { min-width: 96px; }
.lang-row span { color: var(--muted); }

/* ============================================================
   Expériences
   ============================================================ */
.exp {
  display: flex;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--border);
}
.exp:first-of-type { border-top: 0; padding-top: 2px; }
.logo {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  flex: none;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  padding: 5px;
}
.logo--fallback {
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  border: 0;
  padding: 0;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}
.exp__body { flex: 1; min-width: 0; }
.exp__head {
  display: flex;
  justify-content: space-between;
  gap: 8px 16px;
  flex-wrap: wrap;
  align-items: baseline;
}
.exp__company { font-size: 17px; font-weight: 700; }
.exp__role { font-weight: 600; font-size: 14.5px; }
.exp__sector {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-top: 2px;
}
.exp__period { color: var(--muted); font-size: 13.5px; white-space: nowrap; }
.exp__loc { color: var(--muted); font-size: 13.5px; text-align: right; }
.highlights { margin-top: 12px; display: grid; gap: 7px; }
.highlights li { position: relative; padding-left: 20px; }
.highlights li::before {
  content: "▹";
  position: absolute;
  left: 2px;
  color: var(--accent);
  font-weight: 700;
}
.exp .tags { margin-top: 13px; }

/* Consulting : badge + missions imbriquées (timeline) */
.badge-consult {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  vertical-align: middle;
  color: var(--accent);
  background: var(--tag-bg);
  padding: 3px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-left: 8px;
}
.missions {
  margin-top: 16px;
  display: grid;
  gap: 18px;
  padding-left: 18px;
  border-left: 2px solid var(--border);
}
.mission { display: flex; gap: 13px; position: relative; }
.mission::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 16px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--accent);
}
.mission__logo { width: 38px; height: 38px; border-radius: 10px; }
.mission__client { font-size: 15px; font-weight: 700; }
.mission__full { color: var(--muted); font-size: 12.5px; }

/* ============================================================
   Formation / Compétences
   ============================================================ */
.edu { align-items: center; }

/* ============================================================
   Message d'erreur (JSON introuvable)
   ============================================================ */
.error code { background: var(--tag-bg); padding: 1px 6px; border-radius: 6px; }
.error pre { overflow-x: auto; color: var(--muted); font-size: 12.5px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 620px) {
  .cv { padding: 70px 12px 40px; gap: 16px; }
  .card { padding: 20px 16px; }
  .section-title { margin-bottom: 14px; }

  .toolbar { top: 10px; right: 10px; gap: 6px; }
  .tool-btn { padding: 7px 11px; font-size: 13px; }

  .hero { flex-direction: column; text-align: center; gap: 14px; }
  .hero__photo { width: 92px; height: 92px; }
  .hero__name { font-size: 24px; }
  .hero__title { font-size: 16px; }
  .hero__meta { justify-content: center; gap: 6px 14px; font-size: 13.5px; }
  .hero .tags { justify-content: center; }

  .exp { gap: 12px; padding: 16px 0; }
  .logo { width: 42px; height: 42px; }
  .exp__head { flex-direction: column; align-items: flex-start; gap: 3px; }
  .exp__period { white-space: normal; }
  .exp__loc { text-align: left; }

  .missions { padding-left: 12px; gap: 14px; }
  .mission { gap: 10px; }
  .mission::before { left: -18px; top: 14px; }
  .mission__logo { width: 30px; height: 30px; }

  #pdf-label { display: none; }
}

@media (max-width: 360px) {
  .card { padding: 16px 13px; }
  .hero__name { font-size: 22px; }
  .tool-btn { padding: 6px 9px; }
}

/* ============================================================
   Impression / PDF — force le thème clair, masque l'interface.
   (Placé en dernier pour l'emporter dans la cascade.)
   ============================================================ */
@media print {
  @page { size: A4; margin: 12mm; }

  :root,
  :root[data-theme="light"],
  :root[data-theme="dark"],
  :root[data-theme="system"] {
    --bg: #ffffff;
    --bg-grad: none;
    --card: #ffffff;
    --text: #14181f;
    --muted: #565f6b;
    --border: #e2e5ec;
    --accent: #1f39b8;
    --accent-strong: #16299a;
    --tag-bg: #eef2ff;
    --tag-text: #26379a;
    --shadow: none;
  }

  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: #fff !important; background-image: none !important; }
  .toolbar { display: none !important; }
  .cv { max-width: none; padding: 0; gap: 12px; }
  .card { border: 1px solid #e5e7ee; box-shadow: none; padding: 16px 18px; break-inside: avoid; }
  .exp, .mission, .edu { break-inside: avoid; }
  a { text-decoration: none; }
}
