/* ============================================================
   草履虫投资 — 免费课程 (course.bytalk.cn)
   ============================================================ */

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

:root {
  --bg: #ffffff;
  --fg: #1a1a2e;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-bg: #eff6ff;
  --success: #10b981;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 12px rgba(0,0,0,0.1);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---- Navbar ---- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: 56px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
}

.nav-left { display: flex; align-items: center; gap: 10px; }
.nav-right { display: flex; align-items: center; gap: 12px; }

.nav-brand {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--fg);
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
}

.nav-logo { font-size: 20px; }
.nav-title { display: none; }
@media (min-width: 640px) { .nav-title { display: inline; } }

.nav-sep { color: var(--muted); font-size: 14px; }
.nav-current { font-size: 14px; font-weight: 600; color: var(--primary); }
.nav-link { font-size: 13px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.nav-link:hover { color: var(--fg); }

/* Auth area — styled by bytalk-auth.js (shared component) */

/* ---- Page Header ---- */
.page-header {
  padding: 2.5rem 0 1.5rem;
}
.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--fg);
  margin-bottom: 0.25rem;
}
.page-subtitle {
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---- Toolbar ---- */
.toolbar {
  margin-bottom: 1rem;
}

.search-box {
  position: relative;
  max-width: 320px;
}
.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #9ca3af;
}
.search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--fg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.search-input::placeholder { color: #9ca3af; }

/* ---- Category Tabs ---- */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 2rem;
}

.cat-btn {
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  background: #f3f4f6;
  color: var(--muted);
}
.cat-btn:hover { background: #e5e7eb; color: var(--fg); }
.cat-btn.active { background: var(--primary); color: #fff; }

/* ---- Course Grid ---- */
.course-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 3rem;
}
@media (min-width: 768px) { .course-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .course-grid { grid-template-columns: repeat(4, 1fr); } }

.course-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.2s, border-color 0.2s;
}
.course-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.card-cover {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, #eff6ff, #eef2ff, #faf5ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  position: relative;
  overflow: hidden;
}
.card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.card-badge-free {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  background: var(--success);
  color: #fff;
}
.card-badge-type {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  background: var(--primary);
  color: #fff;
}

.card-body {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 12px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-video, .btn-file, .btn-download {
  display: block;
  width: 100%;
  padding: 8px 0;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  text-align: center;
  transition: background 0.15s;
}
.btn-video { background: var(--primary); color: #fff; }
.btn-video:hover { background: var(--primary-hover); }
.btn-file, .btn-download { background: var(--success); color: #fff; }
.btn-file:hover, .btn-download:hover { background: #059669; }

/* ---- Empty & Loading States ---- */
.empty-state, .loading-state {
  text-align: center;
  padding: 4rem 0;
}
.empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }
.empty-title { font-size: 1.1rem; color: var(--muted); margin-bottom: 0.25rem; }
.empty-hint { font-size: 0.875rem; color: var(--muted); }
.loading-state { color: var(--muted); font-size: 0.95rem; }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
  width: 100%;
  max-height: 90vh;
}

.modal-video { max-width: 800px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 12px;
}
.modal-actions { display: flex; align-items: center; gap: 8px; }
.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--fg); }

.video-container {
  aspect-ratio: 16/9;
  background: #000;
  position: relative;
}
.video-container iframe,
.video-container video {
  width: 100%;
  height: 100%;
  border: none;
}
#videoError {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.5);
  font-size: 14px;
}

/* PDF Modal */
.modal-pdf {
  max-width: 1100px;
  height: 90vh;
  display: flex;
  flex-direction: column;
}
.pdf-container {
  flex: 1;
  overflow: hidden;
}
.pdf-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

.btn-download {
  padding: 6px 14px !important;
  width: auto !important;
  text-decoration: none;
}

/* ---- Footer ---- */
.site-footer {
  text-align: center;
  padding: 2rem 1.5rem;
  font-size: 12px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}
.site-footer a { color: var(--primary); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* ---- Responsive Fixes ---- */
@media (max-width: 480px) {
  .page-title { font-size: 1.35rem; }
  .course-grid { grid-template-columns: 1fr; }
  .nav-link.hide-mobile { display: none; }
}
