/* ============================================================
   CHAPITRES.CSS — Styles for chapitres.html
   Extracted from inline <style> block
   Design tokens are provided by saas.css
   ============================================================ */

html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: #fff;
  padding: 8px 16px;
  z-index: 9999;
  border-radius: 0 0 var(--r-sm) 0;
  font-weight: 700;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ═══════════════════════════════════════════
   NAVBAR (chapitres-specific, kept as ch-navbar)
   ═══════════════════════════════════════════ */
.ch-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
.ch-navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.ch-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.ch-logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: #fff;
  box-shadow: 0 2px 8px rgba(108,92,231,.3);
}
.ch-logo-text {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -.3px;
}
.ch-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ch-nav-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  text-decoration: none;
}
.ch-nav-btn:hover {
  background: var(--primary-bg);
  color: var(--primary);
}
.ch-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: .9rem;
  font-weight: 800;
  font-family: var(--font-heading);
  cursor: pointer;
  margin-left: 4px;
}

/* ═══════════════════════════════════════════
   HERO + STATS
   ═══════════════════════════════════════════ */
.ch-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #4834D4 40%, #3D1FA8 100%);
  color: #fff;
  padding: 48px 24px 56px;
  position: relative;
  overflow: hidden;
}
.ch-hero::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 400px;
  height: 400px;
  background: rgba(255,255,255,.06);
  border-radius: 50%;
}
.ch-hero::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -5%;
  width: 300px;
  height: 300px;
  background: rgba(255,255,255,.04);
  border-radius: 50%;
}
.ch-hero-inner {
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}
.ch-hero h1 {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -.5px;
  margin-bottom: 6px;
}
.ch-hero-sub {
  font-size: 1.05rem;
  opacity: .85;
  font-weight: 600;
  margin-bottom: 32px;
}

.ch-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  max-width: 640px;
}
.ch-stat {
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: var(--r-md);
  padding: 16px 12px;
  text-align: center;
}
.ch-stat-value {
  display: block;
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 2px;
}
.ch-stat-label {
  font-size: .78rem;
  font-weight: 600;
  opacity: .75;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ═══════════════════════════════════════════
   LEVEL TABS + SEARCH
   ═══════════════════════════════════════════ */
.ch-toolbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.ch-tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--r-md);
  padding: 4px;
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border);
}
.ch-tab {
  padding: 10px 24px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: .92rem;
  color: var(--text-soft);
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.ch-tab:hover { color: var(--text); }
.ch-tab.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(108,92,231,.3);
}

.ch-search {
  position: relative;
  flex: 0 1 300px;
}
.ch-search input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-family: var(--font-body);
  font-size: .92rem;
  background: var(--bg-card);
  color: var(--text);
  transition: border-color .2s, box-shadow .2s;
}
.ch-search input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(108,92,231,.12);
}
.ch-search input::placeholder { color: var(--text-muted); }
.ch-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: .85rem;
}

/* ═══════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════ */
.ch-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

.ch-level-section {
  margin-bottom: 16px;
}
.ch-level-section.hidden { display: none; }

/* ═══════════════════════════════════════════
   SUBJECT SECTIONS
   ═══════════════════════════════════════════ */
.ch-subject {
  margin-bottom: 32px;
  padding: 24px;
  background: var(--bg-card);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .3s;
}
.ch-subject:hover {
  box-shadow: var(--shadow-sm);
}
.ch-subject-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.ch-subject-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.ch-subject-icon.histoire   { background: var(--coral-light); color: var(--coral); }
.ch-subject-icon.geo        { background: var(--green-light); color: var(--green); }
.ch-subject-icon.sciences   { background: var(--orange-light); color: #E17055; }
.ch-subject-icon.emc        { background: var(--pink-light); color: var(--pink); }
.ch-subject-icon.anglais    { background: var(--blue-light); color: var(--blue); }
.ch-subject-icon.maths      { background: var(--indigo-light); color: var(--indigo); }
.ch-subject-icon.temps      { background: var(--teal-light); color: #00B894; }

.ch-subject-info { flex: 1; }
.ch-subject-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.2px;
}
.ch-subject-count {
  font-size: .82rem;
  color: var(--text-soft);
  font-weight: 600;
}

/* ═══════════════════════════════════════════
   CHAPTER CARDS
   ═══════════════════════════════════════════ */
.ch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.ch-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--text);
  transition: all .2s ease;
  position: relative;
  overflow: hidden;
}
.ch-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.ch-card:hover .ch-card-arrow {
  opacity: 1;
  transform: translateX(0);
}

