/* ============================================================
   J Vijayavallabh

   Structure: every section on the page sits on ONE two-column
   grid. A mono metadata spine on the left, the substance on the
   right, hairline rules between records. Work, papers, projects
   and education are all the same kind of object (a dated,
   domain-tagged record) so they share one component rather than
   a ledger here and cards there.

   Colour reads as a single-cell cluster legend: six categorical
   hues on cool paper. Colour codes research domain, never
   decoration. A record sets --dot from its data-domain and every
   marker inside inherits it.

   Layers below: tokens, base, primitives, layout, components,
   responsive, print. Sizes and spacing come from the scales in
   the token block, never invented per component.
   ============================================================ */

/* ─────────────────────────────────────────────────────────────
   1. Tokens
   ───────────────────────────────────────────────────────────── */

:root {
  /* colour */
  --paper:   #f4f5f9;
  --card:    #ffffff;
  --ink:     #141821;
  --ink-2:   #3d4757;
  --muted:   #6b7688;
  --rule:    #d9dee8;
  --rule-2:  #e9ecf3;

  --genomics: #1d7a6e;
  --geometry: #6d4aa6;
  --privacy:  #b23a63;
  --agents:   #c36a18;
  --vision:   #1f63b0;
  --speech:   #4f6b2a;

  /* type families */
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans:  'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --mono:  'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* type scale: one ladder, no per-component invented sizes */
  --t-label:   .72rem;
  --t-meta:    .78rem;
  --t-sm:      .9rem;
  --t-body:    1rem;
  --t-lede:    1.08rem;
  --t-title:   1.38rem;
  --t-head:    clamp(1.8rem, 3.2vw, 2.5rem);
  --t-display: clamp(2.35rem, 4.6vw, 3.4rem);

  --lh-tight:  1.08;
  --lh-title:  1.22;
  --lh-body:   1.6;

  --tr-label:   .14em;
  --tr-title:  -.011em;
  --tr-display:-.022em;

  /* space: 4px base, used instead of ad-hoc margins */
  --s1: .25rem;
  --s2: .5rem;
  --s3: .75rem;
  --s4: 1rem;
  --s5: 1.5rem;
  --s6: 2rem;
  --s7: 3rem;
  --s8: clamp(2.75rem, 5vw, 4.5rem);
  --s9: clamp(3.5rem, 7vw, 6rem);

  /* layout */
  --shell: 1120px;
  --gutter: clamp(20px, 5vw, 56px);
  --spine: 148px;
  --spine-gap: clamp(16px, 3vw, 40px);
  --bar: 76px;            /* topbar height plus air, for anchor targets */
  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:  #0e1219;
    --card:   #161b24;
    --ink:    #e8ebf1;
    --ink-2:  #b7c0ce;
    --muted:  #828ea0;
    --rule:   #28303d;
    --rule-2: #1c2330;

    --genomics: #3fb8a4;
    --geometry: #a98ae0;
    --privacy:  #e8779c;
    --agents:   #e6a04f;
    --vision:   #62a3ea;
    --speech:   #93bd5f;
  }
}

/* a record publishes its domain colour; markers inside inherit it */
[data-domain='genomics'] { --dot: var(--genomics); }
[data-domain='geometry'] { --dot: var(--geometry); }
[data-domain='privacy']  { --dot: var(--privacy); }
[data-domain='agents']   { --dot: var(--agents); }
[data-domain='vision']   { --dot: var(--vision); }
[data-domain='speech']   { --dot: var(--speech); }

/* ─────────────────────────────────────────────────────────────
   2. Base
   ───────────────────────────────────────────────────────────── */

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0; font-weight: 400; }
p, figure, dd, dl { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }

a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: .22em; }
a:hover { text-decoration-color: currentColor; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }

sup { line-height: 0; font-size: .7em; }

/* maths variables set in serif italic, the way a paper sets them */
var { font-family: var(--serif); font-style: italic; font-size: 1.06em; }

.skip {
  position: absolute;
  left: -9999px;
  background: var(--ink);
  color: var(--paper);
  padding: var(--s3) var(--s4);
  z-index: 99;
}
.skip:focus { left: var(--s2); top: var(--s2); }

/* ─────────────────────────────────────────────────────────────
   3. Primitives
   ───────────────────────────────────────────────────────────── */

/* the single label style: eyebrows, spine labels, field names */
.label {
  font-family: var(--mono);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  color: var(--muted);
}

/* the single domain marker */
.legend li::before,
.record-domain::before {
  content: '';
  inline-size: 8px;
  block-size: 8px;
  border-radius: 50%;
  background: var(--dot, var(--muted));
  flex: none;
}

.ext::after { content: ' \2197'; font-size: .85em; }

.flag {
  display: inline-block;
  vertical-align: .2em;
  margin-inline-start: var(--s2);
  font-family: var(--mono);
  font-size: .64rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--rule);
  border-radius: 100px;
  padding: 2px 9px;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────
   4. Layout: the shell, and the one spine grid
   ───────────────────────────────────────────────────────────── */

