/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
   Shared stylesheet for all Konigi course pages.
   Edit this file — changes apply to every course.
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --paper:      #fafaf9;
  --ink:        #222222;
  --rule:       #d6d4d1;
  --surface:    #e7e5e4;
  --tint:       #f5f5f4;
  --muted:      #78716c;
  --accent:     #C4633F;
  --accent-dk:  #9c4a2e;
  --accent-bg:  rgba(196,99,63,0.07);
  --accent-bg2: rgba(196,99,63,0.13);
  --sidebar-w:  268px;
  --header-h:   0px;
}

html { scroll-behavior: smooth; overscroll-behavior: none; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Source Sans 3', sans-serif;
  font-size: 16px;
  line-height: 1.65;
  display: flex;
  min-height: 100vh;
  overscroll-behavior: none;
  overflow-x: hidden;
}

p { text-wrap: pretty; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent-dk); }

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  background: var(--paper);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.sidebar-logo svg { width: 33px; height: 36px; flex-shrink: 0; }

.sidebar-logo-text {
  font-family: 'Figtree', sans-serif;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1;
}

.sidebar-logo-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1px;
}

.sidebar-course {
  padding: 16px 24px 14px;
  border-bottom: 1px solid var(--rule);
}

.sidebar-section-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}

.sidebar-course-title {
  font-family: 'Figtree', serif;
  font-size: 20px;
  color: var(--ink);
  line-height: 1.3;
  margin-bottom: 12px;
}

.progress-bar-wrap {
  height: 1px;
  background: var(--rule);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--rule) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 3px; }

.sidebar-back {
  flex-shrink: 0;
  display: block;
  padding: 14px 24px;
  border-top: 1px solid var(--rule);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  transition: color 0.12s;
}
.sidebar-back:hover { color: var(--accent); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 20px 7px 24px;
  cursor: pointer;
  text-decoration: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 400;
  transition: all 0.12s ease;
  position: relative;
  line-height: 1.35;
  text-wrap: pretty;
}

.nav-item:hover { color: var(--ink); background: var(--tint); }

.nav-item.active {
  color: var(--accent);
  background: var(--accent-bg);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 5px; bottom: 5px;
  width: 2px;
  background: var(--accent);
}

.nav-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--rule);
  min-width: 36px;
  transition: color 0.12s;
  flex-shrink: 0;
}

.nav-item.active .nav-num { color: var(--accent); }
.nav-item.completed .nav-num { color: var(--accent); }
.nav-item.completed { color: var(--muted); }

.nav-check {
  width: 15px; height: 15px;
  border: 1.5px solid var(--rule);
  border-radius: 50%;
  margin-left: auto;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
  color: transparent;
}

.nav-item.completed .nav-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ─── MAIN ─── */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

/* ─── HERO ─── */
.hero {
  padding: 64px 72px 52px;
  max-width: 1440px;
}

.hero-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-label::after {
  content: '';
  flex: 1;
  max-width: 48px;
  height: 1px;
  background: var(--accent);
  opacity: 0.4;
}

.hero h1 {
  font-family: 'Figtree', serif;
  font-size: clamp(3rem, 5.5vw, 4.8rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--ink);
  margin-bottom: 20px;
  text-wrap: balance;
}

.hero-intro {
  font-size: 24px;
  color: var(--muted);
  line-height: 1.7;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 20px 0;
  margin-bottom: 28px;
}

.hero-meta {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 28px;
  margin-right: 28px;
  border-right: 1px solid var(--rule);
}

.hero-stat:last-child { border-right: none; }

.hero-stat-num {
  font-family: 'Figtree', serif;
  font-size: 2rem;
  color: var(--ink);
  line-height: 1;
}

.hero-stat-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ─── INTRO CALLOUT ─── */
.intro-callout {
  background: var(--tint);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding-block: 36px;
}

.intro-callout__inner {
  max-width: 1440px;
  padding-inline: 72px;
  column-count: 2;
  column-gap: 3rem;
}

.intro-callout p {
  font-size: 24px;
  color: var(--muted);
  line-height: 1.75;
}

.intro-callout p + p { margin-top: 12px; }

.hl {
  color: var(--ink);
  font-weight: 500;
}

/* ─── MODULE WRAP ─── */
.modules-wrap { padding: 0 72px 80px; max-width: 1440px; }

.module {
  padding: 56px 0;
  border-bottom: 1px solid var(--rule);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.module.visible { opacity: 1; transform: translateY(0); }

.module-header {
  display: grid;
  grid-template-columns: 1fr;
  row-gap: 1rem;
  margin-bottom: 36px;
}
.module-num { grid-column: 1 / -1; justify-self: start; }
.module-title-wrap { grid-column: 1; }

.module-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid var(--accent-bg2);
  padding: 4px 9px;
  border-radius: 3px;
  white-space: nowrap;
}

