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

/* ---------- Design tokens ---------- */
:root {
  --ink: #0f0f10;
  --muted: #63646c;
  --faint: #9a9ba3;
  --rule: #e7e7eb;
  --bg: #ffffff;
  --accent: #2f6feb;
  --accent-soft: rgba(47, 111, 235, 0.08);
  --accent-line: rgba(47, 111, 235, 0.32);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  --font-sans: 'IBM Plex Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;

  --sp-1: 0.4rem;
  --sp-2: 0.7rem;
  --sp-3: 1.1rem;
  --sp-4: 1.8rem;
  --sp-5: 2.8rem;
  --sp-6: 4.5rem;
}

/* ---------- Global ---------- */
html {
  font-size: 16px;
  scroll-behavior: smooth;
  scrollbar-color: var(--accent) #ffffff;
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #ffffff;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 0;
}

::selection {
  background: var(--accent);
  color: #ffffff;
}

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

a {
  transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease);
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  padding: var(--sp-6) 2rem 8rem;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 680px;
  margin: 0 auto;
}

/* ---------- Header ---------- */
header {
  margin-bottom: var(--sp-5);
}

.header-top {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.avatar {
  flex: 0 0 auto;
  width: 160px;
}

.avatar img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 19 / 20;
  object-fit: cover;
  object-position: 50% 5%;
  border-radius: 6px;
  border: 1px solid var(--rule);
}

.avatar figcaption {
  margin-top: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--faint);
  text-align: center;
}

.header-info {
  flex: 0 1 auto;
  max-width: 430px;
  min-width: 0;
}

h1 {
  font-family: var(--font-mono);
  font-size: 1.85rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: var(--sp-1);
}

.subtitle {
  font-family: var(--font-mono);
  font-style: normal;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.contact {
  margin-top: var(--sp-3);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
}

.contact-row {
  display: flex;
  gap: 0.35rem;
}

.contact a {
  color: var(--muted);
  text-decoration: none;
  padding: 0.16rem 0.45rem;
  border: 1px solid var(--rule);
}

.contact a:hover {
  color: var(--accent);
  border-color: var(--accent-line);
}

.social-icons {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.1rem;
}

.social-icons a {
  display: inline-flex;
  color: var(--muted);
  padding: 0;
  border: none;
}

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

/* ---------- Nav ---------- */
.site-nav {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 20;
  margin-bottom: 1rem;
  box-shadow: 0 8px 16px -12px rgba(15, 15, 16, 0.16);
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  row-gap: 0.5rem;
  column-gap: 1.4rem;
  padding: 0.9rem 0;
}

nav a {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 0.3rem;
  border-bottom: 2px solid transparent;
}

nav a:hover,
nav a.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.nav-home {
  display: inline-flex;
  align-items: center;
  padding-bottom: 0;
  border-bottom: none !important;
  color: var(--accent) !important;
  opacity: 0.85;
}

.nav-home:hover {
  opacity: 1;
}

.nav-home .dino-svg,
.nav-home .legs-a,
.nav-home .legs-b {
  animation: none;
}

.nav-home:hover .dino-svg {
  animation: dino-bob 0.9s steps(2, end) infinite;
}

.nav-home:hover .legs-a {
  animation: legswap 0.9s steps(1, end) infinite;
}

.nav-home:hover .legs-b {
  animation: legswap 0.9s steps(1, end) infinite reverse;
}

.dino-svg {
  display: block;
  shape-rendering: crispEdges;
  image-rendering: pixelated;
}

@keyframes dino-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes legswap {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.subnav {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 0.7rem 0 0.9rem;
}

.subnav:empty {
  display: none;
  padding: 0;
  margin: 0;
}

.subnav a {
  color: var(--muted);
  text-decoration: none;
  padding-left: 0.7rem;
  border-left: 2px solid var(--rule);
  line-height: 1.3;
}

.subnav a:hover {
  color: var(--ink);
  border-left-color: var(--faint);
}

.subnav a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* On wide viewports the subnav docks in the left margin and tracks scroll. */
@media (min-width: 1200px) {
  .subnav {
    position: fixed;
    top: 50%;
    right: calc(50% + 410px);
    transform: translateY(-50%);
    width: 190px;
    padding: 0;
  }
}

/* ---------- Sections ---------- */
.page section + section {
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--rule);
}

.section-title {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: var(--sp-4);
  color: var(--ink);
  scroll-margin-top: 5.5rem;
}

.section-title::before {
  content: '## ';
  color: var(--accent);
}

.about-text p {
  margin-bottom: 1.1rem;
  max-width: 600px;
  font-size: 0.98rem;
}

.about-text p:last-child {
  margin-bottom: 0;
}

.about-text a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(47, 111, 235, 0.35);
}

.about-text a:hover {
  text-decoration-color: var(--ink);
  color: var(--ink);
}

h3 {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 2.4rem 0 1rem;
  scroll-margin-top: 6.5rem;
}

#research-interests {
  margin-top: 1rem;
}

h3::before {
  content: '/// ';
  color: var(--accent);
}

/* ---------- Entries ---------- */
.entry {
  display: grid;
  grid-template-columns: 108px 1fr;
  gap: 0 1.5rem;
  margin-bottom: 2.2rem;
}

.entry-date {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--muted);
  padding-top: 0.18rem;
  line-height: 1.35;
}

.entry-title {
  font-size: 0.96rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.entry-title em {
  font-weight: 400;
  font-style: italic;
}

.entry-body {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.4;
}

.entry-body + .entry-body {
  margin-top: 0.6rem;
}

.entry-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: rgba(47, 111, 235, 0.35);
}

.entry-body a:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

.tag {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  margin-left: 0.3rem;
  white-space: nowrap;
}

.tag::before {
  content: '[';
}

.tag::after {
  content: ']';
}

.focus-list {
  list-style: none;
}

.focus-list li {
  padding: 0.2rem 0 0.2rem 1.3rem;
  font-size: 0.98rem;
  line-height: 1.35;
  position: relative;
}

.focus-list li::before {
  content: '■';
  color: var(--accent);
  position: absolute;
  left: 0;
}

.focus-list li span {
  color: var(--muted);
  font-size: 0.88rem;
}

/* ---------- Back to top ---------- */
.back-to-top {
  position: fixed;
  right: 1.5rem;
  bottom: 1.5rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  border: 1px solid var(--accent-line);
  border-radius: 2px;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 15, 16, 0.14);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease), background-color 0.15s var(--ease), color 0.15s var(--ease);
  z-index: 30;
}

.back-to-top::before {
  content: '↑';
  font-size: 1rem;
}

.back-to-top.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.back-to-top:hover {
  background: var(--accent);
  color: #ffffff;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
  .header-top {
    gap: 1.1rem;
  }

  .avatar {
    width: 72px;
  }
}

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

  .entry-date {
    margin-bottom: 0.3rem;
  }

  nav {
    column-gap: 1rem;
  }
}
