/* ==========================================================================
   Design tokens — change fonts/accent here to retheme the whole site.
   ========================================================================== */

:root {
  --font-heading: "Newsreader", Georgia, serif;
  --font-body: "Inter", -apple-system, "Segoe UI", sans-serif;

  --bg: #faf9f6;
  --bg-subtle: #f1efe9;
  --text: #21201c;
  --text-muted: #6f6d66;
  --border: #e4e1d8;

  /* Light mode: burnt amber accent */
  --accent: #b45309;
  --accent-strong: #92400a;
  --accent-tint: rgba(180, 83, 9, 0.09);

  --max-width: 53rem;
}

[data-theme="dark"] {
  --bg: #141517;
  --bg-subtle: #1d1f22;
  --text: #e8e6e1;
  --text-muted: #97948c;
  --border: #2a2c30;

  /* Dark mode: deep teal accent */
  --accent: #2fbdb0;
  --accent-strong: #4fd6c9;
  --accent-tint: rgba(47, 189, 176, 0.12);
}

/* Theme-switch animation: the new theme sweeps out from the toggle button
   in a circle (View Transitions API; browsers without it just cross-fade). */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* While a view transition drives the switch, per-property transitions
   would smear the snapshot — pause them for the click. */
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition: none !important;
}

/* ==========================================================================
   Base
   ========================================================================== */

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background 0.25s ease, color 0.25s ease;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

h1 { font-size: 2.4rem; }
h2 { font-size: 1.55rem; }

p { margin: 0 0 1rem; }

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

a:hover {
  color: var(--accent-strong);
  border-bottom-color: currentColor;
}

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

/* ==========================================================================
   Header / nav
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.15rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-icons {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}

.nav-icons a {
  display: inline-flex;
  color: var(--text-muted);
  border-bottom: none;
  transition: color 0.15s ease, transform 0.15s ease;
}

.nav-icons a:hover {
  color: var(--accent);
  border-bottom: none;
  transform: translateY(-1px);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-link {
  font-size: 1.05rem;
  color: var(--text-muted);
  border-bottom: none;
  position: relative;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: -3px;
  height: 1.5px;
  background: var(--accent);
  transition: right 0.2s ease;
}

.nav-link:hover {
  color: var(--text);
  border-bottom: none;
}

.nav-link:hover::after {
  right: 0;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-tint);
}

/* Show one icon per theme */
[data-theme="light"] .icon-sun { display: none; }
[data-theme="dark"] .icon-moon { display: none; }

/* ==========================================================================
   Hero / about
   ========================================================================== */

.hero {
  display: flex;
  align-items: flex-start;
  gap: 2rem;
  padding: 4rem 0 1rem;
}

.hero-subtitle {
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

.hero-visual {
  position: relative;
  flex-shrink: 0;
  margin-top: 0.75rem;
}

.hero-photo {
  position: relative;
  display: block;
  width: 12.5rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
}

.sprig {
  color: var(--accent);
}

/* The hero sprig only shows as the fallback when there's no photo */
.sprig-hero {
  display: none;
  width: 5.25rem;
  height: auto;
  opacity: 0.55;
  transform: rotate(18deg);
}

/* No photo: a photo-sized frame with the sprig inside marks the spot */
.hero-visual.no-photo {
  width: 12.5rem;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--accent-tint), var(--bg-subtle));
  display: flex;
  align-items: center;
  justify-content: center;
}

.hero-visual.no-photo .hero-photo {
  display: none;
}

.hero-visual.no-photo .sprig-hero {
  display: block;
  width: 4.5rem;
  opacity: 0.55;
  transform: rotate(12deg);
}

/* Small caption under the hero photo */
.hero-caption {
  margin: 0.6rem 0 0;
  max-width: 12.5rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
}

.hero-visual.no-photo .hero-caption {
  display: none;
}

.sprig-footer {
  width: 9rem;
  height: auto;
  opacity: 0.5;
  margin-bottom: 0.4rem;
}

/* Contact links now live as icons in the nav (top-left corner) */

/* ==========================================================================
   Sections
   ========================================================================== */

.section {
  padding: 2.5rem 0;
}

/* Small teal mark before section headings — the one decorative flourish */
.section h2::before {
  content: "◆";
  font-size: 0.55em;
  color: var(--accent);
  margin-right: 0.65rem;
  vertical-align: 0.25em;
}

