/* =====================================================================
   nav.css  —  Navigation automatique du site pédagogique
   Charger via : <link rel="stylesheet" href="nav.css">
   ===================================================================== */

/* ── Bloc supérieur ─────────────────────────────────────────────────── */
.sn-top-block  { margin-bottom: 18px; }
.sn-footer-block {
  margin-top: 32px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}

/* ── Fil d'Ariane ───────────────────────────────────────────────────── */
.sn-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: .80em;
  color: #718096;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}
.sn-breadcrumb a { color: #0969da; text-decoration: none; }
.sn-breadcrumb a:hover { text-decoration: underline; }
.sn-sep { color: #cbd5e0; font-size: .9em; }
.sn-bc-current { font-weight: 700; color: #2d3748; }

/* ── Menu du chapitre (onglets) ─────────────────────────────────────── */
.sn-ch-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 14px;
}
.sn-tab {
  text-decoration: none;
  font-size: .82em;
  font-weight: 600;
  padding: 5px 16px;
  border-radius: 20px;
  border: 1.5px solid #e2e8f0;
  color: #0969da;
  background: #fff;
  transition: background .15s, border-color .15s;
}
.sn-tab:hover {
  background: #ebf5ff;
  border-color: #93c5fd;
}
.sn-tab-active {
  background: #0969da;
  color: #fff;
  border-color: #0969da;
}
.sn-tab-active:hover { background: #0851b0; }

/* ── Navigation précédent / suivant ─────────────────────────────────── */
.sn-ch-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 8px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.sn-btn, .sn-btn-disabled {
  display: inline-block;
  font-size: .81em;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1.5px solid #e2e8f0;
  text-decoration: none;
  text-align: center;
  transition: background .15s, border-color .15s;
  max-width: 40%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sn-btn { color: #0969da; background: #fff; }
.sn-btn:hover { background: #ebf5ff; border-color: #93c5fd; }

.sn-btn-summary {
  max-width: none;
  color: #4a5568;
  border-color: #cbd5e0;
  background: #f8fafc;
  flex-shrink: 0;
}
.sn-btn-summary:hover { background: #eef2f7; color: #2d3748; }

.sn-btn-disabled {
  color: #a0aec0;
  background: #f8fafc;
  cursor: default;
  pointer-events: none;
}

/* ── Bouton retour en haut ───────────────────────────────────────────── */
#sn-back-top {
  position: fixed;
  bottom: 26px;
  right: 22px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #0969da;
  color: #fff;
  font-size: 1.5em;
  line-height: 44px;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(0,0,0,.20);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, background .15s;
  z-index: 999;
}
#sn-back-top:hover { background: #0851b0; }

/* ── Sommaire automatique ────────────────────────────────────────────── */
.sn-toc {
  background: #f0f7ff;
  border: 1.5px solid #bfdbfe;
  border-radius: 8px;
  margin: 14px 0 22px;
}
.sn-toc-title {
  cursor: pointer;
  font-weight: 700;
  font-size: .9em;
  color: #1e40af;
  padding: 10px 14px;
  list-style: none;
  user-select: none;
}
.sn-toc-title::-webkit-details-marker { display: none; }
.sn-toc[open] .sn-toc-title {
  border-bottom: 1px solid #bfdbfe;
}
.sn-toc-list {
  margin: 0;
  padding: 8px 14px 10px 36px;
  font-size: .86em;
  line-height: 1.9;
}
.sn-toc-list a { color: #1d4ed8; text-decoration: none; }
.sn-toc-list a:hover { text-decoration: underline; }

/* ── Signature auteur ──────────────────────────────────────────────── */
.sn-author {
  text-align: center;
  font-size: .82em;
  color: #718096;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  font-weight: 600;
  letter-spacing: .02em;
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .sn-btn, .sn-btn-disabled {
    max-width: 44%;
    font-size: .74em;
    padding: 6px 8px;
  }
  .sn-btn-summary { font-size: .74em; padding: 6px 8px; }
  .sn-breadcrumb  { font-size: .76em; }
}

/* ── Recherche globale (injectée par nav.js) ──────────────────────── */
#sn-search-btn {
  position: fixed; top: 14px; right: 14px; z-index: 900;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid #cbd5e1; background: #fff; cursor: pointer;
  font-size: 1.05rem; box-shadow: 0 2px 10px rgba(0,0,0,.14);
  transition: transform .15s, box-shadow .15s;
}
#sn-search-btn:hover { transform: scale(1.07); box-shadow: 0 4px 14px rgba(0,0,0,.2); }
#sn-search-overlay {
  display: none; position: fixed; inset: 0; z-index: 950;
  background: rgba(15,23,42,.55); backdrop-filter: blur(2px);
  align-items: flex-start; justify-content: center; padding: 9vh 16px 16px;
}
#sn-search-box {
  width: 100%; max-width: 620px; background: #fff; border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.35); overflow: hidden;
}
#sn-search-input {
  width: 100%; border: none; outline: none; padding: 16px 20px;
  font-size: 1.05rem; font-family: inherit; border-bottom: 1px solid #e2e8f0;
}
#sn-search-results { max-height: 56vh; overflow-y: auto; }
#sn-search-results a {
  display: flex; align-items: baseline; gap: 8px; padding: 10px 16px;
  text-decoration: none; color: #1e293b; font-size: .9rem;
  border-bottom: 1px solid #f1f5f9;
}
#sn-search-results a:last-child { border-bottom: none; }
#sn-search-results a:hover, #sn-search-results a.sn-sr-sel { background: #eff6ff; }
.sn-sr-section {
  flex-shrink: 0; font-size: .7rem; font-weight: 700; color: #2563eb;
  background: #eff6ff; border-radius: 10px; padding: 2px 8px; white-space: nowrap;
}
.sn-sr-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sn-sr-kind { flex-shrink: 0; font-size: .7rem; color: #64748b; white-space: nowrap; margin-left: auto; }
.sn-sr-empty { padding: 14px 16px; color: #64748b; font-size: .9rem; }
@media print { #sn-search-btn, #sn-search-overlay { display: none !important; } }
@media (max-width: 600px) { #sn-search-btn { top: 10px; right: 10px; width: 38px; height: 38px; } }

/* ═══════════════════════════════════════════════════════════════════
   Chrome de chapitre (refonte navy) — injecté par nav.js sur body.cn-chrome
   ═══════════════════════════════════════════════════════════════════ */
body.cn-chrome { padding: 0; background: #f4f6f9; }
body.cn-chrome .c { max-width: 880px; margin: 28px auto 40px; }

/* Barre de navigation */
.cn-nav {
  background: #15314f; position: sticky; top: 0; z-index: 100;
  box-shadow: 0 4px 16px rgba(8,20,38,.25);
}
.cn-nav-inner {
  max-width: 880px; margin: 0 auto; display: flex; align-items: center;
  gap: 14px; padding: 11px 18px;
}
.cn-brand { display: flex; align-items: center; gap: 9px; text-decoration: none; flex-shrink: 0; }
.cn-brand-logo {
  width: 27px; height: 27px; border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.cn-brand-name { font-family: var(--ui); color: #fff; font-weight: 800; font-size: .92rem; letter-spacing: -.01em; }
.cn-brand-name span { color: #7da6e8; font-weight: 600; }
.cn-back {
  font-family: var(--ui); margin-left: auto; color: #bcd0ea; text-decoration: none;
  font-weight: 600; font-size: .86rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cn-back:hover { color: #fff; }

/* Fil d'Ariane */
.cn-crumb { background: #fff; border-bottom: 1px solid #e6eaf0; }
.cn-crumb-inner {
  font-family: var(--ui); max-width: 880px; margin: 0 auto; padding: 9px 18px;
  font-size: .78rem; color: #64748b; font-weight: 500;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.cn-crumb-inner a { color: #64748b; text-decoration: none; }
.cn-crumb-inner a:hover { color: #2563eb; }
.cn-crumb-cur { color: #475569; font-weight: 600; }
.cn-crumb-sep { color: #cbd5e1; }

/* Bandeau navy */
.cn-band { position: relative; overflow: hidden; color: #fff; background: linear-gradient(135deg, #13294a, #1e457f); }
.cn-band::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px);
  background-size: 46px 46px;
}
.cn-band-inner { position: relative; max-width: 880px; margin: 0 auto; padding: 30px 18px 0; }
.cn-eyebrow {
  font-family: var(--sc); font-size: .74rem; font-weight: 600; letter-spacing: .1em;
  color: #9ec2f2; margin-bottom: 12px; text-transform: uppercase;
}
.cn-headrow { display: flex; align-items: flex-start; gap: 16px; }
.cn-num {
  font-family: var(--ui); font-weight: 800; font-size: 2.4rem; line-height: 1;
  color: rgba(255,255,255,.3); letter-spacing: -.03em; flex-shrink: 0; padding-top: 2px;
}
.cn-headmain { flex: 1; min-width: 0; }
.cn-title {
  font-family: var(--ui); font-size: clamp(1.5rem, 3.4vw, 2.1rem); font-weight: 800;
  letter-spacing: -.02em; line-height: 1.06; margin: 0 0 8px; color: #fff;
}
.cn-sub { font-family: var(--serif); font-size: 1rem; color: #dbe7f8; margin: 0; max-width: 620px; }

/* Onglets */
.cn-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 18px; }
.cn-tab {
  font-family: var(--ui); display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  color: #cfe0f5; border-radius: 10px 10px 0 0; padding: 10px 16px;
  font-size: .86rem; font-weight: 600; white-space: nowrap;
}
.cn-tab:hover { background: rgba(255,255,255,.1); color: #fff; }
.cn-tab-active, .cn-tab-active:hover { background: #f4f6f9; color: #15314f; font-weight: 700; }

/* Footer navy */
.cn-footer { background: #15314f; color: #9ec2f2; text-align: center; padding: 22px 16px; }
.cn-footer p { margin: 0; font-size: .82rem; font-family: var(--ui); }

/* ── Sommaire latéral « Dans ce chapitre » (pages cours) ───────────── */
body.cn-has-side .cn-nav-inner,
body.cn-has-side .cn-crumb-inner,
body.cn-has-side .cn-band-inner { max-width: 1080px; }
.cn-body {
  max-width: 1080px; margin: 28px auto 40px; padding: 0 18px;
  display: grid; grid-template-columns: minmax(0, 1fr) 244px; gap: 34px; align-items: start;
}
body.cn-has-side .c { max-width: none; margin: 0; }
body.cn-has-side .c h2 { scroll-margin-top: 76px; }
.cn-side { position: sticky; top: 70px; align-self: start; }
.cn-side-box {
  background: #fff; border: 1px solid var(--card-bd, #e6eaf0); border-radius: 14px;
  padding: 18px 18px 16px; box-shadow: 0 1px 3px rgba(8,20,38,.05);
}
.cn-side-title {
  font-family: var(--sc, 'Spectral SC', serif); font-size: .78rem; font-weight: 600;
  letter-spacing: .04em; color: #64748b; margin-bottom: 13px;
}
.cn-toc-nav { display: flex; flex-direction: column; gap: 2px; }
.cn-toc-link {
  display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 8px;
  text-decoration: none; color: #334155; font-size: .88rem; font-weight: 600;
  font-family: var(--ui, 'Hanken Grotesk', sans-serif); line-height: 1.35;
}
.cn-toc-link:hover { background: #eff6ff; color: #1d4ed8; }
.cn-toc-num { color: #64748b; font-weight: 700; font-size: .78rem; flex-shrink: 0; }
@media (max-width: 980px) {
  .cn-body { grid-template-columns: 1fr; gap: 16px; }
  .cn-side { position: static; order: -1; }
}
@media print {
  .cn-side { display: none !important; }
  .cn-body { display: block; max-width: 100%; padding: 0; }
}

@media (max-width: 600px) {
  .cn-num { font-size: 1.8rem; }
  body.cn-chrome .c { margin: 16px auto 24px; }
  .cn-nav-inner, .cn-crumb-inner, .cn-band-inner { padding-left: 14px; padding-right: 14px; }
}
@media print {
  .cn-nav, .cn-crumb, .cn-footer, .cn-tabs, #sn-back-top { display: none !important; }
  .cn-band { background: #13294a !important; }
  body.cn-chrome { padding: 0; }
  body.cn-chrome .c { margin: 0; box-shadow: none; border: none; }
}
