/* ============================================================
   LearnPythonForExcel.com — Global Stylesheet
   ============================================================ */

:root {
  --color-bg: #ffffff;
  --color-bg-alt: #f7f9fc;
  --color-bg-dark: #0f172a;
  --color-text: #1f2937;
  --color-text-muted: #64748b;
  --color-text-inverse: #f1f5f9;
  --color-border: #e2e8f0;
  --color-primary: #2b6cb0;        /* Python blue */
  --color-primary-dark: #1e4e8c;
  --color-secondary: #f6c343;      /* Python yellow */
  --color-accent: #217346;         /* Excel green */
  --color-accent-light: #d4edda;
  --color-code-bg: #1e293b;
  --color-code-text: #e2e8f0;
  --color-success: #16a34a;
  --color-warning: #f59e0b;
  --color-danger: #dc2626;
  --color-info: #0284c7;

  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif;
  --font-mono: 'SF Mono', Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  --font-display: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.10), 0 4px 6px rgba(0,0,0,0.05);

  --max-width: 1200px;
  --content-width: 760px;
}

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); line-height: 1.25; margin: 1.8em 0 0.6em; color: var(--color-text); }
h1 { font-size: 2.25rem; margin-top: 0; }
h2 { font-size: 1.65rem; border-bottom: 2px solid var(--color-border); padding-bottom: 0.3em; }
h3 { font-size: 1.3rem; }
h4 { font-size: 1.1rem; }
p { margin: 0 0 1.1em; }
ul, ol { padding-left: 1.4em; margin: 0 0 1.1em; }
li { margin-bottom: 0.4em; }
hr { border: none; border-top: 1px solid var(--color-border); margin: 2.5em 0; }
blockquote {
  border-left: 4px solid var(--color-primary);
  background: var(--color-bg-alt);
  padding: 0.8em 1.1em;
  margin: 1.2em 0;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
}
small, .small { font-size: 0.875rem; color: var(--color-text-muted); }

/* ---------- Header & navigation ---------- */
.site-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.nav-wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85em 1.2em;
  gap: 1em;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #fff;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text small { font-size: 0.72rem; color: var(--color-text-muted); font-weight: 500; }

.main-nav { display: flex; align-items: center; gap: 0.4em; }
.main-nav a {
  color: var(--color-text);
  padding: 0.45em 0.8em;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.95rem;
}
.main-nav a:hover { background: var(--color-bg-alt); text-decoration: none; }
.main-nav a.active { color: var(--color-primary); background: var(--color-bg-alt); }
.main-nav .cta {
  background: var(--color-primary);
  color: #fff !important;
  padding: 0.5em 1.1em;
  margin-left: 0.4em;
}
.main-nav .cta:hover { background: var(--color-primary-dark); }

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4em 0.6em;
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
}

@media (max-width: 880px) {
  .menu-toggle { display: inline-block; }
  .main-nav {
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--color-bg);
    flex-direction: column;
    align-items: stretch;
    padding: 0.5em 1em 1em;
    gap: 0.1em;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    display: none;
  }
  .main-nav.open { display: flex; }
  .main-nav a { padding: 0.8em 0.6em; border-radius: 0; }
  .main-nav .cta { margin: 0.4em 0 0; text-align: center; }
}

/* ---------- Layout ---------- */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.2em; }
.page { padding: 2.5em 1.2em 3em; max-width: var(--max-width); margin: 0 auto; }

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2.5em;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2em 1.2em 3em;
}
.layout-content { min-width: 0; max-width: var(--content-width); }
.sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  font-size: 0.93rem;
}
.sidebar h3 {
  margin-top: 0;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  border: none;
  padding: 0;
}
.sidebar ol, .sidebar ul { list-style: none; padding-left: 0; margin: 0 0 1.3em; }
.sidebar li { margin-bottom: 0.15em; }
.sidebar a {
  display: block;
  padding: 0.35em 0.7em;
  color: var(--color-text);
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.sidebar a:hover { background: var(--color-bg-alt); text-decoration: none; }
.sidebar a.current { color: var(--color-primary); border-left-color: var(--color-primary); background: var(--color-bg-alt); font-weight: 600; }
.sidebar .module-link { font-weight: 600; font-size: 0.95rem; margin-top: 0.8em; color: var(--color-text); }
.sidebar .lesson-link { padding-left: 1.2em; font-size: 0.88rem; color: var(--color-text-muted); }

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; padding: 1.5em 1em 2em; gap: 1.5em; }
  .sidebar { position: static; max-height: none; overflow: visible; border-bottom: 1px solid var(--color-border); padding-bottom: 1em; }
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(135deg, #f0f7ff 0%, #e8f5ee 100%);
  padding: 4em 1.2em 4em;
  text-align: center;
}
.hero h1 {
  font-size: 2.7rem;
  max-width: 800px;
  margin: 0 auto 0.4em;
  line-height: 1.15;
}
.hero p.lead {
  font-size: 1.2rem;
  max-width: 680px;
  margin: 0 auto 1.8em;
  color: var(--color-text-muted);
}
.hero-cta {
  display: inline-flex;
  gap: 0.7em;
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  display: inline-block;
  padding: 0.85em 1.6em;
  font-size: 1rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--color-primary); color: #fff !important; }
