/* ==========================================================================
   Richard J. Barker CV: CoSE theme
   Palette sampled from cosecloud.com (#004053 deep teal, #0f7f9f cyan,
   #5590ad steel). Type: IBM Plex Sans / Plex Mono (CoSE house fonts).
   ========================================================================== */

:root {
  color-scheme: light;
  --bg: #f5f8f9;
  --surface: #ffffff;
  --surface-2: #eaf1f3;
  --ink: #0f2a33;
  --ink-soft: #3d5a64;
  --muted: #5f7f8a;
  --rule: #cfdde1;
  --primary: #004053;
  --primary-ink: #ffffff;
  --accent: #0f7f9f;
  --accent-soft: #d7ebf1;
  --steel: #5590ad;
  --leaf: #3f7d4e;
  --leaf-soft: #e1efe4;
  --shadow: 0 1px 2px rgb(0 40 53 / .06), 0 4px 16px rgb(0 40 53 / .06);
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 70rem;
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1a20;
  --surface: #10262e;
  --surface-2: #163340;
  --ink: #e4eef1;
  --ink-soft: #b5c9cf;
  --muted: #8ba6af;
  --rule: #23434f;
  --primary: #7ec3d8;
  --primary-ink: #04212a;
  --accent: #4fc0dd;
  --accent-soft: #123b48;
  --steel: #8db7cf;
  --leaf: #8fcf9d;
  --leaf-soft: #17352a;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  transition: background-color .25s ease, color .25s ease;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--primary); }
[data-theme="dark"] a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3, h4 { line-height: 1.2; color: var(--ink); margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); letter-spacing: -.02em; }
h2 { font-size: 1.5rem; letter-spacing: -.01em; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
code, .mono { font-family: var(--mono); font-size: .9em; }
img { max-width: 100%; height: auto; }

.skip-link { position: absolute; left: -999px; top: .5rem; background: var(--primary); color: var(--primary-ink); padding: .5rem 1rem; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: .5rem; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.site-header .wrap { display: flex; align-items: center; gap: .75rem; min-height: 4rem; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); font-weight: 600; white-space: nowrap; }
.brand-mark {
  display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink); font-family: var(--mono); font-size: .8rem; letter-spacing: .02em;
}
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; line-height: 1.1; }
.site-nav { display: flex; gap: .15rem; margin-left: auto; flex-wrap: wrap; }
.site-nav a { color: var(--ink-soft); text-decoration: none; padding: .4rem .5rem; border-radius: var(--radius-sm); font-size: .95rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }

.header-tools { display: flex; align-items: center; gap: .5rem; }
.version-switch {
  display: inline-flex; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; background: var(--surface);
}
.version-switch a {
  font-size: .8rem; text-decoration: none; color: var(--ink-soft); padding: .25rem .7rem; border-radius: 999px; white-space: nowrap;
}
.version-switch a[aria-current="true"] { background: var(--primary); color: var(--primary-ink); }

.icon-btn {
  display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink); cursor: pointer; padding: 0;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

.nav-toggle { display: none; }
@media (max-width: 860px) {
  .site-header .wrap { flex-wrap: wrap; padding-block: .5rem; }
  .nav-toggle { display: inline-grid; margin-left: auto; }
  .site-nav { order: 10; width: 100%; display: none; flex-direction: column; padding-bottom: .5rem; }
  .site-nav.open { display: flex; }
  .header-tools { margin-left: 0; }
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: 4rem 0 3rem; overflow: hidden; }
.hero::before {
  /* faint orbit + root motif */
  content: ""; position: absolute; inset: -20% -10% auto auto; width: 38rem; height: 38rem; pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, transparent 58%, color-mix(in srgb, var(--accent) 18%, transparent) 58.3%, transparent 58.9%),
    radial-gradient(circle at 50% 50%, transparent 44%, color-mix(in srgb, var(--steel) 14%, transparent) 44.3%, transparent 44.8%),
    radial-gradient(circle at 50% 50%, transparent 30%, color-mix(in srgb, var(--leaf) 14%, transparent) 30.3%, transparent 30.8%);
  opacity: .9;
}
.hero .wrap { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 2rem; align-items: center; }
.avatar { width: 8.5rem; height: 8.5rem; border-radius: 50%; border: 3px solid var(--surface); box-shadow: var(--shadow); object-fit: cover; }
.eyebrow { font-family: var(--mono); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: .5rem; }
.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 46rem; }
.roles { list-style: none; padding: 0; margin: 0 0 1rem; color: var(--ink-soft); font-size: .98rem; }
.roles li::before { content: "▸ "; color: var(--accent); }
@media (max-width: 640px) { .hero .wrap { grid-template-columns: 1fr; } .avatar { width: 6.5rem; height: 6.5rem; } }

