/* CU Platform — Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

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

:root {
  /* Colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #16161f;
  --bg-card-hover: #1c1c28;
  --bg-elevated: #1e1e2a;
  --bg-glass: rgba(22, 22, 31, 0.7);

  --text-primary: #e8e8ef;
  --text-secondary: #8b8ba0;
  --text-muted: #5a5a70;

  --accent: #6366f1;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --accent-glow: rgba(99, 102, 241, 0.3);

  --green: #22c55e;
  --green-soft: rgba(34, 197, 94, 0.12);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.12);
  --rose: #f43f5e;
  --rose-soft: rgba(244, 63, 94, 0.12);
  --cyan: #06b6d4;
  --cyan-soft: rgba(6, 182, 212, 0.12);

  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.12);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

  --max-width: 1200px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ====== LAYOUT ====== */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 24px; }

/* ====== HEADER ====== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
  padding: 16px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), #a855f7);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-glow);
}

.logo-text { font-weight: 700; font-size: 18px; letter-spacing: -0.5px; }
.logo-sub { font-size: 12px; color: var(--text-muted); font-weight: 400; }

.search-bar {
  flex: 1;
  max-width: 400px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
}

.search-bar input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-bar input::placeholder { color: var(--text-muted); }

.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  pointer-events: none;
}

.nav-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.nav-stat { display: flex; align-items: center; gap: 4px; }
.nav-stat .num { color: var(--text-primary); font-weight: 600; }

/* ====== HERO ====== */
.hero {
  padding: 48px 0 32px;
  text-align: center;
}

.hero h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.hero p { color: var(--text-secondary); font-size: 16px; }

/* ====== COURSES GRID ====== */
.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
  padding: 16px 0 60px;
}

.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.course-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #a855f7, var(--cyan));
  opacity: 0;
  transition: var(--transition);
}

.course-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.course-card:hover::before { opacity: 1; }

.course-card-header { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }

.course-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.course-icon.dev { background: var(--accent-soft); }
.course-icon.general { background: var(--green-soft); }
.course-icon.business { background: var(--amber-soft); }
.course-icon.stem { background: var(--cyan-soft); }
.course-icon.soft { background: var(--rose-soft); }
.course-icon.other { background: rgba(255,255,255,0.06); }

.course-name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.3px;
}

.course-category {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

.course-category.dev { background: var(--accent-soft); color: var(--accent); }
.course-category.general { background: var(--green-soft); color: var(--green); }
.course-category.business { background: var(--amber-soft); color: var(--amber); }
.course-category.stem { background: var(--cyan-soft); color: var(--cyan); }
.course-category.soft { background: var(--rose-soft); color: var(--rose); }
.course-category.other { background: rgba(255,255,255,0.06); color: var(--text-secondary); }

.course-stats {
  display: flex;
  gap: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.course-stat {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

.course-stat .val { color: var(--text-primary); font-weight: 600; }

/* ====== COURSE DETAIL VIEW ====== */
.course-view { display: none; padding: 32px 0 60px; }
.course-view.active { display: block; }
.courses-list.hidden { display: none; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--bg-card);
  transition: var(--transition);
  font-family: inherit;
  margin-bottom: 24px;
}

.back-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.course-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 32px;
}

.course-detail-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
}

.course-detail-title { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }

.course-links {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.course-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  transition: var(--transition);
}

.course-link:hover { background: var(--bg-card-hover); border-color: var(--accent); }

/* Activities */
.activities-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 32px;
  flex-wrap: wrap;
}

.activity-chip {
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.activity-weight {
  font-weight: 700;
  color: var(--accent);
}

/* Themes */
.theme-list { display: flex; flex-direction: column; gap: 12px; }

.theme-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.theme-card:hover { border-color: var(--border-hover); }

.theme-header {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.theme-header:hover { background: var(--bg-card-hover); }

.theme-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 15px;
}

.theme-order {
  width: 28px;
  height: 28px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.theme-meta {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.theme-body {
  display: none;
  padding: 0 24px 20px;
  border-top: 1px solid var(--border);
}

.theme-body.open { display: block; padding-top: 16px; }

.theme-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin: 16px 0 8px;
  font-weight: 600;
}

.theme-section-title:first-child { margin-top: 0; }

.longread-item, .exercise-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: var(--transition);
}

.longread-item:hover, .exercise-item:hover { background: var(--bg-elevated); }

.longread-item .icon { font-size: 16px; }

.exercise-type {
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  background: var(--accent-soft);
  color: var(--accent);
}

.exercise-activity {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
}

/* ====== TRANSCRIPT VIEW ====== */
.transcript-view { display: none; padding: 32px 0 60px; }
.transcript-view.active { display: block; }

.transcript-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  max-height: 70vh;
  overflow-y: auto;
}