.btn-primary:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-secondary {
  background: #fff;
  color: var(--color-text) !important;
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg-alt); text-decoration: none; }
.btn-accent { background: var(--color-accent); color: #fff !important; }
.btn-accent:hover { background: #195a36; text-decoration: none; }

/* ---------- Cards & grids ---------- */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5em;
  margin: 2em 0;
}
.card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.6em 1.4em;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.card h3 { margin-top: 0; font-size: 1.15rem; }
.card .icon {
  display: inline-flex;
  width: 44px; height: 44px;
  align-items: center; justify-content: center;
  background: var(--color-bg-alt);
  color: var(--color-primary);
  border-radius: var(--radius-md);
  font-size: 1.3rem;
  margin-bottom: 0.6em;
  font-weight: 700;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.3em;
  margin: 2em 0;
}
.module-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 1.3em 1.4em;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
}
.module-card:hover { box-shadow: var(--shadow-md); text-decoration: none; transform: translateY(-2px); }
.module-card .num {
  display: inline-block;
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  margin-bottom: 0.4em;
}
.module-card h3 { margin: 0 0 0.5em; font-size: 1.15rem; color: var(--color-text); }
.module-card p { color: var(--color-text-muted); font-size: 0.95rem; margin: 0 0 0.8em; flex: 1; }
.module-card .meta {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 0.7em;
  display: flex;
  justify-content: space-between;
}
.module-card.scenario { border-left-color: var(--color-accent); }
.module-card.scenario .num { color: var(--color-accent); }
.module-card.capstone { border-left-color: var(--color-secondary); }
.module-card.capstone .num { color: #b58a00; }

/* ---------- Lesson page ---------- */
.lesson-header {
  margin-bottom: 2em;
  padding-bottom: 1.2em;
  border-bottom: 1px solid var(--color-border);
}
.crumbs {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: 0.6em;
}
.crumbs a { color: var(--color-text-muted); }
.lesson-header h1 { margin: 0.1em 0 0.4em; font-size: 2.1rem; }
.lesson-meta {
  display: flex;
  gap: 1.2em;
  flex-wrap: wrap;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}
.lesson-meta span::before { content: "•"; margin-right: 0.5em; color: var(--color-border); }
.lesson-meta span:first-child::before { content: ""; margin: 0; }

.objectives {
  background: #f0f7ff;
  border-left: 4px solid var(--color-info);
  padding: 1em 1.3em;
  border-radius: var(--radius-sm);
  margin: 1.5em 0 2em;
}
.objectives h4 { margin: 0 0 0.5em; color: var(--color-info); font-size: 0.95rem; text-transform: uppercase; letter-spacing: 0.05em; }
.objectives ul { margin: 0; padding-left: 1.2em; }

/* ---------- Code blocks ---------- */
pre, code {
  font-family: var(--font-mono);
  font-size: 0.92rem;
}
code {
  background: #f1f5f9;
  color: #be185d;
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  font-size: 0.88em;
}
pre {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: 1.1em 1.3em;
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: 1.55;
  margin: 1.3em 0;
  font-size: 0.88rem;
  position: relative;
}
pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}
pre::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 1em;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  background: rgba(0,0,0,0.25);
  padding: 0.2em 0.6em;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