.link-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.btn {
  display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .9rem; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--ink); text-decoration: none; font-size: .92rem; font-weight: 500;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn svg { width: 1rem; height: 1rem; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.1); color: var(--primary-ink); }

/* ---------- Sections ---------- */
main section { padding: 2.5rem 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--rule); margin-bottom: 1.5rem; padding-bottom: .5rem; }
.section-head h2 { margin: 0; }
.section-head .aside { color: var(--muted); font-size: .9rem; }
.section-alt { background: var(--surface-2); }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.card h3 { margin-bottom: .35rem; }
.card p:last-child { margin-bottom: 0; }
.card .card-foot { margin-top: auto; padding-top: .75rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.card-icon { font-size: 1.6rem; line-height: 1; margin-bottom: .6rem; }

/* Landing doors */
.doors { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.25rem; margin-top: 2rem; }
.door { text-decoration: none; color: inherit; transition: transform .15s ease, border-color .15s ease; }
.door:hover { transform: translateY(-2px); border-color: var(--accent); color: inherit; }
.door .go { color: var(--accent); font-weight: 600; margin-top: auto; }

/* Project hubs (landing): umbrella hub spans the row, themed hubs 4 → 2 → 1 across */
.hub-grid { grid-template-columns: repeat(4, 1fr); }
.hub-grid .featured { grid-column: 1 / -1; }
@media (max-width: 960px) { .hub-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .hub-grid { grid-template-columns: 1fr; } }

/* Metrics */
.metric { text-align: left; }
.metric .num { font-family: var(--mono); font-size: 2rem; font-weight: 500; color: var(--primary); line-height: 1.1; }
.metric .lbl { color: var(--ink-soft); font-size: .92rem; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-family: var(--mono); padding: .15rem .55rem; border-radius: 999px;
  background: var(--accent-soft); color: var(--primary); text-decoration: none; border: 1px solid transparent; white-space: nowrap;
}
[data-theme="dark"] .chip { color: var(--accent); }
a.chip:hover { border-color: var(--accent); }
.chip.leaf { background: var(--leaf-soft); color: var(--leaf); }
.chip.badge { background: var(--primary); color: var(--primary-ink); }
.chip svg { width: .85rem; height: .85rem; }

/* Timeline entries */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; padding: .9rem 0; border-bottom: 1px dashed var(--rule); }
.entry:last-child { border-bottom: 0; }
.entry .when { font-family: var(--mono); font-size: .85rem; color: var(--muted); padding-top: .15rem; }
.entry .what strong { display: block; }
.entry .where { color: var(--ink-soft); font-size: .95rem; }
.entry .detail { margin-top: .3rem; font-size: .95rem; }
@media (max-width: 600px) { .entry { grid-template-columns: 1fr; gap: .2rem; } }

/* Themes (academic research areas) */
.theme-card .kw { margin-top: .5rem; display: flex; flex-wrap: wrap; gap: .3rem; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; color: var(--ink-soft); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }

/* ---------- Publications ---------- */
.pub-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: 1.25rem; }
.pub-tools input[type="search"] {
  flex: 1 1 16rem; padding: .55rem .8rem; border-radius: var(--radius-sm); border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink); font: inherit; font-size: .95rem;
}
.filter-btn {
  font: inherit; font-size: .82rem; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--rule);
  background: var(--surface); color: var(--ink-soft); cursor: pointer;
}
.filter-btn[aria-pressed="true"] { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.pub-count { color: var(--muted); font-size: .9rem; margin-left: auto; font-family: var(--mono); }

.pub-year { font-family: var(--mono); color: var(--muted); font-size: .9rem; margin: 1.5rem 0 .25rem; border-bottom: 1px solid var(--rule); padding-bottom: .2rem; }
.pubs { list-style: none; margin: 0; padding: 0; counter-reset: pub; }
.pub { padding: .85rem 0; border-bottom: 1px dashed var(--rule); }
.pub:last-child { border-bottom: 0; }
.pub .title { font-weight: 600; color: var(--ink); }
.pub .title a { color: inherit; text-decoration: none; }
.pub .title a:hover { color: var(--accent); text-decoration: underline; }
.pub .authors { font-size: .92rem; color: var(--ink-soft); }
.pub .authors .me { font-weight: 700; color: var(--ink); }
.pub .venue { font-size: .92rem; color: var(--ink-soft); }
.pub .venue em { color: var(--ink); }
.pub .meta { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .4rem; align-items: center; }
.pub .summary { font-size: .95rem; margin: .35rem 0 0; }
.pub[hidden] { display: none; }
.copy-bib { font: inherit; font-size: .78rem; font-family: var(--mono); padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--rule); background: transparent; color: var(--ink-soft); cursor: pointer; }
.copy-bib:hover { border-color: var(--accent); color: var(--accent); }