/* ====== FOOTER ====== */
.footer {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ====== LOADING ====== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  color: var(--text-muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
  .courses-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 28px; }
  .search-bar { max-width: none; }
  .nav-stats { display: none; }
  .course-detail-header { flex-direction: column; gap: 12px; }
  .course-detail-title { font-size: 22px; }
  .activities-bar { gap: 8px; }
  .header-inner { flex-wrap: wrap; }
}

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ====== ANIMATIONS ====== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.3s ease-out; }

/* ====== CLICKABLE ITEMS ====== */
a.longread-item, a.exercise-item {
  text-decoration: none;
  color: var(--text-primary);
  cursor: pointer;
}

a.longread-item:hover, a.exercise-item:hover {
  background: var(--bg-elevated);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.open-icon {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-muted);
  opacity: 0;
  transition: var(--transition);
}

a.longread-item:hover .open-icon,
a.exercise-item:hover .open-icon {
  opacity: 1;
  color: var(--accent);
}

.longread-type {
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 10px;
  font-weight: 500;
  background: var(--green-soft);
  color: var(--green);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.course-link.lms-link {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.course-link.lms-link:hover {
  background: var(--accent);
  color: white;
}

.arrow {
  transition: transform 0.2s ease;
  display: inline-block;
}

.empty-state {
  text-align: center;
  padding: 60px;
  color: var(--text-muted);
  font-size: 16px;
  grid-column: 1 / -1;
}

/* ====== COURSE LINKS WRAP ====== */
.course-links { flex-wrap: wrap; }

/* ====== MATERIALS CONTENT ====== */
.longread-section {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
}

.longread-section:last-child { border-bottom: none; }

.longread-header-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text-primary);
  transition: var(--transition);
  margin-bottom: 12px;
}

.longread-header-link:hover {
  background: var(--bg-elevated);
}

.longread-header-link .longread-name { flex: 1; }

.materials-content {
  padding: 0 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.material-markdown {
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-secondary);
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
  overflow-x: auto;
}

.material-markdown h1, .material-markdown h2, .material-markdown h3 {
  color: var(--text-primary);
  margin: 12px 0 8px;
  font-weight: 700;
}

.material-markdown h1 { font-size: 20px; }
.material-markdown h2 { font-size: 17px; }
.material-markdown h3 { font-size: 15px; }

.material-markdown p { margin: 6px 0; }
.material-markdown a { color: var(--accent); text-decoration: underline; }
.material-markdown ul, .material-markdown ol { padding-left: 20px; margin: 6px 0; }
.material-markdown img { max-width: 100%; border-radius: var(--radius-sm); margin: 8px 0; }
.material-markdown code { background: var(--bg-card); padding: 2px 6px; border-radius: 4px; font-size: 13px; }
.material-markdown pre { background: var(--bg-card); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; }

/* File cards */
.file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.file-card:hover { border-color: var(--border-hover); }

.file-icon { font-size: 28px; }

.file-info { flex: 1; }
.file-name { font-size: 14px; font-weight: 500; color: var(--text-primary); word-break: break-all; }
.file-size { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.file-download {
  padding: 6px 14px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  transition: var(--transition);
}

.file-download:hover { background: var(--accent); color: white; }

/* ktalk cards */
.ktalk-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(168, 85, 247, 0.08));
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
}

.ktalk-icon { font-size: 32px; }
.ktalk-info { flex: 1; }
.ktalk-title { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }

.ktalk-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
}

.ktalk-link:hover { text-decoration: underline; }

/* Exercises section */
.exercises-section { margin-top: 16px; }

/* Inline loading */
.loading-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.spinner-sm {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
