/* ============================================
   Guide Monte Escalier — Main Stylesheet
   SPIP Template (reproduction du design Kadence WP)
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-primary: #2B6CB0;
  --color-primary-dark: #215387;
  --color-text: #2D3748;
  --color-text-light: #666;
  --color-bg: #fff;
  --color-bg-light: #f7fafc;
  --color-bg-gray: #f0f4f8;
  --color-border: #e2e8f0;
  --color-success: #4CAF50;
  --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --max-width: 1280px;
  --header-height: 64px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.1);
}

html { font-size: 20px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-stack);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-dark); text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
ul, ol { padding-left: 1.5em; }

/* --- Layout --- */
.site-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.site-content { flex: 1; }
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }
.container-wide { max-width: 1280px; margin: 0 auto; padding: 0 20px; }

/* ===================== HEADER ===================== */
.site-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 100;
  height: var(--header-height);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1280px; margin: 0 auto; padding: 0 20px;
  height: var(--header-height);
}
.site-logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--color-text); }
.site-logo img { height: 36px; width: auto; }
.site-logo:hover { text-decoration: none; color: var(--color-primary); }

/* Desktop Navigation */
.main-nav { display: flex; align-items: center; gap: 4px; list-style: none; padding: 0; margin: 0; }
.main-nav > li { position: relative; }
.main-nav > li > a {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 14px; border-radius: 6px; font-size: .93rem; font-weight: 500;
  color: var(--color-text); transition: background .15s, color .15s;
}
.main-nav > li > a:hover { background: var(--color-bg-gray); color: var(--color-primary); text-decoration: none; }
.nav-arrow { font-size: .65rem; transition: transform .2s; }
.main-nav > li:hover .nav-arrow { transform: rotate(180deg); }

/* Dropdown */
.nav-dropdown {
  display: none; position: absolute; top: 100%; left: 0;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 220px; padding: 6px 0; z-index: 200;
  list-style: none;
}
.main-nav > li:hover > .nav-dropdown { display: block; }
.nav-dropdown a {
  display: block; padding: 8px 16px; font-size: .9rem; color: var(--color-text);
  transition: background .15s;
}
.nav-dropdown a:hover { background: var(--color-bg-gray); color: var(--color-primary); text-decoration: none; }

/* CTA button in nav */
.nav-cta a {
  background: var(--color-primary) !important; color: #fff !important;
  border-radius: 20px !important; padding: 8px 20px !important; font-weight: 600;
}
.nav-cta a:hover { background: var(--color-primary-dark) !important; }

/* Hamburger */
.menu-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.menu-toggle span { display: block; width: 24px; height: 2px; background: var(--color-text); margin: 5px 0; transition: .3s; border-radius: 2px; }
.menu-toggle.active span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ===================== ARTICLE HEADER ===================== */
.article-header {
  background: var(--color-bg-light);
  border-bottom: 1px solid var(--color-border);
  padding: 40px 0 32px;
  text-align: center;
}
.article-header h1 {
  font-size: 1.75rem; font-weight: 700; line-height: 1.3;
  color: var(--color-primary); margin-bottom: 12px;
}
.article-meta { color: var(--color-text-light); font-size: .85rem; }
.article-meta a { color: var(--color-text-light); }

/* Intro / chapô */
.article-intro {
  background: var(--color-bg-light); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 20px 24px; margin: 24px 0;
  font-size: .95rem; line-height: 1.7;
}

/* ===================== ARTICLE CONTENT ===================== */
.article-body { padding: 32px 0 40px; }
.entry-content h2 {
  font-size: 1.4rem; font-weight: 700; color: var(--color-primary);
  margin: 36px 0 16px; padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
}
.entry-content h3 {
  font-size: 1.2rem; font-weight: 700; color: var(--color-primary-dark);
  margin: 28px 0 12px;
}
.entry-content p { margin: 0 0 16px; }
.entry-content ul, .entry-content ol { margin: 0 0 16px; }
.entry-content li { margin-bottom: 6px; }
.entry-content img {
  display: block; margin: 16px auto; border-radius: var(--radius);
  max-width: 100%;
}
.entry-content blockquote,
.entry-content .redaction-revision {
  border-left: 4px solid var(--color-primary);
  background: var(--color-bg-light);
  padding: 16px 20px; margin: 20px 0;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-style: italic; color: var(--color-text-light);
}
.entry-content strong { font-weight: 600; }
.entry-content a { border-bottom: 1px solid rgba(43,108,176,.3); }
.entry-content a:hover { border-bottom-color: var(--color-primary); }

