/* ============================================================
   Cody Learn Portal — Mobile-first stylesheet
   Designed for commute reading + desktop study sessions
   ============================================================ */

:root {
  --bg: #0f1117;
  --bg2: #1a1d26;
  --bg3: #252836;
  --border: #2d3148;
  --text: #e8eaf0;
  --text-muted: #8b91a8;
  --text-dim: #545872;
  --accent-a: #3b82f6;
  --accent-b: #8b5cf6;
  --accent-c: #10b981;
  --accent-d: #f59e0b;
  --accent-active: #60a5fa;
  --danger: #ef4444;
  --success: #22c55e;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --max-read: 700px;
  --nav-h: 56px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7ff;
    --bg2: #ffffff;
    --bg3: #eef0f8;
    --border: #dde1f0;
    --text: #1a1d2e;
    --text-muted: #5c6080;
    --text-dim: #9098b8;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
  }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  min-height: 100vh;
}

/* ── Nav ── */
.nav {
  position: sticky;
  top: 0;
  height: var(--nav-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  z-index: 100;
  backdrop-filter: blur(8px);
}

.nav-logo {
  font-weight: 700;
  font-size: 1rem;
  color: var(--accent-active);
  text-decoration: none;
  white-space: nowrap;
}

.nav-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
  overflow: hidden;
  flex: 1;
}

.nav-breadcrumb a { color: var(--text-muted); text-decoration: none; }
.nav-breadcrumb a:hover { color: var(--text); }
.nav-breadcrumb .sep { color: var(--text-dim); }
.nav-breadcrumb .current { color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-progress {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  display: none;
}
@media(min-width:480px) { .nav-progress { display: block; } }

/* ── Layout ── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

.reading-container {
  max-width: var(--max-read);
  margin: 0 auto;
  padding: 32px 20px 80px;
}

/* ── Hero ── */
.hero {
  padding: 48px 20px 40px;
  text-align: center;
  max-width: 800px;
  margin: 0 auto;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.3);
  color: var(--accent-active);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 20px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.hero h1 {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.hero h1 span { color: var(--accent-active); }

.hero-sub {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto 32px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}

.stat {
  text-align: center;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Progress bar ── */
.global-progress {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 20px;
}

.progress-track {
  max-width: 800px;
  margin: 0 auto;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.progress-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-a), var(--accent-b));
  border-radius: 999px;
  transition: width 0.6s ease;
}

/* ── Phase grid ── */
.phases {
  padding: 40px 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.phases-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.phase-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.phase-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--phase-color, var(--accent-a));
}

