/* ============================================================
   Cambridge IGCSE & O Level Computer Science (0478/0984/2210)
   course + lesson styles. Linked by app/igcse-cs/layout.tsx so both the
   syllabus landing and every lesson get it. Mirrors the AQA sibling
   (public/gcse-cs/lesson.css) so the lesson-builder skill produces the same
   chrome — BUT with the IGCSE house rules baked in:
     • pre.pseudocode  — Cambridge pseudocode, one statement per line, white card
     • pre.idle-code   — Python in the IDLE editor palette ON WHITE (rule 2)
     • figure.real-world — researched real photo / rich diagram for theory (rule 3)
   Cambridge pseudocode is plain styled text (no renderer); Python uses
   <IdleCode> (app/_components/IdleCode.tsx) — never the dark <PyCode>.
   ============================================================ */

:root {
  --cs:       #6366F1;   /* indigo — course brand */
  --cs-dark:  #4338CA;
  --cs-soft:  #EEF0FE;
  --cs-ink:   #1E1B4B;
}

.lesson {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: #FBFBFE;
  color: var(--ink, #0F172A);
  margin: 0;
  line-height: 1.55;
}

/* Per-unit accent (Unit N = syllabus Topic N) — IGCSE_Memory.md §3 */
.lesson--unit-1  { --lvl: #0891B2; --lvl-soft: #E2F6FB; }  /* 1 Data representation         */
.lesson--unit-2  { --lvl: #2563EB; --lvl-soft: #E7F0FE; }  /* 2 Data transmission           */
.lesson--unit-3  { --lvl: #0D9488; --lvl-soft: #E2F7F4; }  /* 3 Hardware                    */
.lesson--unit-4  { --lvl: #6366F1; --lvl-soft: #EEF0FE; }  /* 4 Software                    */
.lesson--unit-5  { --lvl: #16A34A; --lvl-soft: #E6F8ED; }  /* 5 The internet & its uses     */
.lesson--unit-6  { --lvl: #D97706; --lvl-soft: #FEF1E0; }  /* 6 Automated & emerging tech   */
.lesson--unit-7  { --lvl: #7C3AED; --lvl-soft: #F1EBFE; }  /* 7 Algorithm design            */
.lesson--unit-8  { --lvl: #1D4ED8; --lvl-soft: #E5EDFE; }  /* 8 Programming                 */
.lesson--unit-9  { --lvl: #EA580C; --lvl-soft: #FEEDE2; }  /* 9 Databases                   */
.lesson--unit-10 { --lvl: #E11D48; --lvl-soft: #FDE7ED; }  /* 10 Boolean logic              */

/* ---------- Header ---------- */
.lesson-header {
  background: linear-gradient(135deg, var(--lvl, var(--cs)) 0%, var(--cs-dark) 100%);
  color: #fff;
  padding: 44px 32px 38px;
  border-bottom: 6px solid rgba(255,255,255,0.25);
}
.lesson-header .lesson-crumbs {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.76rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(255,255,255,0.85); margin: 0 0 14px;
}
.lesson-header .lesson-crumbs a { color: rgba(255,255,255,0.9); text-decoration: none; }
.lesson-header .lesson-crumbs a:hover { color: #fff; text-decoration: underline; }
.lesson-header .lesson-crumbs .sep { opacity: 0.55; }
.lesson-header .lesson-crumbs .here { color: #fff; font-weight: 600; }
.lesson-header .lesson-tag {
  display: inline-block; font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  background: rgba(255,255,255,0.22); padding: 5px 12px; border-radius: 999px;
  margin-bottom: 14px; backdrop-filter: blur(4px);
}
.lesson-header h1 {
  font-size: clamp(1.7rem, 4vw, 2.5rem); font-weight: 800;
  letter-spacing: -0.02em; margin: 0 0 6px; max-width: 900px;
}
.lesson-header .lesson-sub { font-size: 0.95rem; opacity: 0.9; margin: 0; }

/* The Cambridge syllabus reference badge */
.spec-ref {
  display: inline-block;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.78rem; font-weight: 700;
  background: var(--cs-soft); color: var(--cs-dark);
  border: 1px solid #D7DAFB; border-radius: 8px;
  padding: 4px 10px; margin: 0 0 4px;
}

/* ---------- Main column ---------- */
.lesson main { max-width: 880px; margin: 0 auto; padding: 30px 24px 80px; }

/* ---------- Sections ---------- */
.lesson-section {
  background: #fff; border: 1px solid #E6E7FB; border-radius: 16px;
  padding: 26px 28px 22px; margin-bottom: 22px; position: relative; overflow: hidden;
}
.lesson-section::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--lvl, var(--cs));
}
.lesson-section h2 {
  display: flex; align-items: center; gap: 10px;
  font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em;
  margin: 0 0 14px; color: var(--cs-ink);
}
.lesson-section h2 .time {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.7rem; font-weight: 600;
  background: var(--cs-soft); color: var(--cs-dark);
  padding: 3px 10px; border-radius: 999px; margin-left: auto;
}
.lesson-section h3 { font-size: 1.02rem; font-weight: 700; margin: 18px 0 8px; color: var(--cs-ink); }
.lesson-section p, .lesson-section li, .lesson-section dd { font-size: 0.95rem; }
.lesson-section ul, .lesson-section ol { padding-left: 22px; }
.lesson-section li { margin-bottom: 6px; }

/* ---------- Cambridge pseudo-code block (rule 1: one statement per line) ---------- */
.pseudocode-label, .code-block-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: #6B7280; margin: 14px 0 4px;
}
pre.pseudocode {
  font-family: 'JetBrains Mono', 'Courier New', ui-monospace, monospace;
  font-size: 0.88rem; line-height: 1.7;
  background: #FCFCFF; color: #1E1B4B;
  border: 1px solid #D7DAFB; border-left: 4px solid var(--cs);
  border-radius: 10px; padding: 14px 18px; overflow-x: auto;
  margin: 4px 0 12px; white-space: pre; tab-size: 2;
}

/* ---------- Python code blocks: IDLE palette on WHITE (rule 2) ---------- */
pre.idle-code {
  font-family: 'Consolas', 'Courier New', ui-monospace, monospace;
  font-size: 0.9rem; line-height: 1.6;
  background: #FFFFFF; color: #000000;
  border: 1px solid #CBD2E0; border-left: 4px solid var(--lvl, var(--cs));
  border-radius: 10px; padding: 14px 18px; overflow-x: auto;
  margin: 4px 0 12px; white-space: pre; tab-size: 4;
}
pre.idle-code .idle-kw      { color: #FF7700; }                 /* keywords  — orange */
pre.idle-code .idle-builtin { color: #900090; }                /* built-ins — purple */
pre.idle-code .idle-def     { color: #0000FF; }                /* def/class names — blue */
pre.idle-code .idle-string  { color: #00AA00; }                /* strings   — green  */
pre.idle-code .idle-comment { color: #DD0000; }                /* comments  — red    */
pre.idle-code .idle-name,
pre.idle-code .idle-op      { color: #000000; }                /* everything else — black */

/* IDLE-style shell / program output (white card, blue stdout) */
pre.idle-output {
  font-family: 'Consolas', 'Courier New', ui-monospace, monospace;
  font-size: 0.9rem; line-height: 1.6;
  background: #FFFFFF; color: #0000FF;
  border: 1px dashed #CBD2E0; border-radius: 10px;
  padding: 12px 18px; overflow-x: auto; margin: 4px 0 12px; white-space: pre-wrap;
}

/* ---------- Inline code ---------- */
.lesson code:not(pre code) {
  background: var(--cs-soft); padding: 2px 6px; border-radius: 4px;
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.85em; color: var(--cs-ink);
}

/* ---------- Callouts (mirror the textbook learning features) ---------- */
.keyterm, .techterm, .keypoint, .beyond-spec, .exam-tip, .callout {
  border-radius: 10px; padding: 12px 16px; margin: 14px 0; font-size: 0.92rem;
}
.keyterm   { background: #ECFDF3; border-left: 4px solid #16A34A; }      /* Key terms (green) */
.keyterm strong   { color: #166534; }
.techterm  { background: #EFF6FF; border-left: 4px solid #2563EB; }      /* Tech terms (blue) */
.techterm strong  { color: #1E40AF; }
.keypoint  { background: var(--cs-soft); border-left: 4px solid var(--cs); }
.keypoint strong  { color: var(--cs-dark); }
.beyond-spec { background: #F8FAFC; border-left: 4px solid #94A3B8; color: #475569; }
.beyond-spec strong { color: #334155; }
.exam-tip  { background: #FEF3C7; border-left: 4px solid #F59E0B; }
.exam-tip strong  { color: #92400E; }
.callout   { background: #FEF3C7; border-left: 4px solid #F59E0B; }
.callout strong { color: #92400E; }
.callout ul, .keyterm ul, .keypoint ul { margin: 6px 0 0; }

/* ---------- Exam Practice questions ---------- */
.exam-q {
  border: 1px solid #E6E7FB; border-radius: 12px;
  padding: 14px 16px 12px; margin: 14px 0; background: #FCFCFF;
}
.exam-q .exam-q-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.exam-q .cmd {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--cs); color: #fff; padding: 3px 9px; border-radius: 6px;
}
.exam-q .marks {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.78rem; font-weight: 700;
  color: var(--cs-dark); margin-left: auto;
}
.exam-q p { margin: 0 0 6px; }
details.markscheme {
  background: #ECFDF3; border: 1px solid #BBF7D0; border-radius: 8px;
  padding: 8px 14px; margin-top: 8px;
}
details.markscheme summary { cursor: pointer; font-weight: 700; color: #166534; font-size: 0.9rem; }
details.markscheme[open] summary { margin-bottom: 6px; }
details.markscheme ul { margin: 4px 0 0; padding-left: 20px; }
details.markscheme li { font-size: 0.9rem; }

/* ---------- Tables: reference / trace / truth ---------- */
table.ref, table.trace-table, table.truth-table {
  width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.9rem;
}
table.ref th, table.ref td,
table.trace-table th, table.trace-table td,
table.truth-table th, table.truth-table td {
  text-align: left; padding: 8px 12px; border: 1px solid #E2E4FA; vertical-align: top;
}
table.ref thead th, table.trace-table thead th, table.truth-table thead th {
  background: var(--cs-soft); color: var(--cs-dark); font-weight: 700; letter-spacing: 0.02em;
}
table.trace-table td, table.truth-table td {
  font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 0.85rem; text-align: center;
}
table.trace-table th:last-child, table.trace-table td:last-child { text-align: left; }

/* Place-value table (binary/hex) — monospace, centred */
table.placevalue td, table.placevalue th {
  font-family: 'JetBrains Mono', ui-monospace, monospace; text-align: center;
}

/* ---------- Diagrams (flowcharts, gates, architecture) ---------- */
figure.cs-diagram {
  background: #fff; border: 1px solid #E6E7FB; border-radius: 14px;
  padding: 16px; margin: 14px 0; text-align: center;
}
figure.cs-diagram svg { max-width: 100%; height: auto; }
figure.cs-diagram figcaption { margin-top: 10px; font-size: 0.9rem; color: #64748B; text-align: left; }

/* ---------- Real-world figure (rule 3: researched photos / rich visuals for theory) ---------- */
figure.real-world {
  background: #fff; border: 1px solid #E6E7FB; border-radius: 14px;
  padding: 14px; margin: 16px 0; text-align: center;
}
figure.real-world img,
figure.real-world svg { max-width: 100%; height: auto; border-radius: 10px; }
figure.real-world figcaption {
  margin-top: 10px; font-size: 0.9rem; color: #475569; text-align: left; line-height: 1.5;
}
figure.real-world .credit {
  display: block; margin-top: 4px; font-size: 0.74rem; color: #94A3B8;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ---------- Try-It tasks ---------- */
.task { border: 1px solid #E6E7FB; border-radius: 12px; padding: 14px 18px; margin: 12px 0; background: #FCFCFF; }
.task-tag {
  display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; padding: 3px 10px; border-radius: 999px; margin-bottom: 8px;
}
.task--easy    .task-tag { background: #DCFCE7; color: #166534; }
.task--medium  .task-tag { background: #FEF3C7; color: #92400E; }
.task--stretch .task-tag { background: #FEE2E2; color: #991B1B; }

/* ---------- Key-terms glossary card ---------- */
dl.key-terms { background: var(--cs-soft); border-radius: 12px; padding: 16px 20px; margin: 14px 0 0; }
dl.key-terms dt { font-weight: 700; color: var(--cs-dark); margin-top: 8px; }
dl.key-terms dt:first-child { margin-top: 0; }
dl.key-terms dd { margin: 2px 0 0 0; color: var(--ink, #0F172A); }

/* ---------- Reveal blocks ---------- */
.lesson details:not(.markscheme) {
  background: var(--cs-soft); border-radius: 10px; padding: 10px 16px; margin: 12px 0;
}
.lesson details:not(.markscheme) summary { cursor: pointer; font-weight: 700; color: var(--cs-dark); }
.lesson details:not(.markscheme)[open] summary { margin-bottom: 8px; }

/* ---------- Footer + prev/next nav ---------- */
.lesson .site-footer { text-align: center; padding: 24px; border-top: 1px solid #E6E7FB; background: #fff; }
.lesson .site-footer .muted { color: #94A3B8; font-size: 0.88rem; }
.lesson-foot { display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin: 36px 0 8px; }
.lesson-foot__btn {
  flex: 1; min-width: 220px; padding: 16px 18px; border: 1px solid #E2E8F0; background: #fff;
  border-radius: 14px; text-decoration: none; color: var(--ink, #0F172A); display: block;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.lesson-foot__btn:hover {
  transform: translateY(-2px); border-color: var(--cs);
  box-shadow: 0 10px 24px -16px rgba(99,102,241,0.5); text-decoration: none;
}
.lesson-foot__btn[aria-disabled="true"] { opacity: 0.55; pointer-events: none; }
.lesson-foot__dir {
  display: block; font-family: 'JetBrains Mono', monospace; font-size: 0.72rem;
  letter-spacing: 0.1em; text-transform: uppercase; color: #64748B; margin-bottom: 4px;
}
.lesson-foot__title { display: block; font-weight: 700; font-size: 1rem; color: var(--ink, #0F172A); }
.lesson-foot__btn--next { text-align: right; }
@media (max-width: 720px) { .lesson-foot { flex-direction: column; } .lesson-foot__btn--next { text-align: left; } }

/* The syllabus landing (app/igcse-cs/page.tsx) uses the Hub's shared course-page
   styles (.course-page, .hero, .level, .lesson-card) from public/styles.css —
   the same pattern as the AQA, Scratch and EV3 landings. */
