/* ----------------------------------------------------------------------------
   Flexoki palette tokens
   https://stephango.com/flexoki
---------------------------------------------------------------------------- */

:root {
  --paper:    #FFFCF0;
  --base-50:  #F2F0E5;
  --base-100: #E6E4D9;
  --base-150: #DAD8CE;
  --base-200: #CECDC3;
  --base-300: #B7B5AC;
  --base-500: #878580;
  --base-600: #6F6E69;
  --base-700: #575653;
  --base-800: #403E3C;
  --base-850: #343331;
  --base-900: #282726;
  --base-950: #1C1B1A;
  --black:    #100F0F;

  --red-l:    #AF3029;
  --red-d:    #D14D41;
  --orange-l: #BC5215;
  --orange-d: #DA702C;
  --yellow-l: #AD8301;
  --yellow-d: #D0A215;
  --green-l:  #66800B;
  --green-d:  #879A39;
  --cyan-l:   #24837B;
  --cyan-d:   #3AA99F;
  --blue-l:   #205EA6;
  --blue-d:   #4385BE;
  --purple-l: #5E409D;
  --purple-d: #8B7EC8;
  --magenta-l:#A02F6F;
  --magenta-d:#CE5D97;
}

/* Light theme */
:root,
[data-theme="light"] {
  --bg:       var(--paper);
  --bg-2:     var(--base-50);
  --ui:       var(--base-100);
  --ui-2:     var(--base-150);
  --ui-3:     var(--base-200);
  --tx-3:     var(--base-300);
  --tx-2:     var(--base-600);
  --tx:       var(--black);
  --accent:   var(--blue-l);
  --accent-2: var(--cyan-l);
}

/* Dark theme */
[data-theme="dark"] {
  --bg:       var(--black);
  --bg-2:     var(--base-950);
  --ui:       var(--base-900);
  --ui-2:     var(--base-850);
  --ui-3:     var(--base-800);
  --tx-3:     var(--base-700);
  --tx-2:     var(--base-500);
  --tx:       var(--base-200);
  --accent:   var(--blue-d);
  --accent-2: var(--cyan-d);
}

/* ----------------------------------------------------------------------------
   Reset / base
---------------------------------------------------------------------------- */

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

html {
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--tx);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-feature-settings: "kern", "liga", "calt";
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--ui-3); color: var(--tx); }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { text-decoration-thickness: 2px; }

h1, h2, h3, h4, h5, h6 {
  color: var(--tx);
  line-height: 1.25;
  margin: 2em 0 0.6em;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.85rem; margin-top: 0; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p, ul, ol, blockquote, pre, table { margin: 0 0 1.1em; }

ul, ol { padding-left: 1.4em; }

blockquote {
  border-left: 2px solid var(--ui-3);
  padding-left: 1em;
  color: var(--tx-2);
  font-style: italic;
}

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

code, pre, kbd, samp {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.92em;
}
code {
  background: var(--ui);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}
pre {
  background: var(--bg-2);
  border: 1px solid var(--ui);
  padding: 0.9em 1em;
  overflow-x: auto;
  border-radius: 4px;
}
pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
}

img { max-width: 100%; height: auto; }

table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--ui); padding: 0.5em 0.6em; text-align: left; }
th { color: var(--tx-2); font-weight: 600; }

/* ----------------------------------------------------------------------------
   Layout — narrow column, gutter-sticky nav on wide screens
---------------------------------------------------------------------------- */

.site {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 2rem 1.25rem 4rem;
  row-gap: 1.5rem;
}

.site > * { min-width: 0; }

.site-header { grid-column: 1; }
.site-nav    { grid-column: 1; }
.site-main   { grid-column: 1; max-width: 38rem; }
.site-footer { grid-column: 1; max-width: 38rem; }

@media (min-width: 1100px) {
  .site {
    grid-template-columns: minmax(10rem, 1fr) minmax(0, 38rem) minmax(2rem, 1fr);
    column-gap: 3rem;
    padding: 3rem 2rem 5rem;
  }
  .site-header { grid-column: 2; }
  .site-main   { grid-column: 2; }
  .site-footer { grid-column: 2; }
  .site-nav {
    grid-column: 1;
    grid-row: 1 / span 3;
    justify-self: end;
    position: sticky;
    top: 3rem;
    align-self: start;
    text-align: right;
  }
}

/* ----------------------------------------------------------------------------
   Header / title / tagline
---------------------------------------------------------------------------- */

.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--ui);
  padding-bottom: 1rem;
}

.site-title {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: var(--tx);
}
.site-title:hover { text-decoration: none; }

