/* ── Theme variables ─────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg:        #0a0a0a;
  --surface:   #111111;
  --surface2:  #161616;
  --border:    #1e1e1e;
  --border-h:  #383838;
  --text:      #d0d0d0;
  --muted:     #555555;
  --accent:    #cc2222;
  --sidebar-w: 240px;
  --topbar-h:  52px;
}

[data-theme="light"] {
  --bg:       #f4f4f4;
  --surface:  #ffffff;
  --surface2: #efefef;
  --border:   #dddddd;
  --border-h: #bbbbbb;
  --text:     #1a1a1a;
  --muted:    #888888;
  --accent:   #bb1111;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

a               { color: var(--accent); text-decoration: none; }
a:visited       { color: var(--accent); }
a:hover         { color: var(--text); }

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 32px 0 24px;
  overflow-y: auto;
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  padding: 0 24px 28px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.sidebar-brand h1 {
  font-size: 1rem;
  font-weight: 600;
  color: #f0f0f0;
  letter-spacing: -0.2px;
}

[data-theme="light"] .sidebar-brand h1 { color: #1a1a1a; }

.sidebar-brand .tagline {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.68rem;
  color: var(--muted);
  margin-top: 5px;
  line-height: 1.5;
  letter-spacing: 0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 0 16px;
}

.sidebar-nav .nav-section {
  margin-bottom: 20px;
}

.sidebar-nav .nav-label {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.6rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px;
  margin-bottom: 6px;
}

.sidebar-nav a {
  display: block;
  padding: 6px 8px;
  font-size: 0.82rem;
  color: var(--text);
  border-radius: 3px;
  transition: background 0.12s, color 0.12s;
}

.sidebar-nav a:hover {
  background: var(--surface2);
  color: var(--accent);
}

.sidebar-footer {
  padding: 20px 24px 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer a {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.72rem;
  color: var(--muted);
}

.sidebar-footer a:hover { color: var(--text); }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  padding: 5px 10px;
  cursor: pointer;
  margin-top: 4px;
  transition: border-color 0.15s, color 0.15s;
  text-align: left;
}

.theme-toggle:hover { border-color: var(--border-h); color: var(--text); }

/* ── Mobile topbar ───────────────────────────────────────────── */
.topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  z-index: 300;
  gap: 14px;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  transition: background 0.15s;
}

.topbar-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f0f0f0;
  flex: 1;
}

[data-theme="light"] .topbar-title { color: #1a1a1a; }

.topbar .theme-toggle { margin-top: 0; }

/* Overlay when sidebar open on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 190;
}

body.sidebar-open .sidebar-overlay { display: block; }
body.sidebar-open .sidebar { transform: translateX(0) !important; }

/* ── Main content area ───────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  max-width: 1250px;
  width: 100%;
  padding: 52px 32px 48px;
}

/* ── Section heading ─────────────────────────────────────────── */
section { margin-bottom: 56px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.section-head h2 {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  font-weight: normal;
}

.section-head::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Card grid ───────────────────────────────────────────────── */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

/* Base card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  padding: 20px 20px 16px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.18s, transform 0.18s;
}

.card:hover {
  border-color: var(--border-h);
  border-top-color: var(--accent);
  transform: translateY(-2px);
}

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: #e8e8e8;
  line-height: 1.45;
  margin-bottom: 10px;
}

[data-theme="light"] .card-title { color: #111111; }

.card-desc {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.65;
  flex: 1;
}

.card-links {
  margin-top: 16px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.card-links a {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.7rem;
  padding: 3px 10px;
  border: 1px solid var(--border);
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}

.card-links a:hover { color: var(--text); border-color: var(--border-h); }

/* ── Image card ──────────────────────────────────────────────── */
.card.img-card {
  padding: 0;
  overflow: hidden;
  border-top: none;
  border: 1px solid var(--border);
  position: relative;
  height: 200px;
  background-color: #0a0a0a;
  background-image: linear-gradient(
    to bottom,
    transparent 20%,
    rgba(0,0,0,0.55) 55%,
    rgba(0,0,0,0.88) 100%
  ), var(--thumb);
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center top;
}

.card.img-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-h);
}

.card.img-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-top: 2px solid var(--accent);
  pointer-events: none;
}

.img-card-body {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 16px 14px;
}

.img-card-body .card-title {
  color: #f0f0f0;
  text-shadow:
    0 1px 3px rgba(0,0,0,0.9),
    0 2px 8px rgba(0,0,0,0.7);
  font-size: 0.88rem;
  margin-bottom: 6px;
}

.img-card-body .card-desc {
  color: rgba(220,220,220,0.82);
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  font-size: 0.73rem;
  line-height: 1.5;
}

.img-card-body .card-links {
  margin-top: 10px;
}

.img-card-body .card-links a {
  background: rgba(0,0,0,0.55);
  border-color: rgba(255,255,255,0.15);
  color: rgba(210,210,210,0.85);
  backdrop-filter: blur(4px);
}

.img-card-body .card-links a:hover {
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}

/* ── Publication cards ───────────────────────────────────────── */
.pub-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card.pub {
  width: 100%;
  flex-direction: row;
  align-items: flex-start;
  gap: 20px;
  padding: 14px 20px;
}

.pub-year {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 4px;
  min-width: 52px;
}

.pub-body { flex: 1; }

.pub-venue {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  color: var(--accent);
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.pub-doi {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.65rem;
  color: var(--muted);
  margin-top: 6px;
}

.pub-doi a { color: var(--muted); }
.pub-doi a:hover { color: var(--text); }

/* ── Footer ──────────────────────────────────────────────────── */
footer {
  padding: 20px 32px;
  border-top: 1px solid var(--border);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.72rem;
  color: var(--muted);
}

footer a { color: var(--muted); }
footer a:hover { color: var(--text); }

/* ── Prose styles (for project write-up pages) ───────────────── */
.prose { max-width: 720px; }

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  color: #e8e8e8;
  line-height: 1.3;
  margin-top: 2em;
  margin-bottom: 0.6em;
}

[data-theme="light"] .prose h1,
[data-theme="light"] .prose h2,
[data-theme="light"] .prose h3,
[data-theme="light"] .prose h4 { color: #111; }

.prose h1 { font-size: 1.6rem; margin-top: 0; }
.prose h2 { font-size: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.prose h3 { font-size: 1rem; }
.prose h4 { font-size: 0.9rem; color: var(--muted); }

.prose p { margin-bottom: 1em; }

.prose ul, .prose ol {
  margin: 0 0 1em 1.4em;
}

.prose li { margin-bottom: 0.3em; }

.prose pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 14px 16px;
  overflow-x: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.8rem;
  line-height: 1.55;
  margin-bottom: 1em;
}

.prose code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.83em;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 1px 5px;
}

.prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

.prose img {
  max-width: 100%;
  display: block;
  margin: 1.2em 0;
  border: 1px solid var(--border);
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1em;
  font-size: 0.85rem;
}

.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 7px 12px;
  text-align: left;
}

.prose th { background: var(--surface2); color: var(--text); }

.prose blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 1em;
  padding: 6px 16px;
  color: var(--muted);
  font-style: italic;
}

.prose a { color: var(--accent); }
.prose a:hover { color: var(--text); }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .topbar { display: flex; }

  .main-wrap {
    margin-left: 0;
    padding-top: var(--topbar-h);
  }

  main { padding: 32px 20px 40px; }

  .cards { grid-template-columns: 1fr 1fr; }

  .card.img-card { height: 190px; }

  .card.pub { flex-direction: column; gap: 4px; }
  .pub-year  { min-width: unset; }

  footer { padding: 16px 20px; }
}
