/* ============================================
   PM Stats · ML · AI — Global Design System
   ============================================ */

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

:root {
  --bg:          #f9f8f6;
  --surface:     #ffffff;
  --border:      #e5e3de;
  --text:        #1a1917;
  --text-muted:  #6b6860;
  --accent:      #4f46e5;
  --accent-light:#ede9fe;
  --accent-dark: #3730a3;
  --pm-bg:       #fef3c7;
  --pm-border:   #d97706;
  --pm-text:     #78350f;
  --interactive-bg: #f0f4ff;
  --interactive-border: #c7d2fe;
  --success:     #059669;
  --code-bg:     #f1f0ed;

  --font-sans:   'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:   'JetBrains Mono', 'Fira Code', monospace;

  --max-width:   720px;
  --radius:      8px;
  --radius-lg:   12px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
}
h1 { font-size: 2.25rem; }
h2 { font-size: 1.5rem;  margin: 2.5rem 0 1rem; }
h3 { font-size: 1.15rem; margin: 2rem 0 0.75rem; }
h4 { font-size: 1rem;    margin: 1.5rem 0 0.5rem; font-weight: 600; }

p  { margin-bottom: 1.1rem; color: var(--text); }
p:last-child { margin-bottom: 0; }

a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

strong { font-weight: 600; }

ul, ol { padding-left: 1.5rem; margin-bottom: 1.1rem; }
li { margin-bottom: 0.35rem; }

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

/* --- Layout --- */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-logo {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.site-logo span { color: var(--accent); }

.site-nav {
  display: flex;
  gap: 1.5rem;
  align-items: center;
}
.site-nav a {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
}
.site-nav a:hover { color: var(--accent); text-decoration: none; }
.site-nav a.active { color: var(--accent); }

.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
}

/* --- Chapter progress bar --- */
.progress-bar {
  height: 3px;
  background: var(--border);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 200;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.1s;
}

/* --- Chapter Header --- */
.chapter-header {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
.chapter-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.chapter-title { margin: 0 0 0.75rem; }
.chapter-subtitle {
  font-size: 1.1rem;
  color: var(--text-muted);
  font-weight: 400;
  margin: 0 0 0.85rem;
}
.chapter-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}
.chapter-meta-pill {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0.25rem 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.chapter-meta-pill.green {
  background: #f0fdf4;
  border-color: #6ee7b7;
  color: #065f46;
}

/* --- Inline term definition --- */
abbr[title] {
  text-decoration: underline dotted var(--text-muted);
  cursor: help;
}
.term {
  border-bottom: 1px dotted var(--accent);
  cursor: help;
  color: inherit;
}

/* --- PM Insight Callout --- */
.pm-insight {
  background: var(--pm-bg);
  border-left: 3px solid var(--pm-border);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.25rem;
  margin: 1.75rem 0;
}
.pm-insight-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pm-border);
  margin-bottom: 0.4rem;
}
.pm-insight p { color: var(--pm-text); margin: 0; font-size: 0.95rem; }

/* --- Key Concept Callout --- */
.key-concept {
  background: var(--accent-light);
  border: 1px solid var(--interactive-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1.75rem 0;
}
.key-concept-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.key-concept p { margin: 0; font-size: 0.95rem; }

/* --- Interactive Block --- */
.interactive {
  background: var(--interactive-bg);
  border: 1px solid var(--interactive-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 2rem 0;
}
.interactive-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.interactive-label::before {
  content: '◆';
  font-size: 0.6rem;
}

/* --- Divider --- */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* --- Chapter Nav Footer --- */
.chapter-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}
.chapter-nav-btn {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-width: 160px;
}
.chapter-nav-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  text-decoration: none;
}
.chapter-nav-btn.next { text-align: right; }
.chapter-nav-direction {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.chapter-nav-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

/* --- TOC / Chapter Cards (index page) --- */
.toc-grid {
  display: grid;
  gap: 0.75rem;
  margin-top: 2rem;
}
.chapter-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chapter-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
  text-decoration: none;
}
.chapter-card.coming-soon {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}
.chapter-card-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  min-width: 2rem;
  text-align: center;
  line-height: 1.4;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.chapter-card-body { flex: 1; }
.chapter-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.2rem;
}
.chapter-card-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.chapter-card-tag {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  flex-shrink: 0;
  align-self: center;
}
.tag-live { background: #d1fae5; color: #065f46; }
.tag-soon { background: var(--border); color: var(--text-muted); }

/* --- Hero (index page) --- */
.hero {
  padding: 4rem 0 3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}
.hero-eyebrow {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.hero h1 { margin-bottom: 1rem; }
.hero-lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 580px;
  margin-bottom: 0;
}

/* --- Chapter toggle button (replaces plain "Chapters" link) --- */
.chap-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.15s;
}
.chap-toggle:hover,
.chap-toggle.active,
.chap-toggle.is-open { color: var(--accent); }

.chap-caret {
  font-size: 0.65rem;
  transition: transform 0.2s;
  display: inline-block;
}
.chap-toggle.is-open .chap-caret { transform: rotate(180deg); }

/* --- Chapter dropdown panel --- */
.chap-panel {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.28s ease, box-shadow 0.2s;
  position: sticky;
  top: 53px;           /* just below the header */
  z-index: 90;
}
.chap-panel.is-open {
  max-height: 600px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.07);
}

.chap-panel-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1rem 1.5rem 1.25rem;
}

