/* === RESET (Meyer v2.0, public domain) === */
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,
a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,
strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,
label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,
details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,
section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}
blockquote,q{quotes:none}
blockquote:before,blockquote:after,q:before,q:after{content:"";content:none}

/* === CSS CUSTOM PROPERTIES (light default) === */
:root {
  --bg: #f8fafc;
  --bg-alt: #ffffff;
  --text: #334155;
  --text-strong: #111827;
  --heading-bg: #3b82f6;
  --heading-text: #ffffff;
  --link: #3b82f6;
  --link-hover: #2563eb;
  --border: #e2e8f0;
  --code-bg: #f1f5f9;
  --code-color: #16a34a;
  --blockquote-bg: #e2e8f0;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,.1);
  --nav-bg: #1e293b;
  --nav-text: #f1f5f9;
  --nav-hover: #3b82f6;
  --page-nav-bg: #f1f5f9;
  --page-nav-hover: #3b82f6;
  --table-border: #cbd5e1;
  --table-stripe: #f8fafc;
}
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --text: #cbd5e1;
  --text-strong: #f1f5f9;
  --heading-bg: #1e40af;
  --heading-text: #e0e7ff;
  --link: #60a5fa;
  --link-hover: #93bbfd;
  --border: #334155;
  --code-bg: #1e293b;
  --code-color: #4ade80;
  --blockquote-bg: #1e293b;
  --card-bg: #1e293b;
  --card-shadow: 0 1px 3px rgba(0,0,0,.4);
  --nav-bg: #020617;
  --nav-text: #e2e8f0;
  --page-nav-bg: #1e293b;
  --table-border: #475569;
  --table-stripe: #1e293b;
}

/* === BASE === */
*,*::before,*::after{box-sizing:border-box}
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 1rem;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
  margin: 0; padding: 0;
  padding-top: 60px; /* room for fixed nav */
  transition: background .3s, color .3s;
}
strong, b { font-weight: 700; color: var(--text-strong); }
sup { font-size: .75em; vertical-align: super; }
sub { font-size: .75em; vertical-align: sub; }
a { color: var(--link); text-decoration: none; transition: color .2s; }
a:hover { color: var(--link-hover); text-decoration: underline; }
img { max-width: 100%; height: auto; border-radius: 6px; }

/* === LAYOUT CONTAINER === */
main, body > section, body > .content {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
}

/* === HEADINGS === */
h1,h2,h3,h4 {
  font-weight: 700;
  background: var(--heading-bg);
  color: var(--heading-text);
  padding: .75rem 1rem;
  margin: 1.5rem 0 .75rem;
  border-radius: 6px;
  line-height: 1.3;
}
h1 { font-size: 1.85rem; text-align: center; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1.05rem; }
h5 { font-weight: 600; margin: 1rem 0 .5rem; }

/* === TEXT === */
p { margin: .75rem 0; }
blockquote {
  margin: 1rem 0;
  padding: .85rem 1.25rem;
  background: var(--blockquote-bg);
  border-left: 4px solid var(--link);
  border-radius: 0 6px 6px 0;
}

/* === LISTS === */
ol, ul { margin: .5rem 0 .5rem 1.5rem; }
ol li { list-style: decimal; padding: .25rem 0; }
ul li { list-style: disc; padding: .25rem 0; }
dl { margin: .5rem 0; }
dd { margin-left: 1.25rem; padding-bottom: .5rem; }

/* === CODE === */
code, pre {
  font-family: 'Fira Code', 'Cascadia Code', 'Courier New', monospace;
  background: var(--code-bg);
  color: var(--code-color);
  border-radius: 4px;
  transition: background .3s, color .3s;
}
code { padding: .15rem .35rem; font-size: .9em; }
pre { padding: 1rem; margin: 1rem 0; overflow-x: auto; line-height: 1.5; border: 1px solid var(--border); }
pre code { padding: 0; background: none; }

/* === TABLES === */
table {
  width: 100%;
  margin: 1rem auto;
  border-collapse: collapse;
  overflow-x: auto;
  display: block;
}
@media(min-width:640px){ table { display: table; } }
th, td { border: 1px solid var(--table-border); padding: .5rem .75rem; text-align: left; }
th { background: var(--heading-bg); color: var(--heading-text); font-weight: 600; }
tr:nth-child(even) { background: var(--table-stripe); }

/* === SVG / MERMAID === */
svg { display: block; margin: 1rem auto; max-width: 100%; height: auto; }
.mermaid_container, .mermaid-diagram, .mermaid {
  margin: 1.5rem auto;
  padding: 1rem;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-width: 100%;
  text-align: center;
}
.mermaid svg { margin: 0 auto; display: block; }