.ch-card-emoji {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}
.ch-card[data-subject="histoire"] .ch-card-emoji   { background: var(--coral-light); }
.ch-card[data-subject="geo"] .ch-card-emoji        { background: var(--green-light); }
.ch-card[data-subject="sciences"] .ch-card-emoji   { background: var(--orange-light); }
.ch-card[data-subject="emc"] .ch-card-emoji        { background: var(--pink-light); }
.ch-card[data-subject="anglais"] .ch-card-emoji    { background: var(--blue-light); }
.ch-card[data-subject="maths"] .ch-card-emoji      { background: var(--indigo-light); }
.ch-card[data-subject="temps"] .ch-card-emoji      { background: var(--teal-light); }

.ch-card-body { flex: 1; min-width: 0; }
.ch-card-title {
  font-family: var(--font-heading);
  font-size: .98rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -.2px;
  line-height: 1.3;
}
.ch-card-desc {
  font-size: .82rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin-bottom: 10px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ch-card-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 600;
}
.ch-card-meta i { font-size: .7rem; }

.ch-card-arrow {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateX(-6px) translateY(-50%);
  opacity: 0;
  color: var(--primary);
  transition: all .2s;
  font-size: .85rem;
}

/* Progress bar mini */
.ch-card-progress {
  margin-top: 10px;
}
.ch-card-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 50px;
  overflow: hidden;
}
.ch-card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-light), var(--primary));
  border-radius: 50px;
  transition: width .6s ease;
}
.ch-card-progress-fill.complete {
  background: linear-gradient(90deg, var(--green), #55EFC4);
}
.ch-card-progress-text {
  font-size: .72rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-top: 4px;
  text-align: right;
}
.ch-card-progress-text.complete { color: var(--green); }

/* Badge "termine" */
.ch-card-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .65rem;
  box-shadow: 0 2px 6px rgba(0,184,148,.3);
}

/* ═══════════════════════════════════════════
   EMPTY STATE (search no results)
   ═══════════════════════════════════════════ */
.ch-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  display: none;
}
.ch-empty-icon { font-size: 3rem; margin-bottom: 12px; }
.ch-empty-text {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-soft);
}

/* ═══════════════════════════════════════════
   CENTRE D'ENTRAÎNEMENT
   ═══════════════════════════════════════════ */
.ch-training {
  max-width: 1200px;
  margin: 56px auto 0;
  padding: 0 24px;
}
.ch-training-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.ch-training-icon {
  font-size: 1.8rem;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #6C5CE7, #A29BFE);
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(108,92,231,.25);
}
.ch-training-title {
  font-family: 'Inter', sans-serif;
  font-weight: 900;
  font-size: 1.4rem;
  color: #1a1a2e;
}
.ch-training-sub {
  font-size: .85rem;
  color: #6b7b8d;
  margin-top: 2px;
}
.ch-training-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

/* ── Card base ── */
.ch-training-card {
  display: flex;
  align-items: center;
  gap: 18px;
  border-radius: 20px;
  padding: 28px 24px;
  text-decoration: none;
  color: #fff;
  position: relative;
  overflow: hidden;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s;
}
.ch-training-card:hover {
  transform: translateY(-6px) scale(1.01);
}

/* ── Progression card ── */
.ch-training-progression {
  background: linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%);
  box-shadow: 0 8px 32px rgba(108,92,231,.3);
}
.ch-training-progression:hover {
  box-shadow: 0 16px 48px rgba(108,92,231,.4);
}
.ch-training-progression::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(255,255,255,.15) 0%, transparent 70%);
  border-radius: 50%;
}
.ch-training-progression::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: -20px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(255,255,255,.1) 0%, transparent 70%);
  border-radius: 50%;
}

