/* ---------- Tokens ---------- */
:root {
  --bg: #fbfbf9;
  --surface: #f2f2ee;
  --ink: #1f2328;
  --muted: #5d6470;
  --line: #e3e3dd;
  --accent: #2b5b8a;
  --accent-hover: #1d4163;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --max: 960px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16181b;
    --surface: #1e2125;
    --ink: #e8e8e4;
    --muted: #a0a6b0;
    --line: #2d3136;
    --accent: #7fb0e0;
    --accent-hover: #a6c8ea;
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: clamp(2.4rem, 6vw, 3.6rem); letter-spacing: -0.01em; }
h2 { font-size: 1.8rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1.1em; max-width: 65ch; }
.lead { font-size: 1.25rem; color: var(--muted); }
.muted { color: var(--muted); }

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 1.5rem; }
section { padding: 3.5rem 0; }
section + section { border-top: 1px solid var(--line); }

/* ---------- Header / nav ---------- */
.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-top: 1.1rem; padding-bottom: 1.1rem;
}
.brand { font-family: var(--serif); font-size: 1.35rem; color: var(--ink); text-decoration: none; }
.site-nav ul { list-style: none; display: flex; gap: 1.6rem; margin: 0; padding: 0; }
.site-nav a { color: var(--muted); text-decoration: none; font-size: .95rem; padding: .25rem 0; border-bottom: 2px solid transparent; }
.site-nav a:hover { color: var(--ink); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.nav-toggle {
  display: none; background: none; border: 1px solid var(--line); color: var(--ink);
  font: inherit; font-size: .9rem; padding: .35rem .8rem; border-radius: 6px; cursor: pointer;
}
@media (max-width: 680px) {
  .nav-toggle { display: block; }
  .site-header .wrap { flex-wrap: wrap; }
  .site-nav { width: 100%; display: none; }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; gap: .4rem; padding: .6rem 0 .2rem; }
}

/* ---------- Home ---------- */
.hero { padding: 4.5rem 0 3.5rem; }
.hero-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 3rem; align-items: center; }
.hero-photo { aspect-ratio: 4 / 5; width: 100%; object-fit: cover; border-radius: 8px; background: var(--surface); }
@media (max-width: 780px) {
  .hero-grid { grid-template-columns: 1fr; gap: 2rem; }
  .hero-photo { max-width: 320px; }
}

.button {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  padding: .7rem 1.4rem; border-radius: 6px; font-weight: 500; margin-top: .5rem;
}
.button:hover { background: var(--accent-hover); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .button { color: #101214; } :root:not([data-theme="light"]) .button:hover { color: #101214; } }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; margin-top: 2rem; }
.card { background: var(--surface); border-radius: 8px; padding: 1.5rem; }
.card h3 { margin-bottom: .4rem; }
.card p { margin: 0; color: var(--muted); font-size: .98rem; }
.card a.card-link { display: inline-block; margin-top: .8rem; font-size: .95rem; }

/* ---------- Experience / Resume ---------- */
.entry { display: grid; grid-template-columns: 180px 1fr; gap: 1rem 2rem; padding: 1.6rem 0; border-top: 1px solid var(--line); }
.entry:first-of-type { border-top: 0; }
.entry .when { color: var(--muted); font-size: .92rem; }
.entry h3 { margin-bottom: .1rem; }
.entry .where { color: var(--muted); margin-bottom: .6rem; }
.entry ul { margin: 0; padding-left: 1.1rem; max-width: 65ch; }
.entry li { margin-bottom: .35rem; }
@media (max-width: 680px) { .entry { grid-template-columns: 1fr; gap: .3rem; } }

/* ---------- Contact ---------- */
.contact-list { list-style: none; padding: 0; margin: 1.5rem 0 0; }
.contact-list li { padding: .6rem 0; border-top: 1px solid var(--line); display: flex; gap: 1.5rem; }
.contact-list li:last-child { border-bottom: 1px solid var(--line); }
.contact-list span { color: var(--muted); min-width: 90px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 2rem 0 3rem; font-size: .92rem; color: var(--muted); }
.site-footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.site-footer ul { list-style: none; display: flex; gap: 1.2rem; margin: 0; padding: 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--ink); }

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


/* ---------- Photography gallery ---------- */
/* Photos sit in rows; wider (landscape) photos get more width, so each row is about the same height. */
.gallery { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: 2rem; }
.gallery::after { content: ""; flex-grow: 10; } /* keeps a short last row from stretching */
.gallery figure {
  --r: 1.5;                          /* width / height of the photo; set by script.js */
  margin: 0;
  flex-grow: var(--r);
  flex-basis: calc(var(--r) * 240px); /* 240px is the target row height */
}
.gallery a { display: block; }
.gallery img {
  width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover;
  border-radius: 4px; background: var(--surface);
}
.gallery a:hover img { opacity: .92; }
.gallery figcaption { font-size: .88rem; color: var(--muted); padding-top: .4rem; }


/* ---------- Embedded resume PDF ---------- */
.pdf-frame {
  display: block;
  width: 100%;
  height: 85vh;
  min-height: 600px;
  margin-top: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.pdf-frame p { padding: 1.5rem; }

/* ---------- Project write-ups (projects.html) ---------- */
.project-index ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: flex; flex-wrap: wrap; gap: .6rem 1.6rem; }
.project h3 { margin-top: 2rem; }
.project ul { max-width: 65ch; padding-left: 1.1rem; }
.project li { margin-bottom: .5rem; }
.tools { color: var(--muted); font-size: .92rem; }
.project-figure { margin: 2rem 0; }
.project-figure img { width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--line); }
.project-figure figcaption { font-size: .88rem; color: var(--muted); padding-top: .5rem; max-width: 65ch; }
