/* ==========================================================================
   Couleurs mesurées sur le logo MSA
   ========================================================================== */
:root {
  --navy-900: #0b0652;    /* bleu marine foncé (bandeaux, pied de page) */
  --navy-800: #120a78;    /* bleu du logo (« MSA ») */
  --navy-700: #2a2290;
  --red: #c0001a;         /* rouge des rayons */
  --red-dark: #96001f;
  --violet: #4a0a6a;      /* pointes violettes des rayons */
  --glow: #f3dcc4;        /* centre lumineux des rayons */
  --bar: #9a9a9a;         /* barre grise sous « MSA » */
  --rays: linear-gradient(90deg, var(--violet), var(--red) 60%, var(--glow));
  --radius: 10px;

  /* Rôles (mode clair) */
  --bg: #fbfbfd;
  --bg-alt: #f1f0f7;
  --surface: #ffffff;
  --text: #140f3f;
  --muted: #5c5a73;
  --border: #d7d6e6;
  --link: var(--red-dark);
  --header-bg: #ffffff;
  --nav-link: var(--navy-800);
  --icon-bg: var(--navy-800);
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.06);
  color-scheme: light;
}

/* Mode sombre, activé uniquement avec le bouton (le site est en clair par défaut) */
:root[data-theme="dark"] {
  --bg: #0a0820;
  --bg-alt: #110e2c;
  --surface: #17133a;
  --text: #e9e8f4;
  --muted: #a9a7c2;
  --border: #2c2758;
  --link: #ff7083;
  --header-bg: #0f0c29;
  --nav-link: #dcdbf0;
  --icon-bg: var(--navy-700);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 20px rgba(0,0,0,.35);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--link); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; margin: 0 0 .6em; }
