/* ═══════════════════════════════════════════════════
   COURS TENSORFLOW.JS — apprendre-javascript.fr
   Design System & Theme
   ═══════════════════════════════════════════════════ */

:root {
  /* Backgrounds */
  --bg:            #0a0e17;
  --bg2:           #0f1420;
  --bg3:           #141a28;
  --bg-card:       #111827;
  --editor-bg:     #0d1117;

  /* Surfaces */
  --surface:       rgba(255,255,255,0.025);
  --surface2:      rgba(255,255,255,0.05);
  --surface3:      rgba(255,255,255,0.08);
  --glass:         rgba(15,20,32,0.85);
  --glass-border:  rgba(255,255,255,0.06);

  /* Borders */
  --border:        rgba(255,255,255,0.06);
  --border2:       rgba(255,255,255,0.1);
  --border3:       rgba(255,255,255,0.15);

  /* Text */
  --text:          rgba(255,255,255,0.92);
  --text2:         rgba(255,255,255,0.55);
  --text3:         rgba(255,255,255,0.35);

  /* Accents */
  --cyan:          #00d2ff;
  --cyan-dim:      #00a8cc;
  --cyan-glow:     rgba(0,210,255,0.25);
  --cyan-bg:       rgba(0,210,255,0.06);
  --orange:        #ff6b35;
  --orange-dim:    #e05a2b;
  --orange-glow:   rgba(255,107,53,0.25);
  --orange-bg:     rgba(255,107,53,0.06);
  --green:         #00ff88;
  --green-bg:      rgba(0,255,136,0.08);
  --yellow:        #ffd600;
  --yellow-bg:     rgba(255,214,0,0.08);
  --red:           #ff4757;
  --red-bg:        rgba(255,71,87,0.06);
  --violet:        #a855f7;

  /* TF.js specific */
  --tf-color:      #ff6b35;
  --tf-bg:         rgba(255,107,53,0.06);

  /* Fonts */
  --font:          'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono:          'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Layout */
  --topbar-h:      52px;
  --sidebar-w:     260px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;
  --radius-xl:     18px;

  --ease:          cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

::selection { background: rgba(255,107,53,0.3); color: #fff; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }


/* ═══════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: var(--topbar-h);
  background: var(--glass);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--glass-border);
}

.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-logo {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  text-decoration: none; display: flex; align-items: center; gap: 8px;
  transition: color 0.25s var(--ease);
}
.topbar-logo:hover { color: var(--cyan); }
.topbar-logo .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow), 0 0 4px var(--cyan); flex-shrink: 0;
}
.topbar-sep { width: 1px; height: 20px; background: var(--border2); }

.topbar-page {
  font-size: 0.76rem; font-weight: 600; color: var(--tf-color);
  letter-spacing: 0.04em; padding: 3px 10px; border-radius: var(--radius-sm);
  background: var(--tf-bg); border: 1px solid rgba(255,107,53,0.12);
}

.topbar-nav { display: flex; gap: 4px; }
.topbar-link {
  font-size: 0.74rem; font-weight: 500; color: var(--text2);
  text-decoration: none; padding: 6px 12px; border-radius: var(--radius-md);
  transition: all 0.2s var(--ease);
}
.topbar-link:hover { color: var(--text); background: var(--surface2); }
.topbar-link.active { color: var(--orange); background: var(--tf-bg); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.tf-loaded-badge {
  font-size: 0.62rem; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text3);
  font-family: var(--mono);
}
.tf-loaded-badge.loaded { color: var(--green); border-color: rgba(0,255,136,0.2); background: var(--green-bg); }

.back-link {
  font-size: 0.74rem; font-weight: 500; color: var(--text2);
  text-decoration: none; padding: 6px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border2); background: var(--surface);
  transition: all 0.25s var(--ease);
}
.back-link:hover { color: var(--cyan); border-color: rgba(0,210,255,0.25); background: var(--cyan-bg); }

.mobile-menu-btn {
  display: none; background: none; border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 8px 10px; cursor: pointer;
  flex-direction: column; gap: 3px; align-items: center;
}
.mobile-menu-btn span {
  display: block; width: 16px; height: 1.5px; background: var(--text2);
  border-radius: 1px;
}


/* ═══════════════════════════════════════════════════
   LAYOUT
   ═══════════════════════════════════════════════════ */
.page-layout {
  display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; height: 100dvh; padding-top: var(--topbar-h);
}


/* ═══════════════════════════════════════════════════
   SIDEBAR — TOC
   ═══════════════════════════════════════════════════ */
.sidebar {
  background: var(--bg2); border-right: 1px solid var(--border);
  padding: 16px 0 30px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent;
}

.sidebar-mobile-header {
  display: none; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.sidebar-mobile-title { font-size: 0.95rem; font-weight: 700; color: #fff; }
.sidebar-mobile-close {
  background: none; border: 1px solid var(--border); color: var(--text2);
  padding: 5px 12px; border-radius: var(--radius-sm); font-family: var(--font);
  font-size: 0.74rem; cursor: pointer; transition: all 0.2s var(--ease);
}
.sidebar-mobile-close:hover { color: var(--text); border-color: var(--border2); }

.toc-header {
  display: flex; align-items: center; gap: 8px;
  padding: 0 18px; margin-bottom: 16px;
  font-size: 0.95rem; font-weight: 700; color: var(--text);
}
.toc-icon { font-size: 1.1rem; }

.sidebar-title {
  font-size: 0.63rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--text3); padding: 0 18px; margin-bottom: 8px;
}

/* TOC links */
.toc-list { display: flex; flex-direction: column; gap: 2px; padding: 0 10px; margin-bottom: 20px; }

.toc-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; font-size: 0.76rem; font-weight: 500;
  color: var(--text2); text-decoration: none;
  border-radius: var(--radius-md); border: 1px solid transparent;
  transition: all 0.2s var(--ease);
}
.toc-item:hover { background: var(--surface2); color: var(--text); border-color: var(--border); }
.toc-item.active {
  background: var(--tf-bg); color: var(--orange);
  border-color: rgba(255,107,53,0.18);
}
.toc-num {
  font-family: var(--mono); font-size: 0.6rem; font-weight: 600;
  color: var(--text3); width: 22px; flex-shrink: 0;
}
.toc-item.active .toc-num { color: var(--orange); }

/* Stats */
.sidebar-stats {
  margin: 0 14px; padding: 16px; background: var(--bg-card);
  border-radius: var(--radius-lg); border: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.2);
}
.sidebar-stats h4 {
  font-size: 0.63rem; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 10px;
}
.stat-row { display: flex; justify-content: space-between; font-size: 0.76rem; margin-bottom: 5px; color: var(--text2); }
.stat-row .val { font-weight: 700; color: var(--orange); font-family: var(--mono); font-size: 0.82rem; }
.progress-track { height: 4px; background: var(--surface3); border-radius: 99px; margin-top: 10px; overflow: hidden; }
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--orange), var(--yellow));
  border-radius: 99px; transition: width 0.6s var(--ease);
  box-shadow: 0 0 8px var(--orange-glow);
}
.progress-text { font-size: 0.66rem; color: var(--text3); margin-top: 6px; text-align: right; }