/* === UTILITY CLASSES from lessons === */
.analogy-box {
  background: var(--bg-alt);
  border-left: 4px solid var(--link);
  padding: 1rem 1.25rem;
  margin: 1rem 0;
  border-radius: 0 8px 8px 0;
}
.example-container {
  background: var(--bg-alt);
  border: 2px solid #22c55e;
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 10px;
}
.practice-activity {
  background: var(--bg-alt);
  border: 2px solid #eab308;
  padding: 1rem;
  margin: 1rem 0;
  border-radius: 10px;
}
.comment-block {
  border-left: 4px solid var(--link);
  padding: .65rem 1rem;
  margin: 1rem 0;
  border-radius: 0 5px 5px 0;
}
.code-comment { color: #0891b2; font-style: italic; }
.center { text-align: center; }

/* ===========================
   SITE NAV (injected by nav.js)
   =========================== */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: var(--nav-bg);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 1.25rem;
}
.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--nav-text) !important;
  text-decoration: none !important;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.nav-links a {
  color: var(--nav-text) !important;
  text-decoration: none !important;
  font-size: .9rem;
  transition: color .2s;
}
.nav-links a:hover { color: var(--nav-hover) !important; }
.theme-btn {
  background: none;
  border: 1px solid rgba(255,255,255,.25);
  color: var(--nav-text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: .25rem .55rem;
  border-radius: 6px;
  line-height: 1;
  transition: border-color .2s;
}
.theme-btn:hover { border-color: var(--nav-hover); }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }
.nav-toggle { display: none; background: none; border: none; color: var(--nav-text); font-size: 1.5rem; cursor: pointer; }

/* ===========================
   PREV / NEXT NAV
   =========================== */
.page-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  margin: 2.5rem 0 1rem;
  padding: 1rem 0;
  border-top: 2px solid var(--border);
}
.page-nav-link {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1rem;
  background: var(--page-nav-bg);
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none !important;
  transition: background .2s, color .2s;
  max-width: 40%;
}
.page-nav-link:hover { background: var(--page-nav-hover); color: #fff !important; }
.page-nav-link .arrow { font-size: 1.2rem; }
.page-nav-home {
  font-size: .85rem;
  padding: .5rem .85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none !important;
  transition: background .2s;
}
.page-nav-home:hover { background: var(--page-nav-bg); }

/* ===========================
   INDEX PAGE CARDS
   =========================== */
.hero { text-align: center; padding: 2.5rem 1rem 1.5rem; }
.hero h1 { background: none; color: var(--text-strong); font-size: 2.2rem; margin-bottom: .5rem; }
.hero p { color: var(--text); font-size: 1.1rem; max-width: 600px; margin: 0 auto; }
.section-group { margin: 2rem 0; }
.section-group h2 {
  font-size: 1.25rem;
  display: inline-block;
  margin-bottom: 1rem;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.card-grid li {
  list-style: none !important;
  margin: 0 !important;
  padding: 0 !important;
}
.card-grid a {
  display: block;
  padding: 1.15rem 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--card-shadow);
  text-decoration: none !important;
  transition: transform .15s, box-shadow .15s;
  color: var(--text) !important;
}
.card-grid a:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.card-grid .card-title {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--link);
  margin-bottom: .3rem;
}
.card-grid .card-desc {
  font-size: .88rem;
  color: var(--text);
  line-height: 1.45;
}

/* ===========================
   MOBILE
   =========================== */
@media (max-width: 700px) {
  body { padding-top: 56px; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1rem; }
  main, body > section { padding: 1rem .85rem; }
  .nav-toggle { display: block; }
  .nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: var(--nav-bg);
    padding: .75rem 1.25rem 1rem;
    gap: .85rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
  }
  .nav-links.open { display: flex; }
  .page-nav { flex-direction: column; }
  .page-nav-link { max-width: 100%; width: 100%; justify-content: center; }
  .hero h1 { font-size: 1.6rem; }
  .card-grid { grid-template-columns: 1fr; }
  table { font-size: .85rem; }
}

/* === FOOTER === */
footer {
  margin-top: 2rem;
  padding: 1rem 0;
  text-align: left;
}

/* BEGIN footer-nav-styles (managed by add_footer_nav.py) */
/* Static lesson footer (inserted by add_footer_nav.py into each lesson HTML) */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: .85rem;
    color: var(--text);
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}
.site-footer a { color: var(--link); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer p { margin: .35rem 0; }

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: .5rem;
}

/* First/last in a section uses <span></span> as a placeholder; keep it inert */
.page-nav > span:empty { flex: 0 0 auto; }

@media print {
    .site-footer { display: none !important; }
}
/* END footer-nav-styles */
