/* ═══════════════════════════════════════════════════════════════
   VOX BATI — Outils gratuits
   Composants du calculateur. À charger APRÈS blog.css (réutilise ses
   variables :root, son header/footer, sa typo).
   ═══════════════════════════════════════════════════════════════ */

/* ─── Garde-fous anti scroll horizontal ─── */
html, body { overflow-x: hidden; max-width: 100%; }
/* overflow-x: clip sur les conteneurs : tout descendant trop large est
   rogné AU NIVEAU DU CONTENEUR et ne peut plus pousser la page de côté.
   clip (et non hidden) n'ouvre pas de conteneur de défilement. */
.tool-wrap, .tool-content { overflow-x: clip; }
.tool-wrap, .tool-card, .tool-result, .tool-content { max-width: 100%; box-sizing: border-box; }
.tool-input, select.tool-input { max-width: 100%; box-sizing: border-box; }
/* Enfants de conteneurs flex : autoriser le rétrécissement (sinon un texte
   long bloque le rétrécissement et déborde -> scroll horizontal). */
.tool-input-wrap > *, .tool-breakdown-row > *, .vbsheet-opt > * { min-width: 0; }

/* ─── Conteneur outil ─── */
.tool-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}

.tool-header { margin: 8px 0 28px; }
.tool-header h1 {
  font-size: clamp(27px, 5vw, 36px);
  font-weight: 800;
  color: var(--ink);
  line-height: 1.18;
  margin: 14px 0 10px;
}
.tool-header p.tool-intro {
  font-size: 17px;
  color: var(--mute);
  margin: 0;
}

/* ─── Carte calculateur ─── */
.tool-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 18px 40px -24px rgba(13, 27, 42, 0.22);
  margin-bottom: 32px;
}

.tool-question { margin-bottom: 24px; }
.tool-question:last-of-type { margin-bottom: 8px; }
.tool-question .q-label {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 12px;
}
.tool-question .q-label .q-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  margin-right: 8px;
}

