/* PyLearn - Main Stylesheet */

/* ── Code editor font ── */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }
body { font-family: 'Inter', system-ui, sans-serif; }

/* ── Code blocks ── */
pre, code { font-family: 'Fira Code', 'Cascadia Code', monospace; }
pre { border-radius: 0.5rem; overflow-x: auto; }
code:not(pre code) {
  background: #f1f5f9;
  color: #6366f1;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.875em;
}
.dark code:not(pre code) {
  background: #1e293b;
  color: #a5b4fc;
}

/* ── Syntax highlight overrides (highlight.js) ── */
.hljs { border-radius: 0.5rem; font-size: 0.9rem; line-height: 1.6; }

/* ── Progress bar ── */
.progress-bar {
  height: 8px;
  border-radius: 9999px;
  background: #e2e8f0;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.5s ease;
}
.dark .progress-bar { background: #334155; }

/* ── XP Badge ── */
.xp-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 9999px;
}

/* ── Streak flame ── */
.streak-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: #fff;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
}

/* ── Level badge ── */
.level-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 9999px;
}

/* ── Topic card ── */
.topic-card {
  transition: transform 0.2s, box-shadow 0.2s;
}
.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(99,102,241,0.15);
}

/* ── Lesson sidebar ── */
.lesson-sidebar { min-height: calc(100vh - 64px); }
.sidebar-topic {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.875rem;
}
.sidebar-topic:hover { background: rgba(99,102,241,0.08); }
.sidebar-topic.active { background: rgba(99,102,241,0.15); color: var(--primary); font-weight: 600; }
.sidebar-topic.completed .check { color: var(--success); }

/* ── Quiz ── */
.quiz-option {
  display: block; width: 100%;
  padding: 12px 16px;
  border: 2px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  background: transparent;
}
.quiz-option:hover { border-color: var(--primary); background: rgba(99,102,241,0.04); }
.quiz-option.selected { border-color: var(--primary); background: rgba(99,102,241,0.08); }
.quiz-option.correct { border-color: var(--success); background: rgba(16,185,129,0.08); }
.quiz-option.incorrect { border-color: var(--danger); background: rgba(239,68,68,0.08); }
.dark .quiz-option { border-color: #334155; }
.dark .quiz-option:hover { border-color: var(--primary); }

/* ── Timer ring ── */
.timer-ring { transform: rotate(-90deg); }
.timer-ring-fill {
  stroke-dasharray: 220;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

/* ── Challenge difficulty badges ── */
.badge-easy   { background:#dcfce7; color:#166534; }
.badge-medium { background:#fef9c3; color:#854d0e; }
.badge-hard   { background:#fee2e2; color:#991b1b; }
.dark .badge-easy   { background:#14532d; color:#86efac; }
.dark .badge-medium { background:#422006; color:#fde68a; }
.dark .badge-hard   { background:#450a0a; color:#fca5a5; }

/* ── Code editor textarea ── */
.code-editor {
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 200px;
  tab-size: 4;
}

/* ── Certificate ── */
.certificate-container {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  padding: 4px;
}
.certificate-inner {
  background: #fff;
  border-radius: 12px;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.certificate-inner::before {
  content: '';
  position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%236366f1' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

/* ── Toast notifications ── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 10px;
  color: #fff;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 360px;
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--info); }
.toast-warning { background: var(--warning); }
@keyframes slideIn  { from { transform: translateX(100%); opacity:0; } to { transform: translateX(0); opacity:1; } }
@keyframes fadeOut  { from { opacity:1; } to { opacity:0; transform: translateY(10px); } }

/* ── Responsive ── */
@media (max-width: 768px) {
  .lesson-sidebar { display: none; }
  .lesson-sidebar.open { display: block; position: fixed; inset: 0; z-index: 50; overflow-y: auto; }
}

/* ── Dark mode extras ── */
.dark { color-scheme: dark; }
.dark .hljs { background: #0f172a; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
.dark ::-webkit-scrollbar-thumb { background: #475569; }

/* ── Print (certificate) ── */
@media print {
  nav, footer, .no-print { display: none !important; }
  .certificate-container { box-shadow: none !important; }
}
