/* === Reset & Variables === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --sidebar-bg: #1a1d23;
  --sidebar-text: #b0b7c3;
  --sidebar-active: #ffffff;
  --sidebar-accent: #4f8cff;
  --primary: #4f8cff;
  --primary-hover: #3a7ae8;
  --success: #34c759;
  --warning: #ff9f0a;
  --danger: #ff3b30;
  --text: #1a1d23;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: 'SF Mono', 'Fira Code', monospace;
  --sidebar-width: 280px;
  --topnav-height: 56px;
  --transition: .2s ease;
}

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

/* ============================================================
   GLOBAL TOP NAV — persistent on every page (Krug rule #1)
   ============================================================ */
.topnav {
  position: sticky;
  top: 0;
  z-index: 500;
  height: var(--topnav-height);
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 4px;
}

.topnav-logo {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  letter-spacing: -.3px;
  margin-right: 32px;
  flex-shrink: 0;
}
.topnav-logo span { color: var(--sidebar-accent); }

.topnav-links {
  display: flex;
  gap: 2px;
  flex: 1;
}

.topnav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.topnav-link:hover {
  color: #fff;
  background: rgba(255,255,255,.08);
}
/* "You are here" — Krug principle */
.topnav-link.active {
  color: #fff;
  background: rgba(79,140,255,.2);
}

.topnav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topnav-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sidebar-text);
}
.topnav-progress-bar {
  width: 80px;
  height: 6px;
  background: rgba(255,255,255,.1);
  border-radius: 3px;
  overflow: hidden;
}
.topnav-progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: 3px;
  transition: width .4s ease;
}

/* Mobile hamburger */
.topnav-burger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-direction: column;
  gap: 4px;
}
.topnav-burger span {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
}

@media (max-width: 768px) {
  .topnav { padding: 0 16px; }
  .topnav-logo { margin-right: 0; }
  .topnav-links {
    display: none;
    position: absolute;
    top: var(--topnav-height);
    left: 0; right: 0;
    background: var(--sidebar-bg);
    flex-direction: column;
    padding: 8px;
    border-top: 1px solid rgba(255,255,255,.08);
    box-shadow: var(--shadow-lg);
  }
  .topnav-links.open { display: flex; }
  .topnav-burger { display: flex; }
  .topnav-link { padding: 12px 16px; border-radius: var(--radius-sm); }
  .topnav-progress-bar { width: 48px; }
}

/* ============================================================
   LANDING PAGE
   ============================================================ */
.landing { padding-top: 0; }
.landing-hero {
  text-align: center;
  padding: 64px 24px 48px;
  max-width: 720px;
  margin: 0 auto;
}
.landing-hero h1 {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: -1.5px;
  line-height: 1.1;
  margin-bottom: 16px;
}
.landing-hero p {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 480px;
  margin: 0 auto;
}

.landing-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.landing-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  border: 2px solid transparent;
}
.landing-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.landing-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 20px;
}
.landing-card-icon.blue { background: rgba(79,140,255,.1); }
.landing-card-icon.green { background: rgba(52,199,89,.1); }
.landing-card-icon.orange { background: rgba(255,159,10,.1); }

.landing-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.landing-card p {
  font-size: 14px;
  color: var(--text-secondary);
  flex: 1;
  margin-bottom: 16px;
}
.landing-card-meta {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
}

@media (max-width: 768px) {
  .landing-hero h1 { font-size: 28px; }
  .landing-hero p { font-size: 15px; }
  .landing-cards { grid-template-columns: 1fr; padding: 0 16px 40px; }
}

/* ============================================================
   COURSE PAGE — sidebar + main
   ============================================================ */
.course-layout {
  display: flex;
  min-height: calc(100vh - var(--topnav-height));
}