.phase-card:hover {
  border-color: var(--phase-color, var(--accent-a));
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.phase-card.locked {
  opacity: 0.5;
  pointer-events: none;
  cursor: not-allowed;
}

.phase-card.active { border-color: var(--phase-color, var(--accent-a)); }

.phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.phase-id {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  color: var(--phase-color, var(--accent-a));
}

.phase-status {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.phase-status.active-badge { color: var(--success); }

.phase-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.phase-subtitle {
  font-size: 0.84rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.4;
}

.phase-meta {
  display: flex;
  gap: 16px;
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ── Module list ── */
.modules {
  padding: 32px 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.module-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.module-row {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}

.module-row:hover { border-color: var(--phase-color, var(--accent-a)); background: var(--bg3); }
.module-row.completed { opacity: 0.7; }
.module-row.current { border-color: var(--phase-color, var(--accent-a)); background: var(--bg3); }

.module-check {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
}

.module-row.completed .module-check {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.module-row.current .module-check {
  border-color: var(--phase-color, var(--accent-a));
}

.module-info { flex: 1; }

.module-id {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.module-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 2px;
}

.module-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.module-arrow {
  color: var(--text-dim);
  font-size: 1.1rem;
}

/* ── Lesson content ── */
.lesson-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.lesson-phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--phase-color, var(--accent-a));
  margin-bottom: 12px;
}

.lesson-header h1 {
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 14px;
}

.lesson-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.lesson-meta span::before {
  margin-right: 5px;
}

/* ── Content typography ── */
.content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 40px 0 14px;
  letter-spacing: -0.01em;
  padding-top: 8px;
}

.content h2:first-child { margin-top: 0; }

.content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 28px 0 10px;
  color: var(--text);
}

.content p {
  margin-bottom: 16px;
  color: var(--text);
}

.content ul, .content ol {
  margin: 0 0 16px 20px;
  color: var(--text);
}

.content li { margin-bottom: 6px; }

.content strong { color: var(--text); font-weight: 700; }

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

.content code {
  background: var(--bg3);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: #93c5fd;
}

.content pre {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 20px 0;
  font-size: 0.88rem;
  line-height: 1.6;
}

.content pre code {
  background: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}

/* Syntax highlighting hints */
.kw { color: #c084fc; }
.fn { color: #60a5fa; }
.st { color: #4ade80; }
.cm { color: #6b7280; font-style: italic; }
.nu { color: #fb923c; }
.tp { color: #f9a8d4; }

/* ── Callout boxes ── */
.callout {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin: 24px 0;
  border-left: 3px solid;
}

.callout-why {
  background: rgba(59,130,246,0.08);
  border-color: var(--accent-a);
}

.callout-warning {
  background: rgba(239,68,68,0.08);
  border-color: var(--danger);
}

.callout-good {
  background: rgba(34,197,94,0.08);
  border-color: var(--success);
}

.callout-tip {
  background: rgba(245,158,11,0.08);
  border-color: var(--accent-d);
}

.callout-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  opacity: 0.7;
}

/* ── Flaw drill box ── */
.flaw-drill {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 32px 0;
}

.flaw-drill-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.flaw-icon {
  width: 32px; height: 32px;
  background: rgba(239,68,68,0.12);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.flaw-drill-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.flaw-drill-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Exercise box ── */
.exercise-box {
  background: rgba(59,130,246,0.06);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 32px 0;
}

.exercise-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent-active);
}

/* ── Resources ── */
.resources {
  margin: 32px 0;
}

.resources h3 { margin-top: 0; }

.resource-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  margin: 0;
}

.resource-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
}

.resource-item a {
  color: var(--text);
  text-decoration: none;
  flex: 1;
}

.resource-item a:hover { color: var(--accent-active); }

.resource-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}

.badge-free {
  background: rgba(34,197,94,0.12);
  color: var(--success);
}

.badge-paid {
  background: rgba(245,158,11,0.12);
  color: var(--accent-d);
}

.badge-interactive {
  background: rgba(59,130,246,0.12);
  color: var(--accent-active);
}

/* ── Lesson nav footer ── */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0;
  margin-top: 40px;
  border-top: 1px solid var(--border);
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  cursor: pointer;
}

.btn:hover { background: var(--bg3); }

.btn-primary {
  background: var(--accent-a);
  border-color: var(--accent-a);
  color: white;
}

.btn-primary:hover { background: #2563eb; }

.btn-complete {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.btn-complete:hover { background: #16a34a; }

.complete-btn-area {
  text-align: center;
  margin: 32px 0;
}

/* ── Objective list ── */
.objectives {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 32px;
}

.objectives h3 {
  margin: 0 0 12px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

.objectives ul {
  list-style: none;
  margin: 0;
}

.objectives li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.objectives li::before {
  content: '→';
  color: var(--accent-active);
  flex-shrink: 0;
  margin-top: 2px;
}

/* ── Concept tags ── */
.concept-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 28px;
}

.concept-tag {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ── Footer ── */
footer {
  border-top: 1px solid var(--border);
  padding: 24px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.78rem;
  margin-top: 60px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Utilities ── */
.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.mt-0 { margin-top: 0; }
.mb-8 { margin-bottom: 8px; }
.gap-top { margin-top: 40px; }