/* ---------- Callouts ---------- */
.callout {
  border-left: 4px solid;
  padding: 1em 1.3em;
  margin: 1.5em 0;
  border-radius: var(--radius-sm);
  background: var(--color-bg-alt);
}
.callout .callout-title {
  font-weight: 700;
  margin-bottom: 0.4em;
  display: flex;
  align-items: center;
  gap: 0.4em;
}
.callout-tip { border-color: var(--color-success); background: #f0fdf4; }
.callout-tip .callout-title { color: #15803d; }
.callout-warn { border-color: var(--color-warning); background: #fffbeb; }
.callout-warn .callout-title { color: #b45309; }
.callout-danger { border-color: var(--color-danger); background: #fef2f2; }
.callout-danger .callout-title { color: #b91c1c; }
.callout-info { border-color: var(--color-info); background: #f0f9ff; }
.callout-info .callout-title { color: #0369a1; }
.callout-excel { border-color: var(--color-accent); background: #f0fdf4; }
.callout-excel .callout-title { color: var(--color-accent); }

/* ---------- Step-by-step walkthroughs ---------- */
.walkthrough { counter-reset: step; margin: 2em 0; }
.walkthrough .step {
  position: relative;
  padding: 1.2em 1.3em 1.2em 4em;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin-bottom: 1em;
  counter-increment: step;
}
.walkthrough .step::before {
  content: counter(step);
  position: absolute;
  left: 1em;
  top: 1.1em;
  width: 2.2em;
  height: 2.2em;
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}
.walkthrough .step h4 { margin: 0 0 0.4em; font-size: 1.05rem; }
.walkthrough .step pre { margin-top: 0.8em; }
.walkthrough .step p:last-child { margin-bottom: 0; }

/* ---------- Tables ---------- */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.5em 0;
  font-size: 0.93rem;
}
th, td {
  border: 1px solid var(--color-border);
  padding: 0.6em 0.9em;
  text-align: left;
}
th {
  background: var(--color-bg-alt);
  font-weight: 600;
}
tr:nth-child(even) td { background: #fafbfc; }

/* ---------- Lesson nav (prev/next) ---------- */
.lesson-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1em;
  margin: 3em 0 1em;
}
.lesson-nav a {
  display: block;
  padding: 1em 1.2em;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: #fff;
  transition: all 0.15s ease;
}
.lesson-nav a:hover { background: var(--color-bg-alt); border-color: var(--color-primary); text-decoration: none; }
.lesson-nav .label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  margin-bottom: 0.3em;
}
.lesson-nav .title { font-weight: 600; color: var(--color-text); }
.lesson-nav .next { text-align: right; }
@media (max-width: 600px) {
  .lesson-nav { grid-template-columns: 1fr; }
  .lesson-nav .next { text-align: left; }
}

/* ---------- Exercise box ---------- */
.exercise {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid var(--color-warning);
  padding: 1.3em 1.4em;
  border-radius: var(--radius-md);
  margin: 2em 0;
}
.exercise h4 {
  margin: 0 0 0.6em;
  color: #b45309;
  display: flex; align-items: center; gap: 0.4em;
}
.exercise ol, .exercise ul { margin-bottom: 0; }

/* ---------- Key takeaways ---------- */
.takeaways {
  background: var(--color-bg-alt);
  padding: 1.3em 1.5em;
  border-radius: var(--radius-md);
  margin: 2em 0;
}
.takeaways h4 { margin: 0 0 0.6em; color: var(--color-primary); }
.takeaways ul { margin-bottom: 0; }

/* ---------- Ad slots ---------- */
.ad-slot {
  background: repeating-linear-gradient(45deg, #f8fafc, #f8fafc 10px, #f1f5f9 10px, #f1f5f9 20px);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 1em;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin: 2em 0;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-slot::before { content: "Advertisement"; opacity: 0.5; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.15em; }
.ad-footer { margin-top: 2em; min-height: 120px; }

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-bg-dark);
  color: var(--color-text-inverse);
  padding: 3em 1.2em 1.5em;
  margin-top: 4em;
}
.site-footer .footer-grid {
  max-width: var(--max-width);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 2em;
  padding-bottom: 2em;
  border-bottom: 1px solid #334155;
}
.site-footer h4 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #cbd5e1;
  margin: 0 0 0.8em;
}
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin-bottom: 0.4em; }
.site-footer a { color: #94a3b8; font-size: 0.92rem; }
.site-footer a:hover { color: #fff; }
.site-footer .copy {
  max-width: var(--max-width);
  margin: 1.5em auto 0;
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
}
@media (max-width: 700px) {
  .site-footer .footer-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Pill / badge ---------- */
.pill {
  display: inline-block;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--color-bg-alt);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pill-beginner { background: #dcfce7; color: #166534; }
.pill-intermediate { background: #fef3c7; color: #92400e; }
.pill-advanced { background: #fee2e2; color: #991b1b; }
.pill-scenario { background: #dbeafe; color: #1e40af; }

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 2em; }
.mb-2 { margin-bottom: 2em; }

/* ---------- Print (training manual) ---------- */
@media print {
  .site-header, .site-footer, .sidebar, .ad-slot, .lesson-nav, .menu-toggle { display: none !important; }
  .layout { grid-template-columns: 1fr; padding: 0; }
  body { font-size: 11pt; color: #000; }
  pre { background: #f3f3f3; color: #000; border: 1px solid #ccc; }
  code { color: #b91c1c; background: #f3f3f3; }
  a { color: #000; text-decoration: underline; }
  h1, h2, h3 { page-break-after: avoid; }
  pre, blockquote, .callout, .exercise, .walkthrough .step { page-break-inside: avoid; }
  .manual-toc a::after { content: leader('.') target-counter(attr(href), page); }
}
