/* ============================================================
   Christopher J Crowley — personal site
   Design tokens: fluid teal + laser green on ink/paper
   ============================================================ */

/* ---------- Tokens: light (default / system-light) ---------- */
:root {
  --ground:      #f4f6f7;
  --surface:     #ffffff;
  --surface-alt: #eef1f2;
  --ink:         #0f1c26;
  --body:        #2c3b45;
  --muted:       #61727d;
  --line:        #dde3e6;
  --accent:      #0e8f86;   /* fluid teal */
  --accent-deep: #0a6f68;
  --laser:       #3f9e2c;   /* lab green, legible on light */
  --shadow:      0 1px 2px rgba(15,28,38,.04), 0 8px 30px rgba(15,28,38,.06);

  /* Hero + footer band — LIGHT variant (flips with theme) */
  --hero-bg:          #e7eef0;
  --hero-heading:     #0f1c26;
  --hero-text:        #2c3b45;
  --hero-muted:       #5c6f79;
  --hero-line:        rgba(15,28,38,.18);
  --hero-veil-strong: rgba(231,238,240,.92);
  --hero-veil-mid:    rgba(231,238,240,.55);
  --hero-veil-soft:   rgba(231,238,240,.06);
  /* Flow-field canvas colors (read by main.js) */
  --flow-bg:    #e7eef0;
  --flow-fade:  rgba(231,238,240,0.05);
  --flow-teal:  rgba(14,143,134,0.32);
  --flow-green: rgba(63,158,44,0.46);
}
/* ---------- Tokens: dark via OS (only when not explicitly light) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground:      #0c141b;
    --surface:     #111d26;
    --surface-alt: #16232d;
    --ink:         #eaf1f2;
    --body:        #c2ced4;
    --muted:       #8496a0;
    --line:        #21323d;
    --accent:      #35c0b3;
    --accent-deep: #6fd8cc;
    --laser:       #7dd957;
    --shadow:      0 1px 2px rgba(0,0,0,.3), 0 10px 34px rgba(0,0,0,.4);

    --hero-bg:          #08111a;
    --hero-heading:     #ffffff;
    --hero-text:        #eef4f2;
    --hero-muted:       #93a7a1;
    --hero-line:        rgba(255,255,255,.12);
    --hero-veil-strong: rgba(8,17,26,.92);
    --hero-veil-mid:    rgba(8,17,26,.62);
    --hero-veil-soft:   rgba(8,17,26,.15);
    --flow-bg:    #0b141c;
    --flow-fade:  rgba(11,20,28,0.055);
    --flow-teal:  rgba(53,192,179,0.42);
    --flow-green: rgba(125,217,87,0.55);
  }
}
/* ---------- Tokens: dark via explicit toggle ---------- */
:root[data-theme="dark"] {
  --ground:      #0c141b;
  --surface:     #111d26;
  --surface-alt: #16232d;
  --ink:         #eaf1f2;
  --body:        #c2ced4;
  --muted:       #8496a0;
  --line:        #21323d;
  --accent:      #35c0b3;
  --accent-deep: #6fd8cc;
  --laser:       #7dd957;
  --shadow:      0 1px 2px rgba(0,0,0,.3), 0 10px 34px rgba(0,0,0,.4);

  --hero-bg:          #08111a;
  --hero-heading:     #ffffff;
  --hero-text:        #eef4f2;
  --hero-muted:       #93a7a1;
  --hero-line:        rgba(255,255,255,.12);
  --hero-veil-strong: rgba(8,17,26,.92);
  --hero-veil-mid:    rgba(8,17,26,.62);
  --hero-veil-soft:   rgba(8,17,26,.15);
  --flow-bg:    #0b141c;
  --flow-fade:  rgba(11,20,28,0.055);
  --flow-teal:  rgba(53,192,179,0.42);
  --flow-green: rgba(125,217,87,0.55);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--body);
  font-family: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: "Spectral", Georgia, serif; color: var(--ink); text-wrap: balance; margin: 0; font-weight: 500; }
