/* ===== Reset & typography ===== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI',
               Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
  font-size: 16px;
  line-height: 1.65;
  color: #202328;
  background: #fdfdfc;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

code, pre, .meta code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono',
               Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

a {
  color: #1c5fa8;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 100ms ease, color 100ms ease;
}

a:hover {
  border-bottom-color: currentColor;
}

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.25;
  margin: 0 0 0.5em 0;
}

h1 { font-size: 2rem;  }
h2 { font-size: 1.35rem; margin-top: 2.5rem; letter-spacing: -0.005em; }
h3 { font-size: 1.08rem; font-weight: 600; }

p { margin: 0 0 1em 0; }

ul { padding-left: 1.3em; }

em, strong { font-style: normal; }
strong { font-weight: 600; }
em { color: #363b42; }

/* ===== Layout ===== */

.site-header {
  border-bottom: 1px solid #e7e3db;
  background: rgba(253, 253, 252, 0.9);
  backdrop-filter: saturate(180%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header nav {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.85rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.site-header .home {
  font-weight: 600;
  color: #202328;
  border-bottom: none;
}

.site-header .nav-links {
  display: flex;
  gap: 1.25rem;
  font-size: 0.94rem;
}

.site-header .nav-links a {
  color: #565c64;
  border-bottom: none;
}

.site-header .nav-links a:hover {
  color: #1c5fa8;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

section {
  margin-bottom: 2.5rem;
}

/* Offset anchor targets so the sticky header doesn't cover the heading */
section[id] {
  scroll-margin-top: 72px;
}

/* Justified body text with auto-hyphenation to avoid loose lines */
#research > p,
#bio > p,
.paper .abstract,
.news-list .item-body,
.more {
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
  -webkit-hyphens: auto;
}

footer {
  max-width: 720px;
  margin: 3rem auto 2rem;
  padding: 1.5rem 1.25rem 0;
  border-top: 1px solid #e7e3db;
  font-size: 0.86rem;
  color: #6b7178;
}

footer a {
  color: inherit;
}

/* ===== Profile block ===== */

.profile {
  display: flex;
  gap: 1.75rem;
  align-items: center;
  margin-top: 0.5rem;
  margin-bottom: 3rem;
}

.profile .portrait {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid #e7e3db;
}

.profile-text h1 {
  margin-bottom: 0.15rem;
}

.profile-text .affiliation {
  color: #565c64;
  margin-bottom: 0.5rem;
  font-size: 1.02rem;
}

.profile-text .contact {
  margin: 0;
  color: #565c64;
  font-size: 0.94rem;
  line-height: 1.5;
}

.profile-text .contact a {
  color: #1c5fa8;
}

.profile-text .contact .sep {
  margin: 0 0.4em;
  color: #b5b0a6;
}

@media (max-width: 540px) {
  .profile {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .profile .portrait {
    width: 110px;
    height: 110px;
  }
}

/* ===== Papers block ===== */

.paper {
  padding: 1rem 0;
  border-top: 1px solid #ede9e0;
}

.paper:first-of-type {
  border-top: none;
  padding-top: 0.5rem;
}

.paper h3 {
  margin-bottom: 0.25rem;
  font-size: 1.04rem;
  line-height: 1.4;
}

.paper .meta {
  font-size: 0.9rem;
  color: #6b7178;
  margin-bottom: 0.75rem;
}

.paper .abstract {
  margin: 0;
  color: #2c3138;
}

.paper .badge {
  display: inline-block;
  margin-left: 0.4em;
  padding: 0.12em 0.55em;
  font-size: 0.74rem;
  font-weight: 500;
  border-radius: 3px;
  background: #ede7d8;
  color: #8a6c2e;
  vertical-align: middle;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.paper.in-preparation {
  opacity: 0.95;
}

/* ===== News block ===== */

.news-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.news-list li {
  display: flex;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f1ede3;
  align-items: baseline;
}

.news-list li:last-child {
  border-bottom: none;
}

.news-list .date {
  flex: 0 0 5.5rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  color: #6b7178;
}

.news-list .item-body {
  flex: 1 1 auto;
  min-width: 0;
}

@media (max-width: 540px) {
  .news-list li {
    flex-direction: column;
    gap: 0.15rem;
  }
  .news-list .date {
    flex: 0 0 auto;
    font-size: 0.82rem;
  }
}

/* ===== Inline accents ===== */

.opening-question {
  font-style: italic;
  color: #363b42;
  font-size: 1.06rem;
  margin-bottom: 1.25rem;
  padding-left: 0.8rem;
  border-left: 2px solid #d4a853;
}

.day-night {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.1rem 0 0.9rem;
}

.dn-col {
  position: relative;
  padding-top: 0.55rem;
  border-top: 1px solid #e7e3db;
}

.dn-day   { border-top-color: #d4a853; }
.dn-night { border-top-color: #1c5fa8; }

.dn-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8a9099;
  margin-bottom: 0.35rem;
}

.dn-day .dn-label   { color: #8a6c2e; }
.dn-night .dn-label { color: #1c5fa8; }

.dn-col p {
  margin: 0;
}

@media (max-width: 540px) {
  .day-night {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

.guiding-principle,
.current-work {
  color: #565c64;
  font-size: 0.98rem;
}

.guiding-principle {
  margin-top: 0.6em;
}

.current-work {
  margin-top: 0.4em;
}

.guiding-principle em,
.current-work em {
  color: #565c64;
  font-style: italic;
}

.paper .citations {
  color: #8a6c2e;
  font-weight: 500;
}

.paper .more, .more {
  font-size: 0.93rem;
  color: #6b7178;
  margin-top: 1rem;
  font-style: italic;
}

/* ===== TODO placeholder styling (visible only while filling in) ===== */

.todo {
  background: #fff3cd;
  color: #7a5900;
  padding: 0.1em 0.35em;
  border-radius: 3px;
  font-size: 0.92em;
}

/* ===== Split artifact: Theory → Production ===== */

.split-artifact {
  margin: 2.5rem 0 3rem;
  border: 1px solid #e7e3db;
  border-radius: 6px;
  overflow: hidden;
  background: #fdfdfc;
}

.artifact-header {
  padding: 1rem 1.25rem 0.9rem;
  border-bottom: 1px solid #ede9e0;
  background: #faf8f3;
}

.invariant-display {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 0.85rem;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92rem;
  color: #363b42;
}

.invariant-part {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45em;
}

.invariant-display .ivar {
  font-weight: 600;
  color: #1c5fa8;
  font-variant-numeric: tabular-nums;
  min-width: 1.2em;
  display: inline-block;
  text-align: right;
  transition: color 120ms ease;
}

.invariant-display .ivar.pulse {
  color: #d4a853;
}

.invariant-display .ivar-label {
  color: #6b7178;
  font-size: 0.86rem;
}

.invariant-display .invariant-sep {
  color: #b5b0a6;
}

.artifact-tagline {
  margin: 0.45rem 0 0.75rem;
  color: #565c64;
  font-size: 0.96rem;
}

.slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.slider-wrap .slider-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.9rem;
  color: #565c64;
}

.slider-wrap input[type="range"] {
  flex: 1 1 auto;
  accent-color: #1c5fa8;
  height: 1.1rem;
}

.slider-wrap .slider-current {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.9rem;
  color: #1c5fa8;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 1.4em;
  text-align: right;
}

.artifact-tri {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  min-height: 280px;
}

.artifact-panel {
  position: relative;
  padding: 0.85rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid #ede9e0;
}

.artifact-panel:last-child {
  border-right: none;
}

.panel-lean     { background: #faf7ef; }
.panel-latex    { background: #fdfdfc; }
.panel-semantic { background: #f5f7fb; }

.artifact-panel .panel-title {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
  color: #8a9099;
}

.panel-lean .panel-title     { color: #8a6c2e; }
.panel-latex .panel-title    { color: #565c64; }
.panel-semantic .panel-title { color: #1c5fa8; }

.panel-semantic .geometry {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 170px;
  display: block;
  margin: 0 auto 0.55rem;
}

.semantic-desc {
  margin: 0;
  font-size: 0.84rem;
  line-height: 1.5;
  color: #2c3138;
}

.semantic-desc code {
  background: #e5ebf4;
  padding: 0.04em 0.3em;
  border-radius: 3px;
  font-size: 0.86em;
}

.latex-render {
  flex: 1 1 auto;
  display: block;
  font-size: 0.8rem;
  color: #202328;
  overflow-x: auto;
  min-height: 0;
  text-align: left;
}

.latex-render mjx-container {
  margin: 0 !important;
}

.latex-render mjx-container[display="true"] {
  text-align: left !important;
  margin: 0.1em 0 !important;
}

.geometry .g-edge {
  stroke: #b8c2d0;
  stroke-width: 0.35;
  opacity: 0.7;
}

.geometry .g-node {
  fill: #fdfdfc;
  stroke: #1c5fa8;
  stroke-width: 1.2;
}

.geometry .g-node-label {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 6px;
  fill: #565c64;
  text-anchor: middle;
  dominant-baseline: middle;
}

.geometry .g-ring {
  fill: none;
  stroke: #ede9e0;
  stroke-width: 0.4;
  stroke-dasharray: 1.5 1.5;
}

.lean-code {
  flex: 1 1 auto;
  margin: 0;
  padding: 0;
  background: transparent;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.72rem;
  line-height: 1.55;
  color: #363b42;
  white-space: pre;
  overflow-x: auto;
}

.lean-code .lean-kw  { color: #8a6c2e; font-weight: 600; }
.lean-code .lean-ty  { color: #1c5fa8; }
.lean-code .lean-num { color: #b54a3b; font-weight: 600; }
.lean-code .lean-cm  { color: #8a9099; font-style: italic; }

.artifact-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid #ede9e0;
  background: #faf8f3;
}

.artifact-buttons button {
  font: inherit;
  font-size: 0.88rem;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  padding: 0.35rem 0.8rem;
  background: #fdfdfc;
  border: 1px solid #d9d4c6;
  border-radius: 4px;
  color: #363b42;
  cursor: pointer;
  transition: background 100ms ease, border-color 100ms ease, color 100ms ease;
}

.artifact-buttons button:hover {
  background: #f3eedc;
  border-color: #c9bfa4;
  color: #1c5fa8;
}

.artifact-buttons button[aria-selected="true"] {
  background: #1c5fa8;
  border-color: #1c5fa8;
  color: #fdfdfc;
}

.artifact-reveal {
  padding: 0 1rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 220ms ease, padding 220ms ease;
  font-size: 0.94rem;
  color: #2c3138;
}

.artifact-reveal.open {
  max-height: 520px;
  padding: 0.9rem 1rem 1.1rem;
  border-top: 1px solid #ede9e0;
}

.artifact-reveal h4 {
  margin: 0 0 0.45rem;
  font-size: 0.96rem;
  font-weight: 600;
  color: #202328;
}

.artifact-reveal p, .artifact-reveal ol, .artifact-reveal ul {
  margin: 0 0 0.6rem;
}

.artifact-reveal ol, .artifact-reveal ul {
  padding-left: 1.25rem;
}

.artifact-reveal code {
  background: #f3eedc;
  padding: 0.06em 0.3em;
  border-radius: 3px;
}

@media (max-width: 720px) {
  .artifact-tri {
    grid-template-columns: 1fr;
  }
  .artifact-panel {
    border-right: none;
    border-bottom: 1px solid #ede9e0;
  }
  .artifact-panel:last-child {
    border-bottom: none;
  }
  .invariant-display {
    font-size: 0.84rem;
  }
  .panel-semantic .geometry {
    max-height: 200px;
  }
  .latex-render {
    min-height: 110px;
  }
}

/* ===== Selection ===== */

::selection {
  background: #f3e4b3;
  color: #202328;
}