.chap-panel-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.3rem;
}

.chap-panel-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.12s;
  border: 1px solid transparent;
}
.chap-panel-item:hover {
  background: var(--accent-light);
  border-color: var(--interactive-border);
  text-decoration: none;
}
.chap-panel-item.current {
  background: var(--accent-light);
  border-color: var(--interactive-border);
}

.chap-panel-num {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent);
  background: white;
  border: 1px solid var(--interactive-border);
  border-radius: 5px;
  padding: 0.15rem 0.4rem;
  min-width: 1.8rem;
  text-align: center;
  flex-shrink: 0;
  line-height: 1.4;
}
.chap-panel-item.current .chap-panel-num {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.chap-panel-title {
  font-size: 0.83rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}
.chap-panel-item.current .chap-panel-title { font-weight: 600; }

/* --- Responsive --- */
@media (max-width: 600px) {
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.25rem; }
  .main-content { padding: 2rem 1.1rem 5rem; }
  .site-nav { display: none; }
  .chapter-nav { flex-direction: column; }
  .chapter-nav-btn { min-width: unset; width: 100%; }
  .chapter-nav-btn.next { text-align: left; }
  .chap-panel-grid { grid-template-columns: 1fr; }
  .chap-toggle { display: flex; }  /* always show on mobile since site-nav hides */
}

/* --- Utility --- */
.text-muted { color: var(--text-muted); }
.text-sm    { font-size: 0.875rem; }
.mt-0 { margin-top: 0; }

/* --- Floating feedback button --- */
.feedback-btn {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
.feedback-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 16px rgba(79,70,229,0.12);
  text-decoration: none;
}
@media (max-width: 600px) {
  .feedback-btn { bottom: 1rem; right: 1rem; padding: 0.45rem 0.8rem; }
}

/* --- Share bar --- */
.share-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 3rem 0 1.5rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.share-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-right: 0.25rem;
  flex-shrink: 0;
}
.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: 99px;
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  white-space: nowrap;
}
.share-btn:hover { background: var(--accent-light); border-color: var(--interactive-border); color: var(--accent); text-decoration: none; }
.share-btn svg { flex-shrink: 0; }
.share-wa  { color: #128c7e; border-color: #b2dfdb; background: #f0faf9; }
.share-wa:hover { background: #d0f0eb; border-color: #128c7e; color: #075e54; }

/* ============================================
   Quiz Component
   ============================================ */

.quiz-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin: 2.5rem 0 0;
}

.quiz-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.quiz-section-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.quiz-section-label::before { content: '◆'; font-size: 0.6rem; }

.quiz-section-count {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Progress bar + dots */
.quiz-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 1rem;
}

.quiz-dots { display: flex; gap: 0.35rem; align-items: center; }

.qdot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s;
}
.qdot.current  { background: var(--accent); }
.qdot.correct  { background: var(--success); }
.qdot.incorrect { background: #dc2626; }

/* Question text */
.quiz-q-text {
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.6;
  margin: 0 0 1rem;
  color: var(--text);
}

/* Options */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.quiz-option {
  width: 100%;
  text-align: left;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s, opacity 0.12s;
  line-height: 1.45;
}

.quiz-option:hover:not([disabled]) {
  border-color: var(--accent);
  background: var(--accent-light);
}

.quiz-option.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent-dark);
  font-weight: 500;
}

.quiz-option.correct {
  border-color: var(--success);
  background: #f0fdf4;
  color: #065f46;
  font-weight: 600;
}

.quiz-option.correct::after {
  content: ' ✓';
  font-weight: 700;
}

.quiz-option.incorrect {
  border-color: #dc2626;
  background: #fef2f2;
  color: #991b1b;
  font-weight: 500;
}

.quiz-option.incorrect::after {
  content: ' ✗';
  font-weight: 700;
}

.quiz-option.dimmed {
  opacity: 0.45;
}

/* Explanation */
.quiz-explanation {
  background: var(--code-bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.quiz-explanation strong { color: var(--text); }

/* Actions */
.quiz-actions { display: flex; justify-content: flex-end; }

.quiz-btn {
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.quiz-btn:hover:not([disabled]) { opacity: 0.88; }
.quiz-btn[disabled] {
  opacity: 0.38;
  cursor: default;
}

.quiz-btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.quiz-btn.secondary:hover { background: var(--accent-light); opacity: 1; }

/* Score card */
.quiz-score {
  text-align: center;
  padding: 1rem 0 0.5rem;
}

.quiz-score-num {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 0.5rem;
}
.quiz-score-num span { font-size: 1.5rem; color: var(--text-muted); font-weight: 400; }

.quiz-score-msg {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0.4rem 0 1rem;
}

.quiz-score-dots {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  margin-bottom: 1.25rem;
}
.quiz-score-dots .qdot { width: 10px; height: 10px; }

/* Locked state */
.quiz-locked {
  text-align: center;
  padding: 1.5rem 1rem;
  color: var(--text-muted);
}
.quiz-locked-icon { font-size: 1.5rem; margin-bottom: 0.6rem; }
.quiz-locked-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.4rem;
}
.quiz-locked-desc {
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: 320px;
  margin: 0 auto;
}

/* Responsive */
@media (max-width: 600px) {
  .quiz-section { padding: 1.25rem 1rem; }
  .quiz-option  { font-size: 0.875rem; padding: 0.65rem 0.85rem; }
}