/* CTA Buttons in content */
.cta-btn {
  display: inline-block; background: var(--color-primary); color: #fff;
  padding: 12px 28px; border-radius: 25px; font-weight: 600; font-size: 1rem;
  text-align: center; margin: 16px auto; border: none; cursor: pointer;
  transition: background .2s, transform .15s;
  text-decoration: none; border-bottom: none;
}
.cta-btn:hover { background: var(--color-primary-dark); transform: translateY(-1px); text-decoration: none; color: #fff; }
.text-center { text-align: center; }

/* ===================== TABLE OF CONTENTS ===================== */
.toc-container {
  background: var(--color-bg-light); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 0; margin: 24px 0;
  overflow: hidden;
}
.toc-header {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 20px; cursor: pointer; user-select: none;
  font-weight: 700; font-size: .95rem; color: var(--color-text);
  border-bottom: 1px solid transparent;
}
.toc-header:hover { color: var(--color-primary); }
.toc-toggle {
  background: none; border: none; color: var(--color-primary);
  font-size: .85rem; cursor: pointer; font-weight: 400;
}
.toc-toggle::before { content: "["; }
.toc-toggle::after { content: "]"; }
.toc-body { display: none; padding: 0 24px 16px; }
.toc-body.open { display: block; }
.toc-container.open .toc-header { border-bottom-color: var(--color-border); }
.toc-body ol { padding-left: 0; counter-reset: toc-counter; list-style: none; }
.toc-body > ol > li { counter-increment: toc-counter; margin-bottom: 4px; }
.toc-body > ol > li::before { content: counter(toc-counter) " "; font-weight: 600; color: var(--color-primary); }
.toc-body > ol > li > a { color: var(--color-primary); font-weight: 500; font-size: .93rem; border-bottom: none; }
.toc-body > ol > li > a:hover { text-decoration: underline; }
.toc-body ol ol { padding-left: 20px; margin-top: 4px; counter-reset: toc-sub-counter; }
.toc-body ol ol li { counter-increment: toc-sub-counter; margin-bottom: 2px; }
.toc-body ol ol li::before { content: counter(toc-counter) "." counter(toc-sub-counter) " "; font-weight: 500; color: var(--color-primary); }
.toc-body ol ol li a { color: var(--color-primary); font-size: .88rem; border-bottom: none; }

/* ===================== TABLES (TablePress-like) ===================== */
.entry-content table {
  width: 100%; border-collapse: collapse; margin: 20px 0;
  border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow);
}
.entry-content table th {
  background: var(--color-primary); color: #fff;
  padding: 12px 16px; text-align: left; font-weight: 600; font-size: .9rem;
}
.entry-content table td {
  padding: 10px 16px; border-bottom: 1px solid var(--color-border);
  font-size: .9rem;
}
.entry-content table tr:nth-child(even) td { background: var(--color-bg-light); }
.entry-content table tr:hover td { background: #e8f0fe; }
.entry-content table tr:last-child td { border-bottom: none; }

/* ===================== AUTHOR BOX ===================== */
.author-box {
  display: flex; align-items: flex-start; gap: 20px;
  background: var(--color-bg-light); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 24px; margin: 32px 0;
}
.author-avatar {
  flex-shrink: 0; width: 80px; height: 80px; border-radius: 50%; overflow: hidden;
}
.author-avatar img {
  width: 80px; height: 80px; border-radius: 50%;
  object-fit: cover; border: 3px solid var(--color-border);
}
.author-info .author-name {
  font-weight: 700; font-size: 1.05rem; color: var(--color-primary); margin-bottom: 6px;
}
.author-info p { font-size: .9rem; color: var(--color-text-light); margin: 0; line-height: 1.6; }

/* ===================== DEVIS IFRAME ===================== */
.devis-section { margin: 40px 0; text-align: center; }
.devis-section h2 { color: var(--color-primary); margin-bottom: 16px; font-size: 1.4rem; border: none; }
.devis-section iframe { border: 0; width: 100%; border-radius: var(--radius); min-height: 400px; }

/* ===================== FOOTER ===================== */
.site-footer {
  background: var(--color-bg-light); border-top: 1px solid var(--color-border);
  padding: 24px 0; text-align: center; margin-top: 40px;
}
.footer-links { display: flex; justify-content: center; gap: 24px; flex-wrap: wrap; margin-bottom: 12px; list-style: none; padding: 0; }
.footer-links a { color: var(--color-text); font-size: .9rem; }
.footer-links a:hover { color: var(--color-primary); }
.footer-copy { font-size: .85rem; color: var(--color-text-light); }

/* ===================== SCROLL TO TOP ===================== */
.scroll-top {
  position: fixed; bottom: 24px; right: 24px; z-index: 999;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--color-primary); color: #fff;
  border: none; cursor: pointer; font-size: 1.2rem;
  display: none; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lg); transition: opacity .3s, transform .3s;
}
.scroll-top.visible { display: flex; }
.scroll-top:hover { background: var(--color-primary-dark); transform: translateY(-2px); }

