/* ============================================================
   Toby L. Kirk — personal academic site
   Editorial serif + fluid motifs. No frameworks.
   ============================================================ */

:root {
  --paper: #f7f3ec;
  --paper-2: #efe9dd;
  --paper-3: #e7e0d1;
  --ink: #1d1a16;
  --ink-soft: #5c564c;
  --ink-faint: #8a8377;
  --accent: #0e6a63;
  --accent-deep: #0a4f4a;
  --rule: rgba(29, 26, 22, 0.16);
  --rule-soft: rgba(29, 26, 22, 0.08);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
  --max: 1120px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 300;
  font-size: 1.075rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: var(--paper); }

a { color: var(--accent-deep); text-decoration: none; }
a:hover { color: var(--accent); }

img { max-width: 100%; display: block; }

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

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.1rem clamp(1.25rem, 4vw, 3rem);
  transition: background 0.35s ease, box-shadow 0.35s ease, padding 0.35s ease;
}
.nav.scrolled {
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 var(--rule-soft);
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.nav-name {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.nav-name:hover { color: var(--accent); }

.nav-links {
  display: flex;
  gap: clamp(0.9rem, 2vw, 1.6rem);
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.nav-links a {
  color: var(--ink-soft);
  padding-bottom: 3px;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav-links a:hover { color: var(--ink); }
.nav-links a.active {
  color: var(--accent-deep);
  border-bottom-color: var(--accent);
}
.nav-contact { color: var(--accent-deep) !important; }

@media (max-width: 720px) {
  .nav { position: absolute; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .nav.scrolled { background: none; backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
  .nav-links { flex-wrap: wrap; gap: 0.8rem 1rem; }
}

/* ---------------- Hero ---------------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  overflow: hidden;
}

#flow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-inner {
  position: relative;
  z-index: 2;
  max-width: var(--max);
  margin: 0 auto;
  padding: clamp(6rem, 14vh, 9rem) clamp(1.25rem, 4vw, 3rem) 4rem;
}

.hero-kicker {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 1.6rem;
}

.hero-name {
  font-family: var(--serif);
  font-optical-sizing: auto;
  font-size: clamp(3.2rem, 10vw, 7.5rem);
  font-weight: 300;
  line-height: 1.02;
  letter-spacing: -0.015em;
  margin-bottom: 2rem;
}

.hero-line {
  max-width: 34em;
  font-size: clamp(1.1rem, 1.6vw, 1.35rem);
  line-height: 1.55;
  color: var(--ink-soft);
}
.hero-line em {
  font-style: italic;
  color: var(--accent-deep);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2.6rem;
}
.hero-links a {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  border: 1px solid var(--ink);
  padding: 0.6rem 1.3rem;
  transition: border-color 0.25s, color 0.25s, background 0.25s;
  background: color-mix(in srgb, var(--paper) 55%, transparent);
}
.hero-links a:hover {
  border-color: var(--accent-deep);
  background: var(--accent-deep);
  color: var(--paper);
}

.hero-scroll {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 1.6rem;
  transform: translateX(-50%);
  color: var(--ink-faint);
  font-size: 1.1rem;
  animation: drift 2.6s ease-in-out infinite;
}
@keyframes drift {
  0%, 100% { transform: translate(-50%, 0); }
  50% { transform: translate(-50%, 8px); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-scroll { animation: none; }
}

/* ---------------- Sections ---------------- */

.section {
  padding: clamp(4.5rem, 10vw, 8rem) clamp(1.25rem, 4vw, 3rem);
}
.section > * {
  max-width: var(--max);
  margin-left: auto;
  margin-right: auto;
}
.section-alt {
  background: var(--paper-2);
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
}

.section-head {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 1.1rem;
  margin-bottom: clamp(2rem, 5vw, 3.5rem);
}
.section-head h2 {
  font-family: var(--serif);
  font-size: clamp(1.9rem, 4vw, 3rem);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.section-intro {
  max-width: 46em;
  font-size: 1.12rem;
  color: var(--ink-soft);
  margin-bottom: clamp(2.2rem, 5vw, 3.6rem);
}

/* ---------------- About ---------------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr;
  gap: clamp(2rem, 5vw, 4.5rem);
  align-items: start;
}
@media (max-width: 820px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-photo { max-width: 340px; }
}

.about-photo img {
  filter: saturate(0.92);
  box-shadow: 0 18px 44px -18px rgba(29, 26, 22, 0.35);
}
.about-photo figcaption {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-top: 0.9rem;
}

.about-text p + p { margin-top: 1.15rem; }
.about-text .lede {
  font-size: 1.35rem;
  line-height: 1.5;
  font-weight: 300;
  letter-spacing: -0.005em;
}
.about-text strong { font-weight: 500; }
.about-phd {
  font-style: italic;
  color: var(--accent-deep);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule-soft);
  border-top: 1px solid var(--rule-soft);
  border-bottom: 1px solid var(--rule-soft);
  margin-top: clamp(2.5rem, 6vw, 4.5rem);
}
@media (max-width: 640px) {
  .metrics { grid-template-columns: 1fr; }
}
.metric {
  background: var(--paper);
  padding: 1.6rem 1rem;
  text-align: center;
}
.metric-n {
  display: block;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 2.9rem);
  font-weight: 400;
  color: var(--accent-deep);
  line-height: 1.1;
}
.metric-l {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* ---------------- Research ---------------- */

.research-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(1.25rem, 3vw, 2.5rem);
}
@media (max-width: 900px) {
  .research-grid { grid-template-columns: 1fr; }
}

.research-card {
  background: var(--paper);
  border: 1px solid var(--rule-soft);
  padding: clamp(1.5rem, 3vw, 2.2rem);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}
.research-card:hover {
  transform: translateY(-4px);
  border-color: var(--rule);
  box-shadow: 0 22px 40px -24px rgba(29, 26, 22, 0.3);
}
.research-icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
  margin-bottom: 1.2rem;
}
.research-card h3 {
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 0.8rem;
}
.research-card p {
  font-size: 0.98rem;
  color: var(--ink-soft);
}

/* ---------------- Highlights ---------------- */

.hl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(1.75rem, 4vw, 4rem);
  align-items: center;
  padding: clamp(2.2rem, 5vw, 3.6rem) 0;
}
.hl + .hl { border-top: 1px solid var(--rule-soft); }
.hl:nth-child(even) .hl-fig { order: 2; }
@media (max-width: 820px) {
  .hl { grid-template-columns: 1fr; }
  .hl:nth-child(even) .hl-fig { order: 0; }
}

.hl-fig {
  background: #fff;
  border: 1px solid var(--rule-soft);
  padding: clamp(0.8rem, 2vw, 1.4rem);
  box-shadow: 0 24px 48px -30px rgba(29, 26, 22, 0.35);
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}
.hl:hover .hl-fig {
  transform: translateY(-4px);
  box-shadow: 0 30px 56px -30px rgba(29, 26, 22, 0.42);
}
.hl-fig img { border-radius: 0; }
.hl-fig figcaption {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--ink-faint);
  letter-spacing: 0.04em;
  margin-top: 0.8rem;
}

.hl-meta {
  font-family: var(--sans);
  font-size: 0.74rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.7rem;
}
.hl-year {
  color: var(--accent);
  font-weight: 600;
}
.hl-body h3 {
  font-family: var(--serif);
  font-size: clamp(1.35rem, 2.4vw, 1.8rem);
  font-weight: 500;
  line-height: 1.28;
  letter-spacing: -0.005em;
  margin-bottom: 0.55rem;
}
.hl-body h3 a {
  color: var(--ink);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.35s ease, color 0.25s ease;
}
.hl-body h3 a:hover {
  color: var(--accent-deep);
  background-size: 100% 1px;
}
.hl-authors {
  font-family: var(--sans);
  font-size: 0.83rem;
  font-weight: 450;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
}
.hl-body > p:last-child {
  font-size: 0.99rem;
  color: var(--ink-soft);
}

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

.pub-year {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent-deep);
  border-bottom: 1px solid var(--rule-soft);
  padding-bottom: 0.5rem;
  margin: 2.8rem 0 1rem;
}
.pub-list > .pub-year:first-child { margin-top: 0; }

.pubs {
  list-style: none;
}
.pubs li {
  display: flex;
  gap: 1.1rem;
  padding: 0.65rem 0;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.pub-y {
  flex: 0 0 3em;
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent);
  padding-top: 0.25em;
}
.pub-t { flex: 1; }
.pubs li + li { border-top: 1px dashed var(--rule-soft); }
.pubs .pa { color: var(--ink-soft); }
.pubs .pa b { font-weight: 500; color: var(--ink); }
.pubs a {
  color: var(--ink);
  font-weight: 400;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.3s ease, color 0.2s ease;
}
.pubs a:hover { color: var(--accent-deep); background-size: 100% 1px; }
.pubs i { color: var(--ink-faint); }

/* ---------------- Collaborators (network) ---------------- */

.net {
  position: relative;
  height: 600px;
}

.net-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.net-edges .e {
  stroke: rgba(29, 26, 22, 0.16);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}
.net-edges .e2 {
  stroke: rgba(14, 106, 99, 0.28);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  vector-effect: non-scaling-stroke;
}

.net-dot {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 4px var(--paper-2);
}
.net-dot-hub {
  width: 15px;
  height: 15px;
  background: var(--ink);
  box-shadow: 0 0 0 4px var(--paper-2), 0 0 0 5px var(--rule);
}

.net-node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, 14px);
  text-align: center;
  width: max-content;
  max-width: 190px;
  background: var(--paper-2);
  padding: 0.15rem 0.5rem;
}
.net-node.lab-up {
  transform: translate(-50%, calc(-100% - 14px));
}
a.net-node { display: block; color: inherit; }
.net-node h3 {
  font-family: var(--serif);
  font-size: 1.08rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: 0.2rem;
  color: var(--ink);
  transition: color 0.25s ease;
}
.net-node:hover h3 {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.net-node p {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-deep);
}
.net-hub h3 {
  font-size: 1.3rem;
  font-weight: 600;
}

