/* ═══════════════════════════════════════════════════
   Fonts
═══════════════════════════════════════════════════ */
@font-face {
  font-family: Atkinson;
  src: url(/fonts/atkinson-regular.woff) format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Atkinson;
  src: url(/fonts/atkinson-bold.woff) format("woff");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

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

html {
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

/* ═══════════════════════════════════════════════════
   Design tokens
═══════════════════════════════════════════════════ */
:root {
  --bg:          #f7f7f5;
  --fg:          #1a1a1a;
  --fg-muted:    #6b6b6b;
  --accent:      #0055b3;
  --border:      #e2e2df;
  --code-bg:     #ededea;
  --header-bg:   rgba(247, 247, 245, 0.88);

  /* Legacy aliases used by inline utility classes in HTML */
  --color-global-bg:   var(--bg);
  --color-global-text: var(--fg);
  --color-link:        var(--accent);
  --color-accent:      var(--accent);
  --color-accent-2:    var(--fg);
  --color-quote:       var(--fg-muted);
  --color-border:      var(--border);
  --color-card-bg:     #ffffff;
  --color-shadow:      rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
  --bg:          #13151e;
  --fg:          #dde3ed;
  --fg-muted:    #8490a8;
  --accent:      #d97a43;
  --border:      #222838;
  --code-bg:     #1b1f2e;
  --header-bg:   rgba(19, 21, 30, 0.88);

  --color-global-bg:   var(--bg);
  --color-global-text: var(--fg);
  --color-link:        var(--accent);
  --color-accent:      var(--accent);
  --color-accent-2:    var(--fg);
  --color-quote:       var(--fg-muted);
  --color-border:      var(--border);
  --color-card-bg:     transparent;
  --color-shadow:      rgba(0, 0, 0, 0.4);
}

/* ═══════════════════════════════════════════════════
   Base
═══════════════════════════════════════════════════ */
body {
  font-family: Atkinson, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.75;
  margin: 0;
  padding: 0;
  padding-top: 4.5rem;
  background-color: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

@media (max-width: 640px) {
  body { padding-top: 3.75rem; }
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--fg);
}

h1 { font-size: 1.75rem; margin-top: 0; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.0625rem; }

p {
  margin-top: 0;
  margin-bottom: 1.25rem;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
  transition: opacity 0.15s ease;
}

a:hover { opacity: 0.72; }

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    'Liberation Mono', 'Courier New', monospace;
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.12em 0.36em;
  border-radius: 3px;
}

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

/* ═══════════════════════════════════════════════════
   Utility classes (minimal, matches HTML usage)
═══════════════════════════════════════════════════ */
.bg-global-bg      { background-color: var(--bg); }
.text-global-text  { color: var(--fg); }
.text-accent       { color: var(--accent); }
.text-accent-2     { color: var(--fg); }

.mx-auto           { margin-left: auto; margin-right: auto; }
.flex              { display: flex; }
.flex-col          { flex-direction: column; }
.items-center      { align-items: center; }
.justify-center    { justify-content: center; }
.max-w-3xl         { max-width: 46rem; }
.px-4              { padding-left: 1rem;   padding-right: 1rem; }
.px-8              { padding-left: 2rem;   padding-right: 2rem; }
.py-4              { padding-top: 1rem;    padding-bottom: 1rem; }
.py-8              { padding-top: 2rem;    padding-bottom: 2rem; }
.mb-8              { margin-bottom: 2rem; }
.mb-16             { margin-bottom: 4rem; }
.me-3              { margin-inline-end: 0.75rem; }
.me-4              { margin-inline-end: 1rem; }
.ms-auto           { margin-inline-start: auto; }
.h-4               { height: 1rem; }
.w-4               { width: 1rem; }
.h-7               { height: 1.75rem; }
.w-7               { width: 1.75rem; }
.h-10              { height: 2.5rem; }
.w-6               { width: 1.5rem; }
.text-sm           { font-size: 0.875rem; }
.text-xl           { font-size: 1.25rem; }
.text-2xl          { font-size: 1.5rem; }
.font-normal       { font-weight: 400; }
.font-bold         { font-weight: 700; }
.antialiased       { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
.scroll-smooth     { scroll-behavior: smooth; }
.relative          { position: relative; }
.absolute          { position: absolute; }
.hidden            { display: none; }
.rounded-md        { border-radius: 0.375rem; }
.opacity-75        { opacity: 0.75; }
.text-center       { text-align: center; }
.text-xs           { font-size: 0.75rem; }
.gap-3             { gap: 0.75rem; }
.p-1               { padding: 0.25rem; }
.underline         { text-decoration: underline; }
.underline-offset-2{ text-underline-offset: 2px; }
.border            { border: 1px solid var(--border); }
.border-accent-2\/20 { border-color: color-mix(in srgb, var(--fg) 20%, transparent); }
.bg-accent-2\/10   { background-color: color-mix(in srgb, var(--fg) 8%, transparent); }
.transition-colors { transition: color 0.15s ease, background-color 0.15s ease, border-color 0.15s ease; }

@media (min-width: 640px) {
  .sm\:px-8        { padding-left: 2rem;  padding-right: 2rem; }
  .sm\:flex        { display: flex; }
  .sm\:flex-row    { flex-direction: row; }
  .sm\:items-center{ align-items: center; }
  .sm\:hidden      { display: none; }
  .sm\:text-2xl    { font-size: 1.5rem; }
  .sm\:h-20        { height: 5rem; }
  .sm\:w-12        { width: 3rem; }
  .sm\:me-3        { margin-inline-end: 0.75rem; }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ═══════════════════════════════════════════════════
   Header
═══════════════════════════════════════════════════ */
#main-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: var(--header-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-grid {
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 1rem;
  height: 3.75rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

@media (min-width: 640px) {
  .header-grid {
    padding: 0 2rem;
  }
}

/* Hide SVG logo */
.header-logo {
  display: none;
}

/* Site name */
.header-title {
  flex-shrink: 0;
}

.header-title span {
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--fg);
}

/* Desktop nav */
.header-nav {
  display: none;
}

@media (min-width: 640px) {
  .header-nav {
    display: flex;
    align-items: center;
    gap: 0.125rem;
    margin-left: auto;
  }
}

.header-nav a {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 0.375rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--fg);
  background: var(--border);
  opacity: 1;
}

/* Controls wrapper */
.header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

@media (min-width: 640px) {
  .header-controls {
    margin-left: 0;
  }
}

/* Theme toggle */
#theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;
  height: 1.875rem;
  padding: 0.25rem;
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
  color: var(--fg-muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}

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

/* Sun/moon icon visibility (also set inline by JS) */
:root .sun-icon  { display: none;  }
:root .moon-icon { display: block; }
[data-theme="dark"] .sun-icon  { display: block; }
[data-theme="dark"] .moon-icon { display: none;  }

/* Mobile hamburger */
#toggle-navigation-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.875rem;
  height: 1.875rem;
  padding: 0.25rem;
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  cursor: pointer;
  color: var(--fg-muted);
  z-index: 200;
  position: relative;
  transition: color 0.15s ease, background-color 0.15s ease;
}

