@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700&family=Source+Serif+4:opsz,wght@8..60,700;8..60,800&display=swap');

/* ===== RESET & TOKENS ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --navy: #0f1b2d;
  --blue: #1a56db;
  --blue-light: #3b82f6;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;
  --green: #059669;
  --green-bg: #ecfdf5;
  --green-border: #a7f3d0;
  --amber: #d97706;
  --amber-bg: #fffbeb;
  --amber-border: #fde68a;
  --red: #dc2626;
  --bg: #ffffff;
  --bg-off: #f8fafc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --font: 'DM Sans', -apple-system, sans-serif;
  --font-display: 'Source Serif 4', Georgia, serif;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}
html { scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--text); background: var(--bg-off); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }

/* ===== TOPBAR ===== */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 0;
}
.topbar-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
  flex: 1;
  text-align: center;
  padding-right: 80px;
}
.topbar-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255,255,255,0.75);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.topbar-back:hover { background: rgba(255,255,255,0.08); color: #fff; }
.topbar-back-label { display: inline; }
@media (max-width: 480px) { .topbar-back-label { display: none; } }

/* ===== PAGE LAYOUT ===== */
.cert-layout {
  max-width: 1120px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 228px 1fr;
  align-items: start;
  padding: 0 24px;
}
.cert-page {
  max-width: 800px;
  margin: 0 auto;
  padding: 36px 40px 72px;
}

/* ===== TOC SIDEBAR ===== */
.cert-toc {
  position: sticky;
  top: 68px;
  padding: 40px 8px 40px 0;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
}
.toc-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-left: 12px;
}
.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.toc-link {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  border-left: 2px solid transparent;
  line-height: 1.4;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.toc-link:hover { color: var(--text); background: var(--bg-off); }
.toc-link.active {
  color: var(--blue);
  border-left-color: var(--blue);
  background: var(--blue-bg);
  font-weight: 600;
}
.toc-quiz-link {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

/* ===== LESSON BADGE ===== */
.lesson-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.lesson-badge .num {
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 4px;
}
.lesson-badge .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== LESSON TITLE ===== */
.lesson-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
}
.lesson-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.lesson-meta span { display: flex; align-items: center; gap: 5px; }

/* ===== LESSON CARDS ===== */
.lesson-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.lesson-card h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.lesson-card h2 .card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.lesson-card p { color: var(--text-secondary); font-size: 14.5px; line-height: 1.7; }
.lesson-card p + p { margin-top: 10px; }
.lesson-card p strong { color: var(--text); font-weight: 600; }
.lesson-card ul, .lesson-card ol { padding-left: 20px; margin-top: 8px; }
.lesson-card li { font-size: 14.5px; color: var(--text-secondary); line-height: 1.7; margin-bottom: 4px; }
.lesson-card li strong { color: var(--text); }

/* Callouts */
.callout {
  background: var(--bg-off);
  border-left: 3px solid var(--blue);
  padding: 14px 16px;
  border-radius: 0 8px 8px 0;
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
}
.callout strong { color: var(--text); }
.callout.warning { border-left-color: var(--amber); }
.callout.success { border-left-color: var(--green); }

/* ===== QUIZ SECTION ===== */
.quiz-intro {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
}
.quiz-question {
  background: var(--bg-off);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 18px 20px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.quiz-question.question-wrong {
  border-color: #fecaca;
  background: #fff8f8;
}
.question-num {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.question-text {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 12px;
}
.options-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.option-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--bg);
}
.option-label:hover { border-color: var(--blue-border); background: var(--blue-bg); }
.option-label input[type="radio"] {
  margin-top: 3px;
  flex-shrink: 0;
  accent-color: var(--blue);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.option-text {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.option-label.correct {
  border-color: var(--green-border);
  background: var(--green-bg);
}
.option-label.correct .option-text { color: var(--green); font-weight: 600; }
.option-label.incorrect {
  border-color: #fecaca;
  background: #fef2f2;
}
.option-label.incorrect .option-text { color: var(--red); font-weight: 600; }

/* Quiz submit */
.quiz-submit-area { margin-top: 20px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.quiz-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--red);
  font-weight: 600;
  margin-top: 12px;
}

/* Buttons */
.next-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 11px 28px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s;
}
.next-btn:hover { background: #1648b8; }

/* ===== RESULT BANNERS ===== */
.cert-earned-banner {
  background: var(--green-bg);
  border: 2px solid var(--green-border);
  border-radius: 14px;
  padding: 32px;
  text-align: center;
  margin-top: 20px;
}
.cert-earned-banner h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 10px;
}
.cert-earned-banner p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 22px;
}
.cert-fail-banner {
  background: var(--amber-bg);
  border: 2px solid var(--amber-border);
  border-radius: 14px;
  padding: 28px;
  text-align: center;
  margin-top: 20px;
}
.cert-fail-banner h3 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--amber);
  margin-bottom: 8px;
}
.cert-fail-banner p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 18px;
}

