/* ==========================================================
   Colors and fonts live here. Change --accent to restyle the site.
   ========================================================== */
:root {
  --bg: #ffffff;
  --text: #1f2328;
  --muted: #6a6f76;
  --border: #e7e5e1;
  --accent: #9b3d27;
  --nav-bg: #ffffff;

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --nav-h: 56px;
}

/* Dark colors, used when the visitor's system is in dark mode
   (unless they picked light with the button)... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514;
    --text: #e9e7e3;
    --muted: #a29e98;
    --border: #2d2b28;
    --accent: #e59a82;
    --nav-bg: #252321;
  }
}

/* ...or when they pick dark with the button. Keep these two blocks the same. */
:root[data-theme="dark"] {
  --bg: #161514;
  --text: #e9e7e3;
  --muted: #a29e98;
  --border: #2d2b28;
  --accent: #e59a82;
  --nav-bg: #252321;
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

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

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); scrollbar-gutter: stable; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding-top: var(--nav-h);
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.muted { color: var(--muted); }

/* ==========================================================
   Top navigation bar (stays at the top while scrolling)
   ========================================================== */
.site-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: var(--nav-h);
  background: var(--nav-bg);
  border-bottom: 1px solid var(--border);
}
.nav-inner {
  max-width: 1040px; height: 100%;
  margin: 0 auto; padding: 0 32px;
  display: flex; align-items: center;
}
.nav-links {
  list-style: none; display: flex; gap: 32px;
  overflow-x: auto; scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-links a {
  display: block; padding: 4px 0;
  color: var(--text); text-decoration: none; white-space: nowrap;
  font-size: 1.05rem; border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: var(--accent); }
.nav-links a[aria-current="page"] { border-bottom-color: var(--accent); }

/* Light/dark button, right after the menu */
.theme-toggle {
  flex-shrink: 0; margin-left: 24px;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: none; color: var(--text);
  border: 0; cursor: pointer;
}
.theme-toggle:hover { color: var(--accent); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Show the moon in light mode and the sun in dark mode */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ==========================================================
   Layout: profile on the left, content on the right
   ========================================================== */
.layout {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 32px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 80px;
}

/* ---- Profile column ---- */
.profile { position: sticky; top: var(--nav-h); align-self: start; padding: 40px 0; }

.photo {
  width: 160px; height: auto; aspect-ratio: 4 / 5; object-fit: cover;
  border-radius: 8px; margin-bottom: 20px;
}
.profile .name { font-family: var(--serif); font-size: 1.55rem; font-weight: 600; line-height: 1.25; }
.role { margin-top: 8px; font-weight: 600; line-height: 1.4; }
.profile .muted { margin-top: 2px; }
.status { margin-top: 12px; color: var(--muted); font-size: 0.94rem; }

.links { list-style: none; margin-top: 20px; display: flex; flex-wrap: wrap; gap: 2px 16px; }

.toc {
  margin-top: 28px; padding-top: 20px;
  border-top: 1px solid var(--border);
  display: grid; gap: 2px;
}
.toc a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.toc a:hover { color: var(--text); }

/* ---- Content column ---- */
.content { padding: 40px 0 48px; min-width: 0; }

.page-title { font-family: var(--serif); font-size: 2rem; font-weight: 600; margin-bottom: 16px; }
.pdf-note { margin-bottom: 40px; }
.placeholder { color: var(--muted); font-style: italic; margin-bottom: 8px; }

.content section { padding-bottom: 48px; margin-bottom: 48px; border-bottom: 1px solid var(--border); }
.content section:last-of-type { border-bottom: 0; margin-bottom: 0; }

.content h2 { font-family: var(--serif); font-size: 1.5rem; font-weight: 600; margin-bottom: 24px; }
.content h2.subhead { margin-top: 48px; }

#about p + p { margin-top: 16px; }
.lead { font-size: 1.15rem; }

.focus-list { list-style: none; margin-top: 28px; display: grid; gap: 14px; }
.focus-list h3 { font-size: 1rem; font-weight: 600; }
.focus-list p { color: var(--muted); }

/* ---- Entries: experience, leadership, education ---- */
.timeline { list-style: none; display: grid; gap: 32px; }

.entry {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "body meta";
  column-gap: 24px;
}
.entry-body { grid-area: body; }
.entry-meta {
  grid-area: meta;
  display: flex; flex-direction: column;
  text-align: right; white-space: nowrap;
  color: var(--muted); font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.entry-body h3 { font-size: 1.05rem; font-weight: 600; }
.org { color: var(--muted); margin-top: 2px; }
.entry-body > p:not(.org) { margin-top: 8px; }
.entry-body > ul:not(.tags) { margin-top: 10px; padding-left: 20px; }
.entry-body > ul:not(.tags) li + li { margin-top: 4px; }

/* Tags shown as one quiet line: Python · SQL · ... */
.tags { list-style: none; margin-top: 10px; display: flex; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; }
.tags li:not(:last-child)::after { content: "·"; margin: 0 8px; }

/* ---- Projects ---- */
.project-list { display: grid; gap: 36px; }
.kicker { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; }
.project h3 { font-size: 1.1rem; font-weight: 600; margin: 4px 0 8px; }
.project-links { margin-top: 10px; font-weight: 600; }
.project-links .sep { margin: 0 8px; color: var(--muted); font-weight: 400; }

/* ---- Awards ---- */
.awards { list-style: none; display: grid; gap: 16px; }
.awards li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 16px; }
.awards .year { color: var(--muted); font-variant-numeric: tabular-nums; }
.awards h3 { font-size: 1rem; font-weight: 600; }
.awards p { color: var(--muted); }

/* ---- Skills ---- */
.skills { margin: 0; display: grid; gap: 12px; }
.skill-group { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 16px; }
.skill-group dt { font-weight: 600; }
.skill-group dd { margin: 0; }

/* ---- Post lists: Projects page and Latest Updates on the homepage ---- */
.post-list { list-style: none; display: grid; gap: 32px; }
.content .post-title { font-family: var(--serif); font-size: 1.3rem; font-weight: 600; line-height: 1.3; margin: 0; }
.post-title a { text-decoration: none; }
.post-title a:hover { text-decoration: underline; }
.post-meta { color: var(--muted); font-size: 0.92rem; margin: 4px 0 8px; }
.post-meta .tag { font-weight: 600; text-decoration: none; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.82rem; }
.content h2.updates-title { margin-top: 48px; margin-bottom: 20px; }
.more-note { margin-top: 40px; }

/* ---- Single project page ---- */
.back-link { margin-bottom: 12px; font-size: 0.95rem; }
.back-link a { text-decoration: none; }
.download { margin-top: 20px; }
.update-log { margin: 10px 0 36px; padding-left: 22px; }
.update-log li + li { margin-top: 4px; }

.article p + p, .article p + ul, .article ul + p { margin-top: 14px; }
.article ul { padding-left: 22px; margin-top: 12px; }
.article li + li { margin-top: 6px; }
.content .article h2 { font-size: 1.35rem; margin: 40px 0 12px; }

.photo-figure { margin: 28px 0; }
.photo-figure img { width: 100%; height: auto; border-radius: 8px; }
.photo-figure.portrait img { max-width: 340px; }
.photo-figure figcaption { color: var(--muted); font-size: 0.9rem; margin-top: 8px; }

.site-footer { color: var(--muted); font-size: 0.9rem; margin-top: 48px; }

/* ==========================================================
   Short laptop screens: let the profile scroll with the page
   ========================================================== */
@media (max-height: 760px) {
  .profile { position: static; }
}

/* ==========================================================
   Tablets and phones: profile on top, content below
   ========================================================== */
@media (max-width: 860px) {
  .nav-inner { padding: 0 24px; }
  .layout { grid-template-columns: 1fr; gap: 0; padding: 0 24px; }
  .profile { position: static; padding: 32px 0; border-bottom: 1px solid var(--border); }
  .photo { width: 140px; }
  .toc { display: none; }
  .content { padding-top: 40px; }
}

@media (max-width: 560px) {
  .nav-inner { padding: 0 16px; }
  .nav-links { gap: 18px; }
  .nav-links a { font-size: 0.98rem; }
  .theme-toggle { margin-left: auto; }
  .layout { padding: 0 16px; }
  .entry { grid-template-columns: 1fr; grid-template-areas: "meta" "body"; }
  .entry-meta { flex-direction: row; flex-wrap: wrap; gap: 0 12px; text-align: left; white-space: normal; margin-bottom: 2px; }
  .skill-group { grid-template-columns: 1fr; gap: 0; }
  .content section { padding-bottom: 40px; margin-bottom: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
