/* ---------- palette ---------- */
:root {
  --bg: #ffffff;
  --fg: #333333;
  --muted: #999999;
  --faint: #bbbbbb;
  --rule: #cfcfcf;
  --hair: #eeeeee;
  --link: #0645ad;
  --accent: #4b3f72;
  --nav-bg: rgba(255, 255, 255, 0.85);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16161a;
    --fg: #d6d6da;
    --muted: #8b8b93;
    --faint: #6d6d75;
    --rule: #3a3a42;
    --hair: #2a2a31;
    --link: #8ab4f8;
    --accent: #b5a8e0;
    --nav-bg: rgba(22, 22, 26, 0.85);
  }
}
:root[data-theme="dark"] {
  --bg: #16161a;
  --fg: #d6d6da;
  --muted: #8b8b93;
  --faint: #6d6d75;
  --rule: #3a3a42;
  --hair: #2a2a31;
  --link: #8ab4f8;
  --accent: #b5a8e0;
  --nav-bg: rgba(22, 22, 26, 0.85);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: 820px;
  margin: 0 auto;
  padding: 0 20px;
}

hr {
  height: 1px;
  border: 0;
  padding: 0;
  margin: 34px 0;
  background-image: linear-gradient(to right,
    rgba(128, 128, 128, 0), var(--rule), rgba(128, 128, 128, 0));
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 10px 16px;
  background: var(--bg);
  color: var(--link);
  border: 1px solid var(--rule);
  border-radius: 0 0 6px 0;
}
.skip-link:focus { left: 0; }

/* ---------- nav ---------- */
#nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--nav-bg);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--hair);
}
.nav-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-name {
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
}
.nav-name:hover { text-decoration: none; color: var(--accent); }
.nav-links {
  display: flex;
  gap: 15px;
  margin-left: auto;
  flex-wrap: nowrap;
  overflow-x: auto;
  min-width: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}
.nav-links a:hover { color: var(--accent); text-decoration: none; }

#theme-toggle {
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--muted);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
  padding: 0;
}
#theme-toggle:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 620px) {
  .nav-name { display: none; }
  /* Seven links will not fit a phone width at a readable size, so keep them on
     one swipeable row instead of wrapping and orphaning the last one. */
  .nav-links { margin-left: 0; flex: 1; gap: 14px; }
  .nav-links a { font-size: 13px; }
}

/* ---------- header ---------- */
header.container { margin-top: 28px; }

.head-row {
  display: flex;
  align-items: center;
  gap: 32px;
}
.head-pic img {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  display: block;
  object-fit: cover;
}
.head-desc { flex: 1; min-width: 0; }

h1 {
  font-size: 34px;
  font-weight: 600;
  letter-spacing: -0.4px;
  margin: 0;
  line-height: 1.15;
}
.tagline {
  font-weight: normal;
  font-style: italic;
  color: var(--muted);
  font-size: 17px;
  margin: 8px 0 10px 0;
  max-width: 34ch;
}
.loc {
  font-size: 14px;
  color: var(--faint);
  margin: 0 0 14px 0;
}

.ico-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  max-width: 400px;
}
.ico-row a, .ico-row button {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  gap: 5px;
  font-size: 12.5px;
  font-family: inherit;
  color: var(--link);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 3px 9px;
  background: transparent;
  cursor: pointer;
  line-height: 1.55;
  transition: border-color 0.15s;
}

/* Shared icon glyph. Inherits colour from its link, so it themes for free. */
.ic {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  color: var(--muted);
  transition: color 0.15s;
}
.ico-row a:hover .ic,
.ico-row button:hover .ic,
.contact-links a:hover .ic { color: var(--link); }
.ico-row a:hover, .ico-row button:hover {
  text-decoration: none;
  border-color: var(--link);
}
#email-out, #email-out-2 {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14.5px;
}

@media (max-width: 700px) {
  header.container { margin-top: 20px; }
  .head-row { flex-direction: column; text-align: center; gap: 18px; }
  .head-pic img { width: 150px; height: 150px; }
  .tagline { max-width: none; }
  .ico-row { justify-content: center; }
}

/* ---------- sections ---------- */
section { scroll-margin-top: 60px; }

.ctitle {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--accent);
  margin: 0 0 22px 0;
}

.lede { font-size: 17.5px; margin-top: 0; }
p { margin: 0 0 14px 0; }