.module-title-wrap {}

.module h2 {
  font-family: 'Figtree', serif;
  font-size: clamp(1.5rem, 2.5vw, 2rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  margin-bottom: 4px;
  text-wrap: pretty;
}

.module-tagline {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 18px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.complete-btn {
  display: block;
  margin-top: 28px;
  margin-left: auto;
  padding: 6px 16px;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: var(--paper);
  font-size: 16px;
  font-family: 'Source Sans 3', sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.complete-btn::before { content: '✓'; margin-right: 8px; }
.complete-btn:hover { background: var(--accent); border-color: var(--accent); }
.complete-btn.done { background: var(--accent); border-color: var(--accent); }
.complete-btn.done:hover { background: var(--accent-dk); border-color: var(--accent-dk); }

/* ─── HEADING RULES ─── */
.modules-wrap h3::before,
.modules-wrap h4::before,
.modules-wrap h5::before {
  content: '';
  display: block;
  width: 66px;
  height: 1px;
  background: var(--rule);
  margin-bottom: 1rem;
}
.section-block.checkpoint h3::before { display: none; }

/* ─── SECTION BLOCKS ─── */
.section-block {
  padding: 24px 0;
  margin-bottom: 8px;
}
.section-block.checkpoint {
  border-left: 3px solid var(--accent);
  background: var(--accent-bg);
  padding: 20px 24px;
}

.section-type {
  font-family: 'Figtree', serif;
  font-size: clamp(1.5rem, 2vw, 1.75rem);
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
}

.section-block p {
  font-size: 21px;
  color: var(--muted);
  line-height: 1.75;
}

.section-block p + p { margin-top: 10px; }

.emp { color: var(--ink); font-weight: 500; }
/* lead-in labels at the start of a paragraph get their own line;
   plain .emp stays inline for mid-sentence emphasis */
.emp.emp-lead { display: block; }
.mono { font-family: 'IBM Plex Mono', monospace; font-size: 0.85em; color: var(--accent-dk); background: var(--surface); padding: 1px 5px; border-radius: 3px; }

/* ─── CODE BLOCKS ─── */
.code-wrap {
  margin: 2rem 0;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--rule);
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  padding: 7px 14px;
  border-bottom: 1px solid var(--rule);
}

.code-lang {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
}

.code-dots { display: flex; gap: 4px; }
.code-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--rule); }

pre {
  background: var(--ink);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0;
}

pre code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  line-height: 1.8;
  color: #d4d0c8;
  tab-size: 2;
}

