@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg-primary:     #0a0e14;
  --bg-secondary:   #111820;
  --bg-tertiary:    #1a2332;
  --border:         #1e2d42;
  --text-primary:   #e8edf4;
  --text-secondary: #7a90a8;
  --text-muted:     #66839e;
  --accent-blue:    #4a9eff;
  --accent-blue-hover: #6ab4ff;
  --accent-green:   #2ecc71;
  --accent-red:     #ec6557;
  --accent-yellow:  #f39c12;
  --mono-light:     #8be9fd;
  --nav-bg:         rgba(10, 14, 20, 0.92);

  --font-body: 'Inter', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;

  --text-xs:   0.70rem;
  --text-sm:   0.85rem;
  --text-base: 1.00rem;
  --text-lg:   1.15rem;
  --text-xl:   1.40rem;
  --text-2xl:  2.00rem;
  --text-3xl:  3.20rem;

  --max-width:    1100px;
  --section-gap:  120px;
  --card-pad:     28px;
  --border-radius: 6px;
}

html[data-theme="light"] {
  --bg-primary:     #f5f7fa;
  --bg-secondary:   #ffffff;
  --bg-tertiary:    #eaeef3;
  --border:         #c9d2dc;
  --text-primary:   #101720;
  --text-secondary: #51606f;
  --text-muted:     #65727f;
  --accent-blue:    #1d5fc7;
  --accent-blue-hover: #174ea3;
  --accent-green:   #15803d;
  --accent-red:     #b91c1c;
  --accent-yellow:  #8f5a09;
  --nav-bg:         rgba(255, 255, 255, 0.9);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background 0.2s, color 0.2s;
}

/* ── TICKER BAR ─────────────────────────────────────────────────── */
#ticker-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  z-index: 1000;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  overflow: hidden;
}

.ticker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
}

.ticker-label {
  color: var(--text-muted);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ticker-value { color: var(--text-primary); }
.ticker-value.up   { color: var(--accent-green); }
.ticker-value.down { color: var(--accent-red); }
.ticker-value.muted { color: var(--text-muted); }

.ticker-sep {
  color: var(--border);
  font-size: var(--text-xs);
  user-select: none;
}

.ticker-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

.ticker-dot.offline { background: var(--text-muted); animation: none; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── NAV ─────────────────────────────────────────────────────────── */
#main-nav {
  position: fixed;
  top: 32px;
  left: 0;
  right: 0;
  z-index: 999;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 40px;
}

.nav-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--accent-blue);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 32px;
  list-style: none;
}

.nav-links a {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active { color: var(--text-primary); }

.nav-live {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--accent-green) !important;
  letter-spacing: 0.03em;
}

.nav-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse 2s ease-in-out infinite;
}

.nav-resume {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--accent-blue) !important;
  border: 1px solid var(--accent-blue);
  padding: 6px 14px;
  border-radius: var(--border-radius);
  text-decoration: none;
  transition: background 0.2s, color 0.2s !important;
  letter-spacing: 0.03em;
}

.nav-resume:hover {
  background: var(--accent-blue) !important;
  color: var(--bg-primary) !important;
}

.theme-toggle {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.theme-toggle-track {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: var(--bg-tertiary);
  border: 1px solid #ffffff;
  transition: border-color 0.2s;
}

html[data-theme="light"] .theme-toggle-track { border-color: #000000; }

.theme-toggle-thumb {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-blue);
  transition: transform 0.2s, background 0.2s;
}

html[data-theme="light"] .theme-toggle-thumb {
  transform: translateX(16px);
  background: #f39c12;
}

/* ── LAYOUT ──────────────────────────────────────────────────────── */
main {
  padding-top: 88px; /* ticker 32 + nav 56 */
}

section {
  padding: var(--section-gap) 40px;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
}

/* ── SECTION HEADERS ─────────────────────────────────────────────── */
.section-label {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-blue);
  margin-bottom: 40px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  max-width: 200px;
}

/* ── HERO ────────────────────────────────────────────────────────── */
#hero {
  min-height: calc(100vh - 88px);
  display: flex;
  align-items: center;
  padding-top: 60px;
  padding-bottom: 60px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 80px;
  align-items: center;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--accent-blue);
  text-transform: uppercase;
  margin-bottom: 24px;
}

.hero-eyebrow span { white-space: nowrap; }

.hero-title {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 300;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 24px;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.hero-body {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 36px;
  max-width: 520px;
}

.hero-ctas {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--border-radius);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

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

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-outline:hover { border-color: var(--text-secondary); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding-left: 0;
}
.btn-ghost:hover { color: var(--text-primary); }

.hero-chart-panel {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 20px;
}

.hero-chart-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.hero-chart-label span {
  color: var(--accent-blue);
}

.hero-chart-wrap {
  position: relative;
  height: 200px;
}

/* ── THESIS BLOCK ────────────────────────────────────────────────── */
#thesis {
  padding-top: 0;
  padding-bottom: var(--section-gap);
}

.thesis-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.thesis-cell {
  padding: var(--card-pad);
  background: var(--bg-secondary);
}

.thesis-cell:not(:last-child) {
  border-right: 1px solid var(--border);
}