/* Highlight cards (general) */
.highlight .venue { font-size: .85rem; color: var(--muted); font-family: var(--mono); }

/* ---------- Repo cards ---------- */
.repo h3 { font-family: var(--mono); font-size: 1rem; word-break: break-word; }
.repo .repo-meta { display: flex; gap: .9rem; font-size: .82rem; color: var(--muted); font-family: var(--mono); margin-top: .5rem; flex-wrap: wrap; }
.lang-dot { display: inline-block; width: .65rem; height: .65rem; border-radius: 50%; background: var(--steel); margin-right: .3rem; vertical-align: middle; }
.project-group { margin-bottom: 2.5rem; }
.project-group > p { color: var(--ink-soft); max-width: 48rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding: 2rem 0 3rem; color: var(--muted); font-size: .9rem; }
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: center; }
.site-footer .links { display: flex; flex-wrap: wrap; gap: .5rem; }

.note { font-size: .9rem; color: var(--muted); }
.callout { border-left: 3px solid var(--accent); background: var(--surface); padding: 1rem 1.25rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Print (Academic CV prints cleanly) ---------- */
@media print {
  :root, [data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #fff; --ink: #000; --ink-soft: #222; --muted: #444; --rule: #bbb;
    --primary: #004053; --accent: #004053; --accent-soft: #fff; --shadow: none;
  }
  body { font-size: 10.5pt; }
  .site-header, .site-footer, .pub-tools, .copy-bib, .no-print, .hero::before, .skip-link { display: none !important; }
  .hero { padding: 0 0 1rem; }
  .avatar { display: none; }
  main section { padding: .8rem 0; break-inside: auto; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .pub, .entry { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  .pub .title a[href]::after { content: ""; }
  .section-alt { background: none; }
}

/* ---------- Knowledge Graph Explorer ---------- */
.graph-viewport {
  position: relative;
  width: 100%;
  height: clamp(620px, 80vh, 900px);
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-top: 1rem;
}
#graph-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: block;
}

/* Floating Control Dock */
.graph-dock {
  position: absolute;
  bottom: 1.25rem;
  left: 1.25rem;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.35rem 0.6rem;
  box-shadow: var(--shadow);
}
.graph-dock .dock-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  font-size: 0.9rem;
  font-family: var(--mono);
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.graph-dock .dock-btn:hover {
  background: var(--surface-2);
  border-color: var(--rule);
  color: var(--accent);
}
.graph-dock select {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

/* Floating Status / Legend */
.graph-legend-badge {
  position: absolute;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.8rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
  box-shadow: var(--shadow);
  pointer-events: none;
}

/* Graph Filter Bar */
.graph-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-bottom: 1rem;
}
.graph-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}
.graph-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.graph-types-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: center;
  font-size: 0.88rem;
  color: var(--ink-soft);
}
.graph-types-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}
.graph-types-group input[type="checkbox"] {
  cursor: pointer;
  accent-color: var(--accent);
}

.graph-slider-box {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
  font-family: var(--mono);
}
.graph-slider-box input[type="range"] {
  width: 7.5rem;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Hover Tooltip */
#graph-tooltip {
  position: fixed;
  display: none;
  z-index: 100;
  pointer-events: none;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  box-shadow: var(--shadow);
  max-width: 280px;
  font-size: 0.85rem;
  line-height: 1.35;
  color: var(--ink);
  transition: opacity 0.15s ease;
}
#graph-tooltip .tt-type {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.2rem;
  letter-spacing: 0.04em;
}
#graph-tooltip .tt-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}
#graph-tooltip .tt-venue {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-style: italic;
  margin-bottom: 0.25rem;
}
#graph-tooltip .tt-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  border-top: 1px dashed var(--rule);
  padding-top: 0.25rem;
}

/* Sliding Inspector Side Drawer */
#graph-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: clamp(320px, 32vw, 440px);
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid var(--rule);
  box-shadow: -4px 0 24px rgb(0 40 53 / 0.12);
  z-index: 20;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  overflow-y: auto;
}
#graph-drawer.open {
  transform: translateX(0);
}
.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.drawer-type {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}
.drawer-close {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
}
.drawer-close:hover {
  color: var(--ink);
}
.drawer-title {
  font-size: 1.25rem;
  line-height: 1.25;
  margin-bottom: 0.5rem;
}
.drawer-desc {
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 1.25rem;
  line-height: 1.5;
}
.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}
.drawer-neighbors-title {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.drawer-neighbors-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.neighbor-item {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--rule);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.neighbor-item:hover {
  border-color: var(--accent);
  background: var(--surface-2);
}
.neighbor-item strong {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