/* ==========================================================================
   Publications
   ========================================================================== */

.publication-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.publication {
  margin: 0 -1.1rem;
  border-radius: 0.6rem;
  border-left: 2px solid transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.publication:hover {
  background: var(--bg-subtle);
  border-left-color: var(--accent);
}

/* Whole block is clickable when the paper has a link */
.publication-body {
  display: block;
  padding: 1rem 1.1rem;
  color: inherit;
  border-bottom: none;
}

a.publication-body:hover {
  border-bottom: none;
}

a.publication-body:hover .publication-title {
  color: var(--accent-strong);
}

.publication-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 500;
  margin: 0 0 0.3rem;
}

.publication-authors {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.45rem;
}

.publication-authors strong {
  color: var(--text);
  font-weight: 500;
}

.publication-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.venue-tag {
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-weight: 500;
}


/* ==========================================================================
   Experience timeline
   ========================================================================== */

.timeline {
  list-style: none;
  position: relative;
  margin: 1.5rem 0 0;
  padding: 0;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 0.4rem;
  top: 0.5rem;
  bottom: 0.5rem;
  width: 1.5px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  padding: 0 0 1.9rem 1.9rem;
}

.timeline-item:last-child {
  padding-bottom: 0.25rem;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.4rem;
  width: 0.65rem;
  height: 0.65rem;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  transition: background 0.15s ease;
}

.timeline-item:hover::before {
  background: var(--accent);
}

.timeline-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  margin-bottom: 0.15rem;
}

.timeline-role {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0;
}

.timeline-tag {
  font-size: 0.75rem;
  padding: 0.05rem 0.55rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-weight: 500;
}

.timeline-org {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0 0 0.1rem;
}

.timeline-org a {
  color: inherit;
}

.timeline-org a:hover {
  color: var(--accent-strong);
}

.timeline-period {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.timeline-desc {
  font-size: 0.95rem;
  margin: 0.35rem 0 0;
  color: var(--text);
}

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

.news-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: flex;
  flex-direction: column;
}

.news-item {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
}

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

.news-date {
  flex-shrink: 0;
  width: 6.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.news-text {
  font-size: 0.95rem;
}

@media (max-width: 600px) {
  .news-item {
    flex-wrap: wrap;
    gap: 0.1rem 1rem;
  }

  .news-date {
    width: 100%;
  }
}

/* "new" pill — appears on news items and fresh blog posts, ages out on its
   own (window set in js/main.js) */
.new-badge {
  display: inline-block;
  margin-left: 0.55rem;
  padding: 0.02rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 0.14em;
}

/* ==========================================================================
   Blog / writing
   ========================================================================== */

.post-list {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 0;
  display: flex;
  flex-direction: column;
}

.post-item {
  border-bottom: 1px solid var(--border);
}

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

/* The whole row is one clickable block */
.post-item-link {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 0.85rem 0.6rem;
  margin: 0 -0.6rem;
  border-radius: 0.5rem;
  border-bottom: none;
  color: inherit;
  transition: background 0.15s ease;
}

.post-item-link:hover {
  background: var(--bg-subtle);
  border-bottom: none;
}

.post-item-link:hover .post-title {
  color: var(--accent-strong);
}

.post-date {
  flex-shrink: 0;
  width: 6.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.post-title {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  color: var(--text);
}

.post-title:hover {
  color: var(--accent-strong);
}

.post-tags {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.post-tag {
  font-size: 0.72rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-strong);
}

.view-all {
  display: inline-block;
  margin-top: 1rem;
  font-size: 0.9rem;
}

.empty-note {
  color: var(--text-muted);
  font-style: italic;
  grid-column: 1 / -1;
}

/* Card grid used on the blog index */
.post-grid {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.25rem;
}

.post-card {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  background: var(--bg);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.post-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.09);
}

.post-card > a {
  display: block;
  color: inherit;
  border-bottom: none;
}

.post-card-image,
.post-card-placeholder {
  aspect-ratio: 16 / 9;
  width: 100%;
  display: block;
}

.post-card-image {
  object-fit: cover;
  background: var(--bg-subtle);
}

/* Shown when a post has no image yet: soft tint with a sprig */
.post-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent-tint), var(--bg-subtle));
}

.post-card-placeholder .sprig {
  width: 2.4rem;
  opacity: 0.55;
  transform: rotate(12deg);
}

