/* ---------- Python Basics — modern & friendly theme ---------- */

:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-2: #f3efe7;
  --text: #1f2330;
  --text-muted: #5a6273;
  --border: #e6e1d6;
  --accent: #2563eb;          /* friendly blue */
  --accent-soft: #dbe7ff;
  --accent-strong: #1d4ed8;
  --python-yellow: #ffd43b;   /* official-ish accent */
  --python-blue: #4584b6;
  --code-bg: #1e2230;
  --code-text: #f4f4f5;
  --code-comment: #8b94a7;
  --code-string: #a3e0a3;
  --code-keyword: #ff8db4;
  --code-number: #ffd28a;
  --code-builtin: #8fd3ff;
  --shadow: 0 6px 24px rgba(20, 25, 40, 0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; }

/* ---------- Layout ---------- */

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 4px;
  color: var(--text);
}

.sidebar .brand .logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--python-blue), var(--python-yellow));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 800;
  font-size: 0.95rem;
}

.sidebar .tagline {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 22px;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav .nav-section {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 16px 0 6px;
}

.sidebar nav a {
  display: block;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar nav a:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.sidebar nav a.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.sidebar nav a .step {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-right: 8px;
  font-weight: 600;
}
.sidebar nav a.active .step {
  background: var(--accent);
  color: white;
}

/* ---------- Main content ---------- */

.content {
  padding: 56px clamp(20px, 5vw, 64px);
  max-width: 880px;
}

.eyebrow {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 14px;
}

h1 {
  font-size: 2.25rem;
  line-height: 1.2;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.5rem;
  margin: 40px 0 12px;
  letter-spacing: -0.005em;
}

h3 {
  font-size: 1.15rem;
  margin: 28px 0 8px;
}

p { margin: 0 0 14px; }

ul, ol { padding-left: 22px; }
li { margin: 4px 0; }

.lead {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ---------- Callouts ---------- */

.callout {
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  padding: 14px 16px;
  border-radius: 8px;
  margin: 20px 0;
  color: #1e3a8a;
}
.callout.tip { border-left-color: #16a34a; background: #dcfce7; color: #14532d; }
.callout.warn { border-left-color: #d97706; background: #fef3c7; color: #78350f; }
.callout strong { display: block; margin-bottom: 4px; }

/* ---------- Code blocks ---------- */

code {
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 5px;
  color: #2a2f3d;
}

pre {
  position: relative;
  background: var(--code-bg);
  color: var(--code-text);
  padding: 18px 18px 18px 18px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 14px 0 18px;
  box-shadow: var(--shadow);
  font-size: 0.93rem;
  line-height: 1.55;
}

pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  font-size: inherit;
  display: block;
}

/* lightweight Python syntax classes (used inline in <pre>) */
.tok-c { color: var(--code-comment); font-style: italic; }
.tok-s { color: var(--code-string); }
.tok-k { color: var(--code-keyword); }
.tok-n { color: var(--code-number); }
.tok-b { color: var(--code-builtin); }

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--code-text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}
pre:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255, 255, 255, 0.18); }
.copy-btn.copied { background: #16a34a; border-color: #16a34a; }

/* ---------- Output blocks ---------- */

.output {
  background: #f6f4ee;
  border: 1px dashed var(--border);
  color: #2a2f3d;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  margin: -8px 0 18px;
}
.output::before {
  content: "▶ Output";
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
  font-family: inherit;
}

/* ---------- Cards (TOC on home page) ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.card {
  display: block;
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--accent);
  text-decoration: none;
}
.card .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.card h3 { margin: 0 0 4px; font-size: 1.05rem; }
.card p { margin: 0; color: var(--text-muted); font-size: 0.92rem; }

/* ---------- Footer / pager ---------- */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.pager a {
  flex: 1;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.pager a:hover {
  border-color: var(--accent);
  text-decoration: none;
  background: var(--accent-soft);
}
.pager a.next { text-align: right; align-items: flex-end; }
.pager a .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }
.pager a .title { font-weight: 600; }
.pager a.disabled { visibility: hidden; }

footer.site-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ---------- Mobile ---------- */

.menu-toggle {
  display: none;
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 20;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-block; }
  .content { padding: 64px 20px 40px; }
}