h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
h3 { font-size: 1.15rem; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.section { padding: 64px 0; }
.section.alt { background: var(--bg-alt); }

/* Barre grise du logo sous les titres de section */
.section h2:not(.gallery-title)::after,
.cta h2::after {
  content: ""; display: block; width: 64px; height: 5px; border-radius: 3px;
  background: var(--bar); margin-top: .45em;
}
.cta h2::after { background: rgba(255,255,255,.6); }
.prose h2::after { display: none !important; }

/* ==========================================================================
   Boutons
   ========================================================================== */
.btn {
  display: inline-block;
  padding: .75em 1.4em;
  border-radius: var(--radius);
  background: var(--red);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid var(--red);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-ghost { background: transparent; border-color: rgba(255,255,255,.5); }
.btn-ghost:hover { background: rgba(255,255,255,.1); border-color: #fff; }
.btn-small { padding: .4em .9em; font-size: .9rem; }

/* ==========================================================================
   En-tête
   ========================================================================== */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--header-bg);
  box-shadow: 0 2px 10px rgba(18,10,120,.08);
}
.site-header::after { content: ""; display: block; height: 3px; background: var(--rays); }
.nav { display: flex; align-items: center; gap: 1.4em; min-height: 76px; }
.brand { display: flex; align-items: center; margin-right: auto; text-decoration: none; }
/* Le logo a un fond blanc : on le garde dans un cartouche blanc */
.brand img { height: 60px; width: auto; display: block; background: #fff; border-radius: 8px; }
.menu { display: flex; align-items: center; gap: 1.6em; }
.menu a:not(.btn) { color: var(--nav-link); text-decoration: none; font-weight: 600; }
.menu a:not(.btn):hover, .menu a.active { color: var(--red); box-shadow: inset 0 -2px 0 var(--red); }
:root[data-theme="dark"] .menu a:not(.btn):hover,
:root[data-theme="dark"] .menu a.active { color: var(--link); }
/* Bouton mode clair / sombre */
.theme-toggle {
  display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: transparent; color: var(--nav-link); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--red); color: var(--red); }
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.nav-toggle, .nav-burger { display: none; }

@media (max-width: 980px) {
  .nav { flex-wrap: wrap; gap: 10px; min-height: 64px; }
  .brand img { height: 46px; }

  /* Bouton menu : zone de 44 px pour le doigt, se transforme en croix */
  .nav-burger {
    display: grid; place-items: center; order: 3;
    width: 44px; height: 44px; margin-right: -8px; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-burger span { position: relative; display: block; width: 26px; height: 2px; background: var(--nav-link); transition: background .2s; }
  .nav-burger span::before, .nav-burger span::after {
    content: ""; position: absolute; left: 0; width: 100%; height: 2px; background: var(--nav-link);
    transition: transform .2s;
  }
  .nav-burger span::before { top: -8px; }
  .nav-burger span::after { top: 8px; }
  .nav-toggle:checked ~ .nav-burger span { background: transparent; }
  .nav-toggle:checked ~ .nav-burger span::before { transform: translateY(8px) rotate(45deg); }
  .nav-toggle:checked ~ .nav-burger span::after { transform: translateY(-8px) rotate(-45deg); }

  .theme-toggle { order: 2; width: 44px; height: 44px; }

  /* Menu déplié : grandes lignes faciles à toucher */
  .menu {
    order: 4; display: none; width: 100%;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: 4px 0 16px;
    max-height: calc(100vh - 70px); overflow-y: auto;
  }
  .nav-toggle:checked ~ .menu { display: flex; }
  .menu a:not(.btn) {
    padding: 14px 4px; font-size: 1.05rem;
    border-bottom: 1px solid var(--border);
  }
  .menu a:not(.btn):hover, .menu a.active { box-shadow: inset 4px 0 0 var(--red); padding-left: 14px; }
  .menu .btn { margin-top: 16px; text-align: center; padding: .8em 1em; font-size: 1rem; }
}

/* ==========================================================================
   Bandeau d'accueil et en-têtes de page
   ========================================================================== */
.hero {
  color: #fff;
  padding: 110px 0 100px;
  background:
    linear-gradient(90deg, var(--navy-900) 30%, rgba(11,6,82,.82) 55%, rgba(11,6,82,.35)),
    url("../img/hero-soudure.jpg") right center / cover no-repeat,
    var(--navy-800);
}
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .8rem; color: var(--glow); font-weight: 700; margin: 0 0 1em; }
.hero h1 { max-width: 16em; }
.lead { font-size: 1.2rem; color: #d7d6e6; max-width: 38em; margin: 0 0 2em; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; }

.page-header { background: var(--navy-900); color: #fff; padding: 64px 0 56px; }
.page-header .lead { margin: 0; }
.page-icon { color: var(--glow); margin-bottom: 1em; }
.page-icon svg { width: 44px; height: 44px; }

/* ==========================================================================
   Cartes de services et atouts
   ========================================================================== */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
.card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-3px); border-color: var(--red); }
.card p { color: var(--muted); flex: 1; margin: 0 0 1em; }
.card-icon {
  width: 52px; height: 52px; display: grid; place-items: center;
  border-radius: 12px; background: var(--icon-bg); color: #fff;
  box-shadow: inset 0 -3px 0 var(--red);
  margin-bottom: 1.2em;
}
.more { color: var(--link); font-weight: 600; }

.features .feature { border-left: 3px solid var(--red); padding-left: 18px; }
.features p { color: var(--muted); margin: 0; }

/* ==========================================================================
   Texte Markdown
   ========================================================================== */
.prose { max-width: 760px; }
.prose.intro { margin-bottom: 40px; }
.prose h2 { margin-top: 1.6em; }
.prose ul { padding-left: 1.2em; }
.prose li::marker { color: var(--red); }
.prose table { border-collapse: collapse; width: 100%; margin: 1.5em 0; }
.prose th, .prose td { text-align: left; padding: .6em .8em; border-bottom: 1px solid var(--border); }
.prose th { background: var(--bg-alt); }
.prose blockquote { margin: 1.5em 0; padding: 1em 1.4em; border-left: 4px solid var(--red); background: var(--bg-alt); border-radius: 0 var(--radius) var(--radius) 0; }

.contact-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin: 2em 0; }
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.contact-card h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: .4em; }
.contact-card p { margin: 0; font-weight: 600; }

/* ==========================================================================
   Photos et galeries
   ========================================================================== */
.page-photo { margin: 0 0 2em; max-width: 760px; }
.page-photo img,
.prose img {
  width: auto; max-width: 100%; max-height: 640px; height: auto; display: block;
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.prose img { margin: 1.5em 0; }
.page-photo figcaption { color: var(--muted); font-size: .95rem; margin-top: .7em; }

.gallery-title { margin-top: 2em; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 24px; }
.gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; transition: opacity .15s; }
.gallery a:hover img { opacity: .88; }
.gallery figcaption { color: var(--muted); font-size: .95rem; padding: 16px 20px 20px; margin: 0; }
.gallery figcaption strong { display: block; color: var(--text); font-size: 1.05rem; margin-bottom: .2em; }
.see-all { margin: 28px 0 0; text-align: right; }
.see-all a { text-decoration: none; }