/* ===================== RUBRIQUE (Section) ===================== */
.rubrique-header {
  background: var(--color-bg-light); border-bottom: 1px solid var(--color-border);
  padding: 40px 0; text-align: center;
}
.rubrique-header h1 { font-size: 1.6rem; color: var(--color-primary); font-weight: 700; }
.articles-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px; padding: 32px 0;
}
.article-card {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius); padding: 24px;
  transition: box-shadow .2s, transform .15s;
}
.article-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.article-card h2 { font-size: 1.1rem; margin-bottom: 8px; }
.article-card h2 a { color: var(--color-text); border-bottom: none; }
.article-card h2 a:hover { color: var(--color-primary); }
.article-card p { font-size: .9rem; color: var(--color-text-light); line-height: 1.6; }

/* ===================== SOMMAIRE (Homepage) ===================== */
.home-hero {
  background: var(--color-bg-light);
  border-bottom: 1px solid var(--color-border);
  padding: 40px 0 32px; text-align: center;
}
.home-hero h1 {
  font-size: 1.75rem; font-weight: 700; line-height: 1.3;
  color: var(--color-primary); margin-bottom: 12px;
}

.home-sections { padding: 40px 0; }
.section-block { margin-bottom: 40px; }
.section-block h2 {
  font-size: 1.3rem; color: var(--color-primary); font-weight: 700;
  margin-bottom: 20px; padding-bottom: 8px;
  border-bottom: 2px solid var(--color-border);
}

/* ===================== 404 ===================== */
.page-404 { text-align: center; padding: 80px 20px; }
.page-404 h1 { font-size: 4rem; color: var(--color-primary); margin-bottom: 16px; }
.page-404 p { font-size: 1.1rem; color: var(--color-text-light); margin-bottom: 24px; }

