/* ------------------------------------------------------------------
   shimajalalian.com — stylesheet
   Design: typography-led, figure-forward, light/dark.
   Tokens live on :root and are redefined for dark mode, so colours are
   changed in exactly one place.
   ------------------------------------------------------------------ */

:root {
  /* Cool off-blue: a desaturated steel blue drawn from the portrait's
     background and shirt, over faintly blue-tinted paper. */
  --bg: #f7f9fc;
  --bg-sunk: #eef2f8;
  --surface: #ffffff;
  --fg: #131921;
  --fg-muted: #556070;
  --fg-faint: #828d9d;
  --line: #dde4ee;
  --accent: #2f6090;
  --accent-soft: #e7eff8;
  --accent-ink: #1d4367;
  --shadow: 0 1px 2px rgba(18, 28, 45, .05), 0 8px 24px rgba(18, 28, 45, .06);

  --serif: "Source Serif 4", Charter, Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;

  --measure: 68ch;
  --gutter: clamp(1rem, 4vw, 2.5rem);
  --page: 1140px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131a;
    --bg-sunk: #131a23;
    --surface: #161e28;
    --fg: #eef2f7;
    --fg-muted: #a3afbf;
    --fg-faint: #7a8696;
    --line: #26303d;
    --accent: #82b5df;
    --accent-soft: #152331;
    --accent-ink: #a8cfee;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .38);
  }
}

:root[data-theme="dark"] {
  --bg: #0e131a;
  --bg-sunk: #131a23;
  --surface: #161e28;
  --fg: #eef2f7;
  --fg-muted: #a3afbf;
  --fg-faint: #7a8696;
  --line: #26303d;
  --accent: #82b5df;
  --accent-soft: #152331;
  --accent-ink: #a8cfee;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .38);
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5.5rem; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -.015em;
  margin: 0 0 .5em;
  text-wrap: balance;
}

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-ink); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

img { max-width: 100%; height: auto; display: block; }

.wrap {
  width: 100%;
  max-width: var(--page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: .7rem 1.1rem;
  z-index: 100;
  border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }

/* ---------- header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 4rem;
}

.brand {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.02rem;
  letter-spacing: -.01em;
  color: var(--fg);
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}
.brand span { color: var(--fg-faint); font-weight: 400; }

.nav { display: flex; gap: .25rem; align-items: center; }

.nav a {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: .89rem;
  padding: .45rem .7rem;
  border-radius: 6px;
  white-space: nowrap;
}
.nav a:hover { color: var(--fg); background: var(--bg-sunk); }
.nav a[aria-current="true"] { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg-muted);
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
}
.theme-toggle:hover { color: var(--fg); border-color: var(--fg-faint); }
.theme-toggle svg { width: 16px; height: 16px; }

@media (max-width: 860px) {
  .nav { display: none; }
}

/* ---------- hero ---------- */

.hero {
  padding: clamp(3rem, 8vw, 6rem) 0 clamp(2.5rem, 6vw, 4.5rem);
  border-bottom: 1px solid var(--line);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, .85fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: center;
}

.eyebrow {
  font-size: .75rem;
  font-weight: 650;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}

.hero h1 {
  font-size: clamp(2.3rem, 5.5vw, 3.6rem);
  margin-bottom: .35em;
}

.hero .role {
  font-family: var(--sans);
  font-size: clamp(1rem, 2vw, 1.12rem);
  color: var(--fg-muted);
  font-weight: 500;
  margin-bottom: 1.1em;
}

.hero .tagline {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 2.4vw, 1.35rem);
  font-style: italic;
  color: var(--fg);
  border-left: 3px solid var(--accent);
  padding-left: 1rem;
  margin-bottom: 1.6em;
  max-width: 34ch;
}

.cta-row { display: flex; flex-wrap: wrap; gap: .7rem; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .62rem 1.15rem;
  border-radius: 7px;
  font-size: .92rem;
  font-weight: 550;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-ghost { border-color: var(--line); color: var(--fg); background: var(--surface); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

/* Portrait / hero visual */
.hero-figure {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-sunk);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  /* Taller frame than 4:5, and the crop is biased towards the top of the
     source so there is visible headroom above the subject. */
  aspect-ratio: 3 / 4;
}
.hero-figure img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 12%;
}
.hero-figure svg { width: 100%; height: 100%; display: block; }