/* Sous-titre de section dans la carte (ex : « Finitions du toit ») */
.tool-subhead {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 28px 0 16px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}
.tool-subhead::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Champs de saisie numériques */
.tool-field { margin-bottom: 20px; }
.tool-field label {
  display: block;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 8px;
}
.tool-field .field-hint {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 13px;
  color: var(--mute);
}
.tool-input-wrap { position: relative; display: flex; align-items: center; }
.tool-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--paper);
  -webkit-appearance: none;
  appearance: none;
}
.tool-input:focus { outline: none; border-color: var(--accent-deep); }
/* Masquer les flèches natives des champs number (se superposaient avec l'unité) */
.tool-input::-webkit-outer-spin-button,
.tool-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tool-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
/* Menu déroulant stylé comme un champ, avec flèche custom (fallback si JS off) */
select.tool-input {
  cursor: pointer;
  padding-right: 42px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6a82' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

/* ─── Bottom-sheet picker (remplace le menu natif des <select>) ─── */
.vbsheet-trigger {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 13px 44px 13px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  line-height: 1.35;
  color: var(--ink);
  background-color: var(--paper);
  background-repeat: no-repeat;
  background-position: right 16px center;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.vbsheet-trigger:active { border-color: var(--accent-deep); }
.vbsheet-trigger-label {
  display: block;
  overflow-wrap: anywhere;
}

.vbsheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  overflow: hidden;
  background: rgba(10, 20, 34, 0.55);
  display: flex;
  align-items: flex-end;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.vbsheet-overlay.show { opacity: 1; }

.vbsheet {
  width: 100%;
  background: var(--paper);
  border-radius: 20px 20px 0 0;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-shadow: 0 -16px 50px rgba(10, 20, 34, 0.3);
}
.vbsheet-overlay.show .vbsheet { transform: translateY(0); }

.vbsheet-head {
  padding: 12px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.vbsheet-grip {
  width: 38px;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
  margin: 0 auto 12px;
}
.vbsheet-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  text-align: center;
}
.vbsheet-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 6px 0 10px;
}
.vbsheet-opt {
  width: 100%;
  text-align: left;
  padding: 15px 20px;
  font-size: 15.5px;
  color: var(--ink-2);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  -webkit-tap-highlight-color: transparent;
}
.vbsheet-opt:active { background: rgba(46, 232, 122, 0.08); }
.vbsheet-opt[aria-selected="true"] {
  color: var(--accent-deep);
  font-weight: 700;
}
.vbsheet-opt-label { flex: 1; }
.vbsheet-check {
  flex: none;
  display: flex;
  color: var(--accent-deep);
  opacity: 0;
}
.vbsheet-opt[aria-selected="true"] .vbsheet-check { opacity: 1; }

/* Header de groupe (optgroup) à l'intérieur de la liste —
   bandeau gris clair pour bien séparer visuellement les catégories. */
.vbsheet-group {
  padding: 14px 20px;
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 11.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  background: rgba(13, 27, 42, 0.05);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.vbsheet-group:first-child {
  border-top: none;
}
/* Petit espace après une option et avant un nouveau groupe (transition propre) */
.vbsheet-opt + .vbsheet-group {
  margin-top: 6px;
}

/* PC/tablet (≥ 720px) : centrer le picker en modal, pas en bottom-sheet */
@media (min-width: 720px) {
  .vbsheet-overlay {
    align-items: center;
    justify-content: center;
    padding: 24px;
  }
  .vbsheet {
    width: 100%;
    max-width: 520px;
    border-radius: 20px;
    transform: translateY(20px) scale(0.96);
    transition: transform 0.22s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.22s ease;
    opacity: 0;
    max-height: min(72vh, 640px);
    box-shadow: 0 20px 60px rgba(10, 20, 34, 0.35);
  }
  .vbsheet-overlay.show .vbsheet {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  .vbsheet-grip { display: none; }
  .vbsheet-head {
    padding: 18px 24px 16px;
  }
  .vbsheet-title { font-size: 17px; }
}
.tool-input-wrap .unit {
  position: absolute;
  right: 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--mute);
  pointer-events: none;
}
.tool-input-wrap .tool-input { padding-right: 48px; }

/* Options (boutons radio stylés) */
.tool-options { display: grid; gap: 8px; }
.tool-options.cols-2 { grid-template-columns: 1fr 1fr; }
.tool-opt {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  font-size: 14.5px;
  color: var(--ink-2);
  transition: border-color 0.15s, background 0.15s;
  min-height: 48px;
}
.tool-opt:hover { border-color: var(--accent); }
.tool-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tool-opt .dot {
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #c3ccd9;
  transition: border-color 0.15s;
}
.tool-opt input:checked ~ .dot {
  border-color: var(--accent-deep);
  background: radial-gradient(circle, var(--accent-deep) 0 5px, transparent 6px);
}
.tool-opt:has(input:checked) {
  border-color: var(--accent-deep);
  background: rgba(46, 232, 122, 0.06);
}

/* ─── Résultat ─── */
.tool-result {
  margin-top: 24px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.tool-result[hidden] { display: none; }
.tool-result-head {
  background: linear-gradient(160deg, #0a1422, #132743);
  color: #fff;
  padding: 24px 26px;
  text-align: center;
}
.tool-result-head .result-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}
.tool-result-head .result-value {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 44px;
  font-weight: 800;
  line-height: 1.1;
  margin: 6px 0 0;
  overflow-wrap: break-word;
}
.tool-result-head .result-value em {
  font-style: normal;
  background: linear-gradient(120deg, #2EE87A, #a7ffcb);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
/* Quand le résultat est sur plusieurs lignes (<span class="result-line">), on
   applique le gradient sur chaque ligne — sinon les enfants héritent du
   text-fill transparent SANS le background, et le texte devient invisible. */
.tool-result-head .result-value .result-line {
  display: block;
  background: linear-gradient(120deg, #2EE87A, #a7ffcb);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.tool-result-head .result-value .result-line + .result-line {
  margin-top: 4px;
}
.tool-result-body {
  background: var(--paper);
  padding: 20px 26px;
}
.tool-result-body p { margin: 0 0 10px; font-size: 15px; color: var(--ink-2); line-height: 1.6; }
.tool-result-body p:last-child { margin-bottom: 0; }
.tool-result-body strong { color: var(--ink); }
.tool-result-mention {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--mute);
}
.tool-result-mention strong { color: var(--ink); }

/* Segmented control (2 boutons côte à côte pour un choix binaire fondamental) */
.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  background: var(--bg);
  border-radius: 14px;
  border: 1px solid var(--line);
}
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px;
  border: none;
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-2);
  text-align: center;
  font-family: inherit;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
  -webkit-tap-highlight-color: transparent;
}
.mode-btn:hover {
  background: rgba(13, 27, 42, 0.04);
}
.mode-btn:active {
  transform: scale(0.98);
}
.mode-btn.is-active {
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  color: #0a1422;
  box-shadow: 0 6px 18px rgba(46, 232, 122, 0.35);
}
.mode-btn .mode-icon {
  display: block;
  margin-bottom: 2px;
}
.mode-btn .mode-label {
  font-weight: 800;
  font-size: 15px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  line-height: 1.2;
}
.mode-btn .mode-sub {
  font-size: 12.5px;
  opacity: 0.75;
  line-height: 1.2;
}
.mode-btn.is-active .mode-sub {
  opacity: 0.9;
}
@media (max-width: 420px) {
  .mode-btn { padding: 12px 8px; }
  .mode-btn .mode-label { font-size: 13.5px; }
  .mode-btn .mode-sub { font-size: 11.5px; }
}

/* Liste détaillée du résultat (montants, rails, plaques, appuis, isolant) */
.tool-result-body .result-list {
  list-style: none;
  padding: 0;
  margin: 4px 0 0;
}
.tool-result-body .result-list li {
  padding: 12px 0;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.5;
}
.tool-result-body .result-list li + li {
  border-top: 1px solid var(--line);
}
.tool-result-body .result-list li:first-child { padding-top: 12px; }
.tool-result-body .result-list .sub-line {
  display: block;
  margin-top: 2px;
  font-size: 13.5px;
  color: var(--mute);
  font-weight: 400;
}

/* Liste « tout ce qu'il faut commander » */
.tool-breakdown {
  margin: 2px 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.tool-breakdown[hidden] { display: none; }
.tool-breakdown-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
}
.tool-breakdown-row + .tool-breakdown-row { border-top: 1px solid var(--line); }
.tool-breakdown-label {
  font-size: 14.5px;
  color: var(--ink-2);
}
.tool-breakdown-label small {
  display: block;
  font-size: 12.5px;
  color: var(--mute);
  margin-top: 2px;
}
.tool-breakdown-value {
  flex: 0 1 auto;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}
.tool-breakdown-label { min-width: 0; }

/* CTA VOX BATI intégré dans la carte résultat */
.tool-result-cta {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.tool-result-cta p {
  font-size: 14px;
  color: var(--mute);
  line-height: 1.5;
  margin: 0 0 12px;
  /* Evite les mots orphelins (veuve typographique) : rééquilibre les lignes */
  text-wrap: pretty;
  hyphens: none;
}
.tool-result-cta .blog-cta-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: var(--accent);
  color: #0a1422 !important;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.2;
  padding: 14px 32px;
  border-radius: 13px;
  text-decoration: none;
  box-shadow: 0 12px 26px -8px rgba(46, 232, 122, 0.5);
}
.tool-result-cta .blog-cta-btn small {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 12px;
  opacity: 0.78;
  color: #0a1422 !important;
}
.tool-result-cta .blog-cta-btn:hover { background: #45ff8a; color: #0a1422 !important; }

/* État initial : invitation à répondre */
.tool-hint {
  margin-top: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--mute);
}

/* ─── Section explicative SEO sous l'outil ─── */
.tool-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px 40px;
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink-2);
}
.tool-content h2 {
  font-size: clamp(21px, 3.4vw, 26px);
  color: var(--ink);
  margin: 36px 0 12px;
}
.tool-content p { margin: 0 0 18px; }
.tool-content ul { margin: 0 0 18px; padding-left: 22px; }
.tool-content li { margin-bottom: 7px; }
.tool-content strong { color: var(--ink); }
.tool-content a { color: var(--accent-deep); font-weight: 600; }

