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

/* ─── Design Tokens (Light) ───────────────────────────── */
:root {
  --bg: #ffffff;
  --bg-secondary: #f8f8f8;
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-muted: #888;
  --border: #e0e0e0;
  --accent: #2563eb;
  --code-bg: #f5f5f5;
  --code-border: #e5e5e5;

  --font-body: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-heading: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "Roboto Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;

  --content-width: 700px;
}

/* ─── Dark Theme ──────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --bg: #161616;
    --bg-secondary: #1e1e1e;
    --text: #e0e0e0;
    --text-secondary: #aaa;
    --text-muted: #777;
    --border: #2a2a2a;
    --accent: #6b9eff;
    --code-bg: #1e1e1e;
    --code-border: #333;
  }
}

.dark {
  --bg: #161616;
  --bg-secondary: #1e1e1e;
  --text: #e0e0e0;
  --text-secondary: #aaa;
  --text-muted: #777;
  --border: #2a2a2a;
  --accent: #6b9eff;
  --code-bg: #1e1e1e;
  --code-border: #333;
}

/* ─── Reset ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 300;
  line-height: 1.75;
  min-height: 100vh;
  transition: background 0.2s, color 0.2s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

/* ─── Layout ──────────────────────────────────────────── */
.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ─── Header / Nav ────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-bottom: 3rem;
}
header .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.site-name {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.site-name:hover { text-decoration: none; color: var(--text); }

nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
nav a {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--text-secondary);
}
nav a:hover { color: var(--text); text-decoration: none; }

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  color: var(--text-secondary);
  transition: border-color 0.2s;
}
.theme-toggle:hover { border-color: var(--text-muted); }

/* ─── Main content ────────────────────────────────────── */
main {
  padding-bottom: 4rem;
}

/* ─── Homepage ────────────────────────────────────────── */
.bio {
  margin-bottom: 3rem;
}
.bio h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}
.bio p {
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 0.75rem;
}
.bio p:last-child {
  margin-bottom: 0;
}

/* ─── Post List ───────────────────────────────────────── */
.posts-section + .posts-section {
  margin-top: 3rem;
}
.posts-section h2 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.post-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.post-item {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
}
.post-date {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 90px;
}
.post-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 500;
}
.post-title a {
  color: var(--text);
}
.post-title a:hover {
  color: var(--accent);
}

/* ─── Article ─────────────────────────────────────────── */
.article-header {
  margin-bottom: 2.5rem;
}
.article-back {
  font-family: var(--font-heading);
  font-size: 0.9rem;
  color: var(--text-muted);
  display: inline-block;
  margin-bottom: 2rem;
}
.article-back:hover { color: var(--accent); }

.article-header h1 {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
  color: var(--text);
}
.article-meta {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ─── Article Body ────────────────────────────────────── */
.article-body h2 {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2.5rem 0 0.75rem;
  color: var(--text);
}
.article-body h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 0.5rem;
  color: var(--text);
}
.article-body p {
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
}
.article-body strong {
  color: var(--text);
  font-weight: 600;
}
.article-body em {
  font-style: italic;
}
.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Lists */
.article-body ul, .article-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
  color: var(--text-secondary);
}
.article-body li {
  margin-bottom: 0.35rem;
}
.article-body li strong {
  color: var(--text);
}

/* Code */
.article-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 0.15em 0.4em;
  border-radius: 3px;
  color: var(--text);
}
.article-body pre {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 1.25rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  line-height: 1.6;
}
.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
}

/* Blockquote */
.article-body blockquote {
  border-left: 3px solid var(--border);
  padding: 0.25rem 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

/* ─── Figures & Media ─────────────────────────────────── */
.article-body figure {
  margin: 1.5rem 0;
}
.article-body figure img {
  border: 1px solid var(--border);
  border-radius: 6px;
}
.article-body figcaption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  text-align: center;
}

.article-body audio {
  width: 100%;
  margin: 0.5rem 0;
}

/* Spectrogram grid: 2x2 table */
.spec-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}
.spec-grid figure {
  margin: 0;
}
.spec-grid img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 4px;
}
.spec-grid figcaption {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  text-align: center;
}

.sample-block {
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.sample-block h4 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: var(--text);
}

/* ─── Publications ────────────────────────────────────── */
.pub-list {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}
.pub-item {
  padding-bottom: 1.75rem;
  border-bottom: 1px solid var(--border);
}
.pub-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}
.pub-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.pub-title a { color: var(--text); }
.pub-title a:hover { color: var(--accent); }
.pub-authors {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.3rem;
}
.pub-venue {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.pub-links {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.pub-links a {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}
.pub-links a:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

/* ─── PDF Embed ───────────────────────────────────────── */
.pdf-embed {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.pdf-embed object {
  display: block;
}

/* ─── Footer ──────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  margin-top: 2rem;
}
footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.footer-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.footer-links {
  display: flex;
  gap: 1.25rem;
}
.footer-links a {
  font-size: 0.82rem;
  color: var(--text-muted);
}
.footer-links a:hover {
  color: var(--accent);
}

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .post-item { flex-direction: column; gap: 0.15rem; }
  .post-date { min-width: auto; }
  .article-header h1 { font-size: 1.5rem; }
  footer .container { flex-direction: column; align-items: flex-start; }
}
