/* ================================================================
   System Design Learning Workspace — Shared Stylesheet
   All lessons link this file. Edit here to restyle the whole course.
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg:         #0b0f19;
  --surface:    #131a2b;
  --surface2:   #1b2540;
  --border:     #243052;
  --accent:     #6c9bff;
  --accent2:    #5ef5c5;
  --gold:       #f7c948;
  --text:       #e2e8f4;
  --text-muted: #7a8bb5;
  --green:      #56d364;
  --red:        #f85149;
  --orange:     #f0883e;

  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --radius:     10px;
  --radius-lg: 18px;
  --shadow:  0 4px 24px rgba(0,0,0,0.5);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  margin-bottom: 1.5rem;
  transition: color 0.15s;
}

.back-link:hover {
  color: var(--accent2);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.7;
  padding: 0 1rem 4rem;
}

/* ── Layout ───────────────────────────────────────────────────── */
.lesson-wrapper {
  max-width: 780px;
  margin: 0 auto;
  padding-top: 2.5rem;
}

/* ── Header ───────────────────────────────────────────────────── */
.lesson-header {
  margin-bottom: 2.5rem;
}
.lesson-header .breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lesson-header .breadcrumb a { color: var(--accent); text-decoration: none; }
.lesson-header h1 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.25;
  background: linear-gradient(135deg, #fff 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lesson-header .meta {
  margin-top: 0.6rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Sections ─────────────────────────────────────────────────── */
section { margin-bottom: 2.5rem; }
h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}
h3 { font-size: 1rem; font-weight: 600; color: var(--text); margin: 1rem 0 0.5rem; }
p  { color: var(--text); margin-bottom: 0.8rem; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Code ─────────────────────────────────────────────────────── */
code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: var(--accent2);
}

pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  margin-bottom: 1rem;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}

/* ── Architecture diagram container ──────────────────────────── */
.arch-diagram {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 1.5rem 0;
  text-align: center;
  overflow-x: auto;
}
.arch-diagram svg {
  max-width: 100%;
  height: auto;
}
.arch-diagram .caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1rem;
  font-style: italic;
}

/* ── Comparison cards (e.g., SQL vs NoSQL) ───────────────────── */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
@media (max-width: 580px) { .compare { grid-template-columns: 1fr; } }

.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.compare-card .lang-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 1rem;
}
.compare-card.option-a .lang-label { background: rgba(108,155,255,0.15);  color: var(--accent); }
.compare-card.option-b .lang-label { background: rgba(94,245,197,0.15);  color: var(--accent2); }
.compare-card pre { border: none; border-radius: 0; margin: 0; }

/* ── Trade-off table ─────────────────────────────────────────── */
.tradeoff-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}
.tradeoff-table th {
  text-align: left;
  background: var(--surface);
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tradeoff-table td {
  padding: 0.6rem 1rem;
  border: 1px solid var(--border);
  color: var(--text);
}
.tradeoff-table tr:nth-child(even) td { background: var(--surface); }
.tradeoff-table .pro { color: var(--green); }
.tradeoff-table .con { color: var(--red); }

/* ── Callout boxes ────────────────────────────────────────────── */
.callout {
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
}
.callout.tip       { border-color: var(--accent2); }
.callout.warn      { border-color: var(--gold); }
.callout.danger    { border-color: var(--red); }
.callout.interview { border-color: var(--orange); }
.callout .label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.4rem;
}
.callout           .label { color: var(--accent); }
.callout.tip       .label { color: var(--accent2); }
.callout.warn      .label { color: var(--gold); }
.callout.danger    .label { color: var(--red); }
.callout.interview .label { color: var(--orange); }

/* ── Quiz ─────────────────────────────────────────────────────── */
.quiz-section { margin-top: 2.5rem; }
.quiz-q {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
}
.quiz-q .question {
  font-weight: 600;
  margin-bottom: 1rem;
  font-size: 0.98rem;
}
.options { list-style: none; display: flex; flex-direction: column; gap: 0.5rem; }
.options li button {
  width: 100%;
  text-align: left;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 1rem;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 0.88rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.options li button:hover { border-color: var(--accent); background: rgba(108,155,255,0.08); }
.options li button.correct  { border-color: var(--green) !important; background: rgba(86,211,100,0.1) !important; color: var(--green); }
.options li button.wrong    { border-color: var(--red)   !important; background: rgba(248,81,73,0.1)  !important; color: var(--red); }
.feedback {
  margin-top: 0.7rem;
  font-size: 0.88rem;
  min-height: 1.2em;
  color: var(--text-muted);
}
.feedback.show { color: var(--text); }

/* ── Score bar ────────────────────────────────────────────────── */
#score-bar {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.4rem;
  margin-top: 1.5rem;
  text-align: center;
}
#score-bar.visible { display: block; }
#score-bar .score-num { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
#score-bar p { color: var(--text-muted); font-size: 0.88rem; margin: 0; }

/* ── Primary source card ──────────────────────────────────────── */
.primary-source {
  background: linear-gradient(135deg, var(--surface) 0%, rgba(108,155,255,0.08) 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}
.primary-source .icon { font-size: 1.8rem; flex-shrink: 0; margin-top: 0.1rem; }
.primary-source .label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin-bottom: 0.3rem; }
.primary-source strong { display: block; margin-bottom: 0.2rem; }
.primary-source p { font-size: 0.88rem; color: var(--text-muted); margin: 0; }

/* ── Nav footer ───────────────────────────────────────────────── */
.lesson-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.lesson-footer a { color: var(--accent); }

/* ── Ask the teacher nudge ────────────────────────────────────── */
.ask-teacher {
  background: rgba(94,245,197,0.07);
  border: 1px solid var(--accent2);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-top: 2rem;
  font-size: 0.9rem;
}
.ask-teacher strong { color: var(--accent2); }

/* ── Progress badge ───────────────────────────────────────────── */
.progress-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  background: rgba(108,155,255,0.12);
  border: 1px solid rgba(108,155,255,0.3);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  color: var(--accent);
  font-weight: 600;
}

/* ── Estimation block ─────────────────────────────────────────── */
.estimation {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.4rem;
  margin-bottom: 1.2rem;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.8;
}
.estimation .est-label {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 0.6rem;
}
.estimation .est-result {
  color: var(--accent2);
  font-weight: 500;
}

/* ── Lists ─────────────────────────────────────────────────────── */
ul, ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}
li {
  margin-bottom: 0.3rem;
}