/* ═══════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════ */
.main-area {
  overflow-y: auto; scroll-behavior: smooth;
  padding: 0 0 60px;
}

/* Hero */
.course-hero {
  text-align: center; padding: 48px 24px 40px;
  background: linear-gradient(180deg, rgba(255,107,53,0.05) 0%, transparent 100%);
  border-bottom: 1px solid var(--border);
}
.hero-badge {
  display: inline-block; font-size: 0.62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--orange); background: var(--tf-bg);
  border: 1px solid rgba(255,107,53,0.15); border-radius: 99px;
  padding: 4px 14px; margin-bottom: 16px;
}
.hero-title {
  font-size: 2.4rem; font-weight: 800; line-height: 1.15;
  background: linear-gradient(135deg, #fff 40%, var(--orange));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 10px;
}
.hero-subtitle { font-size: 1rem; color: var(--text2); margin-bottom: 20px; }
.hero-tags { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.hero-tag {
  font-size: 0.64rem; font-weight: 600; padding: 3px 10px;
  border-radius: 99px; background: var(--surface2); color: var(--text3);
  border: 1px solid var(--border); font-family: var(--mono);
}

/* Course sections */
.course-section {
  padding: 36px 32px; margin: 0;
  border-bottom: 1px solid var(--border);
}
.course-section:last-of-type { border-bottom: none; }

.section-header {
  display: flex; align-items: center; gap: 14px; margin-bottom: 20px;
  padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.section-num {
  font-family: var(--mono); font-size: 0.72rem; font-weight: 700;
  color: var(--orange); background: var(--tf-bg);
  border: 1px solid rgba(255,107,53,0.15); border-radius: var(--radius-sm);
  padding: 4px 10px; flex-shrink: 0;
}
.section-header h2 {
  font-size: 1.3rem; font-weight: 700;
  background: linear-gradient(135deg, #fff 60%, var(--orange-dim));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

.section-text {
  font-size: 0.86rem; color: var(--text2); line-height: 1.75; margin-bottom: 16px;
}
.section-text strong { color: var(--text); font-weight: 600; }
.section-text code {
  background: rgba(255,107,53,0.07); color: var(--orange);
  padding: 1px 6px; border-radius: 4px; font-family: var(--mono); font-size: 0.78rem;
  border: 1px solid rgba(255,107,53,0.1);
}

.sub-title {
  font-size: 0.95rem; font-weight: 700; color: var(--orange);
  margin: 24px 0 10px;
}


/* ═══════════════════════════════════════════════════
   CODE BLOCKS
   ═══════════════════════════════════════════════════ */
.code-block {
  background: var(--editor-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden; margin: 14px 0;
}
.code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 14px; border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.2);
}
.code-lang {
  font-size: 0.6rem; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.code-copy {
  font-family: var(--font); font-size: 0.6rem; font-weight: 600;
  padding: 2px 8px; border-radius: 4px; border: 1px solid var(--border);
  background: transparent; color: var(--text3); cursor: pointer;
  transition: all 0.15s var(--ease);
}
.code-copy:hover { color: var(--text2); background: var(--surface2); }
.code-copy.copied { color: var(--green); border-color: rgba(0,255,136,0.2); }

.code-pre {
  padding: 14px 16px; font-family: var(--mono); font-size: 0.74rem;
  color: var(--text); line-height: 1.6; overflow-x: auto;
  white-space: pre; tab-size: 2;
}
.code-pre code { font-family: inherit; }


/* ═══════════════════════════════════════════════════
   CONCEPT GRIDS
   ═══════════════════════════════════════════════════ */
.concept-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px; margin: 16px 0;
}
.concept-grid.four { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

.concept-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 16px;
  transition: all 0.25s var(--ease);
}
.concept-card:hover {
  border-color: rgba(255,107,53,0.25);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}
.concept-card.mini { padding: 12px; }
.concept-icon { font-size: 1.3rem; display: block; margin-bottom: 8px; }
.concept-card h4 { font-size: 0.82rem; font-weight: 600; color: var(--orange); margin-bottom: 4px; }
.concept-card p { font-size: 0.74rem; color: var(--text2); line-height: 1.5; }
.concept-card p code {
  background: rgba(255,107,53,0.07); color: var(--orange);
  padding: 0 4px; border-radius: 3px; font-family: var(--mono); font-size: 0.68rem;
}


/* ═══════════════════════════════════════════════════
   INFO BOXES
   ═══════════════════════════════════════════════════ */
.info-box {
  display: flex; gap: 12px; padding: 14px 18px; margin: 16px 0;
  border-radius: var(--radius-md); border: 1px solid var(--border);
}
.info-box.info { background: var(--cyan-bg); border-left: 3px solid var(--cyan); }
.info-box.warning { background: var(--yellow-bg); border-left: 3px solid var(--yellow); }
.info-box.success { background: var(--green-bg); border-left: 3px solid var(--green); }
.info-icon { font-size: 1rem; flex-shrink: 0; }
.info-box strong { color: var(--text); font-weight: 600; }
.info-box div { font-size: 0.8rem; color: var(--text2); line-height: 1.6; }
.info-box code {
  background: rgba(0,210,255,0.08); color: var(--cyan);
  padding: 0 4px; border-radius: 3px; font-family: var(--mono); font-size: 0.72rem;
}


/* ═══════════════════════════════════════════════════
   INTERACTIVE DEMOS
   ═══════════════════════════════════════════════════ */
.demo-box {
  background: var(--bg-card); border: 1px solid var(--border2);
  border-radius: var(--radius-lg); overflow: hidden; margin: 20px 0;
}
.demo-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; background: var(--tf-bg);
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem; font-weight: 600; color: var(--orange);
}
.demo-body { padding: 18px; }
.demo-controls { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }

.demo-input {
  padding: 8px 14px; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--radius-md); color: var(--text); font-family: var(--mono);
  font-size: 0.82rem; width: 100px; outline: none;
  transition: all 0.2s var(--ease);
}
.demo-input:focus { border-color: rgba(255,107,53,0.4); box-shadow: 0 0 0 2px rgba(255,107,53,0.08); }

.demo-output {
  background: var(--editor-bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
  min-height: 80px; font-family: var(--mono); font-size: 0.74rem;
  color: var(--text); line-height: 1.6; overflow-x: auto;
}
.demo-placeholder { color: var(--text3); font-style: italic; }


/* ═══════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════ */
.btn-primary {
  font-family: var(--font); font-size: 0.74rem; font-weight: 700;
  padding: 8px 18px; border-radius: var(--radius-md);
  border: none; cursor: pointer;
  background: var(--orange); color: #fff;
  box-shadow: 0 0 12px var(--orange-glow);
  transition: all 0.25s var(--ease);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover {
  background: #ff7b4a; box-shadow: 0 0 24px var(--orange-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  font-family: var(--font); font-size: 0.74rem; font-weight: 600;
  padding: 8px 18px; border-radius: var(--radius-md);
  border: 1px solid var(--border2); cursor: pointer;
  background: var(--surface2); color: var(--text2);
  transition: all 0.2s var(--ease);
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.btn-secondary:hover { background: var(--surface3); color: var(--text); border-color: var(--border3); }


/* Course footer */
.course-footer {
  display: flex; justify-content: center; gap: 14px; padding: 40px 24px;
  flex-wrap: wrap;
}


/* ═══════════════════════════════════════════════════
   MOBILE OVERLAY & FAB
   ═══════════════════════════════════════════════════ */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 149;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.sidebar-overlay.open { display: block; }

.mobile-fab {
  display: none; position: fixed; z-index: 120;
  bottom: 20px; left: 16px;
  background: var(--orange); color: #fff; border: none;
  border-radius: 99px; padding: 10px 18px;
  font-family: var(--font); font-size: 0.76rem; font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 24px var(--orange-glow);
  transition: all 0.25s var(--ease);
}
.mobile-fab:hover { box-shadow: 0 6px 32px rgba(255,107,53,0.35); transform: translateY(-2px); }


/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .topbar { padding: 0 16px; }
  .topbar-nav { gap: 2px; }
  .topbar-link { font-size: 0.7rem; padding: 5px 8px; }
  .course-section { padding: 28px 24px; }
  .hero-title { font-size: 2rem; }
}

@media (max-width: 768px) {
  :root { --topbar-h: 46px; }

  .topbar { padding: 0 12px; }
  .topbar-logo-text { display: none; }
  .topbar-sep { display: none; }
  .topbar-page { font-size: 0.66rem; }
  .topbar-nav { display: none; }
  .back-link { display: none; }
  .tf-loaded-badge { display: none; }
  .mobile-menu-btn { display: flex; }

  .page-layout { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; left: 0;
    width: 82vw; max-width: 320px;
    height: 100vh; height: 100dvh; z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
    padding-top: 0;
    box-shadow: 4px 0 30px rgba(0,0,0,0.4);
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar-mobile-header { display: flex; }

  .mobile-fab { display: block; }

  .course-hero { padding: 30px 16px 24px; }
  .hero-title { font-size: 1.6rem; }
  .hero-subtitle { font-size: 0.86rem; }

  .course-section { padding: 24px 16px; }
  .section-header h2 { font-size: 1.1rem; }
  .section-text { font-size: 0.8rem; }
  .code-pre { font-size: 0.68rem; padding: 10px 12px; }

  .concept-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .concept-grid.four { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 8px; }

  .course-hero { padding: 24px 12px 20px; }
  .hero-title { font-size: 1.35rem; }
  .hero-tags { gap: 5px; }
  .hero-tag { font-size: 0.58rem; padding: 2px 7px; }

  .course-section { padding: 20px 12px; }
  .section-header { gap: 10px; }
  .section-header h2 { font-size: 1rem; }
  .section-num { font-size: 0.64rem; padding: 3px 8px; }

  .code-pre { font-size: 0.64rem; padding: 8px 10px; }

  .concept-grid { grid-template-columns: 1fr; }
  .concept-grid.four { grid-template-columns: 1fr; }

  .mobile-fab { bottom: 14px; left: 10px; font-size: 0.72rem; padding: 8px 14px; }
  .sidebar { width: 90vw; }

  .btn-primary { font-size: 0.68rem; padding: 7px 14px; }
  .btn-secondary { font-size: 0.68rem; padding: 7px 14px; }
}

@media (max-height: 500px) and (orientation: landscape) {
  :root { --topbar-h: 36px; }
  .course-hero { padding: 16px 16px 12px; }
  .hero-title { font-size: 1.3rem; }
  .hero-subtitle { display: none; }
  .hero-tags { display: none; }
  .course-section { padding: 16px; }
}