/* Sidebar (only on course page) */
.sidebar {
  width: var(--sidebar-width);
  background: #f8f9fb;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--topnav-height);
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 20px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.progress-ring-container {
  position: relative;
  width: 40px;
  height: 40px;
}
.progress-ring { width: 40px; height: 40px; transform: rotate(-90deg); }
.progress-ring__bg { fill: none; stroke: var(--border); stroke-width: 4; }
.progress-ring__fill {
  fill: none;
  stroke: var(--success);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 138.23;
  stroke-dashoffset: 138.23;
  transition: stroke-dashoffset .6s ease;
}
.progress-ring__text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
}

.sidebar-nav { padding: 8px 0; flex: 1; }

.nav-week {
  padding: 12px 20px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 13px;
  border-left: 3px solid transparent;
  text-decoration: none;
  color: var(--text-secondary);
}
.nav-item:hover {
  background: var(--surface);
  color: var(--text);
}
.nav-item.active {
  background: var(--surface);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.nav-item.completed { color: var(--text); }
.nav-item.completed .nav-icon {
  background: var(--success);
  color: #fff;
}

.nav-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-check { font-size: 13px; opacity: 0; transition: opacity var(--transition); }
.nav-item.completed .nav-check { opacity: 1; color: var(--success); }

.sidebar-toggle {
  display: none;
  position: fixed;
  top: calc(var(--topnav-height) + 12px);
  left: 12px;
  z-index: 200;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: var(--shadow);
}
.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

/* Main content area */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: calc(100vh - var(--topnav-height));
}

.page { padding: 32px; max-width: 860px; margin: 0 auto; }
.hidden { display: none !important; }

/* === Lesson === */
.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.lesson-meta { display: flex; gap: 8px; }
.lesson-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -.5px;
  margin-bottom: 16px;
}
.lesson-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}
.lesson-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  transition: width .3s ease;
  width: 0%;
}