/* Narrow screens: collapse the graph into a vertical chain on a spine */
@media (max-width: 760px) {
  .net { height: auto; }
  .net-edges, .net-dot { display: none; }
  .net-node,
  .net-node.lab-up {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    text-align: left;
    max-width: none;
    width: auto;
    margin-left: 6px;
    padding: 0.85rem 0 0.85rem 1.6rem;
    border-left: 1px solid var(--rule);
  }
  .net-node::before {
    content: "";
    position: absolute;
    left: -5px;
    top: 1.35rem;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px var(--paper-2);
  }
  .net-hub::before {
    width: 13px;
    height: 13px;
    left: -7px;
    background: var(--ink);
  }
}

/* ---------------- Teaching ---------------- */

.teach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
}
@media (max-width: 900px) { .teach-grid { grid-template-columns: 1fr; } }

.teach-col h3 {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule-soft);
}
.teach-col ul { list-style: none; }
.teach-col li {
  font-size: 0.97rem;
  color: var(--ink-soft);
  padding: 0.45rem 0;
}
.teach-col li b { font-weight: 500; color: var(--ink); }
.teach-col p {
  font-size: 0.97rem;
  color: var(--ink-soft);
}

/* ---------------- Contact ---------------- */

.contact {
  text-align: left;
  position: relative;
  overflow: hidden;
}
#flow-contact {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.contact > *:not(canvas) {
  position: relative;
  z-index: 1;
}
.contact-line {
  font-size: 1.15rem;
  color: var(--ink-soft);
  margin-bottom: 1.4rem;
}
button.contact-email {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}
.contact-email {
  display: inline-block;
  font-family: var(--serif);
  font-size: clamp(1.6rem, 5vw, 3.4rem);
  font-weight: 300;
  letter-spacing: -0.01em;
  color: var(--ink);
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 0% 2px;
  background-repeat: no-repeat;
  background-position: 0 96%;
  transition: background-size 0.45s ease, color 0.3s ease;
  word-break: break-all;
}
.contact-email:hover { color: var(--accent-deep); background-size: 100% 2px; }
.contact-addr {
  margin-top: 1.6rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

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

.footer {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 2rem clamp(1.25rem, 4vw, 3rem);
  border-top: 1px solid var(--rule-soft);
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--ink-faint);
}
.footer-links { display: flex; gap: 1.4rem; }
.footer-links a {
  color: var(--ink-soft);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.footer-links a:hover { color: var(--accent-deep); }

/* ---------------- Reveal animation ---------------- */

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s cubic-bezier(0.22, 0.6, 0.25, 1),
              transform 0.7s cubic-bezier(0.22, 0.6, 0.25, 1);
}
.reveal.in {
  opacity: 1;
  transform: none;
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}
