/* ═══════════════════════════════════════════════
   Blog Design System
   Shared across all posts
   ═══════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  --navy: #0a1628;
  --navy-soft: #1a2a4a;
  --ink: #1d2939;
  --body: #374151;
  --muted: #6b7280;
  --faint: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f1f3f5;
  --surface: #f8f9fb;
  --bg: #ffffff;
  --accent: #2563eb;
  --accent-light: #dbeafe;
  --accent-wash: #eff6ff;

  --col-width: 680px;
  --wide-width: 860px;

  --font-body: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-ui: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

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

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

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

::selection {
  background: var(--accent-light);
  color: var(--navy);
}

/* ── Site Header ── */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
}
.site-header-inner {
  max-width: var(--wide-width);
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.site-logo {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
  text-decoration: none;
}
.site-nav {
  display: flex;
  gap: 1.5rem;
}
.site-nav a {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}
.site-nav a:hover { color: var(--navy); }

/* ── Widths ── */
.col       { max-width: var(--col-width); margin-left: auto; margin-right: auto; padding-left: 2rem; padding-right: 2rem; }
.col-wide  { max-width: var(--wide-width); margin-left: auto; margin-right: auto; padding-left: 2rem; padding-right: 2rem; }

/* ═══════════════════
   Hero
   ═══════════════════ */
.hero {
  padding: 5rem 0 3rem;
}
.hero-tags {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.hero-tag {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.25rem 0.7rem;
  border-radius: 100px;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
}
.hero h1 {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 2.8rem;
  line-height: 1.18;
  color: var(--navy);
  letter-spacing: -0.025em;
  margin-bottom: 1.25rem;
}
.hero-meta {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.hero-meta .dot { color: var(--border); }
.hero-cite {
  margin-top: 2rem;
  font-size: 0.88rem;
  font-style: italic;
  color: var(--muted);
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--border);
  background: var(--surface);
  border-radius: 0 8px 8px 0;
  line-height: 1.6;
}
.hero-cite a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-light);
  transition: border-color 0.2s;
}
.hero-cite a:hover { border-bottom-color: var(--accent); }

/* ═══════════════════
   Article Prose
   ═══════════════════ */
article p {
  margin-bottom: 1.4rem;
}
article a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
article a:hover { border-bottom-color: var(--accent); }

article strong { color: var(--ink); }
article em { font-style: italic; }

/* ── Key Message / Callout ── */
.key-message {
  margin: 2.5rem 0;
  padding: 1.5rem 1.75rem;
  border-left: 4px solid var(--accent);
  background: linear-gradient(135deg, var(--accent-wash), var(--bg));
  border-radius: 0 12px 12px 0;
  font-size: 1.02rem;
  line-height: 1.7;
  color: var(--navy-soft);
}

/* ── Headings ── */
article h2 {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.55rem;
  color: var(--navy);
  margin-top: 3.5rem;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
  line-height: 1.3;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-light);
}
article h3 {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--ink);
  margin-top: 2.25rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.005em;
}

/* ── Lists ── */
article ol, article ul {
  padding-left: 1.5rem;
  margin-bottom: 1.4rem;
}
article li {
  margin-bottom: 0.5rem;
}

/* ── Section Dividers ── */
.section-rule {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 3rem 0;
}

/* ── Code ── */
article code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: var(--ink);
}
article pre {
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.65;
}
article pre code {
  background: none;
  padding: 0;
}

/* ═══════════════════
   Math (KaTeX)
   ═══════════════════ */
.katex-display {
  margin: 1.5rem 0;
  overflow-x: auto;
  padding: 0.5rem 0;
}
.math-block {
  margin: 1.75rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border-light);
  overflow-x: auto;
}

/* ═══════════════════
   Figures
   ═══════════════════ */
.figure {
  margin: 2.5rem 0;
}
.figure img {
  width: 100%;
  border-radius: 10px;
}
.figure-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  align-items: start;
}
.figure-grid-item {
  text-align: center;
}
.figure-grid-item img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}
.figure-grid-item .label {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.4rem;
}
figcaption, .figcaption {
  font-family: var(--font-ui);
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 0.8rem;
}
figcaption strong, .figcaption strong {
  color: var(--ink);
  font-weight: 500;
}

/* ═══════════════════
   Embed (iframes for interactive content)
   ═══════════════════ */
.embed-wrap {
  margin: 2rem 0;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface);
}
.embed-wrap iframe {
  width: 100%;
  border: none;
  display: block;
}

/* ═══════════════════
   Cards (for experiments, tips, etc.)
   ═══════════════════ */
.card-stack {
  margin: 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.card {
  padding: 1rem 1.25rem;
  border-radius: 10px;
  border: 1px solid var(--border-light);
  background: var(--bg);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.card:hover {
  border-color: var(--border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}
.card-title {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--navy);
  margin-bottom: 0.35rem;
}
.card p {
  font-size: 0.9rem;
  color: var(--body);
  margin: 0;
  line-height: 1.6;
}

/* ═══════════════════
   Tables
   ═══════════════════ */
article table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-family: var(--font-ui);
  font-size: 0.82rem;
}
article thead th {
  font-weight: 700;
  color: var(--ink);
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
}
article tbody td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--body);
}
article tbody tr:hover {
  background: var(--surface);
}

/* ═══════════════════
   Takeaway Box
   ═══════════════════ */
.takeaway {
  margin: 2.5rem 0;
  padding: 1.75rem;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
}
.takeaway-label {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}
.takeaway ol, .takeaway ul {
  padding-left: 1.25rem;
}
.takeaway li {
  margin-bottom: 0.75rem;
  line-height: 1.65;
}
.takeaway li:last-child {
  margin-bottom: 0;
}

/* ═══════════════════
   Footer
   ═══════════════════ */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 4rem;
  padding: 2rem;
  text-align: center;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--faint);
}

/* ═══════════════════
   Animations
   ═══════════════════ */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in       { animation: fadeUp 0.6s ease-out both; }
.fade-in-d1    { animation-delay: 0.1s; }
.fade-in-d2    { animation-delay: 0.2s; }
.fade-in-d3    { animation-delay: 0.3s; }

/* ═══════════════════
   Responsive
   ═══════════════════ */
@media (max-width: 768px) {
  html { font-size: 16px; }
  .hero h1 { font-size: 2rem; }
  .figure-grid { grid-template-columns: repeat(2, 1fr); }
  .col, .col-wide, .hero { padding-left: 1.25rem; padding-right: 1.25rem; }
  .site-header-inner { padding: 0 1.25rem; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 1.7rem; }
  .hero-meta { font-size: 0.78rem; }
  .figure-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* ═══════════════════
   Giscus Comments
   ═══════════════════ */
.comments-section {
  margin-top: 3rem;
}
.comments-heading {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--navy);
  margin-top: 2rem;
  margin-bottom: 1.5rem;
  border: none;
  padding: 0;
}
.giscus {
  margin-top: 0.5rem;
}
.giscus-frame {
  border: none !important;
}

/* ═══════════════════
   Like button (index page)
   ═══════════════════ */
.like-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.2s;
}
.like-btn svg {
  transition: all 0.2s;
}
.like-btn:hover {
  color: #E24B4A;
}
.like-btn:hover svg {
  stroke: #E24B4A;
  fill: rgba(226, 75, 74, 0.12);
}
