/* ==========================================================================
   CV papier imprimable — sidebar teintée + colonne principale (A4)
   La couleur d'accent est pilotée par la variable CSS --accent, définie
   en inline sur .cv-page depuis PHP (réglable dans /edit).
   ========================================================================== */

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  background: #c9c1ba;
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  color: #231b18;
  -webkit-font-smoothing: antialiased;
  display: flex;
  justify-content: center;
  padding: 28px 16px;
}

/* Marges @page à 0 : le fond dégradé (porté par html à l'impression) remplit
   TOUTE la feuille, bord à bord — Chrome ne peint pas le fond dans une zone
   de marge @page, toute marge ici ferait des bandes blanches. La respiration
   haut/bas de chaque page vient des espaceurs .page-gap du .print-frame
   (thead/tfoot répétés par le navigateur à chaque page). */
@page { size: A4; margin: 0; }

/* Cadre d'impression (cv-pdf.php) : neutre à l'écran, les espaceurs ne
   servent qu'à l'impression. */
.print-frame { border-collapse: collapse; border-spacing: 0; }
.print-frame td { padding: 0; }
.page-gap { height: 0; }
@media print {
  .page-gap { height: 12mm; }
}

/* --- Bouton d'impression (masqué à l'impression) --- */
.print-btn {
  position: fixed;
  top: 16px; right: 16px;
  z-index: 10;
  padding: 9px 16px;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent, #9a3b2e);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(40, 24, 18, .5);
}
.print-btn:hover { filter: brightness(1.08); }