/* ===================== SIMULATOR ===================== */
.mes-container {
  max-width: 100%; margin: 20px auto; padding: 20px;
  background: var(--color-bg-light); border: 1px solid var(--color-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.mes-form-group { width: 100%; margin-bottom: 12px; }
.mes-form-group label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--color-text); }
.mes-form-group select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--color-border);
  border-radius: 6px; font-size: .93rem; background: #fff;
}
.mes-form-row { display: flex; flex-wrap: wrap; gap: 16px; }
.mes-accordion {
  background: var(--color-primary); color: #fff; cursor: pointer;
  padding: 12px 16px; border: none; border-radius: 6px;
  font-size: .93rem; text-align: left; width: 100%; font-weight: 600;
  transition: background .15s;
}
.mes-accordion:hover, .mes-accordion.active { background: var(--color-primary-dark); }
.mes-accordion::after { content: '+'; float: right; font-size: 1.2rem; font-weight: 400; }
.mes-accordion.active::after { content: '−'; }
.mes-panel {
  display: none; background: #fff; border: 1px solid var(--color-border);
  border-radius: 0 0 6px 6px; padding: 12px 16px; margin-top: -4px;
}
.mes-panel label { display: block; padding: 6px 0; font-size: .9rem; cursor: pointer; }
.mes-panel label:hover { color: var(--color-primary); }
.mes-accordion-container { display: flex; flex-wrap: wrap; gap: 16px; margin: 12px 0; }
.mes-accordion-wrapper { flex: 1; min-width: 240px; }
#mes-submit {
  display: block; margin: 16px auto; padding: 12px 32px;
  background: var(--color-success); color: #fff; border: none;
  border-radius: 25px; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: background .2s;
  box-shadow: 0 2px 8px rgba(76,175,80,.3);
}
#mes-submit:hover { background: #45a049; }
#mes-result { padding: 5px; color: var(--color-primary); margin-top: 16px; text-align: center; }

/* Simulator result table */
.mes-devis-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  margin: 16px auto; box-shadow: var(--shadow); border-radius: var(--radius);
  overflow: hidden;
}
.mes-devis-table th { background: var(--color-primary); color: #fff; padding: 12px 15px; text-align: left; }
.mes-devis-table td { padding: 10px 15px; border-bottom: 1px solid var(--color-border); background: #fff; }
.mes-devis-table tr:nth-child(even) td { background: var(--color-bg-light); }
.mes-devis-table tr:hover td { background: #e8f0fe; }
.mes-devis-table tr:last-child td { border-bottom: none; }
.mes-total-price td { font-weight: 700; font-size: 1.05rem; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 768px) {
  :root { --header-height: 56px; }
  
  /* Mobile navigation */
  .main-nav {
    display: none; position: fixed; top: var(--header-height); left: 0; right: 0;
    background: var(--color-bg); border-bottom: 1px solid var(--color-border);
    flex-direction: column; padding: 12px 20px; gap: 0;
    box-shadow: var(--shadow-lg); max-height: calc(100vh - var(--header-height)); overflow-y: auto;
  }
  .main-nav.open { display: flex; }
  .main-nav > li > a { padding: 12px 0; border-bottom: 1px solid var(--color-border); }
  .nav-dropdown {
    position: static; display: none; border: none; box-shadow: none;
    padding: 0 0 0 16px; min-width: auto;
  }
  .main-nav > li.dropdown-open > .nav-dropdown { display: block; }
  .nav-cta { margin-top: 8px; }
  .nav-cta a { display: block; text-align: center; }
  .menu-toggle { display: block; }
  
  /* Content */
  .article-header { padding: 24px 0; }
  .article-header h1 { font-size: 1.35rem; }
  .home-hero { padding: 40px 0; }
  .home-hero h1 { font-size: 1.5rem; }
  .articles-grid { grid-template-columns: 1fr; }
  .entry-content h2 { font-size: 1.2rem; }
  
  /* Author box */
  .author-box { flex-direction: column; align-items: center; text-align: center; }
  
  /* Simulator */
  .mes-form-row { flex-direction: column; }
  .mes-accordion-container { flex-direction: column; }
  .mes-devis-table .article-cell { display: none; }
  
  /* Scroll top smaller */
  .scroll-top { width: 38px; height: 38px; bottom: 16px; right: 16px; }
}

@media (max-width: 480px) {
  .container { padding: 0 14px; }
  .article-header h1 { font-size: 1.2rem; }
  .footer-links { flex-direction: column; gap: 12px; }
}

/* Iframe loader */
.iframe-loader-wrap { position: relative; min-height: 200px; }
.iframe-loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 0; color: var(--clr-primary, #2B6CB0);
}
.iframe-loader p { margin: 16px 0 0; font-size: .95rem; }
.iframe-spinner {
  width: 40px; height: 40px;
  border: 4px solid #e2e8f0; border-top-color: var(--clr-primary, #2B6CB0);
  border-radius: 50%;
  animation: iframe-spin .7s linear infinite;
}
@keyframes iframe-spin { to { transform: rotate(360deg); } }
