/* ═══════════════════════════════════════════════════
   justcalculus — Modern Static Site
   ═══════════════════════════════════════════════════ */

/* — Fonts — */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Newsreader:ital,wght@0,400;0,600;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Warm neutral palette */
  --bg: #fafaf9;
  --bg-card: #ffffff;
  --bg-code: #1c1c1e;
  --bg-math: #f5f3ef;
  --bg-accent: #f0ece4;

  --text: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-muted: #999;

  --accent: #b45309;
  --accent-light: #fef3c7;
  --accent-hover: #92400e;

  --border: #e5e2db;
  --border-light: #f0ede6;

  --max-width: 900px;
  --content-width: 680px;

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  --radius: 10px;
  --radius-sm: 6px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.7;
}

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

a:hover {
  color: var(--accent-hover);
}

/* ── Header ───────────────────────────────────────── */

header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
  background: rgba(255,255,255,0.92);
}

header .inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 60px;
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.logo .just {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

nav {
  display: flex;
  gap: 0.25rem;
}

nav a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 0.4rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s ease;
}

nav a:hover {
  color: var(--text);
  background: var(--bg-accent);
}

nav a.active {
  color: var(--accent);
  background: var(--accent-light);
}

.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
}

/* ── Main ─────────────────────────────────────────── */

main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2.5rem 2rem 5rem;
}

/* ── Hero ─────────────────────────────────────────── */

.hero {
  text-align: center;
  padding: 4rem 0 3rem;
  margin-bottom: 1.5rem;
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: 3rem;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 0.75rem;
}

.hero h1 .just {
  font-style: italic;
  color: var(--accent);
  font-weight: 400;
}

.hero p {
  color: var(--text-secondary);
  font-size: 1.15rem;
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── Section Titles ───────────────────────────────── */

.section-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin: 3rem 0 0.75rem;
  letter-spacing: -0.02em;
}

/* ── Blog Cards ───────────────────────────────────── */

.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1.25rem;
}

.blog-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all 0.2s ease;
}

.blog-card:hover {
  border-color: #ccc;
  box-shadow: 0 8px 30px rgba(0,0,0,0.06);
  transform: translateY(-2px);
}

.blog-card img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
  background: var(--bg-accent);
}

.blog-card .card-body {
  padding: 1.25rem 1.5rem;
}

.blog-card h3 {
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.4rem;
}

.blog-card h3 a {
  color: var(--text);
  text-decoration: none;
}

.blog-card h3 a:hover {
  color: var(--accent);
}

.blog-card .meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  margin-bottom: 0.5rem;
}

.blog-card .excerpt {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ── Tags ─────────────────────────────────────────── */

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.6rem 0;
}

.tag {
  background: var(--bg-accent);
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  letter-spacing: 0.01em;
}

/* ── Lesson List ──────────────────────────────────── */

.lesson-list {
  list-style: none;
  margin-top: 1rem;
}

.lesson-list li {
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  background: var(--bg-card);
  transition: border-color 0.15s;
}

.lesson-list li:hover {
  border-color: var(--border);
}

.lesson-number {
  background: var(--bg-accent);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  white-space: nowrap;
  min-width: 2rem;
  text-align: center;
}

.lesson-list a {
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.lesson-list a:hover {
  color: var(--accent);
}

.lesson-topics {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  line-height: 1.5;
}

/* ── Blog Post (Article) ──────────────────────────── */

article.post {
  max-width: var(--content-width);
  margin: 0 auto;
}

article.post h1 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

article.post .meta {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

article.post h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2.5rem 0 0.8rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

article.post p {
  margin-bottom: 1.3rem;
  line-height: 1.75;
}

article.post img,
article.post .post-figure img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  margin: 1.5rem 0;
  display: block;
  border: 1px solid var(--border-light);
}

article.post .post-figure {
  margin: 2rem 0;
  text-align: center;
}

article.post .post-figure figcaption,
article.post figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-style: italic;
  text-align: center;
}

article.post .math-block {
  background: var(--bg-math);
  padding: 1.2rem 1.5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  font-size: 1.05rem;
  text-align: center;
  border: 1px solid var(--border-light);
}

article.post code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-accent);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
}

article.post pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: var(--bg-code);
  color: #e0e0e0;
  padding: 1.25rem 1.5rem;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.6;
  border: 1px solid #333;
}

article.post pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

article.post blockquote {
  border-left: 3px solid var(--accent);
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  background: var(--accent-light);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  line-height: 1.7;
  color: #444;
}

article.post strong {
  font-weight: 600;
}

article.post em {
  font-style: italic;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
}

.back-link:hover {
  gap: 0.6rem;
}

/* ── Buttons ──────────────────────────────────────── */

.btn {
  display: inline-block;
  background: var(--text);
  color: var(--bg);
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.btn:hover {
  background: #333;
  color: var(--bg);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--bg-accent);
  color: var(--text);
  border-color: #ccc;
}

/* ── Info Box (migration notes) ───────────────────── */

.info-box {
  background: var(--accent-light);
  border: 1px solid #fde68a;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.6;
}

.info-box code {
  background: rgba(0,0,0,0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}

/* ── Footer ───────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  text-align: center;
  padding: 3rem 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

footer a:hover {
  color: var(--accent);
}

footer .logo-inline {
  font-family: var(--font-serif);
}

footer .logo-inline .just {
  font-style: italic;
  color: var(--accent);
}

/* ── Responsive ───────────────────────────────────── */

@media (max-width: 700px) {
  header .inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 1.25rem;
  }

  .nav-toggle { display: block; }

  nav {
    display: none;
    width: 100%;
    flex-direction: column;
    padding: 0.5rem 0;
  }

  nav.open { display: flex; }

  nav a {
    padding: 0.6rem 0.5rem;
  }

  main { padding: 1.5rem 1.25rem 3rem; }

  .hero { padding: 2.5rem 0 2rem; }
  .hero h1 { font-size: 2.2rem; }
  .hero p { font-size: 1rem; }

  .blog-grid { grid-template-columns: 1fr; }

  .lesson-list li {
    flex-direction: column;
    gap: 0.25rem;
  }

  article.post h1 { font-size: 1.7rem; }
  article.post pre { font-size: 0.8rem; padding: 1rem; }
}

/* ── Video Page ────────────────────────────────────── */

.video-grid {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  margin-top: 1.5rem;
}

.video-lesson {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
}

.video-lesson h2 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  letter-spacing: -0.01em;
}

.video-lesson .lesson-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.video-embed {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: #000;
}

.video-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.lesson-links {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-light);
  font-size: 0.88rem;
  font-weight: 500;
}

.lesson-links a {
  text-decoration: none;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.lesson-links a:hover {
  color: var(--accent);
}

.lesson-links a::before {
  content: '';
  display: inline-block;
  width: 0.35rem;
  height: 0.35rem;
  background: var(--accent);
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: middle;
}

/* Video icon for lesson list items */
.lesson-list .video-link {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  white-space: nowrap;
}

.lesson-list .video-link:hover {
  color: var(--accent);
}

/* ── Utilities ────────────────────────────────────── */

.text-center { text-align: center; }
.mt-2 { margin-top: 2rem; }
.mb-2 { margin-bottom: 2rem; }
.flex-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1.5rem 0;
}