@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-figure { max-width: 320px; aspect-ratio: 1 / 1; }
  .hero .tagline { max-width: none; }
}

/* ---------- sections ---------- */

.section { padding: clamp(3rem, 7vw, 5.5rem) 0; border-bottom: 1px solid var(--line); }
.section-alt { background: var(--bg-sunk); }

.section-head { margin-bottom: clamp(1.8rem, 4vw, 3rem); max-width: var(--measure); }
.section-head h2 { font-size: clamp(1.7rem, 3.6vw, 2.3rem); }
.section-head .lede { color: var(--fg-muted); font-size: 1.03rem; margin-top: .4em; }

.prose { max-width: var(--measure); }
.prose p + p { margin-top: 0; }

/* ---------- about ---------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: start;
}

.facts { display: grid; gap: 1.1rem; }

.fact {
  border-left: 2px solid var(--line);
  padding-left: 1rem;
}
.fact dt {
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--fg-faint);
  font-weight: 650;
  margin-bottom: .2rem;
}
.fact dd { margin: 0; font-size: .96rem; }
.fact dd .where { color: var(--fg-muted); display: block; font-size: .88rem; }

@media (max-width: 820px) { .about-grid { grid-template-columns: 1fr; } }

/* ---------- research cards ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 1.4rem;
}

/* Wider cards for groups whose figures are multi-panel and detail-dense. */
.card-grid.cards-lg { grid-template-columns: repeat(auto-fit, minmax(440px, 1fr)); }

/* A card that spans the whole grid row, for a figure that needs full width. */
.card.wide { grid-column: 1 / -1; }
/* Let the figure render at its own aspect ratio, centred and capped in width,
   rather than being letterboxed inside a fixed-height box. */
.card.wide .card-figure { display: block; padding: .6rem; }
/* Cap the HEIGHT rather than the width: a 3:1 panel strip should use the full
   card width, while a near-square figure must not become 800px tall. */
.card.wide .card-figure img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 620px;
  margin-inline: auto;
}