/* ---------- timeline ---------- */
.entry {
  display: grid;
  grid-template-columns: 78px 14px 1fr;
  align-items: stretch;
}
.timespan {
  font-size: 13px;
  text-align: right;
  padding-right: 12px;
  padding-top: 1px;
  color: var(--faint);
  white-space: nowrap;
}
.rail {
  border-left: 2px solid var(--rule);
  position: relative;
}
.entry:last-child .rail { border-left-color: transparent; }
.dot {
  position: absolute;
  top: 5px;
  left: -6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--rule);
  border: 2px solid var(--bg);
}
.desc { padding: 0 0 26px 16px; }
.entry:last-child .desc { padding-bottom: 0; }

.role { font-weight: 600; font-size: 16.5px; }
.where { color: var(--muted); font-size: 14px; margin-bottom: 6px; }
.desc-text { margin-top: 4px; }
.desc ul { margin: 6px 0 0 0; padding-left: 18px; }
.desc li { margin-bottom: 4px; }

@media (max-width: 560px) {
  .entry { grid-template-columns: 60px 14px 1fr; }
  .timespan { font-size: 12px; padding-right: 8px; }
  .desc { padding-left: 12px; }
}

/* ---------- publications ---------- */
.pub {
  border-left: 3px solid var(--rule);
  padding: 2px 0 2px 14px;
  margin-bottom: 20px;
}
.pub-title { font-weight: 600; }
.pub-authors { font-size: 14.5px; color: var(--fg); }
.pub-venue { font-size: 14px; color: var(--muted); font-style: italic; }
.pub-note { font-size: 14px; color: var(--accent); margin-top: 3px; }

/* ---------- projects ---------- */
.project {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--hair);
}
.project:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.proj-head { font-weight: 600; font-size: 16.5px; }
.proj-head .demo {
  font-weight: normal;
  font-size: 13.5px;
  margin-left: 6px;
  white-space: nowrap;
}
.proj-note {
  font-size: 14px;
  color: var(--accent);
  margin-top: 4px;
}
.stack {
  font-size: 13px;
  color: var(--muted);
  margin: 2px 0 8px 0;
}
.project p { margin: 0; }

/* ---------- writing ---------- */
.post-card {
  display: flex;
  gap: 18px;
  align-items: stretch;
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 14px;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s;
}
.post-card:hover {
  text-decoration: none;
  border-color: var(--rule);
  transform: translateY(-2px);
}
.post-thumb {
  width: 132px;
  height: 132px;
  flex-shrink: 0;
  border-radius: 6px;
  object-fit: cover;
  background: #000;
}
.post-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.post-meta {
  font-size: 12px;
  color: var(--faint);
  letter-spacing: 0.3px;
}
.post-title {
  font-size: 16.5px;
  font-weight: 600;
  color: var(--fg);
  margin-top: 3px;
  line-height: 1.3;
}
.post-card:hover .post-title { color: var(--link); }
.post-excerpt {
  font-size: 14.5px;
  color: var(--fg);
  margin-top: 6px;
}
.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}
.post-tags span {
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--hair);
  border-radius: 999px;
  padding: 1px 8px;
}
.post-more {
  font-size: 13px;
  color: var(--link);
  margin-top: 10px;
}
.more-writing {
  font-size: 14px;
  margin: 14px 0 0 0;
}

@media (max-width: 560px) {
  .post-card { flex-direction: column; gap: 12px; }
  .post-thumb { width: 100%; height: 150px; }
}

/* ---------- awards / skills ---------- */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 40px;
}
@media (max-width: 700px) {
  .two-col { grid-template-columns: 1fr; gap: 4px; }
}
h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--fg);
}
.two-col > div > h3:not(:first-child) { margin-top: 22px; }

ul.tight { margin: 0; padding-left: 18px; font-size: 14.5px; }
ul.tight li { margin-bottom: 5px; }

.skills { margin: 0; font-size: 14px; }
.skills dt {
  font-weight: 600;
  color: var(--muted);
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 8px;
}
.skills dd { margin: 1px 0 0 0; }

/* ---------- contact / footer ---------- */
.contact-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
#email-btn-2 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--link);
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}
#email-btn-2:hover { text-decoration: underline; }
#email-btn-2:hover .ic { color: var(--link); }
.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font-size: 14.5px;
  margin: 0 0 14px 0;
}
.contact-links a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.contact-links .ic { width: 15px; height: 15px; }

footer {
  margin: 40px 0 50px 0;
  padding-top: 20px;
  border-top: 1px solid var(--hair);
}
footer p {
  font-size: 13px;
  color: var(--faint);
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .post-card:hover { transform: none; }
}
