/* ==========================================================================
   LearnWithKMK — theme tokens
   A quiet, notebook-like dark theme: near-black charcoal, bone text, muted
   indigo accent. Numbering styled like equation references, since the
   content is genuinely mathematical.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;1,8..60,400&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

:root {
  /* Color */
  --bg: #14151a;
  --surface: #1a1c22;
  --surface-hover: #20222a;
  --border: #2c2f3a;
  --border-soft: #22242c;
  --text: #e6e6ea;
  --text-muted: #8f92a3;
  --text-faint: #63667a;
  --accent: #6d83d1;
  --accent-soft: #6d83d133;
  --link: #8b9fe0;

  /* Type */
  --font-display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  /* Scale */
  --measure: 48rem;
  --radius: 3px;
}

/* ---- Reset ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main.shell {
  padding-bottom: 3rem;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

a:hover {
  border-bottom-color: var(--link);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Subtle scrollbars (all scroll containers) ---- */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background-color: var(--border);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-faint);
  background-clip: padding-box;
}

/* ---- Reading progress bar (article pages only) ---- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  opacity: 0.7;
  z-index: 100;
  transition: width 0.1s ease-out;
}

/* ---- Layout shell ---- */
.shell {
  max-width: 54rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ---- Header / nav ---- */
.site-header {
  border-bottom: 1px solid var(--border-soft);
  padding: 2.25rem 0 1.5rem;
}

.site-header .shell {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.site-mark {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.01em;
  border-bottom: none;
}

.site-mark:hover {
  border-bottom: none;
  color: var(--accent);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.site-nav a {
  color: var(--text-muted);
}

.site-nav a:hover,
.site-nav a[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- Footer ---- */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border-soft);
  margin-top: auto;
  padding: 2rem 0 3rem;
  color: var(--text-faint);
  font-size: 0.85rem;
}

.site-footer .shell {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-links {
  display: flex;
  gap: 1.1rem;
}

.footer-links a {
  color: var(--text-muted);
}

/* ---- Hero / about blurb on homepage ---- */
.hero {
  padding: 2.5rem 0 3rem;
}

.hero p {
  max-width: var(--measure);
  color: var(--text-muted);
  font-size: 1.05rem;
}

.hero p:first-of-type {
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.3rem;
  line-height: 1.5;
}

/* ---- Article index ---- */
.index-heading {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 0.6rem;
  margin: 2.5rem 0 0.5rem;
}

.article-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.article-entry {
  display: flex;
  gap: 1.1rem;
  align-items: baseline;
  padding: 1.15rem 0;
  border-bottom: 1px solid var(--border-soft);
}

.article-entry:last-child {
  border-bottom: none;
}

.see-more-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
  border-bottom: none;
}

.see-more-link:hover {
  color: var(--accent);
  border-bottom: none;
}

.entry-index {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent);
  min-width: 2.1rem;
  flex-shrink: 0;
}

.entry-body {
  flex: 1;
  min-width: 0;
}

.entry-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  display: block;
  border-bottom: none;
}

.entry-title:hover {
  color: var(--accent);
  border-bottom: none;
}

.entry-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-faint);
  margin-top: 0.3rem;
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.entry-tag {
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.05rem 0.45rem;
}

.entry-summary {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 0.4rem;
  line-height: 1.5;
}

/* ---- Article page ---- */
.article-header {
  padding: 2.25rem 0 1rem;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 2rem;
}

.article-title {
  font-family: var(--font-display);
  font-size: 2rem;
  line-height: 1.25;
  color: var(--text);
  margin: 0 0 0.75rem;
}

.article-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
  display: flex;
  gap: 0.9rem;
  flex-wrap: wrap;
  align-items: center;
}

.back-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 1.75rem;
  margin-bottom: 1.5rem;
}

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

/* ---- Article body / prose ---- */
.prose {
  max-width: var(--measure);
}

.prose h1,
.prose h2,
.prose h3 {
  font-family: var(--font-display);
  color: var(--text);
  line-height: 1.35;
  margin-top: 2.4rem;
  margin-bottom: 0.9rem;
}

.prose h2 {
  font-size: 1.4rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-soft);
}

.prose h3 {
  font-size: 1.15rem;
}

.prose p {
  margin: 0 0 1.2rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1.2rem;
  padding-left: 1.4rem;
}

.prose li {
  margin-bottom: 0.4rem;
}

.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.2rem 1.1rem;
  border-left: 2px solid var(--accent);
  color: var(--text-muted);
  font-style: italic;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border-soft);
  margin: 2.5rem 0;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.08em 0.4em;
  color: var(--accent);
}

.prose pre {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 0 0 1.5rem;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.86rem;
  line-height: 1.55;
}

.prose img {
  border-radius: var(--radius);
  margin: 1.5rem 0;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.5rem;
  font-size: 0.9rem;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.7rem;
  text-align: left;
}

.prose th {
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Anchor links added by markdown-it-anchor on headings */
.prose h2 a,
.prose h3 a {
  color: inherit;
  border-bottom: none;
}

/* ---- KaTeX overrides (dark-theme tuning) ---- */
.katex {
  font-size: 1.05em;
  color: var(--text);
}

.katex-display {
  margin: 1.6rem 0;
  padding: 0.6rem 0;
  overflow-x: auto;
  overflow-y: hidden;
}

/* ---- Empty state ---- */
.empty-note {
  color: var(--text-faint);
  font-size: 0.95rem;
  padding: 1.5rem 0;
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
  body {
    font-size: 16px;
  }

  .article-title {
    font-size: 1.6rem;
  }

  .hero p:first-of-type {
    font-size: 1.15rem;
  }

  .article-entry {
    gap: 0.75rem;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