a { color: var(--accent-deep); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
b { color: var(--ink); font-weight: 600; }

.eyebrow {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--accent-deep); margin: 0 0 14px; display: flex; align-items: center; gap: 12px;
}
.eyebrow::before { content: ""; width: 26px; height: 1.5px; background: var(--accent); display: inline-block; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 28px; }
section { padding: 84px 0; border-top: 1px solid var(--line); }
.sec-head { margin-bottom: 40px; max-width: 640px; }
.sec-head h2 { font-size: clamp(28px, 4vw, 40px); line-height: 1.12; }
.sec-head p { color: var(--muted); margin: 14px 0 0; font-size: 17px; }
.lead-para { font-size: 19px; color: var(--ink); font-family: "Spectral", serif; line-height: 1.5; }

/* ---------- Nav ---------- */
header.nav {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--ground) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 20px; }
.brand { font-family: "Spectral", serif; font-weight: 600; font-size: 19px; color: var(--ink); letter-spacing: .01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand .dot { color: var(--accent); }
.nav-links { display: flex; gap: 26px; align-items: center; }
.nav-links a { color: var(--muted); font-size: 14.5px; font-weight: 500; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }
.nav-cta { display: flex; gap: 10px; align-items: center; }
.btn {
  font-family: "IBM Plex Sans", sans-serif; font-size: 14px; font-weight: 600;
  padding: 8px 15px; border-radius: 7px; border: 1px solid var(--accent);
  color: var(--accent-deep); background: transparent; white-space: nowrap; cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.btn:hover { background: var(--accent); color: #fff; text-decoration: none; transform: translateY(-1px); }
.btn.solid { background: var(--accent); color: #fff; }
.btn.solid:hover { background: var(--accent-deep); }
.theme-toggle {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  width: 34px; height: 34px; border-radius: 7px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center; transition: border-color .15s, color .15s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }

/* ---------- Hero ---------- */
.hero { position: relative; background: var(--hero-bg); color: var(--hero-text); overflow: hidden; border-top: none; padding: 0; }
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero::after { /* vignette + legibility */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 78% 20%, transparent 30%, var(--hero-veil-mid) 100%),
              linear-gradient(90deg, var(--hero-veil-strong) 0%, var(--hero-veil-mid) 46%, var(--hero-veil-soft) 100%);
}
.hero-inner { position: relative; z-index: 2; max-width: 1080px; margin: 0 auto; padding: 108px 28px 100px; }
.hero .tag { font-family: "IBM Plex Mono", monospace; font-size: 13px; letter-spacing: .16em; text-transform: uppercase; color: var(--laser); margin: 0 0 20px; }
.hero h1 { color: var(--hero-heading); font-weight: 400; font-size: clamp(44px, 8vw, 84px); line-height: .98; letter-spacing: -.015em; }
.hero h1 span { display: block; }
.hero .role { font-family: "Spectral", serif; font-style: italic; font-size: clamp(19px, 2.6vw, 26px); color: var(--hero-text); margin: 22px 0 0; font-weight: 300; }
.hero .lede { max-width: 540px; color: var(--hero-muted); font-size: 17.5px; line-height: 1.6; margin: 22px 0 34px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.hero .btn { padding: 11px 20px; font-size: 15px; }
.hero .btn.ghost { border-color: var(--hero-line); color: var(--hero-text); }
.hero .btn.ghost:hover { background: color-mix(in srgb, var(--hero-heading) 8%, transparent); border-color: var(--hero-text); }
.hero .btn.laser { background: var(--laser); border-color: var(--laser); color: #06210a; }
.hero .btn.laser:hover { background: #93e86e; border-color: #93e86e; }
.scroll-note { position: absolute; z-index: 2; bottom: 26px; left: 50%; transform: translateX(-50%); font-family: "IBM Plex Mono", monospace; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--hero-muted); }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 56px; align-items: start; }
.about-grid p { margin: 0 0 18px; }
.portrait {
  position: relative; aspect-ratio: 4/5; border-radius: 10px; overflow: hidden;
  background:
    radial-gradient(140% 120% at 70% 15%, rgba(125,217,87,.14), transparent 55%),
    linear-gradient(160deg, #12313a, #0b1a22 70%);
  border: 1px solid var(--line); display: grid; place-items: center; box-shadow: var(--shadow);
}
.portrait span { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .12em; color: rgba(238,244,242,.5); text-align: center; padding: 0 20px; text-transform: uppercase; }
.portrait-img { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); box-shadow: var(--shadow); display: block; }
.facts { margin-top: 22px; display: flex; flex-direction: column; gap: 0; border-top: 1px solid var(--line); }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.facts dt { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; color: var(--ink); font-weight: 500; text-align: right; }

/* ---------- Experience / Education ---------- */
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 56px; }
.col h3 { font-size: 15px; font-family: "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); font-weight: 500; margin-bottom: 8px; }
.tl { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 92px 1fr; gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: none; }
.tl-year { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--accent-deep); font-variant-numeric: tabular-nums; padding-top: 3px; }
.tl-body .t { color: var(--ink); font-weight: 600; font-size: 16.5px; }
.tl-body .o { color: var(--muted); font-size: 14.5px; }
.tl-body .m { color: var(--muted); font-size: 13px; font-style: italic; }

/* ---------- Research ---------- */
.research-lead { max-width: 720px; font-size: 18px; margin-bottom: 40px; }
.more-link { margin: 32px 0 0; font-family: "IBM Plex Mono", monospace; font-size: 14.5px; }
.more-link a { color: var(--accent-deep); }
.more-link a:hover { color: var(--accent); text-decoration: none; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 26px 24px;
  box-shadow: var(--shadow); position: relative;
}
.card .n { font-family: "IBM Plex Mono", monospace; font-size: 12px; color: var(--accent); letter-spacing: .1em; }
.card h3 { font-size: 21px; margin: 14px 0 10px; line-height: 1.2; }
.card p { margin: 0; font-size: 14.5px; color: var(--body); line-height: 1.55; }

/* ---------- Publications ---------- */
.pub-group { margin-bottom: 40px; }
.pub-group:last-child { margin-bottom: 0; }
.pub-group > h3 { font-size: 15px; font-family: "IBM Plex Mono", monospace; text-transform: uppercase; letter-spacing: .14em; color: var(--accent-deep); font-weight: 500; display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.pub-group > h3 .count { color: var(--muted); font-size: 12px; }
.pub { display: grid; grid-template-columns: 30px 1fr; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.pub .idx { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.pub .title { color: var(--ink); font-weight: 500; line-height: 1.4; }
.pub .authors { color: var(--body); font-size: 14.5px; margin-top: 3px; }
.pub .authors b { color: var(--accent-deep); font-weight: 600; }
.pub .venue { font-family: "IBM Plex Mono", monospace; font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.pub .pick { display: inline-block; font-family: "IBM Plex Mono", monospace; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--laser); border: 1px solid color-mix(in srgb, var(--laser) 55%, transparent); border-radius: 20px; padding: 1px 8px; margin-left: 8px; vertical-align: middle; }

/* ---------- Projects (cards are links) ---------- */
.proj-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.proj {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 22px 24px; box-shadow: var(--shadow);
  display: flex; gap: 16px; align-items: flex-start; color: inherit; text-decoration: none;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.proj:hover { text-decoration: none; transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 4px 10px rgba(15,28,38,.06), 0 16px 40px rgba(15,28,38,.10); }
.proj .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--laser); margin-top: 8px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--laser) 18%, transparent); }
.proj .txt { flex: 1; }
.proj h3 { font-size: 18px; margin-bottom: 5px; }
.proj p { margin: 0; font-size: 14.5px; color: var(--body); }
.proj .go { flex: none; align-self: center; font-family: "IBM Plex Mono", monospace; color: var(--muted); transition: transform .15s, color .15s; }
.proj:hover .go { color: var(--accent); transform: translateX(3px); }

/* ---------- Detail / sub-pages ---------- */
.detail { padding: 52px 0 40px; }
.detail .wrap { max-width: 760px; }
.crumb { font-family: "IBM Plex Mono", monospace; font-size: 13px; color: var(--muted); display: flex; gap: 9px; margin-bottom: 26px; flex-wrap: wrap; align-items: center; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--accent-deep); text-decoration: none; }
.crumb .sep { opacity: .5; }
.crumb .cur { color: var(--ink); }
.detail-title { font-size: clamp(32px, 6vw, 52px); line-height: 1.05; margin: 8px 0 0; }
.detail-lede { font-family: "Spectral", serif; font-size: 20px; color: var(--ink); line-height: 1.5; margin: 20px 0 0; }
.media-ph {
  margin: 40px 0; aspect-ratio: 16 / 9; border-radius: 12px; border: 1px solid var(--line);
  background: radial-gradient(140% 120% at 70% 15%, color-mix(in srgb, var(--laser) 12%, transparent), transparent 55%), linear-gradient(160deg, var(--surface-alt), var(--surface));
  display: grid; place-items: center; text-align: center; box-shadow: var(--shadow);
}
.media-ph span { font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 0 24px; }
.detail img.media { width: 100%; border-radius: 12px; border: 1px solid var(--line); margin: 40px 0; display: block; box-shadow: var(--shadow); }
.prose { font-size: 17px; }
.prose p { margin: 0 0 18px; }
.prose h2 { font-size: 24px; margin: 36px 0 12px; }
.prose ul { padding-left: 20px; margin: 0 0 18px; }
.prose li { margin: 0 0 8px; }
.download {
  display: inline-flex; align-items: center; gap: 10px; margin: 8px 0 4px;
  font-family: "IBM Plex Sans", sans-serif; font-size: 15px; font-weight: 600;
  padding: 12px 20px; border-radius: 8px; background: var(--accent); color: #fff; border: 1px solid var(--accent);
  transition: background .15s, transform .15s;
}
.download:hover { background: var(--accent-deep); text-decoration: none; transform: translateY(-1px); }
.note { font-size: 13.5px; color: var(--muted); font-style: italic; margin-top: 10px; }
.back { display: inline-block; margin-top: 44px; font-family: "IBM Plex Mono", monospace; font-size: 14px; color: var(--accent-deep); }
.back:hover { text-decoration: none; color: var(--accent); }

/* figures, video, tables inside detail pages */
.fig { margin: 34px 0; }
.fig img.media, .prose img.media { margin: 0; }
.fig figcaption { font-size: 13.5px; color: var(--muted); font-style: italic; text-align: center; margin-top: 10px; line-height: 1.5; }
.fig-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin: 34px 0; align-items: start; }
.fig-row figure { margin: 0; }
.fig-row img.media { margin: 0; }
.video { position: relative; padding-bottom: 56.25%; height: 0; margin: 34px 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.data-table-wrap { overflow-x: auto; margin: 30px 0; border: 1px solid var(--line); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14.5px; }
table.data caption { text-align: left; padding: 14px 16px 0; color: var(--muted); font-size: 13px; font-style: italic; }
table.data th, table.data td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data thead th { font-family: "IBM Plex Mono", monospace; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; background: var(--surface-alt); position: sticky; top: 0; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }

/* ---------- Resources ---------- */
.res-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 40px; }
.res-list a { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 500; font-size: 15.5px; }
.res-list a:hover { text-decoration: none; color: var(--accent-deep); }
.res-list a .arw { font-family: "IBM Plex Mono", monospace; color: var(--muted); }
.res-list a:hover .arw { color: var(--accent); }

/* ---------- Footer ---------- */
footer { background: var(--hero-bg); color: var(--hero-muted); border-top: 1px solid var(--hero-line); }
.foot-inner { max-width: 1080px; margin: 0 auto; padding: 72px 28px 48px; }
.foot-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.foot-inner h2 { color: var(--hero-heading); font-weight: 400; font-size: clamp(26px, 4vw, 38px); max-width: 460px; line-height: 1.1; }
.foot-links { display: flex; flex-direction: column; gap: 12px; }
.foot-links a { color: var(--hero-text); font-size: 15px; display: flex; align-items: center; gap: 10px; }
.foot-links a .k { font-family: "IBM Plex Mono", monospace; font-size: 11px; color: var(--laser); letter-spacing: .08em; width: 78px; text-transform: uppercase; }
.foot-links a:hover { color: var(--hero-heading); }
.foot-bottom { margin-top: 54px; padding-top: 24px; border-top: 1px solid var(--hero-line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; font-family: "IBM Plex Mono", monospace; font-size: 12px; letter-spacing: .04em; color: var(--hero-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .nav-links { display: none; }
  .about-grid, .cols { grid-template-columns: 1fr; gap: 36px; }
  .cards { grid-template-columns: 1fr; }
  .proj-grid, .res-list { grid-template-columns: 1fr; }
  section { padding: 64px 0; }
}
@media (max-width: 520px) {
  .nav-cta .btn { padding: 7px 11px; font-size: 13px; }
  .brand { font-size: 17px; }
  body { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
