/* =========================================================
   Jack Bâtiment — thème « chantier » (sombre)
   jaune sécurité, orange balisage, gris béton
   ========================================================= */
:root {
  --bg: #16181b;
  --bg2: #1e2125;
  --card: #24282d;
  --card2: #2c3137;
  --ink: #f3f1ea;
  --muted: #a9aeb5;
  --line: #3a4048;
  --jaune: #ffc420;
  --jaune-fonce: #c99600;
  --orange: #ff7a1a;
  --beton: #8d939b;
  --vert: #3cc47c;
  --vert-bg: #173a29;
  --rouge: #ff5d52;
  --rouge-bg: #45201f;
  --bleu: #4fb3ff;
  --ombre: 0 4px 0 rgba(0, 0, 0, .35);
  --rayures: repeating-linear-gradient(-45deg, var(--jaune) 0 14px, #1b1b1b 14px 28px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 "Nunito", system-ui, sans-serif;
  overflow-x: clip;
}
body::before { /* béton discret */
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 196, 32, .06), transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(255, 122, 26, .05), transparent 45%);
}
h1, h2, h3 { font-family: "Baloo 2", "Nunito", sans-serif; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: clamp(1.7rem, 5vw, 2.5rem); }
h2 { font-size: clamp(1.3rem, 3.6vw, 1.7rem); }
h3 { font-size: 1.15rem; }
a { color: var(--jaune); }
p { margin: 0 0 .8em; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; background: rgba(22, 24, 27, .92); backdrop-filter: blur(8px);
  border-bottom: 4px solid transparent; border-image: var(--rayures) 4;
}
.logo { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  font: 800 1.25rem "Baloo 2", sans-serif; }
.logo b { color: var(--jaune); }
.nav-haut { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-haut a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 700; font-size: .95rem; }
.nav-haut a:hover, .nav-haut a.actif { color: #1b1b1b; background: var(--jaune); }

main { max-width: 1040px; margin: 0 auto; padding: 18px 16px 80px; }

/* ---------- David le castor (casque dessiné dans images/castor.svg) ---------- */
.avatar-jack {
  display: inline-block; flex: 0 0 auto; border-radius: 50%;
  width: 72px; height: 72px;
  background: #1e2125 url("images/castor.svg") center / cover no-repeat;
  box-shadow: 0 0 0 3px var(--jaune), 0 6px 18px rgba(0, 0, 0, .45);
}
.avatar-jack.mini { width: 34px; height: 34px; box-shadow: 0 0 0 2px var(--jaune); }

/* ---------- Blocs ---------- */
.carte { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--ombre); }
.grille { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); }
.grille.large { grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.pile > * + * { margin-top: 14px; }
.muted { color: var(--muted); }
.petit { font-size: .9rem; }
.ligne { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.espace { justify-content: space-between; }

.hero { display: flex; gap: 18px; align-items: center; padding: 20px; border-radius: 18px;
  background: linear-gradient(135deg, #2b2f35, #1e2125); border: 1px solid var(--line); margin-bottom: 20px; }
.hero .avatar-jack { width: 110px; height: 110px; }
.bulle { background: #3a3216; border: 1px solid #5a4b1c; border-radius: 14px; padding: 10px 14px; position: relative; }

/* ---------- Échelle des métiers ---------- */
.echelle { display: grid; gap: 12px; }
.metier { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-left: 8px solid var(--jaune); border-radius: 14px; padding: 14px; box-shadow: var(--ombre);
  transition: transform .12s; }
.metier:hover { transform: translateY(-2px); border-color: var(--jaune); }
.metier .emoji { font-size: 2.4rem; text-align: center; }
.metier .marche { font: 800 .8rem "Baloo 2"; color: #1b1b1b; background: var(--jaune); border-radius: 6px; padding: 1px 7px; }
.barre { height: 8px; background: var(--bg2); border-radius: 99px; overflow: hidden; margin-top: 6px; }
.barre > i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--jaune)); border-radius: 99px; }
.tuile { display: block; text-decoration: none; color: inherit; }
.tuile:hover { border-color: var(--jaune); }
.tuile .emoji { font-size: 2rem; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; cursor: pointer; text-decoration: none;
  padding: 10px 16px; border-radius: 12px; border: 0; font-weight: 800; background: var(--jaune); color: #1b1b1b; box-shadow: 0 3px 0 var(--jaune-fonce); }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.sec { background: var(--card2); color: var(--ink); box-shadow: 0 3px 0 #111; border: 1px solid var(--line); }
.btn.orange { background: var(--orange); color: #1b1b1b; box-shadow: 0 3px 0 #a84a05; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.retour { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-weight: 700; }
.retour:hover { color: var(--jaune); }

/* ---------- Modules ---------- */
.module { display: grid; grid-template-columns: 46px 1fr auto; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.module .num { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; background: var(--card2); }
.etat { font-size: .85rem; font-weight: 800; padding: 3px 9px; border-radius: 99px; background: var(--card2); color: var(--muted); white-space: nowrap; }
.etat.ok { background: var(--vert-bg); color: #9ff0c2; }

/* ---------- Leçon ---------- */
.lecon h2 { border-left: 5px solid var(--jaune); padding-left: 10px; margin-top: 8px; }
.lecon ul { margin: 0 0 .8em; padding-left: 1.2em; }
.lecon li { margin: .25em 0; }
.encadre { border-radius: 14px; padding: 14px 16px; }
.encadre.retenir { background: #3a3216; border: 1px solid #6b5716; }
.encadre.terrain { background: #1d2f3d; border: 1px solid #2f5470; }
.encadre.danger { background: var(--rouge-bg); border: 1px solid #7a3532; }
.encadre h3 { margin-bottom: .3em; }

/* ---------- Quiz ---------- */
.choix { display: grid; gap: 10px; margin: 14px 0; }
.choix button { text-align: left; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card2); cursor: pointer; font-weight: 700; }
.choix button:hover:not([disabled]) { border-color: var(--jaune); }
.choix button.bon { border-color: var(--vert); background: var(--vert-bg); }
.choix button.faux { border-color: var(--rouge); background: var(--rouge-bg); }
.explication { margin-top: 10px; }
.score { font: 800 3rem "Baloo 2"; color: var(--jaune); }

/* ---------- Tableaux / recherche ---------- */
.champ { width: 100%; padding: 11px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg2); }
.champ:focus { outline: none; border-color: var(--jaune); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--jaune); font-family: "Baloo 2"; }
code, kbd { font-family: ui-monospace, Consolas, monospace; background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; font-size: .9em; }
kbd { color: var(--jaune); }

.onglets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.onglets a { text-decoration: none; padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-weight: 700; }
.onglets a.actif { background: var(--jaune); color: #1b1b1b; border-color: var(--jaune); }

/* ---------- Formulaires des calculateurs ---------- */
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.form label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); font-weight: 700; }
.form input, .form select { padding: 9px 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg2); width: 100%; }
.resultat { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bg2); border: 1px dashed var(--jaune); }
.resultat b { color: var(--jaune); }

/* ---------- Check-lists ---------- */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.checklist label { display: flex; gap: 10px; align-items: flex-start; cursor: pointer; }
.checklist input { width: 20px; height: 20px; accent-color: var(--jaune); flex: 0 0 auto; margin-top: 3px; }
.zone-notes { width: 100%; min-height: 90px; margin-top: 10px; padding: 10px; border-radius: 10px; border: 2px solid var(--line); background: var(--bg2); }

/* ---------- Simulateur AutoCAD ---------- */
.simu { display: grid; gap: 10px; }
.simu canvas { width: 100%; height: auto; aspect-ratio: 16 / 10; background: #212830; border-radius: 12px; border: 1px solid var(--line); display: block; touch-action: none; }
.console { background: #0f1114; border: 1px solid var(--line); border-radius: 12px; font-family: ui-monospace, Consolas, monospace; font-size: .88rem; }
.console .hist { max-height: 140px; overflow-y: auto; padding: 8px 10px; white-space: pre-wrap; color: #c8ccd2; }
.console .hist .err { color: var(--rouge); }
.console .hist .ok { color: var(--vert); }
.console .saisie { display: flex; align-items: center; gap: 6px; border-top: 1px solid var(--line); padding: 6px 10px; }
.console .saisie span { color: var(--jaune); white-space: nowrap; }
.console input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none; color: var(--ink); font-family: inherit; padding: 6px 0; }
.mission { border-left: 5px solid var(--orange); }
.mission.reussie { border-left-color: var(--vert); }

/* ---------- Attestation ---------- */
.attestation { background: #fbf8ef; color: #1b1b1b; border-radius: 10px; padding: 30px; text-align: center; border: 10px solid transparent; border-image: var(--rayures) 10; }
.attestation h1 { color: #1b1b1b; }
.attestation .nom { font: 800 2rem "Baloo 2"; border-bottom: 2px solid #1b1b1b; display: inline-block; min-width: 60%; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(150%); background: var(--jaune); color: #1b1b1b;
  font-weight: 800; padding: 10px 18px; border-radius: 12px; transition: transform .25s, opacity .25s; z-index: 20; max-width: calc(100% - 32px);
  opacity: 0; pointer-events: none; }
.toast.vu { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ---------- Illustrations animées ---------- */
.illus { margin: 14px 0; }
.illus-cadre { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--ombre); background: #1e2731; }
.illus-svg { display: block; width: 100%; height: auto; }
.illus figcaption { margin-top: 8px; }

/* ---------- Chasse aux dangers ---------- */
.scene-wrap { border-radius: 14px; overflow: hidden; border: 2px solid var(--line); }
.scene-wrap svg { display: block; width: 100%; height: auto; cursor: crosshair; touch-action: manipulation; }

/* ---------- Simulateur : ruban, aide, guide ---------- */
.ruban { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; background: var(--card2); border: 1px solid var(--line); border-radius: 12px; }
.ruban button { display: grid; justify-items: center; gap: 2px; min-width: 64px; padding: 6px 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; font-size: 1.2rem; line-height: 1; }
.ruban button span { font-size: .72rem; font-weight: 800; color: var(--muted); }
.ruban button:hover { border-color: var(--jaune); }
.ruban button:hover span { color: var(--jaune); }
.aide-invite { background: #1d2f3d; border: 1px solid #2f5470; border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.aide-invite b { color: #9fd3ff; }
.guide { background: #3a3216; border: 2px solid var(--jaune); border-radius: 12px; padding: 10px 12px; }
.guide code.gros { font-size: 1.15rem; color: var(--jaune); padding: 2px 8px; }

/* ---------- Jack CAD : interface façon AutoCAD ---------- */
.acad { display: grid; gap: 0; border: 1px solid #0c0e11; border-radius: 12px; overflow: hidden; background: #2b3038; box-shadow: var(--ombre); }
.acad-titre { background: #1a1d22; color: #c8ccd2; font-size: .85rem; padding: 6px 10px; display: flex; gap: 8px; align-items: center; }
.acad-titre b { background: #c0392b; color: #fff; border-radius: 4px; padding: 0 6px; font-family: "Baloo 2"; }
.acad-titre span { margin-left: auto; color: #7d838b; font-size: .78rem; }
.acad-ruban { display: flex; flex-wrap: wrap; background: #353b44; border-bottom: 1px solid #1a1d22; }
.acad-groupe { display: grid; grid-template-rows: 1fr auto; border-right: 1px solid #262a31; padding: 4px 4px 0; }
.acad-btns { display: flex; flex-wrap: wrap; gap: 2px; align-items: flex-start; }
.acad-btns button { display: grid; justify-items: center; gap: 1px; min-width: 54px; padding: 4px 4px; border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; color: #e6e8eb; }
.acad-btns button i { font-style: normal; font-size: 1.25rem; line-height: 1.1; color: #9fd3ff; }
.acad-btns button span { font-size: .7rem; font-weight: 700; color: #c8ccd2; }
.acad-btns button:hover { background: #454c57; border-color: #5a626e; }
.acad-nom { text-align: center; font-size: .68rem; color: #8d939b; border-top: 1px solid #2c3137; padding: 2px 0; text-transform: uppercase; letter-spacing: .05em; }
.acad-calques { align-items: center; padding: 8px 4px; }
.acad-calques select { background: #1e2125; color: #f3f1ea; border: 1px solid #5a626e; border-radius: 6px; padding: 6px 8px; font-weight: 700; min-width: 130px; }
.acad .guide { border-radius: 0; border-width: 0 0 2px; }
.acad-zone { position: relative; }
.acad-zone canvas { display: block; width: 100%; height: auto; cursor: none; touch-action: none; background: #212830; }
.acad-dyn { position: absolute; pointer-events: none; background: rgba(30, 33, 37, .92); border: 1px solid #5a626e; border-radius: 4px; padding: 2px 6px; font: 12px ui-monospace, Consolas, monospace; color: #e6e8eb; white-space: nowrap; z-index: 2; }
.acad-dyn span { color: #9fd3ff; margin-right: 6px; }
.acad-dyn b { background: #4a5260; padding: 0 4px; border-radius: 2px; font-weight: 400; }
.acad .aide-invite { border-radius: 0; border-width: 1px 0 0; }
.acad .console { border-radius: 0; border-width: 1px 0 0; position: relative; }
.acad-suggest { position: absolute; left: 8px; bottom: 44px; background: #1e2125; border: 1px solid #5a626e; border-radius: 6px; z-index: 3; min-width: 280px; box-shadow: 0 6px 18px rgba(0,0,0,.5); }
.acad-suggest button { display: block; width: 100%; text-align: left; padding: 6px 10px; border: 0; background: transparent; cursor: pointer; color: #f3f1ea; font: 13px ui-monospace, Consolas, monospace; }
.acad-suggest button:hover, .acad-suggest button:first-child { background: #2f5470; }
.acad-suggest span { color: #a9aeb5; font-family: Nunito, sans-serif; }
.acad-etat { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; background: #1a1d22; padding: 4px 8px; font: 12px ui-monospace, Consolas, monospace; color: #c8ccd2; }
.acad-modes { display: flex; gap: 4px; flex-wrap: wrap; }
.acad-modes button { border: 1px solid #3a4048; background: #262a31; color: #7d838b; border-radius: 4px; padding: 2px 8px; font: 700 11px ui-monospace, Consolas, monospace; cursor: pointer; }
.acad-modes button.actif { color: #9fd3ff; background: #20384d; border-color: #2f6a99; }
.acad-props { background: #262a31; padding: 6px 10px; font-size: .85rem; color: #e6e8eb; border-top: 1px solid #1a1d22; }

/* ---------- Onglets en boutons (lexique) ---------- */
.onglet-btn { padding: 8px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); color: var(--ink); font-weight: 700; cursor: pointer; }
.onglet-btn.actif { background: var(--jaune); color: #1b1b1b; border-color: var(--jaune); }
details.carte summary { cursor: pointer; list-style: none; }
details.carte summary::-webkit-details-marker { display: none; }
details.carte summary::before { content: "▸ "; color: var(--jaune); }
details.carte[open] summary::before { content: "▾ "; }

/* ---------- Mode équipe ---------- */
.tableau-equipe td { text-align: center; }
.tableau-equipe td:first-child { text-align: left; }
.cell-ok { background: var(--vert-bg); }
.cell-encours { background: #3a3216; }

/* ---------- Devis professionnel (aperçu = document imprimé) ---------- */
.doc-devis { background: #fff; color: #1b1b1b; border-radius: 8px; padding: 28px; font-size: .9rem; line-height: 1.45; max-width: 820px; margin: 0 auto; box-shadow: var(--ombre); }
.doc-devis p { margin: 0 0 .5em; }
.doc-entete { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 16px; }
.doc-logo { display: block; max-height: 70px; max-width: 220px; margin-bottom: 8px; }
.doc-nom { font: 800 1.2rem "Baloo 2", sans-serif; }
.doc-cli { text-align: right; min-width: 220px; }
.doc-titre { font: 800 1.8rem "Baloo 2", sans-serif; letter-spacing: .08em; color: #c99600; }
.doc-client { margin-top: 10px; padding: 10px 12px; border: 1px solid #ccc; border-radius: 8px; text-align: left; }
.doc-table, .doc-totaux { width: 100%; border-collapse: collapse; margin-top: 10px; }
.doc-table th { background: #1b1b1b; color: #ffc420; font-family: "Baloo 2", sans-serif; }
.doc-table th, .doc-table td { border: 1px solid #ccc; padding: 6px 8px; color: #1b1b1b; }
.doc-devis .num { text-align: right; white-space: nowrap; }
.doc-totaux { width: auto; margin-left: auto; min-width: 300px; }
.doc-totaux td { padding: 4px 8px; border-bottom: 1px solid #eee; color: #1b1b1b; }
.doc-ttc td { font-weight: 900; font-size: 1.05rem; background: #fff4cc; }
.doc-mentions { margin-top: 14px; font-size: .8rem; color: #333; }
.doc-signature { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.doc-signature > div { border: 1px solid #999; border-radius: 8px; padding: 10px; min-height: 110px; font-size: .8rem; }

@media (max-width: 600px) {
  .doc-devis { padding: 14px; }
  .doc-cli { text-align: left; }
  .doc-signature { grid-template-columns: 1fr; }
  .ruban button { min-width: 54px; }
}

@media (max-width: 600px) {
  .topbar { padding: 6px 12px; }
  .nav-haut a { padding: 5px 8px; font-size: .88rem; }
  .hero { flex-direction: column; text-align: center; padding: 16px; }
  .metier { grid-template-columns: 44px 1fr; }
  .metier .emoji { font-size: 1.9rem; }
  .metier .etat { grid-column: 1 / -1; justify-self: start; }
  .module { grid-template-columns: 40px 1fr; }
  .module .etat { grid-column: 2; justify-self: start; }
}

@media print {
  .topbar, .nav-haut, .btn, .retour, .no-print, .toast { display: none !important; }
  body { background: #fff; color: #000; }
  body::before { display: none; }
  .carte { box-shadow: none; border-color: #999; background: #fff; color: #000; }
  .checklist li { border-color: #ccc; }
  main { padding: 0; }
  body.impression-devis main > *:not(#apercu) { display: none !important; }
  .doc-devis { box-shadow: none; padding: 0; max-width: none; }
  .illus-cadre { box-shadow: none; }
}