/* --- Feuille A4 --- */
.cv-page {
  position: relative;
  width: 210mm;
  min-height: 297mm;
  box-shadow: 0 24px 60px -20px rgba(40, 24, 18, .5);
  display: flex;
  /* Dégradé (sidebar teintée + colonne crème) porté par la feuille elle-même. */
  background: linear-gradient(to right,
    #f7f1ed 0, #f7f1ed 63.7mm,
    #ece2db 63.7mm, #ece2db 64mm,
    #fdfbf9 64mm);
  /* Pas de padding vertical ici : la respiration haut/bas est portée par les
     colonnes (.cv-side / .cv-main), pour que la sidebar — et le clip de ses
     halos (overflow:hidden) — s'étende jusqu'aux bords de la feuille. Un
     padding sur .cv-page décale le haut de la sidebar sous le bord : le halo
     se coupe alors net à cette frontière au lieu de fondre vers le bord. */
}

/* --- Sidebar --- */
.cv-side {
  position: relative;
  z-index: 1;
  overflow: hidden;
  flex: 0 0 64mm;
  align-self: stretch;
  color: #3a302b;
  padding: 16mm 10mm 14mm;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.cv-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, var(--accent, #9a3b2e) 0%, transparent 71%);
}
.cv-glow-top { top: -150px; left: -130px; width: 360px; height: 360px; opacity: .40; filter: blur(2px); }
.cv-glow-bot { bottom: -180px; right: -150px; width: 400px; height: 400px; opacity: .30; filter: blur(3px); }

.cv-photo {
  position: relative;
  z-index: 1;
  width: 34mm; height: 34mm;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 0 1px #ece2db, 0 0 0 4px #fff, 0 8px 22px -12px rgba(60, 40, 30, .4);
}
.cv-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }

.cv-block { position: relative; z-index: 1; break-inside: avoid; }

.cv-kicker {
  font-family: 'Space Mono', monospace;
  font-size: 8px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent, #9a3b2e);
  margin-bottom: 10px;
}

.cv-contact-list { display: flex; flex-direction: column; gap: 7px; }
.cv-contact-label {
  font-family: 'Space Mono', monospace;
  font-size: 7px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #a89a91;
  margin-bottom: 1px;
}
.cv-contact-value { font-size: 10px; color: #3a302b; line-height: 1.3; word-break: break-word; }

.cv-skills { display: flex; flex-direction: column; gap: 11px; }
.cv-skill-group { break-inside: avoid; }
.cv-skill-cat { font-size: 9px; font-weight: 600; letter-spacing: .02em; color: #3a302b; margin-bottom: 6px; }
.cv-skill-sub { font-size: 8.5px; font-weight: 600; color: var(--accent, #9a3b2e); margin: 1px 0 4px; }
.cv-skill-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.cv-skill-name { font-size: 9.5px; color: #514640; line-height: 1.2; }
.cv-skill-dots { flex: 0 0 auto; font-size: 7.5px; letter-spacing: 1.6px; white-space: nowrap; }
.cv-skill-dots .on { color: var(--accent, #9a3b2e); }
.cv-skill-dots .off { color: #d8ccc3; }
.cv-skill-lvl { flex: 0 0 auto; font-family: 'Space Mono', monospace; font-size: 8px; color: #a89a91; }
/* Compétences non évaluées : regroupées en une ligne de tags "A · B · C". */
.cv-skill-tags { font-size: 9px; color: #6d615b; line-height: 1.4; margin-top: 2px; }

.cv-interets { display: flex; flex-direction: column; gap: 6px; }
.cv-interet-title { font-size: 9.5px; font-weight: 600; color: #3a302b; }
.cv-interet-detail { font-size: 9px; color: #8a7d76; line-height: 1.35; }

/* --- Colonne principale --- */
.cv-main {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  padding: 16mm 13mm 14mm;
  display: flex;
  flex-direction: column;
}

.cv-head { margin-bottom: 17px; }
.cv-kicker-main { font-size: 9px; letter-spacing: .26em; margin-bottom: 9px; }
.cv-name {
  margin: 0;
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 600;
  font-size: 44px;
  line-height: .94;
  letter-spacing: -.022em;
  color: #231b18;
}
.cv-name span { color: var(--accent, #9a3b2e); }
.cv-headline { display: flex; align-items: center; gap: 9px; margin-top: 12px; }
.cv-headline-bar { width: 26px; height: 2px; background: var(--accent, #9a3b2e); }
.cv-headline span:last-child { font-size: 11px; font-weight: 500; letter-spacing: .01em; color: #5f544e; }

/* Statut de disponibilité (badge) */
.cv-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
  padding: 5px 12px 5px 10px;
  font-family: 'Space Mono', monospace;
  font-size: 8.5px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--accent, #9a3b2e);
  border-radius: 20px;
}
.cv-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .35);
}

.cv-sections { display: flex; flex-direction: column; gap: 14px; }

.cv-h2 { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; break-after: avoid; }
.cv-h2-num { font-family: 'Space Mono', monospace; font-weight: 700; font-size: 12px; color: var(--accent, #9a3b2e); }
.cv-h2 h2 {
  margin: 0;
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -.005em;
  color: #231b18;
}
.cv-h2-line { flex: 1; height: 1px; background: #e6ddd6; }

.cv-timeline {
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding-left: 5px;
  border-left: 2px solid #efe6df;
  margin-left: 2px;
}
.cv-item { break-inside: avoid; padding-left: 9px; }
.cv-item-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.cv-item-title { font-weight: 600; font-size: 11.5px; line-height: 1.25; }
.cv-item-year {
  font-family: 'Space Mono', monospace;
  font-size: 8.5px;
  color: var(--accent, #9a3b2e);
  white-space: nowrap;
}
.cv-item-sub { font-size: 9.5px; color: #8a7d76; margin-top: 2px; }
.cv-item-desc { font-size: 9.5px; color: #5f544e; margin-top: 3px; line-height: 1.4; }
.cv-item-em { font-style: italic; color: #a07f72; }
/* Thèmes du programme d'une formation (licence/master) */
.cv-item-themes { font-size: 9px; color: #6d615b; margin-top: 3px; line-height: 1.45; }
.cv-themes-label {
  font-family: 'Space Mono', monospace;
  font-size: 7.5px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent, #9a3b2e);
  margin-right: 2px;
}
/* Diplôme rattaché à une formation (entrée sans année de fin) */
.cv-item-diploma {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  font-size: 9.5px;
  color: #5f544e;
  line-height: 1.3;
}
.cv-item-diploma strong { font-weight: 600; }
.cv-diploma-mark { flex: 0 0 auto; color: var(--accent, #9a3b2e); font-size: 8px; line-height: 1.6; }
.cv-item-link {
  display: inline-block;
  margin-top: 3px;
  font-family: 'Space Mono', monospace;
  font-size: 8.5px;
  color: var(--accent, #9a3b2e);
  text-decoration: none;
  word-break: break-all;
}

/* --- Impression --- */
@media print {
  /* Le dégradé est porté par l'élément racine (html) : avec @page margin:0, le
     fond de la racine remplit CHAQUE page en entier (dernière page comprise),
     bord à bord → plus de fond qui s'arrête en cours de dernière page.
     .cv-page devient transparente mais garde son padding + box-decoration-break
     pour la respiration du contenu en haut/bas de chaque page. */
  html {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    margin: 0;
    padding: 0;
    background: linear-gradient(to right,
      #f7f1ed 0, #f7f1ed 63.7mm,
      #ece2db 63.7mm, #ece2db 64mm,
      #fdfbf9 64mm) !important;
  }
  body { background: transparent; margin: 0; padding: 0; display: block; }
  .cv-page {
    box-shadow: none !important;
    margin: 0 !important;
    min-height: 0 !important;
    background: transparent !important;
    /* la respiration haut/bas de chaque page est assurée par les .page-gap */
    padding: 0 !important;
  }
  /* AUCUN flex fragmenté à l'impression : quand un conteneur flex se coupe
     entre deux pages, Chrome/WebKit positionnent les éléments suivants d'après
     la mise en page NON fragmentée → titres de section superposés au texte
     poussé à la coupure, et haut de page sans respiration. On repasse toute la
     structure en flux block (les `gap` deviennent des marges) et la sidebar en
     float — schéma d'impression fiable dans tous les moteurs. */
  .cv-page { display: block; }
  .cv-side {
    float: left;
    width: 64mm;
    display: block;
    padding-top: 2mm;
    padding-bottom: 0;
  }
  .cv-side > * { margin-bottom: 16px; }
  .cv-photo { margin: 0 auto 16px; }
  .cv-main {
    display: block;
    margin-left: 64mm;
    padding-top: 2mm;
    padding-bottom: 0;
  }
  .cv-sections { display: block; }
  .cv-sections > section { margin-bottom: 14px; }
  .cv-timeline { display: block; }
  .cv-timeline > .cv-item { margin-bottom: 9px; }
  .cv-timeline > .cv-item:last-child { margin-bottom: 0; }
  .cv-skills { display: block; }
  .cv-skills > .cv-skill-group { margin-bottom: 11px; }
  .cv-contact-list { display: block; }
  .cv-contact-list > div { margin-bottom: 7px; }
  .cv-interets { display: block; }
  .cv-interets > div { margin-bottom: 6px; }
  /* Les halos décoratifs de la sidebar sont positionnés en absolu par rapport
     à une colonne qui se fragmente : ils réapparaissent en plein milieu des
     pages suivantes. On les coupe à l'impression. */
  .cv-glow { display: none !important; }
  /* Coupures de page propres : jamais au milieu d'une entrée, jamais juste
     après un titre de section, pas de lignes veuves/orphelines. */
  .cv-item, .cv-block, .cv-skill-group { break-inside: avoid; page-break-inside: avoid; }
  .cv-h2 { break-after: avoid; page-break-after: avoid; }
  .cv-item-desc, .cv-item-sub, p { orphans: 3; widows: 3; }
  .noprint { display: none !important; }
}