.shell {
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* EVERY section body sits on this grid. One spine, one rhythm. */
.record,
.spine-row {
  display: grid;
  grid-template-columns: var(--spine) minmax(0, 1fr);
  gap: var(--spine-gap);
}

.band {
  padding-block-start: var(--s8);
  scroll-margin-top: var(--bar);
}
.band:last-of-type { padding-block-end: var(--s8); }

.band-head { margin-block-end: var(--s6); }
.band-head h2 {
  font-family: var(--serif);
  font-size: var(--t-head);
  line-height: var(--lh-title);
  letter-spacing: var(--tr-title);
  margin-block-start: var(--s1);
}
.band-note {
  margin-block-start: var(--s3);
  font-size: var(--t-sm);
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────────
   5. Topbar
   ───────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s5);
  padding-block: var(--s3);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px);
  border-block-end: 1px solid var(--rule);
}

.topbar-name {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}

.topbar-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  margin-inline-start: auto;
  font-size: .88rem;
}
.topbar-nav a {
  text-decoration: none;
  color: var(--muted);
  white-space: nowrap;
  padding-block-end: 2px;
  border-block-end: 1px solid transparent;
}
.topbar-nav a:hover { color: var(--ink); }
.topbar-nav a[aria-current='true'] {
  color: var(--ink);
  border-block-end-color: var(--ink);
}

.topbar-cv {
  font-family: var(--mono);
  font-size: var(--t-meta);
  letter-spacing: .08em;
  text-decoration: none;
  padding: 5px 12px;
  border: 1px solid var(--rule);
  border-radius: 100px;
  white-space: nowrap;
}
.topbar-cv:hover { border-color: var(--ink); }

/* ─────────────────────────────────────────────────────────────
   6. Hero and the disk
   ───────────────────────────────────────────────────────────── */

.hero {
  padding-block: var(--s9) var(--s8);
  display: grid;
  grid-template-columns: minmax(0, 1.04fr) minmax(0, .96fr);
  gap: var(--s8);
  align-items: center;
  scroll-margin-top: var(--bar);
}

.display {
  font-family: var(--serif);
  font-size: var(--t-display);
  line-height: var(--lh-tight);
  letter-spacing: var(--tr-display);
  margin-block-start: var(--s3);
}
/* the italic line glosses the claim above it, so it sits smaller */
.display em {
  display: block;
  font-style: italic;
  font-weight: 300;
  font-size: .78em;
  line-height: 1.16;
  color: var(--ink-2);
  margin-block-start: var(--s1);
}

.lede {
  font-size: var(--t-lede);
  color: var(--ink-2);
  max-width: 46ch;
  margin-block-start: var(--s5);
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2) var(--s5);
  margin-block-start: var(--s6);
  font-family: var(--mono);
  font-size: .82rem;
}

.disk-frame {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: 460px;
  margin-inline: auto;
}
.disk-frame canvas { display: block; width: 100%; height: 100%; }

.hero-figure figcaption {
  margin: var(--s5) auto 0;
  max-width: 42ch;
  font-size: .84rem;
  line-height: 1.55;
  color: var(--muted);
}
.hero-figure figcaption b { font-weight: 500; color: var(--ink-2); }

.hint {
  display: block;
  margin-block-start: var(--s2);
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: .04em;
}
@media (hover: none) { .hint { display: none; } }

/* ─────────────────────────────────────────────────────────────
   7. Legend
   ───────────────────────────────────────────────────────────── */

.legend {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: var(--s3) var(--s6);
  padding-block: var(--s4);
  border-block: 1px solid var(--rule);
}
.legend ul { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); }
.legend li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: .76rem;
  color: var(--ink-2);
}

/* ─────────────────────────────────────────────────────────────
   8. Record: the one component for work, papers, projects and
      education. They differ by content, never by layout.
   ───────────────────────────────────────────────────────────── */

.record {
  padding-block: var(--s5);
  border-block-start: 1px solid var(--rule);
}
.records > .record:last-child { border-block-end: 1px solid var(--rule); }

.record-spine { padding-block-start: 2px; }

.record-when {
  display: block;
  font-family: var(--mono);
  font-size: var(--t-meta);
  line-height: 1.5;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.record-domain {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-block-start: var(--s2);
  font-family: var(--mono);
  font-size: var(--t-label);
  color: var(--muted);
}

.record-title {
  font-family: var(--serif);
  font-size: var(--t-title);
  line-height: var(--lh-title);
  letter-spacing: var(--tr-title);
  max-width: 44ch;
}
.record-title a { text-decoration-color: var(--rule); }

.record-org {
  margin-block-start: var(--s1);
  font-size: var(--t-sm);
  color: var(--muted);
}
.record-venue {
  font-family: var(--mono);
  font-size: .74rem;
  letter-spacing: .05em;
  color: var(--muted);
  margin-block-end: var(--s2);
}

.gloss {
  margin-block-start: var(--s3);
  color: var(--ink-2);
  max-width: var(--measure);
}

.points { margin-block-start: var(--s4); }
.points li {
  position: relative;
  padding-inline-start: 20px;
  margin-block-end: var(--s2);
  color: var(--ink-2);
  max-width: var(--measure);
}
.points li::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: .72em;
  width: 8px;
  height: 1px;
  background: var(--rule);
}
.points li:last-child { margin-block-end: 0; }