.site-name {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.site-tagline {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-style: italic;
  font-size: 0.95rem;
  color: var(--tx-2);
}

/* ----------------------------------------------------------------------------
   Theme toggle
---------------------------------------------------------------------------- */

.theme-toggle {
  background: transparent;
  border: 1px solid var(--ui-2);
  color: var(--tx-2);
  border-radius: 999px;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: border-color 120ms ease, color 120ms ease, background 120ms ease;
}
.theme-toggle:hover {
  border-color: var(--tx-2);
  color: var(--tx);
  background: var(--bg-2);
}

/* ----------------------------------------------------------------------------
   Navigation
---------------------------------------------------------------------------- */

.site-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.site-nav a {
  color: var(--tx-2);
  text-decoration: none;
  font-size: 0.95rem;
}
.site-nav a:hover { color: var(--tx); }
.site-nav .is-active a { color: var(--tx); font-weight: 600; }

@media (min-width: 1100px) {
  .site-nav ul { flex-direction: column; gap: 0.4rem; }
}

/* ----------------------------------------------------------------------------
   Pages and posts
---------------------------------------------------------------------------- */

.page-body, .post-body { font-size: 1rem; }

.about-headshot {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  float: right;
  margin: 0.25rem 0 1rem 1.5rem;
  border: 1px solid var(--ui-2);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.post-body figure {
  margin: 1.5rem auto;
  text-align: center;
}

.post-body figure img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

.post-body figcaption {
  margin-top: 0.5rem;
  color: var(--tx-2);
  font-size: 0.9rem;
  font-style: italic;
  line-height: 1.4;
}

.post-header { margin-bottom: 1.8rem; }
.post-header h1 { margin-bottom: 0.25rem; }

.post-subtitle {
  color: var(--tx-2);
  font-size: 1.05rem;
  line-height: 1.4;
  margin: 0 0 0.5rem;
}

.post-date {
  color: var(--tx-2);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.post-tags {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--tx-2);
}

.post-list {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
}

.post-list-item { padding: 0.4rem 0; border-bottom: 1px solid var(--ui); }
.post-list-item:last-child { border-bottom: 0; }

.post-list-item a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  text-decoration: none;
  color: var(--tx);
}
.post-list-item a:hover .post-list-title { color: var(--accent); }

.post-list-text {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.post-list-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.post-list-subtitle {
  color: var(--tx-2);
  font-size: 0.9rem;
  line-height: 1.35;
}

.post-list-date {
  color: var(--tx-2);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ----------------------------------------------------------------------------
   CV
---------------------------------------------------------------------------- */

.page-body h2 {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tx-3);
  border-bottom: 1px solid var(--ui);
  padding-bottom: 0.4rem;
  margin-top: 2.5rem;
}

.page-body h3 {
  font-size: 1.02rem;
  font-weight: 600;
  margin: 1.4rem 0 0.15rem;
}

.cv-meta {
  margin: 0 0 0.5rem;
  color: var(--tx-2);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.page-body h3 + .cv-meta + ul,
.page-body h3 + .cv-meta {
  margin-top: 0.2rem;
}

/* ----------------------------------------------------------------------------
   Publications
---------------------------------------------------------------------------- */

.pub-list, .pub-year-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pub-year-group { margin-top: 2rem; }
.pub-year-group:first-child { margin-top: 1rem; }

.pub-year {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tx-3);
  margin: 0 0 0.75rem;
  font-variant-numeric: tabular-nums;
}

.pub {
  border-left: 2px solid transparent;
  padding: 0 0 0 1rem;
  margin: 0 0 1.5rem;
}

.pub.is-first-author { border-left-color: var(--accent); }

.pub-title {
  margin: 0 0 0.2rem;
  font-weight: 600;
  font-size: 1rem;
  line-height: 1.35;
}
.pub-title a { color: var(--tx); text-decoration: none; }
.pub-title a:hover { color: var(--accent); text-decoration: underline; }

.pub-authors {
  margin: 0 0 0.15rem;
  font-size: 0.92rem;
  color: var(--tx-2);
  line-height: 1.45;
}
.pub-authors strong { color: var(--tx); font-weight: 600; }

.pub-meta {
  margin: 0;
  font-size: 0.88rem;
  color: var(--tx-2);
}

/* ----------------------------------------------------------------------------
   Blog search (Pagefind)
---------------------------------------------------------------------------- */

.blog-search {
  margin: 1.25rem 0 1.5rem;
  --pagefind-ui-primary:    var(--accent);
  --pagefind-ui-text:       var(--tx);
  --pagefind-ui-background: var(--bg);
  --pagefind-ui-border:     var(--ui-2);
  --pagefind-ui-tag:        var(--ui);
  --pagefind-ui-border-width: 1px;
  --pagefind-ui-border-radius: 4px;
  --pagefind-ui-font: inherit;
}

/* ----------------------------------------------------------------------------
   Footer
---------------------------------------------------------------------------- */

.site-footer {
  margin-top: 3rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--ui);
  color: var(--tx-2);
  font-size: 0.9rem;
}

.socials {
  list-style: none;
  padding: 0;
  margin: 0 0 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
}
.socials a { color: var(--tx-2); text-decoration: none; }
.socials a:hover { color: var(--tx); text-decoration: underline; }

.colophon { margin: 0; font-size: 0.85rem; color: var(--tx-3); }
