/* =========================================================
   Eric Chu — shared site styles
   Base tokens preserved verbatim from the original index.html,
   with additions for site nav, the blog index, and post pages.
   ========================================================= */

/* ---- CSS Variables for Light/Dark Mode ---- */
:root {
  --bg-color: #ffffff;
  --text-color: #333333;
  --heading-color: #111111;
  --link-color: #3b7ab8;
  --link-hover: #0066cc;            /* old link color, now used for hover */
  --border-color: #eaeaea;
  --meta-color: #666666;
  --secondary-text: #888888;
  --secondary-border: #f0f0f0;

  /* highlight tiers (Eric's red / green / yellow review system) */
  --hl-yellow: rgba(255, 214, 92, 0.40);
  --hl-green:  rgba(110, 200, 130, 0.32);
  --hl-red:    rgba(240, 120, 120, 0.30);

  /* code surfaces */
  --code-bg: #f6f8fa;
  --code-inline-bg: #f0f1f3;
  --code-text: #24292e;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #121212;
    --text-color: #cccccc;
    --heading-color: #ffffff;
    --link-color: #66b3ff;
    --link-hover: #99ccff;
    --border-color: #333333;
    --meta-color: #999999;
    --secondary-text: #777777;
    --secondary-border: #2a2a2a;

    --hl-yellow: rgba(214, 174, 60, 0.32);
    --hl-green:  rgba(90, 170, 110, 0.30);
    --hl-red:    rgba(210, 95, 95, 0.32);

    --code-bg: #1b1b1b;
    --code-inline-bg: #242424;
    --code-text: #e0e0e0;
  }
}

/* ---- Global Styles ---- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  margin: 0;
  padding: 2rem 1.5rem;
  font-size: 16px;
}

main {
  max-width: 600px;
  margin: 0 auto;
}

h1, h2, h3, h4 {
  color: var(--heading-color);
  font-weight: 600;
}

h1 { font-size: 2.2rem; margin: 0 0 0.2em 0; }
h2 { font-size: 1.4rem; margin-top: 2.5rem; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; }
h3 { font-size: 1.1rem; margin-top: 1.4rem; margin-bottom: 0.3rem; }

p { margin-bottom: 1rem; }

a { color: var(--link-color); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--link-hover); text-decoration: underline; }

hr { border: 0; height: 1px; background: var(--border-color); margin: 2rem 0; }

/* ---- Site Nav (added) ---- */
.site-nav {
  max-width: 600px;
  margin: 0 auto 2.25rem auto;
  display: flex;
  align-items: baseline;
  gap: 1.4rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}
.site-nav .nav-home {
  font-weight: 600;
  color: var(--heading-color);
  margin-right: auto;
  font-size: 0.95rem;
}
.site-nav .nav-home:hover { color: var(--link-color); text-decoration: none; }
.site-nav a:not(.nav-home) {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--meta-color);
}
.site-nav a:not(.nav-home):hover { color: var(--link-color); text-decoration: none; }
.site-nav a.active { color: var(--heading-color); }

/* ---- Header Section ---- */
.header-container {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-bottom: 2.5rem;
}
@media (max-width: 600px) {
  .header-container { flex-direction: column; text-align: center; }
}

.profile-pic {
  width: 140px;
  height: 140px;
  border-radius: 20%;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.contact-info { margin-bottom: 0.5rem; color: var(--meta-color); }

.social-links {
  font-size: 1.5rem;
  display: flex;
  gap: 1rem;
  margin-top: 0.8rem;
}
@media (max-width: 600px) {
  .social-links { justify-content: center; }
}
.social-links a { color: var(--heading-color); }
.social-links a:hover { color: var(--link-color); text-decoration: none; }

/* ---- Primary themed lists (homepage) ---- */
.section-intro {
  font-size: 0.85rem;
  color: var(--meta-color);
  margin-top: -0.1rem;
  margin-bottom: 0.7rem;
  padding-left: 0.1rem;
}
ul.theme-list {
  padding-left: 1.2rem;
  margin-top: 0.2rem;
  font-size: 0.875rem;
  line-height: 1.45;
  list-style: none;
}
ul.theme-list li {
  margin-bottom: 0.4rem;
  font-weight: 500;
  color: var(--heading-color);
  position: relative;
}
ul.theme-list li::before {
  content: "▸";
  color: var(--link-color);
  font-weight: bold;
  position: absolute;
  left: -1rem;
  top: 0;
}

ul.theme-list-secondary {
  padding-left: 1.2rem;
  margin-top: 0;
  margin-bottom: 0;
  font-size: 0.8rem;
  line-height: 1.4;
  color: var(--secondary-text);
  list-style: none;
}
ul.theme-list-secondary li::before {
  content: "◦";
  color: var(--meta-color);
  position: absolute;
  left: -0.8rem;
  top: 0;
}
ul.theme-list-secondary li {
  margin-bottom: 0.25rem;
  position: relative;
}
ul.theme-list-secondary a { color: var(--meta-color); }
ul.theme-list-secondary a:hover { color: var(--link-hover); }

.also-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--secondary-text);
  margin-top: 0.7rem;
  margin-bottom: 0.25rem;
  padding-left: 1.2rem;
}

