/* ===== CSS Custom Properties ===== */
:root {
  --color-bg: #ffffff;
  --color-text: #1a1a1a;
  --color-text-muted: #666666;
  --color-link: #0066cc;
  --color-link-hover: #004499;
  --color-border: #e0e0e0;
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, monospace;
  --max-width: 700px;
  --spacing: 1.5rem;
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ===== Layout ===== */
header, main, footer {
  padding: var(--spacing);
  max-width: var(--max-width);
  margin: 0 auto;
}

main {
  min-height: calc(100vh - 200px);
}

/* ===== Navigation (Mobile First) ===== */
nav {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

nav .site-title {
  font-weight: 600;
  font-size: 1.25rem;
  text-decoration: none;
  color: var(--color-text);
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
}

nav a {
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 0.25rem 0;
}

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

/* Desktop navigation */
@media (min-width: 600px) {
  nav {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* ===== Typography ===== */
h1, h2, h3 {
  line-height: 1.3;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

h1 {
  font-size: clamp(1.75rem, 1.5rem + 1vw, 2.25rem);
  margin-top: 0;
}

h2 {
  font-size: clamp(1.35rem, 1.2rem + 0.75vw, 1.75rem);
}

h3 {
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
}

p {
  margin: 0 0 1rem;
}

/* ===== Links ===== */
a {
  color: var(--color-link);
}

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

/* ===== Images ===== */
img {
  max-width: 100%;
  height: auto;
}

/* ===== Code ===== */
code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: #f5f5f5;
  padding: 0.15em 0.35em;
  border-radius: 3px;
}

pre {
  background: #f5f5f5;
  padding: 1rem;
  overflow-x: auto;
  border-radius: 4px;
}

pre code {
  background: none;
  padding: 0;
}

/* ===== Footer ===== */
footer {
  border-top: 1px solid var(--color-border);
  margin-top: 3rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* ===== Publications ===== */
.publication {
  margin-bottom: 1.5rem;
}

.publication a {
  font-size: 0.9em;
}

.year-divider {
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--color-border);
  font-size: 1.25rem;
}

.year-divider:first-of-type {
  margin-top: 0;
}

/* ===== Course List ===== */
.course-list {
  list-style: none;
  padding: 0;
}

.course-list li {
  margin-bottom: 1rem;
}

.course-list a {
  text-decoration: none;
}

.course-list a:hover strong {
  text-decoration: underline;
}

/* ===== Tables ===== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95em;
}

th, td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  font-weight: 600;
  background: #f9f9f9;
}

/* Responsive tables */
@media (max-width: 600px) {
  table {
    font-size: 0.85em;
  }

  th, td {
    padding: 0.4rem 0.5rem;
  }
}

/* ===== Blog Post List ===== */
.post-list {
  list-style: none;
  padding: 0;
}

.post-list li {
  margin-bottom: 0.75rem;
}

.post-date {
  display: inline-block;
  min-width: 6rem;
  font-size: 0.9em;
}

/* ===== Blog Post Page ===== */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.post-header h1 {
  margin-bottom: 0.5rem;
}

.post-header time {
  color: var(--color-text-muted);
  font-size: 0.95em;
}

.post-content img {
  margin: 1.5rem 0;
  border-radius: 4px;
}

.post-content blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 0 0.5rem 1.25rem;
  border-left: 3px solid var(--color-border);
  color: var(--color-text-muted);
  font-style: italic;
}

/* ===== Syntax Highlighting (Prism-inspired) ===== */
.highlight-line {
  display: inline-block;
  width: 100%;
}

code[class*="language-"],
pre[class*="language-"] {
  color: #1a1a1a;
  background: #f5f5f5;
  font-family: var(--font-mono);
  font-size: 0.9em;
  text-align: left;
  white-space: pre;
  word-spacing: normal;
  word-break: normal;
  word-wrap: normal;
  line-height: 1.5;
  tab-size: 2;
}

pre[class*="language-"] {
  padding: 1rem;
  overflow: auto;
  border-radius: 4px;
}

/* Tokens */
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #6a737d;
}

.token.punctuation {
  color: #24292e;
}

.token.property,
.token.tag,
.token.boolean,
.token.number,
.token.constant,
.token.symbol,
.token.deleted {
  color: #005cc5;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #22863a;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
  color: #d73a49;
}

.token.atrule,
.token.attr-value,
.token.keyword {
  color: #d73a49;
}

.token.function,
.token.class-name {
  color: #6f42c1;
}

.token.regex,
.token.important,
.token.variable {
  color: #e36209;
}

/* ===== Projects ===== */
.project-grid {
  display: grid;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.project-card {
  padding: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.project-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

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

.project-card h3 a:hover {
  color: var(--color-link);
}

.project-card p {
  margin: 0 0 0.75rem;
  font-size: 0.95em;
}

.project-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.status {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  font-size: 0.8em;
  border-radius: 3px;
  font-weight: 500;
}

.status-active {
  background: #e6f4ea;
  color: #1e7e34;
}

.status-completed {
  background: #e8eaed;
  color: #5f6368;
}

.status-seeking {
  background: #fef7e0;
  color: #b06000;
}

/* ===== Utilities ===== */
.muted {
  color: var(--color-text-muted);
}

/* ===== Theme Switcher ===== */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.theme-switcher label {
  font-size: 0.85em;
  color: var(--color-text-muted);
}

.theme-switcher select {
  font-size: 0.85em;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
}

/* ===== THEME: LaTeX/Academic ===== */
html.theme-latex {
  --color-bg: #fffff8;
  --color-text: #111111;
  --color-text-muted: #555555;
  --color-link: #a00000;
  --color-link-hover: #700000;
  --color-border: #cccccc;
  --font-sans: 'Crimson Pro', 'Georgia', 'Times New Roman', serif;
  --font-mono: 'CMU Typewriter Text', 'Courier New', monospace;
}

html.theme-latex body {
  font-family: var(--font-sans);
  font-size: clamp(1.05rem, 1rem + 0.25vw, 1.2rem);
}

html.theme-latex h1,
html.theme-latex h2,
html.theme-latex h3 {
  font-weight: 600;
}

html.theme-latex nav .site-title {
  font-variant: small-caps;
  letter-spacing: 0.05em;
}

html.theme-latex hr {
  border: none;
  border-top: 1px solid #999;
  margin: 2rem 0;
}

html.theme-latex blockquote {
  border-left-color: #999;
  font-style: italic;
}

/* ===== THEME: Minimal Classic ===== */
html.theme-minimal {
  --color-bg: #ffffff;
  --color-text: #000000;
  --color-text-muted: #555555;
  --color-link: #0000ee;
  --color-link-hover: #551a8b;
  --color-border: #cccccc;
  --font-sans: serif;
  --font-mono: monospace;
}

html.theme-minimal body {
  font-family: serif;
  font-size: 1rem;
}

html.theme-minimal nav .site-title {
  background: #eeeeee;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
}

html.theme-minimal nav a {
  background: #eeeeee;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
}

html.theme-minimal nav a:hover {
  background: #dddddd;
}

html.theme-minimal hr {
  border-style: dashed;
  border-color: #dddddd;
}

html.theme-minimal footer {
  border-top-style: dashed;
}

html.theme-minimal pre {
  border: 1px solid #dddddd;
  box-shadow: 5px 5px 5px #eeeeee;
  border-radius: 0;
}

html.theme-minimal blockquote {
  background: #f9f9f9;
  border-left: 5px solid #cccccc;
}

html.theme-minimal .project-card {
  border-radius: 0;
}

/* ===== THEME: Retro Terminal ===== */
html.theme-terminal {
  --color-bg: #0d1117;
  --color-text: #c9d1d9;
  --color-text-muted: #8b949e;
  --color-link: #58a6ff;
  --color-link-hover: #79c0ff;
  --color-border: #30363d;
  --font-sans: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Consolas', monospace;
}

html.theme-terminal body {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  background: var(--color-bg);
}

html.theme-terminal nav .site-title {
  color: #7ee787;
}

html.theme-terminal h1,
html.theme-terminal h2,
html.theme-terminal h3 {
  color: #7ee787;
}

html.theme-terminal a {
  color: #58a6ff;
}

html.theme-terminal a:hover {
  color: #79c0ff;
  text-shadow: 0 0 8px rgba(88, 166, 255, 0.5);
}

html.theme-terminal pre,
html.theme-terminal code {
  background: #161b22;
  border: 1px solid #30363d;
}

html.theme-terminal .post-header {
  border-bottom-color: #30363d;
}

html.theme-terminal footer {
  border-top-color: #30363d;
}

html.theme-terminal blockquote {
  border-left-color: #7ee787;
  background: #161b22;
  color: #8b949e;
}

html.theme-terminal .project-card {
  background: #161b22;
  border-color: #30363d;
}

html.theme-terminal .status-active {
  background: #238636;
  color: #ffffff;
}

html.theme-terminal .theme-switcher select {
  background: #161b22;
  border-color: #30363d;
  color: #c9d1d9;
}

/* ===== THEME: Warm & Personal ===== */
html.theme-warm {
  --color-bg: #fefaf6;
  --color-text: #3d3229;
  --color-text-muted: #6b5d4d;
  --color-link: #b85c38;
  --color-link-hover: #8b4513;
  --color-border: #e0d5c8;
  --font-sans: 'Nunito', 'Segoe UI', sans-serif;
  --font-mono: 'Source Code Pro', monospace;
}

html.theme-warm body {
  font-family: var(--font-sans);
}

html.theme-warm nav .site-title {
  color: #5c4033;
}

html.theme-warm h1,
html.theme-warm h2,
html.theme-warm h3 {
  color: #5c4033;
}

html.theme-warm a {
  color: #b85c38;
}

html.theme-warm a:hover {
  color: #8b4513;
}

html.theme-warm pre,
html.theme-warm code {
  background: #f5ede4;
  border: none;
}

html.theme-warm blockquote {
  background: #f5ede4;
  border-left-color: #b85c38;
}

html.theme-warm footer {
  border-top-color: #e0d5c8;
}

html.theme-warm .project-card {
  background: #fffcf8;
  border-color: #e0d5c8;
  box-shadow: 0 2px 8px rgba(92, 64, 51, 0.08);
}

html.theme-warm .status-active {
  background: #d4edda;
  color: #155724;
}

html.theme-warm .post-header {
  border-bottom-color: #e0d5c8;
}