/* Galerie insérée dans un texte Markdown (page Réalisations) */
.prose:has(.gallery) { max-width: none; }
.prose .gallery { margin-top: 2em; }
.prose .gallery img { width: 100%; max-height: none; margin: 0; border-radius: 0; box-shadow: none; }

/* ==========================================================================
   Appel à l'action et pied de page
   ========================================================================== */
.cta { background: linear-gradient(100deg, var(--violet), var(--red)); color: #fff; padding: 48px 0; }
.cta-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px; }
.cta h2 { margin: 0 0 .2em; }
.cta p { margin: 0; }
.cta .btn { background: var(--navy-900); border-color: var(--navy-900); }
.cta .btn:hover { background: #000; border-color: #000; }

.site-footer { background: var(--navy-900); color: #d7d6e6; padding: 48px 0 24px; font-size: .95rem; }
.site-footer a { color: #d7d6e6; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; }
.footer-grid p { margin: 0 0 .4em; }
.footer-grid nav { display: flex; flex-direction: column; gap: .3em; }
.footer-grid nav a { text-decoration: none; }
.footer-logo { background: #fff; border-radius: 8px; padding: 8px 12px; display: inline-block; margin-bottom: .6em; }
.footer-logo img { height: 48px; width: auto; display: block; }
.demo-note { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--navy-700); font-size: .85rem; color: #a9a7c2; }

/* ==========================================================================
   Barre « Appeler » (téléphone uniquement)
   ========================================================================== */
.call-bar { display: none; }

/* ==========================================================================
   Téléphone et petites tablettes
   ========================================================================== */
img { max-width: 100%; }
a { overflow-wrap: anywhere; }

/* Tableaux : défilement horizontal plutôt que débordement de la page */
.prose table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

@media (max-width: 760px) {
  body { font-size: 16px; }
  .container { padding: 0 16px; }
  .section { padding: 44px 0; }

  .hero { padding: 56px 0 52px; background-position: center, 70% center, center; }
  .hero h1 { font-size: clamp(1.75rem, 8vw, 2.3rem); }
  .lead { font-size: 1.05rem; margin-bottom: 1.6em; }
  .actions { flex-direction: column; }
  .actions .btn { text-align: center; }

  .page-header { padding: 40px 0 36px; }
  .page-header h1 { font-size: clamp(1.6rem, 7vw, 2.1rem); }
  .page-icon svg { width: 36px; height: 36px; }

  .grid, .gallery { gap: 16px; }
  .grid { grid-template-columns: 1fr; }
  .card { padding: 22px; }
  .card:hover { transform: none; }
  .card-icon { width: 46px; height: 46px; margin-bottom: 1em; }

  /* Galeries : 2 colonnes compactes, légende courte */
  .gallery { grid-template-columns: 1fr 1fr; }
  .gallery figcaption { padding: 10px 12px 14px; font-size: .85rem; }
  .gallery figcaption strong { font-size: .95rem; }
  .see-all { text-align: center; }

  .features { grid-template-columns: 1fr; }
  .contact-cards { grid-template-columns: 1fr; }

  .page-photo { margin-bottom: 1.4em; }
  .page-photo img, .prose img { max-height: 70vh; }

  .cta { padding: 36px 0; }
  .cta-inner { flex-direction: column; align-items: stretch; text-align: center; }
  .cta h2::after { margin-left: auto; margin-right: auto; }
  .cta .btn { text-align: center; }

  .site-footer { padding: 36px 0 20px; }
  .footer-grid { grid-template-columns: 1fr; gap: 20px; text-align: center; }
  .footer-grid nav { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: .4em 1.2em; }

  /* Barre « Appeler » fixée en bas de l'écran */
  .call-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; align-items: center; justify-content: center; gap: .6em;
    min-height: 56px; padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
    background: var(--red); color: #fff; font-weight: 700; font-size: 1.05rem;
    text-decoration: none; box-shadow: 0 -4px 16px rgba(0,0,0,.18);
  }
  .call-bar svg { width: 20px; height: 20px; }
  .call-bar:active { background: var(--red-dark); }
  body { padding-bottom: calc(56px + env(safe-area-inset-bottom)); }
}

/* Très petits écrans : une seule colonne de photos */
@media (max-width: 400px) {
  .gallery { grid-template-columns: 1fr; }
  .gallery figcaption { font-size: .95rem; }
}
