@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&family=Spectral:wght@400;500;600;700;800&display=swap');

/* ==========================================================================
   chaitjo.com — hand-built static site
   Arc Institute–inspired layout: Spectral serif headings + IBM Plex Sans body,
   on a warm-white + Stanford-cardinal palette. Responsive, dependency-light.
   Shared by index.html and every blog post.
   ========================================================================== */

/* ---------- Design tokens (default: Cardinal — warm monochrome + cardinal accents) ---------- */
:root {
  --bg:        #fcfbf9;   /* warm near-white — primary background */
  --surface:   #f3f1ed;   /* warm light grey — alternating sections */
  --card:      #ffffff;   /* white cards */
  --ink:       #1c1917;   /* warm near-black — headings / strong */
  --fg:        #3b3733;   /* warm dark grey — body text */
  --muted:     #79736c;   /* secondary text */
  --faint:     #aaa39b;   /* meta / tertiary */
  --border:    #ece8e2;   /* warm hairline */
  --border-2:  #e0dbd3;   /* warm hairline (stronger) */
  --accent:    #8c1515;   /* Stanford cardinal — eyebrows, buttons, accents */
  --accent-2:  #6f1010;   /* darker cardinal — hovers */
  --olive-mid: #ddd6cf;   /* warm grey — blockquote rule */
  --band:        #e7e2db;   /* warm grey — nav / footer band */
  --band-fg:     #1c1917;   /* near-black — text on the band */
  --brand-color: var(--accent-2);   /* dark cardinal — nav / footer wordmark */
  --link:        #b3121f;   /* bright cardinal — hyperlinks */
  --link-2:      #8c1515;   /* hover */
  --title:       var(--accent);   /* section-title: cardinal on plain sections, ink on surface */

  --max:    1080px;
  --prose:  720px;
  --radius: 14px;
  --shadow:    0 1px 2px rgba(20,34,63,.04), 0 10px 28px rgba(20,34,63,.06);
  --shadow-lg: 0 2px 4px rgba(20,34,63,.05), 0 18px 44px rgba(20,34,63,.10);

  --font-serif: "Spectral", Georgia, "Times New Roman", serif;
  --font-sans:  "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono:  "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ==========================================================================
   Alternative color schemes — switch-in options for the ?themes picker.
   Cardinal (warm monochrome + cardinal) is the live default in :root above.
   Each block sets its palette, nav/footer band, --link and --title so the
   theme is faithfully restored — e.g. Arc brings back its olive band, navy
   headings and blue links. --title controls the section-heading colour.
   ========================================================================== */

/* Arc — olive on warm sand, navy headings (olive on sand sections), blue links. */
:root[data-theme="arc"] {
  --bg: #fbf8f2; --surface: #eff3ef; --ink: #001f44; --fg: #2c3038;
  --muted: #66695f; --faint: #9a9b8f; --border: #e4e0d3; --border-2: #d8ddd5;
  --accent: #455e48; --accent-2: #37503a; --olive-mid: #aec3b0;
  --band: #aec3b0; --band-fg: #001f44; --brand-color: #001f44;
  --link: #0073e6; --link-2: #005bb5; --title: var(--accent);
}

:root[data-theme="indigo"] {
  --bg: #f7f8fa; --surface: #eef1f6; --ink: #1f2740; --fg: #374151;
  --muted: #6b7280; --faint: #9aa1ad; --border: #e5e8ee; --border-2: #d7dde7;
  --accent: #3a45a0; --accent-2: #2c3680; --olive-mid: #c3cadd;
  --band: #c3cadd; --band-fg: #1f2740; --brand-color: #1f2740;
  --link: var(--accent); --link-2: var(--accent-2);
}

:root[data-theme="terracotta"] {
  --bg: #f8f4ee; --surface: #efe7dd; --ink: #2e2117; --fg: #463a30;
  --muted: #7c7165; --faint: #a99c8c; --border: #e9dfd1; --border-2: #ddd0bf;
  --accent: #b5532a; --accent-2: #95421f; --olive-mid: #d8c3b0;
  --band: #d8c3b0; --band-fg: #2e2117; --brand-color: #2e2117;
  --link: var(--accent); --link-2: var(--accent-2);
}

:root[data-theme="ink"] {
  --bg: #fcfcfb; --surface: #f1f1ef; --ink: #14161a; --fg: #2c2e33;
  --muted: #6a6c70; --faint: #9a9ca0; --border: #e6e6e2; --border-2: #dadad6;
  --accent: #335c7d; --accent-2: #244761; --olive-mid: #d6d7d2;
  --band: #d6d7d2; --band-fg: #14161a; --brand-color: #14161a;
  --link: var(--accent); --link-2: var(--accent-2);
}

/* ---------- Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--link); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--link-2); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--font-serif); line-height: 1.18; font-weight: 600; color: var(--ink); letter-spacing: 0; text-wrap: balance; }
p { text-wrap: pretty; }
strong { font-weight: 600; color: var(--ink); }
hr { border: none; border-top: 1px solid var(--border); margin: 3rem 0; }

/* Accessibility: skip link, keyboard focus ring, reduced motion */
.skip-link {
  position: absolute; left: 1rem; top: -3rem; z-index: 100;
  background: var(--accent); color: #fff; padding: .55rem 1rem; border-radius: 4px;
  font-family: var(--font-sans); font-size: .9rem; font-weight: 500;
  transition: top .15s ease;
}
.skip-link:focus { top: 1rem; text-decoration: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---------- Layout helpers ---------- */
.container { width: 100%; max-width: var(--max); margin-inline: auto; padding-inline: 1.5rem; }
.section { padding-block: clamp(3.5rem, 8vw, 6.25rem); }
.section--surface { background: var(--surface); }

.kicker {
  font-family: var(--font-mono);
  font-size: .78rem; font-weight: 500; letter-spacing: .03em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 .7rem;
}
/* Section titles take the olive accent on sand sections; navy on olive sections
   (olive-on-light-olive is too low-contrast) — mirrors Arc's section colour logic. */
.section-title { font-size: clamp(1.7rem, 3.4vw, 2.25rem); font-weight: 600; margin: 0 0 3rem; color: var(--title); }
.section--surface .section-title { color: var(--ink); }
.section-lead { color: var(--muted); max-width: var(--prose); margin: -1.25rem 0 2rem; }

/* ---------- Navigation ---------- */
.nav {
  position: sticky; top: 0; z-index: 50;
  background: var(--band);
  border-bottom: 1px solid rgba(0, 0, 0, .07);
}
.nav-inner {
  max-width: var(--max); margin-inline: auto; padding: .85rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.nav-brand { font-family: var(--font-serif); font-weight: 600; font-size: 1.6rem; color: var(--brand-color); }
.nav-brand:hover { color: var(--accent-2); text-decoration: none; }
.nav-links { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.nav-links a { color: var(--band-fg); font-size: 1rem; font-weight: 500; transition: color .15s ease; }
.nav-links a:hover { color: var(--link); text-decoration: none; }

/* ---------- Buttons (Arc style: outline rectangle → fills dark-olive on hover) ---------- */
.btn, .btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .75rem 1.6rem; border-radius: 0;
  font-family: var(--font-sans); font-size: .92rem; font-weight: 600; line-height: 1;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.btn:hover, .btn:focus-visible,
.btn-primary:hover, .btn-primary:focus-visible,
.btn-ghost:hover, .btn-ghost:focus-visible {
  background: var(--accent); color: var(--bg); text-decoration: none;
}

/* ---------- Hero / Bio ---------- */
.hero { display: grid; grid-template-columns: 240px 1fr; gap: 2.75rem; align-items: start; }
.hero-photo { width: 240px; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 0; }
.hero-name { font-size: clamp(2.1rem, 5vw, 3rem); font-weight: 600; margin: 0 0 .45rem; letter-spacing: 0; }
.hero-role { font-family: var(--font-mono); font-size: .95rem; color: var(--accent); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; margin: 0 0 1.4rem; }
.hero-bio { max-width: 62ch; }
.hero-bio p { margin: 0 0 1rem; }
.hero-bio p:last-of-type { margin-bottom: 0; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin-top: 1.6rem; }
.socials { display: flex; gap: .5rem; flex-wrap: wrap; }
.social {
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted); transition: color .15s ease;
}
.social:hover { color: var(--accent); text-decoration: none; }
.social svg { width: 21px; height: 21px; fill: currentColor; display: block; }

/* ---------- News + Talks two-panel ---------- */
.news-talks { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 3.5rem; align-items: start; }
.talks-stack { display: flex; flex-direction: column; gap: 1.5rem; }

/* ---------- News ---------- */
.news-list { list-style: none; margin: 0; padding: 0; }
.news-talks .news-list { max-width: none; }
.news-list li { display: grid; grid-template-columns: 7.5rem 1fr; gap: 1rem; padding: .8rem 0; border-top: 1px solid var(--border-2); }
.news-list li:last-child { border-bottom: 1px solid var(--border-2); }
.news-date { color: var(--faint); font-size: .9rem; font-weight: 600; padding-top: .1rem; font-variant-numeric: tabular-nums; }
.news-item { margin: 0; }

/* ---------- Research focus (3 cards) ---------- */
.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2.25rem; }
.card { display: flex; flex-direction: column; }
.card-img { display: block; aspect-ratio: 1 / 1; width: 100%; object-fit: cover; border-radius: 0; }
.card-body { padding: 1.1rem 0 0; }
.card-body h3 { font-family: var(--font-mono); font-size: .92rem; font-weight: 500; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; line-height: 1.45; margin: 0 0 .7rem; }
.card-body p { margin: 0; color: var(--ink); font-size: 1rem; line-height: 1.6; }
.research-note { margin: 2rem 0 0; color: var(--muted); max-width: var(--prose); }

/* ---------- Talks (video grid) ---------- */
.video-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; }
.video-frame { position: relative; aspect-ratio: 16 / 9; border-radius: 0; overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.video-caption { padding: .7rem 0 0; font-size: .92rem; color: var(--muted); }
.video-caption strong { color: var(--ink); font-weight: 600; }

/* ---------- Publications ---------- */
.pub-list { display: flex; flex-direction: column; gap: 3rem; }
.pub { display: grid; grid-template-columns: 210px 1fr; gap: 1.9rem; align-items: start; }
.pub-thumb { display: block; width: 210px; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 0; border: 1px solid var(--border-2); }
.pub-body h3 { font-size: clamp(1.3rem, 2.2vw, 1.6rem); font-weight: 600; line-height: 1.25; margin: 0 0 .55rem; }
.pub-body h3 a { color: var(--ink); }
.pub-body h3 a:hover { color: var(--link); }
.pub-authors { margin: 0 0 .6rem; font-size: 1rem; color: var(--muted); line-height: 1.55; }
.pub-venue { margin: 0; font-family: var(--font-mono); font-size: .9rem; font-weight: 500; color: var(--accent); text-transform: uppercase; letter-spacing: .03em; font-variant-numeric: tabular-nums; }
.pub-venue a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.pub-venue a:hover { color: var(--accent-2); }
.pub-highlight { margin: .6rem 0 0; font-size: .97rem; line-height: 1.55; color: var(--muted); font-style: italic; }
.pub-note { margin: 1.5rem 0 0; font-size: .82rem; color: var(--faint); }
.pub-actions { margin-top: 1.75rem; }

/* ---------- Writing ---------- */
.writing-callout {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem;
  padding-bottom: 1.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border-2);
}
.writing-callout p { margin: 0; color: var(--muted); }
.post-list { list-style: none; margin: 0; padding: 0; columns: 2; column-gap: 2.5rem; }
.post-list li { break-inside: avoid; display: grid; grid-template-columns: 4.5rem 1fr; gap: .75rem; padding: .55rem 0; border-top: 1px solid var(--border-2); }
.post-list .post-year { color: var(--faint); font-size: .88rem; font-weight: 600; padding-top: .1rem; }
.post-list a { color: var(--ink); font-weight: 500; }
.post-list a:hover { color: var(--accent); }

/* ---------- Contact + map ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.1fr; gap: 2.5rem; align-items: start; }
.contact-info p { margin: 0 0 .75rem; }
.contact-info .addr { color: var(--muted); }
.office-photo { margin: 0; }
.office-photo img { display: block; width: 100%; height: 360px; object-fit: cover; border-radius: 0; border: 1px solid var(--border-2); }
.office-photo figcaption { margin-top: .6rem; font-size: .85rem; color: var(--faint); }

/* ---------- Footer ---------- */
.footer { padding-block: 2.5rem; color: var(--band-fg); font-size: .9rem; background: var(--band); }
.footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.footer a { color: var(--ink); }
.footer a:hover { color: var(--accent-2); }

/* ==========================================================================
   Blog post pages (prose)
   ========================================================================== */
.post-wrap { max-width: var(--prose); margin-inline: auto; padding: 3rem 1.5rem 4rem; }
.post-back { font-size: .9rem; font-weight: 600; color: var(--muted); display: inline-block; margin-bottom: 2rem; }
.post-back:hover { color: var(--accent); text-decoration: none; }
.post-header { margin-bottom: 2.5rem; }
.post-title { font-size: clamp(1.9rem, 4.5vw, 2.7rem); font-weight: 600; margin: 0 0 .5rem; letter-spacing: -0.02em; }
.post-subtitle { font-family: var(--font-sans); font-size: 1.18rem; color: var(--muted); margin: 0 0 1rem; font-weight: 400; line-height: 1.5; }
.post-meta { font-family: var(--font-sans); color: var(--faint); font-size: .92rem; }
.post-meta a { color: var(--muted); }

.prose { font-size: 1.075rem; line-height: 1.75; color: var(--fg); }
.prose > * + * { margin-top: 1.25rem; }
.prose h2 { font-size: 1.6rem; margin-top: 2.75rem; }
.prose h3 { font-size: 1.3rem; margin-top: 2rem; }
.prose a { color: var(--link); }
.prose ul, .prose ol { padding-left: 1.4rem; }
.prose li + li { margin-top: .4rem; }
.prose img { border-radius: 10px; }
.prose figure { margin: 2rem 0; }
.prose figure img { margin-inline: auto; }
.prose figcaption { text-align: center; font-family: var(--font-sans); font-size: .9rem; color: var(--faint); margin-top: .6rem; }
.prose blockquote { margin: 1.75rem 0; padding: .25rem 0 .25rem 1.25rem; border-left: 3px solid var(--olive-mid); color: var(--muted); font-style: italic; }
.prose pre { background: #0c2043; color: #eef1f6; padding: 1rem 1.25rem; border-radius: 10px; overflow-x: auto; font-family: var(--font-mono); font-size: .88rem; line-height: 1.55; }
.prose code { font-family: var(--font-mono); font-size: .9em; background: var(--surface); padding: .15em .4em; border-radius: 5px; }
.prose pre code { background: none; padding: 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.prose th, .prose td { border: 1px solid var(--border-2); padding: .5rem .75rem; text-align: left; }
.prose th { background: var(--surface); font-weight: 600; }

.callout { margin: 1.75rem 0; padding: .75rem 0 .75rem 1.25rem; background: none; border-left: 3px solid var(--accent); font-size: .98rem; color: var(--muted); }
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }

.toc { margin: 1.75rem 0; padding: .25rem 0 .25rem 1.25rem; border-left: 2px solid var(--border-2); font-size: .95rem; }
.toc-title { font-family: var(--font-sans); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .5rem; }
.toc ul { margin: 0; padding-left: 1.1rem; }
.toc li { margin: .2rem 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .cards-3, .video-grid { grid-template-columns: 1fr; }
  .news-talks { grid-template-columns: 1fr; gap: 2.5rem; }
  .contact-grid { grid-template-columns: 1fr; }
  .post-list { columns: 1; }
  /* Once single-column, keep figures/videos modest & left-aligned (Arc-style),
     not full-bleed — applies across the whole tablet→phone range.
     Research images use the tighter Arc ratio (best with square images);
     talk videos stay wider so 16:9 thumbnails remain legible. */
  .card { align-items: flex-start; }
  .card-img { max-width: 33%; }
  .talks-stack .video-frame { max-width: 60%; }
}
@media (max-width: 620px) {
  .nav-inner { flex-direction: column; gap: .45rem; padding-block: .7rem; }
  .nav-links { gap: .9rem 1.1rem; justify-content: center; font-size: .85rem; }
  .hero { grid-template-columns: 1fr; gap: 1.5rem; justify-items: center; text-align: center; }
  .hero-bio { text-align: left; }
  .hero-actions { justify-content: center; }
  .news-list li { grid-template-columns: 1fr; gap: .15rem; }
  .news-date { padding-top: 0; }
  .pub { grid-template-columns: 1fr; }
  .pub-thumb { width: 100%; max-width: 220px; }
}

/* ---------- Print ---------- */
@media print {
  .nav, .footer, .video-frame, .office-photo, .pub-actions { display: none; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .section { padding-block: 1rem; }
  .section--surface { background: #fff; }
  a { color: #000; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8pt; color: #555; word-break: break-all; }
}