@media (max-width: 640px) {
  .card-grid.cards-lg { grid-template-columns: 1fr; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  transition: transform .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

/* Figure slot: swap the inline <svg> for an <img> when real figures exist. */
.card-figure {
  aspect-ratio: 16 / 9;
  background: var(--bg-sunk);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.card-figure svg, .card-figure img { width: 100%; height: 100%; display: block; object-fit: cover; }

/* A group containing a single card would otherwise stretch to full width and
   blow the 16:9 figure up to an absurd height. Lay it out side by side. */
.card.feature { flex-direction: row; }
.card.feature .card-figure {
  flex: 0 0 42%;
  aspect-ratio: auto;
  border-bottom: 0;
  border-right: 1px solid var(--line);
}
.card.feature .card-body { padding: 1.7rem 1.8rem; align-self: center; }

@media (max-width: 760px) {
  .card.feature { flex-direction: column; }
  .card.feature .card-figure {
    flex: none;
    aspect-ratio: 16 / 9;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .card.feature .card-body { padding: 1.3rem 1.4rem 1.5rem; }
}

/* Real published figures: show them whole rather than cropping to 16:9, and
   keep the paper's white canvas in both themes so colour maps stay readable. */
.card-figure:not([aria-hidden]) {
  aspect-ratio: auto;
  background: #fff;
  display: flex;
  align-items: center;
}
.card-figure:not([aria-hidden]) img {
  object-fit: contain;
  width: 100%;
  height: auto;
}

/* Full-width feature figure inside a section. */
.figure-wide {
  margin: 0 0 clamp(2rem, 4vw, 3rem);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}
.figure-wide img { width: 100%; height: auto; display: block; }
.figure-wide figcaption {
  padding: 1rem 1.3rem 1.15rem;
  font-size: .89rem;
  line-height: 1.55;
  color: var(--fg-muted);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.figure-wide figcaption strong { color: var(--fg); font-weight: 600; }

/* Source link at the foot of a research tile. */
.card-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: 1rem;
  font-size: .82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}
.card-link svg { width: 14px; height: 14px; transition: transform .15s ease; }
.card-link:hover { color: var(--accent-ink); }
.card-link:hover svg { transform: translateX(3px); }

.card-body { padding: 1.3rem 1.4rem 1.5rem; }
.card h3 { font-size: 1.12rem; margin-bottom: .45em; }
.card p { font-size: .93rem; color: var(--fg-muted); }

.tag {
  display: inline-block;
  font-size: .69rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .22rem .55rem;
  border-radius: 999px;
  margin-bottom: .7rem;
}

.subhead {
  font-family: var(--sans);
  font-size: .76rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  font-weight: 650;
  margin: 2.6rem 0 1.1rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--line);
}
.subhead:first-of-type { margin-top: 0; }

/* ---------- publications ---------- */

.pub-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.5rem; }

.pub {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 1.3rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}
.pub:last-child { border-bottom: 0; padding-bottom: 0; }

.pub-year {
  font-family: var(--mono);
  font-size: .82rem;
  color: var(--fg-faint);
  padding-top: .2rem;
  font-variant-numeric: tabular-nums;
}

.pub-title { font-family: var(--serif); font-size: 1.08rem; font-weight: 600; margin-bottom: .3em; }
.pub-authors { font-size: .9rem; color: var(--fg-muted); margin-bottom: .25em; }
.pub-authors .me { color: var(--fg); font-weight: 650; }
.pub-venue { font-size: .89rem; color: var(--fg-muted); font-style: italic; }

.pub-meta { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.pub-link {
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--line);
  padding: .2rem .55rem;
  border-radius: 5px;
  color: var(--fg-muted);
}
.pub-link:hover { border-color: var(--accent); color: var(--accent); }

.pub-note {
  margin-top: .7rem;
  font-size: .89rem;
  color: var(--fg-muted);
  background: var(--accent-soft);
  border-radius: 7px;
  padding: .7rem .9rem;
}

@media (max-width: 620px) {
  .pub { grid-template-columns: 1fr; gap: .3rem; }
  .pub-year { padding-top: 0; }
}

/* ---------- experience timeline ---------- */

.timeline { list-style: none; margin: 0; padding: 0; }

.tl-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr);
  gap: 1.5rem;
  padding: 1.3rem 0;
  border-top: 1px solid var(--line);
}
.tl-item:first-child { border-top: 0; padding-top: 0; }

.tl-role { font-family: var(--serif); font-size: 1.05rem; font-weight: 600; }
.tl-org { font-size: .9rem; color: var(--fg-muted); margin-top: .15rem; }
.tl-desc { font-size: .93rem; color: var(--fg-muted); }

.tl-item.current .tl-role::after {
  content: "Current";
  display: inline-block;
  margin-left: .6rem;
  vertical-align: 3px;
  font-family: var(--sans);
  font-size: .64rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 650;
  color: var(--accent);
  background: var(--accent-soft);
  padding: .18rem .45rem;
  border-radius: 999px;
}

@media (max-width: 760px) { .tl-item { grid-template-columns: 1fr; gap: .45rem; } }

/* ---------- contact ---------- */

.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 3.5rem);
  align-items: start;
}

.links { display: grid; gap: .55rem; }

.link-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: .75rem .95rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  text-decoration: none;
  color: var(--fg);
  font-size: .94rem;
  transition: border-color .15s, transform .15s;
}
.link-row:hover { border-color: var(--accent); transform: translateX(2px); color: var(--fg); }
.link-row svg { width: 17px; height: 17px; flex: none; color: var(--fg-faint); }
.link-row:hover svg { color: var(--accent); }
.link-row .label { font-weight: 550; }
.link-row .val { margin-left: auto; color: var(--fg-faint); font-size: .85rem; }

@media (max-width: 760px) {
  .contact-grid { grid-template-columns: 1fr; }
  .link-row .val { display: none; }
}

/* ---------- footer ---------- */

.site-footer {
  padding: 2.5rem 0 3rem;
  color: var(--fg-faint);
  font-size: .85rem;
}
.site-footer .wrap { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }
.site-footer a { color: var(--fg-muted); }
