/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg:        #ffffff;
  --bg-alt:    #f5f5f5;
  --fg:        #1a1a1a;
  --fg-muted:  #555555;
  --accent:    #0057b8;
  --accent-h:  #003d82;
  --border:    #dddddd;
  --max-w:     860px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:        #0d1117;
    --bg-alt:    #161b22;
    --fg:        #e6edf3;
    --fg-muted:  #8b949e;
    --accent:    #58a6ff;
    --accent-h:  #79c0ff;
    --border:    #30363d;
  }
}

[data-theme="light"] {
  --bg:        #ffffff;
  --bg-alt:    #f5f5f5;
  --fg:        #1a1a1a;
  --fg-muted:  #555555;
  --accent:    #0057b8;
  --accent-h:  #003d82;
  --border:    #dddddd;
}

[data-theme="dark"] {
  --bg:        #0d1117;
  --bg-alt:    #161b22;
  --fg:        #e6edf3;
  --fg-muted:  #8b949e;
  --accent:    #58a6ff;
  --accent-h:  #79c0ff;
  --border:    #30363d;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.7;
  margin: 0;
  padding: 0;
}

/* ── Layout ────────────────────────────────────────────────── */
header, main, footer {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 1.25rem;
}

header {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  padding-top: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

#theme-toggle {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--fg-muted);
  padding: 0.2em 0.55em;
  line-height: 1;
  flex-shrink: 0;
}

#theme-toggle:hover { color: var(--fg); border-color: var(--fg-muted); }

header a.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.headshot {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }

nav a {
  text-decoration: none;
  color: var(--fg-muted);
  font-size: 0.95rem;
}

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

main { padding-top: 1.5rem; padding-bottom: 3rem; }

footer {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  padding-bottom: 2rem;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
}

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

.footer-social {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.footer-social a {
  display: flex;
  align-items: center;
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-social a:hover { color: var(--accent); }

.footer-social svg {
  width: 1.2rem;
  height: 1.2rem;
}

/* ── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4 {
  line-height: 1.25;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

h1 { font-size: 2rem; margin-top: 0; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p { margin: 0 0 1rem; }

article img { max-width: 100%; height: auto; }

a { color: var(--accent); }
a:hover { color: var(--accent-h); }

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1.25rem;
  border-left: 3px solid var(--accent);
  background: var(--bg-alt);
  color: var(--fg-muted);
}

blockquote p:last-child { margin-bottom: 0; }

code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.875em;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.15em 0.4em;
}

pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.5;
}

pre code { background: none; border: none; padding: 0; font-size: 0.875rem; }

/* ── Post list ─────────────────────────────────────────────── */
.post-list { list-style: none; padding: 0; margin: 0; }

.post-list li {
  display: flex;
  gap: 1.5rem;
  align-items: baseline;
  padding: 0.25rem 0;
}

.post-list time {
  font-size: 0.85rem;
  color: var(--fg-muted);
  white-space: nowrap;
  min-width: 6rem;
}

.post-list a { text-decoration: none; font-weight: 500; }
.post-list a:hover { text-decoration: underline; }

/* ── Post year heading ─────────────────────────────────────── */
.post-year-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 2rem 0 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

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

/* ── Post metadata ─────────────────────────────────────────── */
.post-meta {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-bottom: 2rem;
}

/* ── Presentation list ─────────────────────────────────────── */
.pres-list { list-style: none; padding: 0; margin: 0; }

.pres-list li {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.pres-list li:first-child { border-top: 1px solid var(--border); }

.pres-list .pres-title { font-weight: 600; font-size: 1.05rem; }
.pres-list .pres-meta  { font-size: 0.85rem; color: var(--fg-muted); margin-top: 0.2rem; }

.btn {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.35em 0.9em;
  border: 1px solid var(--accent);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}

.btn:hover {
  background: var(--accent);
  color: var(--bg);
}

/* ── Presentation detail ────────────────────────────────────── */
.pres-description {
  color: var(--fg-muted);
  margin-bottom: 1.25rem;
}

.yt-embed {
  position: relative;
  margin-top: 5rem;
  aspect-ratio: 16 / 9;
}

.yt-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* ── PDF viewer ─────────────────────────────────────────────── */
.pdf-viewer-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 1.5rem 0 1rem;
  overflow: hidden;
}

#pdf-canvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: pointer;
}

.slide-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--bg-alt);
  border-top: 1px solid var(--border);
}

.slide-btn-group {
  display: flex;
  gap: 0.4rem;
}

.slide-btn {
  padding: 0.35em 0.9em;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: none;
  font-size: 0.85rem;
  color: var(--accent);
  cursor: pointer;
  line-height: 1;
  text-decoration: none;
}

.slide-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--bg);
}

.slide-btn:disabled {
  border-color: var(--border);
  color: var(--fg-muted);
  cursor: default;
}

.slide-counter {
  font-size: 0.85rem;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Presentation card grid ────────────────────────────────── */
.pres-year { margin-bottom: 2.5rem; }

.pres-year-heading {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.pres-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

@media (max-width: 600px) {
  .pres-grid { grid-template-columns: 1fr; }
}

@media (min-width: 601px) and (max-width: 820px) {
  .pres-grid { grid-template-columns: repeat(2, 1fr); }
}

.pres-card {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: var(--bg);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.pres-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.pres-card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-alt);
}

.pres-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.pres-card-img--placeholder {
  width: 100%;
  height: 100%;
  background: var(--bg-alt);
}

.pres-card-tooltip {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 0.8rem;
  line-height: 1.55;
  padding: 0.75rem 0.85rem;
  opacity: 0;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.pres-card:hover .pres-card-tooltip { opacity: 1; }

.pres-card-body {
  padding: 0.65rem 0.85rem 0.75rem;
  flex: 1;
}

.pres-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.35;
  margin-bottom: 0.3rem;
  color: var(--fg);
}

.pres-card-meta {
  font-size: 0.78rem;
  color: var(--fg-muted);
}

/* ── Table of Contents (blog single posts) ─────────────────── */
.post-toc {
  position: fixed;
  left: calc(50% + var(--max-w) / 2 + 1.5rem);
  top: 5rem;
  width: 13rem;
  max-height: calc(100vh - 7rem);
  overflow-y: auto;
  font-size: 0.82rem;
  line-height: 1.45;
}

.post-toc-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 0.5rem;
  color: var(--fg-muted);
}

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

.post-toc ul ul {
  padding-left: 0.85rem;
}

.post-toc li { margin: 0.2rem 0; }

.post-toc a {
  color: var(--fg-muted);
  text-decoration: none;
}

.post-toc a:hover { color: var(--accent); }

.post-toc a.toc-active { color: var(--accent); }

.post-toc-top {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.post-toc-top svg {
  width: 0.85rem;
  height: 0.85rem;
  fill: currentColor;
}

/* Hide when viewport is too narrow to show TOC alongside content */
@media (max-width: 1080px) {
  .post-toc { display: none; }
}

/* ── Presentation abstract (below slideshow) ───────────────── */
.post-abstract {
  font-size: 0.95rem;
  color: var(--fg-muted);
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
  margin-top: 0.5rem;
}