/* === Steps === */
.step { display: none; animation: fadeIn .3s ease; }
.step.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Hero (legacy, used in course home) === */
.hero { text-align: center; padding: 60px 20px; }
.hero h1 { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin-bottom: 12px; }
.hero-sub { font-size: 18px; color: var(--text-secondary); margin-bottom: 32px; }
.hero-stats { display: flex; gap: 24px; justify-content: center; margin-bottom: 32px; flex-wrap: wrap; }
.stat-card { background: var(--surface); border-radius: var(--radius); padding: 16px 24px; box-shadow: var(--shadow); }
.stat-value { font-size: 28px; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { padding: 14px 36px; font-size: 16px; border-radius: var(--radius); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { color: var(--text); background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(1.1); }

/* === Badge === */
.badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--primary); color: #fff; }
.badge-outline { background: transparent; border: 1px solid var(--border); color: var(--text-secondary); }

/* === Theory / Quiz / Tips — unchanged === */
.theory-content { background: var(--surface); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); line-height: 1.8; }
.theory-content h2 { font-size: 22px; font-weight: 700; margin: 28px 0 12px; color: var(--text); }
.theory-content h2:first-child { margin-top: 0; }
.theory-content h3 { font-size: 17px; font-weight: 700; margin: 20px 0 8px; color: var(--text); }
.theory-content p { margin-bottom: 12px; }
.theory-content ul, .theory-content ol { margin: 8px 0 16px 20px; }
.theory-content li { margin-bottom: 6px; }
.theory-content strong { color: var(--text); }
.theory-content code { background: #f0f4f8; padding: 2px 6px; border-radius: 4px; font-family: var(--mono); font-size: 13px; }
.theory-content blockquote { border-left: 4px solid var(--primary); padding: 12px 20px; background: rgba(79,140,255,.05); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 16px 0; font-style: italic; }
.theory-content table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.theory-content th, .theory-content td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.theory-content th { background: #f8f9fb; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); }
.theory-content tr:hover td { background: #f8f9fb; }

.tip-box { background: rgba(52,199,89,.08); border: 1px solid rgba(52,199,89,.2); border-radius: var(--radius-sm); padding: 16px 20px; margin: 16px 0; }
.tip-box.warning { background: rgba(255,159,10,.08); border-color: rgba(255,159,10,.2); }
.tip-box.danger { background: rgba(255,59,48,.08); border-color: rgba(255,59,48,.2); }
.tip-box-title { font-weight: 700; margin-bottom: 4px; }

.example-box { background: #f8f9fb; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px 20px; margin: 12px 0; font-size: 14px; }
.example-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--primary); margin-bottom: 6px; }

/* === Quiz === */
.quiz-container { background: var(--surface); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.quiz-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.quiz-header h2 { font-size: 20px; font-weight: 700; }
.quiz-score { font-size: 14px; font-weight: 600; color: var(--text-secondary); }

.question { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.question:last-of-type { border-bottom: none; }
.question-text { font-size: 16px; font-weight: 600; margin-bottom: 14px; line-height: 1.5; }
.question-number { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff; font-size: 13px; font-weight: 700; margin-right: 10px; vertical-align: middle; }

.option { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border: 2px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; cursor: pointer; transition: all var(--transition); font-size: 15px; line-height: 1.5; }
.option:hover { border-color: var(--primary); background: rgba(79,140,255,.03); }
.option.selected { border-color: var(--primary); background: rgba(79,140,255,.08); }
.option.correct { border-color: var(--success) !important; background: rgba(52,199,89,.08) !important; }
.option.wrong { border-color: var(--danger) !important; background: rgba(255,59,48,.06) !important; }
.option.disabled { pointer-events: none; }

.option-marker { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; margin-top: 1px; transition: all var(--transition); }
.option.selected .option-marker { border-color: var(--primary); background: var(--primary); color: #fff; }
.option.correct .option-marker { border-color: var(--success); background: var(--success); color: #fff; }
.option.wrong .option-marker { border-color: var(--danger); background: var(--danger); color: #fff; }

.fill-blank-input { display: inline-block; border: none; border-bottom: 2px solid var(--border); padding: 4px 8px; font-size: 15px; font-family: var(--font); width: 200px; outline: none; transition: border-color var(--transition); background: transparent; }
.fill-blank-input:focus { border-color: var(--primary); }
.fill-blank-input.correct { border-color: var(--success); color: var(--success); }
.fill-blank-input.wrong { border-color: var(--danger); color: var(--danger); }

.explanation { margin-top: 10px; padding: 12px 16px; background: #f8f9fb; border-radius: var(--radius-sm); font-size: 14px; color: var(--text-secondary); display: none; animation: fadeIn .3s ease; }
.explanation.visible { display: block; }

.quiz-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

.quiz-result { text-align: center; padding: 40px 20px; display: none; }
.quiz-result.visible { display: block; }
.quiz-result-score { font-size: 64px; font-weight: 800; margin-bottom: 8px; }
.quiz-result-score.good { color: var(--success); }
.quiz-result-score.ok { color: var(--warning); }
.quiz-result-score.bad { color: var(--danger); }
.quiz-result-text { font-size: 18px; color: var(--text-secondary); margin-bottom: 24px; }

/* === Lesson Nav === */
.lesson-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 32px; padding-top: 24px; border-top: 1px solid var(--border); }
.step-indicator { font-size: 14px; color: var(--text-secondary); font-weight: 600; }

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); background: var(--surface); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .sidebar-toggle { display: flex; }
  .main { margin-left: 0; }
  .page { padding: 20px; padding-top: 24px; }
  .hero h1 { font-size: 24px; }
  .hero-stats { flex-direction: column; gap: 12px; }
  .lesson-title { font-size: 20px; }
  .theory-content { padding: 20px; }
  .quiz-container { padding: 20px; }
  .theory-content table { font-size: 12px; }
  .theory-content th, .theory-content td { padding: 6px 8px; }
}