#toggle-navigation-menu:hover {
  color: var(--fg);
  background: var(--border);
}

#toggle-navigation-menu svg {
  width: 16px;
  height: 16px;
}

#toggle-navigation-menu[aria-expanded="false"] svg:first-of-type { display: block; }
#toggle-navigation-menu[aria-expanded="false"] svg:last-of-type  { display: none;  }
#toggle-navigation-menu[aria-expanded="true"]  svg:first-of-type { display: none;  }
#toggle-navigation-menu[aria-expanded="true"]  svg:last-of-type  { display: block; }

/* ═══════════════════════════════════════════════════
   Mobile nav overlay
═══════════════════════════════════════════════════ */
.mobile-nav-menu {
  /* Desktop: inline flex row */
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.125rem;
  position: static;
  background: transparent;
}

/* nav link styles on desktop (mirrors header-nav) */
.mobile-nav-menu a {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 0.375rem;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.mobile-nav-menu a:hover,
.mobile-nav-menu a.active {
  color: var(--fg);
  background: var(--border);
  opacity: 1;
}

@media (max-width: 639px) {
  /* Hidden by default on mobile */
  .mobile-nav-menu {
    display: none !important;
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    right: 0 !important; bottom: 0 !important;
    background: var(--bg) !important;
    z-index: 150 !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 0.5rem !important;
    padding: 2rem !important;
  }

  .mobile-nav-menu a {
    font-size: 1.25rem !important;
    padding: 0.75rem 2rem !important;
    color: var(--fg) !important;
    width: 100% !important;
    max-width: 260px !important;
    text-align: center !important;
    border: 1px solid var(--border) !important;
    border-radius: 0.5rem !important;
  }

  .mobile-nav-menu a:hover {
    background: var(--border) !important;
  }

  /* Show when menu-open */
  .group.menu-open .mobile-nav-menu {
    display: flex !important;
  }
}

/* ═══════════════════════════════════════════════════
   Main
═══════════════════════════════════════════════════ */
main {
  min-height: calc(100vh - 5rem);
  padding-top: 3rem;
  padding-bottom: 1rem;
}

/* ═══════════════════════════════════════════════════
   Prose
═══════════════════════════════════════════════════ */
.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
}

