/* apps/student/static/student/components.css
   B airy-card component primitives + the curriculum tree family.
   Loaded AFTER layout.css so .s-card / .s-progress / .s-chip / .s-spinner
   win over page-specific card classes (P4.3 B direction).
   Shared/deduped component classes (.s-due-chip, .s-empty-state,
   .s-page-title, .s-join-link, .s-table) live in student.css; the
   curriculum tree (.s-branch / .s-tier / .s-unit-card) lives here. */

/* ── B: Airy card (P4.3) ──────────────────────────────────── */
/* Soft surface, subtle shadow, larger radius, breathing room.
   Apply alongside page-specific card classes (e.g. .s-course-panel,
   .s-worksheet-card, .skill-card) to adopt the airy look. Loads last
   so it wins over the page-specific border/radius/padding/background. */
.s-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
}
.s-card-title { font-family: var(--font-ui); font-size: var(--text-lg); font-weight: 700; margin: 0 0 var(--space-2); color: var(--text); }
.s-card-label { font-size: var(--text-xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* ── B: Progress component (P4.3) ─────────────────────────── */
/* Clean token-based progress bar. The legacy .s-progress-bar-track /
   .s-progress-bar-fill (defined in student.css) remain in use across
   course-detail / curriculum / unit-progress; these .s-progress* classes
   are the refined component for new markup. */
.s-progress { background: var(--border); height: 6px; border-radius: 3px; overflow: hidden; }
.s-progress-bar { background: var(--teal); height: 100%; border-radius: 3px; transition: width 400ms ease-out; }

/* ── B: Chip base (P4.3) ──────────────────────────────────── */
/* .s-due-chip (defined in student.css) is the applied variant; .s-chip is
   the reusable base for future pill labels. */
.s-chip {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  font-family: var(--font-ui);
  white-space: nowrap;
}

/* ── B: Spinner (P4.3) ────────────────────────────────────── */
.s-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: s-spin 0.7s linear infinite;
}
@keyframes s-spin { to { transform: rotate(360deg); } }

/* ── Curriculum tree ──────────────────────────────────────── */
/* Source: curriculum.html inline <style> (P2.1–P2.3). The .s-due-chip
   block that originally lived here was hoisted to the shared section above. */
.s-catalog {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.s-branch-card {
  border: 1px solid var(--border);
  border-top: 4px solid var(--teal);
  border-radius: 12px;
  background: var(--surface-2);
  overflow: hidden;
  transition: box-shadow 250ms ease, transform 250ms ease;
}
.s-branch-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}

/* Branch theme colors */
.s-branch-card[class*="s-branch-core"] {
  border-top-color: #2a7e94;
  --theme-color: #2a7e94;
  --theme-bg: #e8f4f7;
}
.s-branch-card.s-branch-branch_a {
  border-top-color: #2563eb;
  --theme-color: #2563eb;
  --theme-bg: #eff6ff;
}
.s-branch-card.s-branch-branch_b {
  border-top-color: #d97706;
  --theme-color: #d97706;
  --theme-bg: #fffbeb;
}
.s-branch-card.s-branch-branch_c {
  border-top-color: #7c3aed;
  --theme-color: #7c3aed;
  --theme-bg: #f5f3ff;
}
.s-branch-card.s-branch-branch_d {
  border-top-color: #db2777;
  --theme-color: #db2777;
  --theme-bg: #fdf2f8;
}

.s-branch-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  padding: 18px 20px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  color: var(--text);
  transition: background 150ms ease;
}
.s-branch-header:hover { background: rgba(42, 126, 148, 0.03); }

.s-branch-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--theme-bg, var(--teal-pale));
  color: var(--theme-color, var(--teal));
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-top: 2px;
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1),
              background 200ms ease, color 200ms ease;
}
.s-branch-card.expanded .s-branch-chevron {
  transform: rotate(90deg);
  background: var(--theme-color, var(--teal));
  color: white;
}