.date-badge { color: var(--meta-color); font-size: 0.9em; }
.item-links a, .item-links span.no-link { font-size: 0.9em; margin-right: 0.5rem; font-weight: 400; }
.item-links a.highlight { font-weight: 600; }
.item-links a::after, .item-links span.no-link::after { content: " | "; color: var(--meta-color); font-weight: 400; text-decoration: none; display: inline-block; margin-left: 0.5rem; pointer-events: none; }
.item-links a:last-child::after, .item-links span.no-link:last-child::after { content: ""; }

.authors {
  font-size: 0.85em;
  color: var(--meta-color);
  margin-bottom: 0.2rem;
}
ul.theme-list-secondary .item-links a { color: var(--meta-color); }
ul.theme-list-secondary .date-badge { color: var(--secondary-text); }

.section-banner {
  width: 100%;
  height: 70px;
  background-size: cover;
  background-position: center;
  border-radius: 8px;
  margin: 1.5rem 0 1rem 0;
  opacity: 0.8;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* =========================================================
   BLOG INDEX
   ========================================================= */
.blog-intro {
  color: var(--meta-color);
  font-size: 0.95rem;
  margin-top: -0.4rem;
  margin-bottom: 2.5rem;
}

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

/* Year sits in the left margin as a gutter label, so the post titles
   form one continuous column down the page (reads as a timeline). */
.year-group { position: relative; margin-bottom: 1.6rem; }
.year-label {
  position: absolute;
  top: 0;
  left: -5.75rem;
  width: 4.5rem;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--secondary-text);
  font-variant-numeric: tabular-nums;
}

/* No room for a left gutter on narrow viewports — fall back to a quiet
   inline label above each group (still no divider rule). */
@media (max-width: 820px) {
  .year-group { margin-bottom: 2rem; }
  .year-label {
    position: static;
    width: auto;
    text-align: left;
    margin-bottom: 0.6rem;
  }
}

.post-list li { margin-bottom: 1.2rem; }
.post-list li:last-child { margin-bottom: 0; }

.post-date {
  display: block;
  font-size: 0.78rem;
  color: var(--meta-color);
  margin-bottom: 0.15rem;
  font-variant-numeric: tabular-nums;
}
.post-readtime { color: var(--secondary-text); margin-left: 0.9rem; }
.post-title {
  font-size: 1.12rem;
  font-weight: 600;
  color: var(--heading-color);
  line-height: 1.35;
}
.post-title:hover { color: var(--link-color); text-decoration: none; }
.post-excerpt {
  font-size: 0.9rem;
  color: var(--text-color);
  margin-top: 0.25rem;
  line-height: 1.5;
}
.post-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--secondary-text);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  margin-left: 0.5rem;
  vertical-align: middle;
}

/* =========================================================
   POST PAGE
   ========================================================= */
article.post { margin-top: 0.5rem; }

.post-header h1 { font-size: 1.9rem; line-height: 1.2; margin-bottom: 0.4rem; }
.post-header .post-meta {
  color: var(--meta-color);
  font-size: 0.85rem;
  margin-bottom: 2.2rem;
}
.post-header .post-meta a { color: var(--meta-color); }
.post-header .post-meta a:hover { color: var(--link-color); }