.prose a:hover { opacity: 0.72; }

.prose strong {
  font-weight: 600;
  color: var(--fg);
}

.prose blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1.1rem;
  margin-left: 0;
  color: var(--fg-muted);
  font-style: italic;
}

.prose code {
  font-size: 0.85em;
  background: var(--code-bg);
  padding: 0.12em 0.36em;
  border-radius: 3px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Section heading style */
.prose h2 {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--fg);
  margin-top: 3rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  letter-spacing: -0.01em;
}

.prose h2:first-child { margin-top: 0; }

/* ═══════════════════════════════════════════════════
   About section
═══════════════════════════════════════════════════ */
.about-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
}

@media (min-width: 540px) {
  .about-header {
    flex-direction: row;
    align-items: flex-start;
    text-align: left;
  }
}

.about-avatar {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.about-avatar:hover {
  transform: scale(1.04);
}

.about-header-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.title {
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--fg);
  margin: 0 0 0.1rem 0;
  line-height: 1.2;
}

/* Social links */
.about-socials {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

@media (min-width: 540px) {
  .about-socials { justify-content: flex-start; }
}

.about-socials a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--fg-muted);
  text-decoration: none;
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.about-socials a:hover {
  color: var(--fg);
  border-color: var(--fg-muted);
  background: var(--border);
  opacity: 1;
}

.about-socials svg {
  flex-shrink: 0;
  opacity: 0.75;
}

/* ═══════════════════════════════════════════════════
   Publications
═══════════════════════════════════════════════════ */

/* Year headings */
#publications-content h2 {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--fg-muted);
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0;
  border-bottom: none;
}

#publications-content h2:first-child { margin-top: 0; }

.publication-card {
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
}

.publication-card:last-of-type {
  border-bottom: none;
}

.publication-content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.publication-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.45;
  margin: 0;
}

.publication-link {
  color: var(--fg);
  text-decoration: none;
  transition: color 0.15s ease;
}

.publication-link:hover {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
  opacity: 1;
}

.publication-venue {
  font-size: 0.8125rem;
  color: var(--accent);
  font-weight: 500;
  font-style: italic;
}

.publication-authors {
  font-size: 0.8125rem;
  color: var(--fg-muted);
  line-height: 1.5;
}

.publication-year { display: none; }

/* Tags */
.publication-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.3rem;
}