.kw  { color: #d19a66; }
.str { color: #98c379; }
.num { color: #e5c07b; }
.fn  { color: #61afef; }
.type{ color: #e06c75; }
.cm  { color: #8899aa; font-style: italic; }
.tag { color: #56b6c2; }
.attr{ color: #e5c07b; }

/* ─── EXERCISES ─── */
.exercise-list {
  list-style: none;
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.exercise-list li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--muted);
  font-size: 21px;
  line-height: 1.65;
  cursor: pointer;
}

.ex-check {
  width: 17px; height: 17px;
  min-width: 17px;
  border: 1.5px solid var(--rule);
  border-radius: 3px;
  margin-top: 9px; /* centers the 17px box on the first text line (21px x 1.65) */
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s ease;
  font-size: 14px;
  color: transparent;
}

.exercise-list li.done .ex-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.exercise-list li.done .ex-check::after { content: '✓'; }

/* ─── CONCEPT GRID (legacy — prefer .concept-list) ─── */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.concept-card {
  background: var(--tint);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 14px 16px;
}

.concept-card h4 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 5px;
}

.concept-card p {
  font-size: 21px;
  color: var(--muted);
  line-height: 1.55;
}

/* ─── CONCEPT LIST ─── */
.concept-list { margin-top: 2rem; margin-bottom: 2rem; border-top: 1px solid var(--rule); }
.concept-item { display: grid; grid-template-columns: 220px 1fr; column-gap: 2rem; padding: 14px 0; border-bottom: 1px solid var(--rule); align-items: baseline; }
.concept-label { font-family: 'IBM Plex Mono', monospace; font-size: 15px; font-weight: 500; color: var(--ink); letter-spacing: 0.05em; line-height: 1.5; }
.concept-item p { font-size: 21px; color: var(--muted); line-height: 1.6; margin: 0; }

/* ─── CALLOUT ─── */
.callout {
  display: flex;
  gap: 12px;
  background: var(--tint);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 14px 16px;
  margin-top: 14px;
}

.callout p { font-size: 21px; color: var(--muted); line-height: 1.65; margin: 0 !important; }
.callout strong { color: var(--ink); font-weight: 500; }

/* ─── TABLE ─── */
.ref-table { width: 100%; border-collapse: collapse; font-size: 21px; margin-top: 2rem; margin-bottom: 2rem; }
.ref-table th { text-align: left; padding: 9px 14px; background: var(--tint); color: var(--muted); font-family: 'IBM Plex Mono', monospace; font-size: 14px; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; border-bottom: 1px solid var(--rule); }
.ref-table td { padding: 9px 14px; border-bottom: 1px solid var(--rule); color: var(--muted); font-size: 21px; line-height: 1.6; vertical-align: top; }
.ref-table td:first-child { font-family: 'IBM Plex Mono', monospace; font-size: 18px; color: var(--ink); white-space: nowrap; width: 1%; }
.ref-table tr:last-child td { border-bottom: none; }
.ref-table tr:hover td { background: var(--tint); }

/* ─── STEP LIST ─── */
.step-list { list-style: none; margin-top: 16px; display: flex; flex-direction: column; gap: 10px; counter-reset: steps; }
.step-list li { display: flex; align-items: flex-start; gap: 12px; color: var(--muted); font-size: 21px; line-height: 1.65; counter-increment: steps; }
.step-list li::before { content: counter(steps); width: 22px; height: 22px; min-width: 22px; background: var(--accent-bg); border: 1px solid var(--accent-bg2); border-radius: 4px; font-family: 'IBM Plex Mono', monospace; font-size: 14px; color: var(--accent); display: flex; align-items: center; justify-content: center; margin-top: 1px; }

/* ─── CAPSTONE ─── */
.capstone-inner { padding: 28px 0; margin-top: 14px; }
.capstone-inner h3 { font-family: 'Figtree', serif; font-size: clamp(1.3125rem, 1.8vw, 1.5rem); font-weight: 700; color: var(--ink); margin-bottom: 10px; }
.capstone-inner p { color: var(--muted); font-size: 21px; line-height: 1.75; }

/* ─── FOOTER ─── */
.course-footer {
  padding: 32px 72px;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--tint);
  max-width: none;
}

.course-footer p {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── MOBILE HEADER (visible below 900px, where the sidebar is hidden) ─── */
.mobile-header {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}

.mobile-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.mobile-header-logo svg { width: 22px; height: 24px; flex-shrink: 0; }

.mobile-header-text {
  font-family: 'Figtree', sans-serif;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--ink);
  line-height: 1;
}

.mobile-header-back {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 14px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.mobile-header-back:hover { color: var(--accent); }

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--rule); border-radius: 5px; }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; }
  body { display: block; } /* body is a flex row for sidebar + main; stacks header above main */
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .main { margin-left: 0; }
  .hero, .intro-callout__inner, .modules-wrap { padding-left: 24px; padding-right: 24px; }
  .course-footer { padding: 24px; flex-direction: column; gap: 10px; align-items: flex-start; }
  .intro-callout__inner { column-count: 1; }
}

@media (max-width: 600px) {
  .hero-intro { font-size: 18px; }
  .intro-callout p, .section-block p, .capstone-inner p, .callout p, .concept-card p, .concept-item p, .exercise-list li, .step-list li, .ref-table td { font-size: 18px; }
  .concept-item { grid-template-columns: 1fr; gap: 4px; }
  /* keep wide tables from forcing the page wider: let the first column
     wrap, and scroll the table itself if it still can't fit */
  .ref-table { display: block; overflow-x: auto; }
  .ref-table td:first-child { white-space: normal; width: auto; }
  /* re-center the exercise checkbox on the smaller 18px first text line */
  .ex-check { margin-top: 6px; }
  /* step-list li is a flex row, which squeezes the label and description
     into narrow columns on phones; flow as prose with the number inline */
  .step-list li { display: block; }
  .step-list li::before { display: inline-flex; margin-right: 10px; vertical-align: -3px; }
  /* hero stats: one stat per row as two aligned columns — subgrid sizes the
     number column to the widest value, labels take the remaining space */
  .hero-meta { display: grid; grid-template-columns: auto 1fr; column-gap: 24px; }
  .hero-stat {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    column-gap: 24px; /* base .hero-stat gap:3px would override the inherited subgrid gap */
    align-items: baseline;
    padding: 8px 0;
    margin-right: 0;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }
  .hero-stat:last-child { border-bottom: none; }
  .hero-stat-num { font-size: 1.25rem; }
}