.post-body { font-size: 0.86rem; line-height: 1.7; }
.post-body h2 { font-size: 1.3rem; margin-top: 2.2rem; }
.post-body h3 { font-size: 1.05rem; margin-top: 1.6rem; }
.post-body ul, .post-body ol { padding-left: 2.1rem; margin-top: 0.3rem; margin-bottom: 1rem; }
.post-body li { margin-bottom: 0.15rem; }
/* tighten the gap between a lead-in paragraph and the list it introduces */
.post-body p:has(+ ul), .post-body p:has(+ ol) { margin-bottom: 0.3rem; }
.post-body li > ul, .post-body li > ol { margin-top: 0.15rem; }

/* figures / images */
.post-body figure { margin: 1.8rem auto; }   /* auto centers a width-constrained figure */
.post-body img {
  max-width: 100%;
  height: auto;
  display: block;
  margin-left: auto;    /* center the image when it's narrower than its container */
  margin-right: auto;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.post-body figcaption {
  font-size: 0.8rem;
  color: var(--meta-color);
  text-align: center;
  margin-top: 0.55rem;
}

/* side-by-side figures */
.figure-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin: 1.8rem 0;
}
.figure-row figure {
  margin: 0; /* overrides the default 1.8rem auto margin from .post-body figure */
  flex: 1;
}

/* blockquote */
.post-body blockquote {
  border-left: 3px solid var(--link-color);
  margin: 1.5rem 0;
  padding: 0.1rem 0 0.1rem 1rem;
  color: var(--meta-color);
  font-style: italic;
}
.post-body blockquote p:last-child { margin-bottom: 0; }

/* inline + block code */
.post-body code {
  font-family: "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  font-size: 0.86em;
  background: var(--code-inline-bg);
  padding: 0.12em 0.4em;
  border-radius: 4px;
}
.post-body pre {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 1.4rem 0;
  line-height: 1.5;
}
.post-body pre code {
  background: none;
  padding: 0;
  font-size: 0.70rem;
  color: var(--code-text);
}

/* highlight tiers — usage: <span class="hl">…</span> / hl-green / hl-red */
.hl, .hl-yellow { background: var(--hl-yellow); border-radius: 2px; padding: 0.02em 0.18em; }
.hl-green { background: var(--hl-green); border-radius: 2px; padding: 0.02em 0.18em; }
.hl-red   { background: var(--hl-red);   border-radius: 2px; padding: 0.02em 0.18em; }

/* text "figures": recreate screenshot-style question/context cards in HTML */
.text-fig {
  text-align: left;
  max-width: 400px;       /* smaller overall width */
  margin: 0 auto;         /* centered */
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  background: var(--code-bg);
  font-size: 0.7rem;      /* smaller text */
  line-height: 1.95;
}
.text-fig p { margin: 0.1rem 0; }
.text-fig .fig-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--secondary-text);
  line-height: 1.4;
  margin: 0.8rem 0 0.2rem;
}
.text-fig .fig-label:first-child { margin-top: 0; }
.chip {
  display: inline-block;
  padding: 0.0em 0.2em;
  border-radius: 2px;
  font-weight: 500;
  white-space: nowrap;
}
.chip-green  { background: #cdebd7; color: #1f6b3b; }
.chip-yellow { background: #fbf0bf; color: #7a5d12; }
.chip-blue   { background: #cfe0f5; color: #28567f; }
.chip-purple { background: #ded7f3; color: #56469b; }
.chip-red    { background: #f7d2ca; color: #a23a26; }
.chip-orange { background: #f8dcb4; color: #8f5413; }
.chip-pink   { background: #f6d2e3; color: #97356c; }

/* a "key takeaway" callout, optional */
.callout {
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--link-color);
  border-radius: 6px;
  background: var(--secondary-border);
  padding: 0.8rem 1rem;
  margin: 1.5rem 0;
  font-size: 0.92rem;
}
.callout .callout-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--secondary-text);
  margin-bottom: 0.3rem;
}

/* KaTeX sizing so display math doesn't overflow on mobile */
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.2rem 0; }

/* footer back-link */
.post-footer {
  margin-top: 3rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
}
.post-footer a { color: var(--meta-color); }
.post-footer a:hover { color: var(--link-color); }