/* ─── Grille des outils (page /outils) ─── */
.tools-grid {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.tool-tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.tool-tile:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
  box-shadow: 0 22px 46px -22px rgba(13, 27, 42, 0.25);
  text-decoration: none;
}
.tool-tile .tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(46, 232, 122, 0.16), rgba(17, 200, 121, 0.16));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-deep);
}
.tool-tile h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  margin: 0;
}
.tool-tile p { font-size: 13.5px; color: var(--mute); margin: 0; line-height: 1.5; }
.tool-tile .tile-go {
  margin-top: auto;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-deep);
  padding-top: 8px;
}

/* ─── Responsive ─── */
@media (min-width: 601px) and (max-width: 1024px) {
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
  .tool-wrap, .tool-content { max-width: 680px; padding-left: 32px; padding-right: 32px; }
}

@media (max-width: 600px) {
  .tool-wrap, .tool-content { padding-left: 18px; padding-right: 18px; }
  .tool-card { padding: 20px; }
  .tool-options.cols-2 { grid-template-columns: 1fr; }
  .tool-result-head .result-value { font-size: 36px; }
  .tool-result-cta .blog-cta-btn { width: 100%; }
  .tools-grid { grid-template-columns: 1fr; padding: 18px 16px; }
  .tool-content { font-size: 16px; }
}