.post-card-body {
  padding: 1.1rem 1.15rem 1.35rem;
}

.post-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.post-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  /* outdent by the pill's own padding so the tag text aligns with the date */
  margin: 0 0 0.55rem -0.5rem;
}

.post-card-title {
  font-family: var(--font-heading);
  font-size: 1.18rem;
  font-weight: 500;
  margin: 0 0 0.35rem;
  color: var(--text);
}

.post-card:hover .post-card-title {
  color: var(--accent-strong);
}

.post-card-summary {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
}

/* Individual blog post pages */
.post-header {
  padding: 3rem 0 0;
}

.post-header h1 {
  font-size: 2rem;
  margin-bottom: 0.4rem;
}

.post-header .post-card-meta {
  font-size: 0.85rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.post-content img {
  max-width: 100%;
  border-radius: 0.6rem;
}

.post-content h2 {
  margin-top: 2.25rem;
}

.post-content h3 {
  margin-top: 1.5rem;
}

/* Auto-generated table of contents on post pages */
.toc {
  margin: 1.75rem 0 0.5rem;
  padding: 0.9rem 1.2rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  font-size: 0.92rem;
}

.toc summary {
  font-family: var(--font-heading);
  font-weight: 500;
  font-size: 1.02rem;
  color: var(--text);
  cursor: pointer;
}

.toc ul {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.toc li.toc-sub {
  padding-left: 1.1rem;
}

.toc a {
  color: var(--text-muted);
  border-bottom: none;
}

.toc a:hover {
  color: var(--accent-strong);
}

/* Comments (Cusdis widget renders in an iframe) */
.comments-section {
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
}

.comments-section iframe {
  width: 100%;
  border: 0;
}

.post-content blockquote {
  margin: 1.25rem 0;
  padding: 0.25rem 0 0.25rem 1.1rem;
  border-left: 2px solid var(--accent);
  font-family: var(--font-heading);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .post-item-link {
    flex-wrap: wrap;
    gap: 0.2rem 1rem;
  }

  .post-date {
    width: 100%;
  }

  .post-tags {
    margin-left: 0;
  }
}

/* ==========================================================================
   Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  padding: 1.5rem 0 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Small screens
   ========================================================================== */

@media (max-width: 600px) {
  h1 { font-size: 1.9rem; }

  /* Two-row header taller than desktop's — keep anchor targets clear of it */
  html {
    scroll-padding-top: 7rem;
  }

  /* Stack the hero: name and subtitle first, then the centred portrait,
     then the intro paragraphs. display:contents lifts the text block's
     children into the flex column so the photo can slot between them. */
  .hero {
    flex-direction: column;
    gap: 0; /* spacing comes from the children's own margins */
    padding-top: 2.5rem;
  }

  .hero-text {
    display: contents;
  }

  .hero h1 { order: 1; }
  .hero .hero-subtitle { order: 2; margin-bottom: 0.5rem; }
  .hero .hero-visual { order: 3; }
  .hero .hero-text p:not(.hero-subtitle) { order: 4; }

  .hero-visual {
    align-self: center;
    margin: 0.5rem 0 1.25rem;
  }

  /* The caption below is wider than the photo, so the photo needs its own
     centring inside the visual block */
  .hero-photo {
    width: 11rem;
    margin: 0 auto;
  }

  /* Subtitle stacks as two clean lines: role, then university — no dangling
     separator dot */
  .subtitle-sep {
    display: none;
  }

  .subtitle-org {
    display: block;
  }

  /* Caption may run wider than the photo, but never to a third line */
  .hero-caption {
    max-width: 17rem;
  }

  /* The single-row nav is wider than a phone screen — wrap it into two rows:
     icons on top, page links + theme toggle below. */
  .nav {
    flex-wrap: wrap;
    padding: 0.8rem 1.25rem 0.9rem;
    row-gap: 0.45rem;
  }

  .nav-icons {
    gap: 1rem;
  }

  /* Bigger touch targets without changing the look: pad each icon link and
     pull the padding back out of the layout */
  .nav-icons a {
    padding: 0.55rem;
    margin: -0.55rem;
  }

  .nav-right {
    width: 100%;
    justify-content: space-between;
    gap: 0.35rem;
  }

  /* Sized so the links row still fits a 320px screen */
  .nav-link {
    font-size: 0.92rem;
  }

  .theme-toggle {
    padding: 0.32rem;
  }
}