/* ── Mort Subite card ── */
.ch-training-mortsubite {
  background: linear-gradient(135deg, #1A0A0A 0%, #4A0000 50%, #FF4500 100%);
  box-shadow: 0 8px 32px rgba(255,69,0,.25);
}
.ch-training-mortsubite:hover {
  box-shadow: 0 16px 48px rgba(255,69,0,.35);
}
.ch-training-mortsubite::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(255,69,0,.25) 0%, transparent 70%);
  border-radius: 50%;
}
.ch-training-mortsubite::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: -20px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, rgba(255,23,68,.15) 0%, transparent 70%);
  border-radius: 50%;
}

/* ── Emoji icon ── */
.ch-training-emoji {
  font-size: 2.8rem;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.15);
  border-radius: 16px;
  backdrop-filter: blur(4px);
}

/* ── Card body ── */
.ch-training-card-body {
  flex: 1;
  position: relative;
  z-index: 1;
}
.ch-training-card-title {
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 1.2rem;
  margin-bottom: 6px;
  letter-spacing: .3px;
}
.ch-training-card-desc {
  font-size: .85rem;
  color: rgba(255,255,255,.8);
  line-height: 1.5;
}

/* ── Arrow ── */
.ch-training-arrow {
  color: rgba(255,255,255,.6);
  font-size: 1.2rem;
  transition: transform .25s;
  position: relative;
  z-index: 1;
}
.ch-training-card:hover .ch-training-arrow {
  transform: translateX(6px);
  color: #fff;
}

@media (max-width: 640px) {
  .ch-training { margin-top: 36px; }
  .ch-training-cards { grid-template-columns: 1fr; }
  .ch-training-card { padding: 22px 18px; }
  .ch-training-emoji { width: 52px; height: 52px; font-size: 2.2rem; }
  .ch-training-card-title { font-size: 1.05rem; }
}

/* ═══════════════════════════════════════════
   FOOTER (chapitres-specific)
   ═══════════════════════════════════════════ */
.ch-footer {
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  background: var(--bg-card);
}
.ch-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.ch-footer-brand {
  font-family: var(--font-heading);
  font-weight: 800;
  font-size: .88rem;
  color: var(--text-soft);
}
.ch-footer-links {
  display: flex;
  gap: 24px;
}
.ch-footer-links a {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.ch-footer-links a:hover { color: var(--primary); }

/* ═══════════════════════════════════════════
   ANIMATIONS
   ═══════════════════════════════════════════ */
.ch-subject {
  animation: fadeUp .4s ease both;
}
.ch-subject:nth-child(1) { animation-delay: .05s; }
.ch-subject:nth-child(2) { animation-delay: .10s; }
.ch-subject:nth-child(3) { animation-delay: .15s; }
.ch-subject:nth-child(4) { animation-delay: .20s; }
.ch-subject:nth-child(5) { animation-delay: .25s; }
.ch-subject:nth-child(6) { animation-delay: .30s; }
.ch-subject:nth-child(7) { animation-delay: .35s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════
   FOCUS VISIBLE
   ═══════════════════════════════════════════ */
:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {
  .ch-navbar-inner { height: 54px; }
  .ch-hero { padding: 36px 20px 44px; }
  .ch-hero h1 { font-size: 1.6rem; }
  .ch-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-width: 100%;
  }
  .ch-stat { padding: 12px 8px; }
  .ch-stat-value { font-size: 1.4rem; }

  .ch-toolbar { padding: 16px 16px 0; flex-direction: column; align-items: stretch; }
  .ch-tabs { align-self: flex-start; }
  .ch-search { flex: 1 1 100%; }

  .ch-main { padding: 16px 16px 48px; }
  .ch-subject { padding: 16px; }
  .ch-grid { grid-template-columns: 1fr; gap: 12px; }
  .ch-card { padding: 16px; }
  .ch-card-emoji { width: 44px; height: 44px; font-size: 1.3rem; }

  .ch-footer-inner { flex-direction: column; text-align: center; }
  .ch-footer-links { flex-wrap: wrap; justify-content: center; gap: 16px; }
}

@media (max-width: 400px) {
  .ch-stats { grid-template-columns: repeat(2, 1fr); }
  .ch-logo-text { display: none; }
}