/* Link buttons */
.cert-btn {
  display: inline-block;
  background: var(--blue);
  color: #fff !important;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 28px;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s;
  margin: 4px;
}
.cert-btn:hover { background: #1648b8; }
.cert-btn.green { background: var(--green); }
.cert-btn.green:hover { background: #047857; }
.cert-btn.amber { background: var(--amber); border: none; cursor: pointer; font-family: var(--font); font-size: 14px; }
.cert-btn.amber:hover { background: #b45309; }
.cert-btn.outline {
  background: var(--bg);
  color: var(--navy) !important;
  border: 1px solid var(--border);
}
.cert-btn.outline:hover { background: var(--bg-off); }

/* Already earned */
.already-earned {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 24px;
}
.already-earned h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 8px;
}
.already-earned p { font-size: 14px; color: var(--text-secondary); margin-bottom: 6px; }

/* ===== KNOWLEDGE CHECK CTA ===== */
.cert-cta-card {
  background: linear-gradient(135deg, var(--navy) 0%, #1e3a5f 100%);
  border-radius: 16px;
  padding: 40px 36px;
  text-align: center;
  color: #fff;
  box-shadow: 0 8px 32px rgba(15, 27, 45, 0.18);
}
.cert-cta-icon {
  font-size: 44px;
  line-height: 1;
  margin-bottom: 16px;
}
.cert-cta-card h3 {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.cert-cta-card p {
  font-size: 14.5px;
  color: rgba(255,255,255,0.8);
  line-height: 1.65;
  margin-bottom: 10px;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}
.cert-cta-note {
  font-size: 12.5px !important;
  color: rgba(255,255,255,0.5) !important;
  margin-bottom: 28px !important;
}
.cert-cta-btn {
  background: #fff !important;
  color: var(--navy) !important;
  font-size: 15px !important;
  padding: 13px 32px !important;
  border-radius: 9px !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: transform 0.15s, box-shadow 0.15s !important;
}
.cert-cta-btn:hover {
  background: #f0f4ff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.2) !important;
}

/* ===== CERTIFICATIONS HUB ===== */
.hub-page { max-width: 960px; margin: 0 auto; padding: 40px 24px 72px; }
.hub-header { margin-bottom: 36px; }
.hub-header h1 {
  font-family: var(--font-display);
  font-size: 34px;
  font-weight: 800;
  color: var(--navy);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.hub-header p { font-size: 15px; color: var(--text-secondary); line-height: 1.6; }
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.cert-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.cert-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.07);
  border-color: var(--blue-border);
}
.cert-card.earned {
  border-color: var(--green-border);
  background: linear-gradient(to bottom right, #fff, var(--green-bg));
}
.cert-card.earned:hover { border-color: var(--green); }
.cert-card-icon { font-size: 36px; line-height: 1; }
.cert-card-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.3;
}
.cert-card-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.cert-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}
.cert-badge-required {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}
.cert-badge-earned {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid var(--green-border);
}
.cert-card-arrow {
  font-size: 13px;
  font-weight: 700;
  color: var(--blue);
}
.cert-card.earned .cert-card-arrow { color: var(--green); }

/* Progress summary */
.hub-progress {
  background: var(--navy);
  border-radius: 14px;
  padding: 24px 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}
.hub-progress-text { flex: 1; }
.hub-progress-text h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}
.hub-progress-text p { font-size: 13px; color: rgba(255,255,255,0.6); }
.hub-progress-num {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 800;
  color: #34d399;
  flex-shrink: 0;
  line-height: 1;
}
.hub-progress-num span { font-size: 20px; color: rgba(255,255,255,0.4); }

/* ===== CERTIFICATE PAGE ===== */
.cert-view-page { max-width: 800px; margin: 0 auto; padding: 32px 24px 60px; }
.cert-actions { display: flex; gap: 12px; justify-content: center; margin-bottom: 28px; flex-wrap: wrap; }
.certificate {
  background: #fff;
  border: 3px solid var(--navy);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0,0,0,0.1);
}
.cert-body {
  padding: 52px 48px 40px;
  text-align: center;
}
.cert-logo-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.cert-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--blue);
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font-display);
  flex-shrink: 0;
}
.cert-logo-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
}
.cert-icon-big { font-size: 60px; line-height: 1; margin-bottom: 20px; }
.cert-of-completion {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.cert-divider {
  width: 56px;
  height: 3px;
  background: var(--blue);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.cert-title-display {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.25;
  margin-bottom: 28px;
}
.cert-certifies { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.cert-recipient-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 24px;
  word-break: break-all;
}
.cert-date-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
}
.cert-date-item { text-align: center; }
.cert-date-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 4px; }
.cert-date-val { font-size: 14px; font-weight: 600; color: var(--text); }
.cert-id-line { font-size: 10px; color: var(--text-muted); font-family: monospace; margin-top: 20px; }
.cert-footer-bar {
  background: var(--navy);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cert-footer-bar .left { font-size: 12px; color: rgba(255,255,255,0.55); }
.cert-footer-bar .right { font-size: 12px; color: rgba(255,255,255,0.55); }
.cert-not-earned {
  text-align: center;
  padding: 48px 24px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}

/* ===== FOOTER ===== */
.course-footer {
  text-align: center;
  padding: 24px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.6;
}

/* ===== PRINT ===== */
@media print {
  .topbar, .cert-actions, .course-footer { display: none !important; }
  body { background: #fff; }
  .cert-view-page { padding: 0; margin: 0; max-width: 100%; }
  .certificate { box-shadow: none; border: 2px solid #000; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 960px) {
  .cert-layout { grid-template-columns: 1fr; padding: 0; }
  .cert-toc { display: none; }
}
@media (max-width: 640px) {
  .cert-page { padding: 24px 16px 48px; }
  .lesson-title { font-size: 26px; }
  .cert-body { padding: 32px 24px 28px; }
  .cert-title-display { font-size: 20px; }
  .hub-page { padding: 28px 16px 48px; }
  .hub-header h1 { font-size: 26px; }
  .hub-progress { flex-direction: column; text-align: center; }
  .cert-date-row { flex-direction: column; gap: 12px; }
}