.thesis-cell-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-blue);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.thesis-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.thesis-items li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding-left: 12px;
  border-left: 2px solid var(--border);
}

/* ── PROJECTS ────────────────────────────────────────────────────── */
.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 40px;
}

.filter-bar {
  display: flex;
  gap: 8px;
}

.filter-btn {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}

.filter-btn.active,
.filter-btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  background: rgba(74, 158, 255, 0.08);
}

.projects-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.project-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--card-pad);
  transition: border-color 0.2s;
}

.project-card:hover { border-color: var(--bg-tertiary); }

.project-card.hidden { display: none; }

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-blue);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.card-tech-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tech-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  letter-spacing: 0.04em;
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.card-subtitle {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.card-thesis {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 20px;
}

.card-chart-container {
  margin-bottom: 20px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: 16px;
  position: relative;
  height: 180px;
}

.card-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.metrics-col-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.metrics-col-label.results  { color: var(--accent-green); }
.metrics-col-label.breaks   { color: var(--accent-red); }

.metric-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  margin-bottom: 6px;
}

.metric-key   { color: var(--text-secondary); }
.metric-value { color: var(--text-primary); }
.metric-value.negative { color: var(--accent-red); }
.metric-value.positive { color: var(--accent-green); }

.breaks-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.breaks-list li {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  padding-left: 12px;
  position: relative;
}

.breaks-list li::before {
  content: '●';
  position: absolute;
  left: 0;
  color: var(--accent-red);
  font-size: 0.5rem;
  top: 2px;
}

/* ── FORMULA BLOCK ───────────────────────────────────────────────── */
.formula-block {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-bottom: 16px;
}

.formula-toggle {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  letter-spacing: 0.05em;
  transition: color 0.2s;
}

.formula-toggle:hover { color: var(--accent-blue); }

.formula-content {
  margin-top: 14px;
  padding: 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  overflow-x: auto;
}

.formula-content p {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-family: var(--font-mono);
}

.katex { color: var(--text-primary); }

/* ── CARD LINKS ──────────────────────────────────────────────────── */
.card-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.card-link {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-blue);
  text-decoration: none;
  letter-spacing: 0.05em;
  transition: opacity 0.2s;
}

.card-link:hover { opacity: 0.75; }

.card-link.disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  pointer-events: none;
}

/* ── EXPERIENCE TIMELINE ─────────────────────────────────────────── */
.timeline {
  position: relative;
  padding-left: 32px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 48px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -36px;
  top: 6px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-blue);
  border: 2px solid var(--bg-primary);
}

.timeline-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.timeline-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.timeline-org {
  font-size: var(--text-sm);
  color: var(--accent-blue);
  margin-bottom: 10px;
}

.timeline-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.timeline-bullets li {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
}

.timeline-bullets li::before {
  content: '·';
  position: absolute;
  left: 0;
  color: var(--text-muted);
}

/* ── WRITING ─────────────────────────────────────────────────────── */
.writing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.writing-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--border-radius);
  padding: var(--card-pad);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.2s;
}

.writing-card:hover { border-color: var(--text-muted); }

.writing-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.writing-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.4;
}

.writing-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.55;
  flex: 1;
}

.writing-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: auto;
}

.writing-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--accent-blue);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.writing-cta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent-blue);
  letter-spacing: 0.05em;
}

.writing-card.pending {
  opacity: 0.75;
  pointer-events: none;
}

.writing-card.pending .writing-title { color: var(--text-secondary); }

/* ── CONTACT / FOOTER ────────────────────────────────────────────── */
#contact {
  padding-bottom: 80px;
  border-top: 1px solid var(--border);
}

.contact-name {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.contact-meta {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.contact-meta span { color: var(--text-primary); }

.contact-links {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 32px;
  margin-bottom: 48px;
}

.contact-link {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--accent-blue);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  transition: border-color 0.2s;
}

.contact-link:hover { border-color: var(--accent-blue); }

.footer-meta {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.8;
}

/* ── UTILITIES ───────────────────────────────────────────────────── */
.mono { font-family: var(--font-mono); }
.text-green  { color: var(--accent-green); }
.text-red    { color: var(--accent-red); }
.text-yellow { color: var(--accent-yellow); }
.text-blue   { color: var(--accent-blue); }
.text-muted  { color: var(--text-muted); }

/* ── MOBILE ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  section { padding: 60px 20px; }
  main { padding-top: 88px; }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .thesis-grid { grid-template-columns: 1fr; }
  .thesis-cell:not(:last-child) {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .projects-header { flex-direction: column; align-items: flex-start; gap: 16px; }
  .filter-bar { flex-wrap: wrap; }

  .card-metrics { grid-template-columns: 1fr; }

  .hero-ctas { flex-direction: column; }
  .btn { width: max-content; }

  #main-nav { padding: 0 20px; }

  /* Mobile nav — hide text labels, keep logo + live + resume */
  .nav-links .nav-text-link { display: none; }
  .nav-links { gap: 16px; }
  .nav-live-full { display: none; }

  /* Mobile ticker — abbreviated */
  .ticker-item.hide-mobile { display: none; }

  .contact-links { flex-direction: column; gap: 12px; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