.s-branch-info { flex: 1; min-width: 0; }
.s-branch-label {
  display: block;
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 1.1rem;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}
.s-branch-desc {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.s-branch-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}
.s-branch-tier-count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.s-branch-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 400ms cubic-bezier(0.4, 0, 0.2, 1);
}
.s-branch-card.expanded .s-branch-body { max-height: 5000px; }
.s-branch-body-inner {
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}

/* Tier accordion (inside branch) */
.s-tier-group {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 10px;
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow 200ms ease;
}
.s-tier-group:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.s-tier-group.dimmed { opacity: 0.5; }
.s-tier-group.dimmed:hover { opacity: 0.65; }

.s-tier-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  border: none;
  background: none;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
  color: var(--text);
  transition: background 150ms ease;
}
.s-tier-header:hover { background: rgba(42, 126, 148, 0.04); }

.s-tier-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 0.6rem;
  color: var(--text-muted);
  transition: transform 250ms cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}
.s-tier-group.expanded .s-tier-chevron { transform: rotate(90deg); }

.s-tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 22px;
  padding: 0 7px;
  border-radius: 5px;
  background: var(--theme-bg, var(--teal-pale));
  color: var(--theme-color, var(--teal));
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}
.s-tier-group.dimmed .s-tier-badge { background: #eee; color: #999; }

.s-tier-info { flex: 1; min-width: 0; }
.s-tier-label {
  display: block;
  font-weight: 700;
  font-size: 0.84rem;
  color: var(--text);
  line-height: 1.3;
}
.s-tier-desc {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
  margin-top: 1px;
}

.s-tier-stat {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.s-tier-stat-active { color: var(--theme-color, var(--teal)) !important; }

.s-tier-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 350ms cubic-bezier(0.4, 0, 0.2, 1),
              padding 250ms ease;
  padding: 0 14px;
}
.s-tier-group.expanded .s-tier-body {
  max-height: 2000px;
  padding: 2px 14px 14px;
}

/* Unit cards inside tiers */
.s-tier-body .s-unit-card {
  margin-bottom: 5px;
  padding: 9px 12px;
  border-radius: 6px;
  border-color: var(--border);
  transition: all 150ms ease;
}
.s-tier-body .s-unit-card.active:hover {
  border-color: var(--theme-color, var(--teal));
  box-shadow: 0 0 0 3px var(--theme-bg, rgba(42,126,148,0.1));
}
.s-tier-body .s-unit-pct {
  font-size: 0.75rem;
  color: var(--theme-color, var(--teal));
  font-weight: 600;
}
.s-tier-body .s-progress-bar-fill { background: var(--theme-color, var(--teal)); }
.s-tier-body .s-unit-card:last-child { margin-bottom: 0; }

/* Branch mastery slot (lazy fragment) */
.s-branch-mastery[hidden] { display: none; }
.s-branch-mastery.empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Skeleton loading state */
.s-branch-skeleton {
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.s-branch-skeleton-bar {
  height: 40px;
  border-radius: 6px;
  background: var(--border);
  opacity: 0.4;
  animation: s-skeleton-pulse 1.2s ease-in-out infinite;
}
.s-branch-skeleton-bar:nth-child(2) { animation-delay: 0.15s; }
.s-branch-skeleton-bar:nth-child(3) { animation-delay: 0.3s; }
@keyframes s-skeleton-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.55; }
}

/* Retry button */
.s-branch-retry {
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.s-branch-retry-btn {
  margin-top: 8px;
  padding: 6px 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-family: var(--font-body);
  transition: background 150ms ease;
}
.s-branch-retry-btn:hover { background: var(--surface-2); }

/* Responsive: 2-column grid for branches on wider screens */
@media (min-width: 680px) {
  .s-catalog {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  .s-branch-card.expanded { grid-column: 1 / -1; }
}