/* his work is numbers, so the numbers get pulled out */
.figures {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3) var(--s6);
  margin-block-start: var(--s4);
  padding-block-start: var(--s3);
  border-block-start: 1px solid var(--rule-2);
}
.figures li { display: flex; flex-direction: column; }
.figures b {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 500;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.figures span { font-size: .74rem; color: var(--muted); margin-block-start: 2px; }

.record-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s5);
  margin-block-start: var(--s4);
  font-family: var(--mono);
  font-size: var(--t-meta);
}

.is-patent .record-title { font-style: italic; }

.courses {
  margin-block-start: var(--s3);
  font-size: .84rem;
  line-height: 1.55;
  color: var(--muted);
  max-width: 62ch;
}
.stat { margin-block-start: var(--s2); font-size: var(--t-sm); color: var(--ink-2); }
.stat b { font-family: var(--mono); font-weight: 500; }

/* ─────────────────────────────────────────────────────────────
   9. Rows on the same spine: toolkit, honours
   ───────────────────────────────────────────────────────────── */

.spine-row {
  padding-block: var(--s3);
  border-block-start: 1px solid var(--rule);
}
.toolkit > .spine-row:last-child,
.honours > .spine-row:last-child { border-block-end: 1px solid var(--rule); }

.toolkit dt { padding-block-start: 2px; }
.toolkit dd { color: var(--ink-2); }

.honours-block { margin-block-start: var(--s7); }
.honours span:last-child { color: var(--ink-2); font-size: var(--t-sm); }
.honours b { font-weight: 500; color: var(--ink); }

/* ─────────────────────────────────────────────────────────────
   10. Contact and footer
   ───────────────────────────────────────────────────────────── */

.contact {
  display: grid;
  grid-template-columns: var(--spine) minmax(0, 1fr);
  gap: var(--spine-gap);
  align-items: start;
}

.portrait {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  object-fit: cover;
  filter: grayscale(1);
}

.contact-note {
  color: var(--ink-2);
  max-width: 54ch;
}

.contact-list {
  margin-block-start: var(--s5);
  display: grid;
  gap: var(--s3);
  max-width: 460px;
}
.contact-list div {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: var(--s3);
  padding-block-end: var(--s2);
  border-block-end: 1px solid var(--rule-2);
  font-size: var(--t-sm);
}
.contact-list dt { padding-block-start: 3px; }

.cv-button {
  display: inline-block;
  margin-block-start: var(--s6);
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .06em;
  text-decoration: none;
  padding: 11px 22px;
  border: 1px solid var(--ink);
  border-radius: 100px;
}
.cv-button:hover { background: var(--ink); color: var(--paper); }

.footer {
  border-block-start: 1px solid var(--rule);
  margin-block-start: var(--s8);
  padding-block: var(--s5) var(--s7);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--s2);
  font-family: var(--mono);
  font-size: var(--t-label);
  letter-spacing: .06em;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────────
   11. Responsive
   ───────────────────────────────────────────────────────────── */

@media (max-width: 940px) {
  .hero {
    grid-template-columns: 1fr;
    gap: var(--s6);
    padding-block-start: var(--s7);
  }
  .hero-figure { order: -1; }
  .disk-frame { max-width: 330px; }
  .hero-figure figcaption { text-align: center; }
}

@media (max-width: 700px) {
  /* the nav wraps onto its own full-width row rather than clipping */
  .topbar { flex-wrap: wrap; gap: var(--s3) var(--s4); }
  .topbar-nav {
    order: 3;
    width: 100%;
    margin-inline-start: 0;
    justify-content: space-between;
    gap: var(--s2) var(--s3);
    font-size: .82rem;
  }
  .topbar-cv { margin-inline-start: auto; }

  .record,
  .spine-row,
  .contact {
    grid-template-columns: 1fr;
    gap: var(--s3);
  }
  /* the spine folds into one inline metadata line */
  .record-spine {
    display: flex;
    align-items: center;
    gap: var(--s4);
    padding-block-start: 0;
  }
  .record-when br { display: none; }
  .record-domain { margin-block-start: 0; }
  .honours .record-when:empty { display: none; }
  .portrait { width: 104px; height: 104px; }
  .contact-list div { grid-template-columns: 1fr; gap: 0; }
}

/* ─────────────────────────────────────────────────────────────
   12. Print: it is a CV site, so let it print like a CV
   ───────────────────────────────────────────────────────────── */

@media print {
  .topbar, .hero-figure, .legend, .skip, .cv-button, .hint, .footer { display: none; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .hero { display: block; padding-block: 0 var(--s5); }
  .band { padding-block-start: var(--s5); }
  .record, .spine-row { break-inside: avoid; }
  a { text-decoration: none; }
}