.tag {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.12rem 0.45rem;
  border-radius: 0.2rem;
  text-decoration: none;
  letter-spacing: 0.01em;
  transition: opacity 0.15s ease;
}

.tag:hover { opacity: 0.8; }

.tag-safety {
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  color: var(--accent);
}

.tag-arxiv {
  background: rgba(22, 163, 74, 0.12);
  color: #16a34a;
}

[data-theme="dark"] .tag-arxiv {
  color: #4ade80;
  background: rgba(74, 222, 128, 0.12);
}

.tag-interpretability {
  background: rgba(109, 40, 217, 0.1);
  color: #6d28d9;
}

[data-theme="dark"] .tag-interpretability {
  color: #a78bfa;
  background: rgba(167, 139, 250, 0.12);
}

.tag-workshop {
  background: rgba(194, 65, 12, 0.1);
  color: #c2410c;
}

[data-theme="dark"] .tag-workshop {
  color: #fb923c;
  background: rgba(251, 146, 60, 0.12);
}

/* ═══════════════════════════════════════════════════
   Timeline (Resume)
═══════════════════════════════════════════════════ */
.timeline {
  display: flex;
  flex-direction: column;
  margin: 0.5rem 0 2rem;
}

.timeline-item {
  position: relative;
  padding: 1.1rem 0 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
  position: absolute;
  left: 0;
  top: 1.65rem;
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
}

.timeline-header {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  margin-bottom: 0.25rem;
}

.timeline-org {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--fg);
}

.timeline-role {
  font-size: 0.85rem;
  color: var(--fg-muted);
}

.timeline-dates {
  font-size: 0.78rem;
  color: var(--fg-muted);
  margin-top: 0.1rem;
}

.timeline-desc {
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin-top: 0.2rem;
  line-height: 1.6;
}

/* Skills chip list */
#resume-content ul {
  list-style: none;
  padding: 0;
  margin: 0.75rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

#resume-content ul li {
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.22rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  color: var(--fg-muted);
}

/* ═══════════════════════════════════════════════════
   Footer
═══════════════════════════════════════════════════ */
body > div:last-of-type {
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  font-size: 0.78rem;
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

/* ═══════════════════════════════════════════════════
   Loading
═══════════════════════════════════════════════════ */
.loading-spinner {
  color: var(--fg-muted);
  font-size: 0.875rem;
  padding: 2.5rem 0;
  text-align: center;
}

/* ═══════════════════════════════════════════════════
   Bee easter egg
═══════════════════════════════════════════════════ */
.hover-b {
  transition: color 0.12s ease;
}
.hover-b:hover {
  color: #f59e0b;
}

.flying-bee {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  font-size: 1.2em;
  line-height: 1;
  will-change: transform, opacity;
  animation: bee-fly 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

@keyframes bee-fly {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  20%  { transform: translate(calc(var(--dx) * 0.2), calc(var(--dy) * 0.2)) rotate(90deg); }
  40%  { transform: translate(calc(var(--dx) * 0.4 + 6px), calc(var(--dy) * 0.4 - 4px)) rotate(180deg); }
  60%  { transform: translate(calc(var(--dx) * 0.6 - 4px), calc(var(--dy) * 0.6 + 6px)) rotate(270deg); }
  80%  { transform: translate(calc(var(--dx) * 0.8 + 3px), calc(var(--dy) * 0.8 - 3px)) rotate(360deg); }
  100% { transform: translate(var(--dx), var(--dy)) rotate(450deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .flying-bee {
    animation: bee-fade 200ms ease-out forwards;
  }
  @keyframes bee-fade { to { opacity: 0; } }
}

/* ═══════════════════════════════════════════════════
   Misc
═══════════════════════════════════════════════════ */
.cactus-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
  transition: opacity 0.15s ease;
}
.cactus-link:hover { opacity: 0.72; }

:focus-visible {
  outline: 2px dashed var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
