/* ==========================================================================
   Rajat Masiwal — personal site
   Plain CSS, no build step. Light + dark themes via [data-theme] on <html>.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f6f7;
  --ink: #132033;
  --ink-soft: #2c3a4b;
  --muted: #5d6b7a;
  --line: #e1e6ea;
  --navy: #0b1730;
  --navy-2: #13253f;
  --accent: #1d5fa8;
  --accent-ink: #164a85;
  --accent-soft: #e2ecf8;
  --warm: #a33f16;
  --warm-soft: #f9e6db;
  --shadow: 0 1px 2px rgba(19, 32, 51, .05), 0 10px 28px -14px rgba(19, 32, 51, .16);
  --shadow-lg: 0 2px 4px rgba(19, 32, 51, .05), 0 22px 44px -20px rgba(19, 32, 51, .28);
  --radius: 14px;
  --maxw: 1140px;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --font-mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
  /* pastel bands on code cards */
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1320;
  --surface: #111c2c;
  --surface-2: #162336;
  --ink: #e7edf4;
  --ink-soft: #c9d3de;
  --muted: #94a3b4;
  --line: #213047;
  --navy: #070f1d;
  --navy-2: #0a1526;
  --accent: #6aa9f0;
  --accent-ink: #9cc6f7;
  --accent-soft: #15304f;
  --warm: #f59a62;
  --warm-soft: #3a2418;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -12px rgba(0, 0, 0, .5);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, .3), 0 22px 44px -18px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 76px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-soft);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-ink); }

h1, h2, h3, h4 {
  font-family: var(--font-serif);
  color: var(--ink);
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 .5em;
  font-variation-settings: "opsz" 72;
}
h1 { font-size: clamp(2.6rem, 5.5vw, 4.2rem); font-weight: 500; letter-spacing: -0.025em; }
h2 { font-size: clamp(2rem, 3.6vw, 2.8rem); letter-spacing: -0.02em; }
h3 { font-size: 1.3rem; font-variation-settings: "opsz" 24; }
p { margin: 0 0 1em; }
strong { color: var(--ink); font-weight: 600; }
code { font-family: var(--font-mono); font-size: .88em; }

.container { width: min(100% - 2.5rem, var(--maxw)); margin-inline: auto; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 300;
  background: var(--ink); color: var(--bg); padding: .5rem .9rem; border-radius: 8px;
}
.skip-link:focus { left: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
/* teal focus rings disappear on the dark hero, transparent header and footer */
.hero :focus-visible, .home .site-header:not(.solid) :focus-visible, .site-footer :focus-visible, .lightbox :focus-visible { outline-color: #fff; }

svg.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
  transition: background-color .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.nav { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 1rem; }
.brand {
  font-family: var(--font-serif); font-size: 1.25rem; font-weight: 600; color: var(--ink);
  text-decoration: none; letter-spacing: -0.01em; white-space: nowrap; transition: color .3s ease;
}
.brand span { color: var(--accent); }
.nav-links { display: flex; align-items: center; gap: .15rem; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  position: relative; display: block; padding: .45rem .75rem;
  font-size: .93rem; font-weight: 500; color: var(--muted); text-decoration: none; transition: color .2s ease;
}
.nav-links a::after {
  content: ""; position: absolute; left: .75rem; right: .75rem; bottom: .2rem; height: 1.5px;
  background: currentColor; transform: scaleX(0); transform-origin: left; transition: transform .25s ease;
}
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a:hover::after, .nav-links a[aria-current="page"]::after { transform: scaleX(1); }
.nav-actions { display: flex; align-items: center; gap: .35rem; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; padding: 0; transition: all .2s ease;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }
.menu-toggle { display: none; }

.site-header.menu-open { background: var(--bg); }

/* Home: header floats transparently over the dark hero until scrolled */
.home .site-header { position: fixed; left: 0; right: 0; }
.home .site-header:not(.solid) {
  background: transparent; border-bottom-color: transparent;
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.home .site-header:not(.solid) .brand,
.home .site-header:not(.solid) .nav-links a { color: rgba(255, 255, 255, .88); }
.home .site-header:not(.solid) .brand span { color: #8dbdf5; }
.home .site-header:not(.solid) .nav-links a:hover { color: #fff; }
.home .site-header:not(.solid) .icon-btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .22); color: #fff; }
.home .site-header:not(.solid) .icon-btn:hover { background: rgba(255, 255, 255, .16); }

@media (max-width: 900px) {
  .menu-toggle { display: inline-grid; }
  .nav-links {
    position: absolute; top: 68px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    padding: .5rem 1.25rem 1rem; background: var(--bg); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow); display: none;
  }
  .nav-links.open { display: flex; }
  .nav-links a { padding: .75rem .5rem; font-size: 1rem; }
  .nav-links a::after { display: none; }
  .home .site-header:not(.solid) .nav-links.open a { color: var(--muted); }
}

/* ---------- Buttons ---------- */
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .66rem 1.1rem; border-radius: 10px; font-weight: 600; font-size: .93rem; line-height: 1.2;
  text-decoration: none; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  transition: transform .15s ease, border-color .15s ease, background-color .15s ease, color .15s ease;
}
.btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ==========================================================================
   Hero — full-bleed wind map
   ========================================================================== */
.hero {
  position: relative; overflow: hidden; color: #fff; background: #0a1528;
  min-height: 100vh; min-height: 100svh; display: flex; align-items: center; justify-content: center;
  isolation: isolate;
}
.hero canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero .shade {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 46% 40% at 50% 47%, rgba(6, 13, 26, .62), rgba(6, 13, 26, 0) 100%),
    linear-gradient(180deg, rgba(6, 13, 26, .55) 0%, rgba(6, 13, 26, 0) 18%, rgba(6, 13, 26, 0) 70%, rgba(6, 13, 26, .7) 100%);
}
.hero-content { position: relative; z-index: 2; text-align: center; padding: 6.5rem 1.25rem 7.5rem; max-width: 900px; }
.hero h1 {
  color: #fff; font-size: clamp(3rem, 8vw, 5.8rem); font-weight: 500; margin: 0 0 .15em; letter-spacing: -0.03em;
  text-shadow: 0 2px 30px rgba(0, 0, 0, .35);
}
.hero .subtitle { font-size: clamp(1.05rem, 2vw, 1.3rem); font-weight: 500; color: rgba(255, 255, 255, .92); margin: 0 0 2rem; }
.hero .btn-row { justify-content: center; }
.btn-light { background: #fff; border-color: #fff; color: var(--navy); }
.btn-light:hover { background: #fff; border-color: #fff; color: var(--accent); }
.btn-ghost { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .28); color: #fff; backdrop-filter: blur(4px); }
.btn-ghost:hover { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .5); color: #fff; }
.circle-links { display: flex; justify-content: center; gap: .6rem; margin-top: 1.5rem; }
.circle-links a {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .07); color: #fff;
  transition: background-color .2s ease, transform .2s ease;
}
.circle-links a:hover { background: rgba(255, 255, 255, .2); transform: translateY(-2px); color: #fff; }
.circle-links svg { width: 18px; height: 18px; }
.hero-credit {
  position: absolute; z-index: 3; right: 1.5rem; bottom: 1.5rem; font-size: .68rem; color: rgba(255, 255, 255, .5);
  font-family: var(--font-mono); text-align: right; max-width: 340px; line-height: 1.5;
}
.hero-credit a { color: inherit; }
@media (max-width: 760px) { .hero-credit { display: none; } }

/* ==========================================================================
   Sections
   ========================================================================== */
section { padding: clamp(4rem, 8vw, 6.5rem) 0; }
section + section { border-top: 1px solid var(--line); }
.kicker {
  display: block; font-size: .8rem; font-weight: 600; color: var(--accent);
  letter-spacing: .1em; text-transform: uppercase; margin-bottom: .6rem;
}
.section-head { text-align: center; max-width: 760px; margin: 0 auto 3rem; }
.section-head h2 { margin-bottom: .45rem; }
.section-head p { margin: 0 auto; color: var(--muted); font-size: 1.05rem; max-width: 62ch; }


/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: minmax(0, 330px) minmax(0, 1fr); gap: clamp(2.5rem, 6vw, 5rem); align-items: center; max-width: 1000px; }
@media (max-width: 900px) { .about-grid { grid-template-columns: 1fr; } }
.portrait { position: relative; margin: 0; max-width: 330px; }
/* width:100% matters: every child of the frame is absolutely positioned, so a
   shrink-to-fit grid item would collapse to 0x0 */
@media (max-width: 900px) { .portrait { width: 100%; max-width: 360px; margin-inline: auto; } }
.portrait-frame {
  position: relative; aspect-ratio: 3 / 4; border-radius: 20px; overflow: hidden; background: #0a1528;
  box-shadow: var(--shadow-lg);
}
.portrait-frame canvas, .portrait-frame img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.portrait-frame img { z-index: 2; }
.portrait-frame .map-label {
  position: absolute; z-index: 1; left: 1rem; right: 1rem; bottom: .9rem; color: rgba(255, 255, 255, .8);
  font-size: .74rem; font-family: var(--font-mono); letter-spacing: .02em;
}
.portrait-frame .monogram {
  position: absolute; z-index: 1; left: 1rem; top: 1rem; width: 56px; height: 56px; border-radius: 14px;
  display: grid; place-items: center; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25);
  color: #fff; font-family: var(--font-serif); font-size: 1.4rem; backdrop-filter: blur(4px);
}
.about-text h2 { font-size: clamp(2rem, 3.8vw, 2.9rem); margin-bottom: 1.1rem; }
.about-text p { color: var(--muted); font-size: 1.05rem; }
.about-text h2.kicker { font-family: var(--font-sans); font-size: .8rem; letter-spacing: .1em; font-variation-settings: normal; line-height: 1.4; margin: 0 0 1rem; }
.about-text .about-lead { font-size: clamp(1.1rem, 1.6vw, 1.25rem); line-height: 1.6; color: var(--ink-soft); }
.about-text p strong { color: var(--ink); }




/* ---------- Research: one entry per project, figure alternating sides ---------- */
.project {
  display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(1.75rem, 4vw, 3.25rem); align-items: center;
  margin-bottom: clamp(3.5rem, 7vw, 5.5rem);
}
.project.reverse { grid-template-columns: 1fr 1.25fr; }
.project.reverse .project-media { order: 2; }
@media (max-width: 900px) {
  .project, .project.reverse { grid-template-columns: minmax(0, 1fr); }
  .project.reverse .project-media { order: 0; }
}
.project-media { margin: 0; min-width: 0; }
.video-frame {
  position: relative; border-radius: 16px; overflow: hidden; background: #fff;
  border: 1px solid var(--line); box-shadow: var(--shadow-lg);
}
.video-frame video { display: block; width: 100%; height: auto; }
.video-frame.tall { max-width: 480px; margin-inline: auto; }
.vid-toggle {
  position: absolute; right: .7rem; bottom: .7rem; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer; padding: 0;
  border: 1px solid rgba(255, 255, 255, .35); background: rgba(10, 21, 40, .72); color: #fff;
  transition: background-color .2s ease;
}
.vid-toggle:hover { background: rgba(10, 21, 40, .9); }
.vid-toggle svg { width: 14px; height: 14px; }
.vid-toggle .play { display: none; }
.vid-toggle.is-paused .play { display: block; }
.vid-toggle.is-paused .pause { display: none; }
.vid-toggle:focus-visible { outline-color: var(--accent); }
.project:last-child { margin-bottom: 0; }
.theme + .theme { margin-top: clamp(4rem, 8vw, 6rem); }
.theme-title { font-size: clamp(1.7rem, 3vw, 2.2rem); margin: 0 0 clamp(1.75rem, 4vw, 2.75rem); padding-bottom: .7rem; border-bottom: 1px solid var(--line); font-variation-settings: "opsz" 48; }
.fig-frame { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: .75rem; box-shadow: var(--shadow); cursor: zoom-in; }
.fig-frame img { display: block; width: 100%; height: auto; }
.fig-frame picture { display: block; }
.project-text h4 { font-size: clamp(1.3rem, 2.2vw, 1.6rem); margin: 0 0 .8rem; font-variation-settings: "opsz" 32; }
.project-text ul { margin: 0 0 1.1rem; padding-left: 1.1rem; color: var(--muted); }
.project-text li { margin-bottom: .5rem; }
.project-text .ref-label { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); margin: 0 0 .3rem; }
.project-text .ref { font-size: .86rem; color: var(--muted); line-height: 1.55; margin: 0 0 .45rem; }
.project-text .ref a { font-weight: 600; text-decoration: none; }
.project-text .ref a:hover { text-decoration: underline; }

/* ---------- Publications ---------- */
.pub-list { max-width: 820px; margin: 0 auto; list-style: none; padding: 0; }
.pub { padding: 1.2rem 0; border-top: 1px solid var(--line); }
.pub:first-child { border-top: 0; padding-top: 0; }
.pub p { margin: 0; }
.pub .title { font-family: var(--font-serif); font-size: 1.12rem; font-weight: 600; color: var(--ink); line-height: 1.35; margin-bottom: .3rem; font-variation-settings: "opsz" 24; }
.pub .title a { color: inherit; text-decoration: none; }
.pub .title a:hover { color: var(--accent); }
.pub .authors { font-size: .9rem; color: var(--muted); line-height: 1.5; }
.pub .authors b { color: var(--ink); font-weight: 650; }
.pub-meta { font-size: .88rem; color: var(--muted); margin-top: .3rem; }
.pub-meta .venue { color: var(--ink-soft); }
.pub-meta a { font-weight: 600; text-decoration: none; }
.pub-meta a:hover { text-decoration: underline; }
.more-link { text-align: center; margin-top: 2.5rem; }
.more-link a { display: inline-flex; align-items: center; gap: .4rem; font-weight: 600; text-decoration: none; }
.more-link a:hover { text-decoration: underline; }
.more-link svg { width: 15px; height: 15px; }


/* ---------- Links ---------- */
.link-groups { max-width: 820px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 2rem 3rem; }
@media (max-width: 700px) { .link-groups { grid-template-columns: minmax(0, 1fr); } }
.link-group h3 { padding-bottom: .5rem; border-bottom: 1px solid var(--line); margin-bottom: .25rem; }
.link-list { list-style: none; margin: 0; padding: 0; }
.link-list li { padding: .8rem 0; }
.link-list li + li { border-top: 1px solid var(--line); }
.link-list a { font-weight: 600; text-decoration: none; }
.link-list a:hover { text-decoration: underline; }

/* ---------- Footer ---------- */
.site-footer { background: var(--navy-2); color: rgba(255, 255, 255, .72); padding: 2.2rem 0; font-size: .88rem; }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 1rem 2rem; }
.site-footer .f-brand { font-family: var(--font-serif); font-size: 1.15rem; font-weight: 600; color: #fff; text-decoration: none; }
.site-footer .f-contact { display: flex; flex-direction: column; gap: .2rem; }
.site-footer a { color: rgba(255, 255, 255, .85); }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 400; background: rgba(8, 14, 24, .88);
  display: none; align-items: center; justify-content: center; padding: 2rem; cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: min(1400px, 100%); max-height: 100%; background: #fff; border-radius: 8px; padding: .5rem; }
.lightbox-close {
  position: fixed; top: 1rem; right: 1rem; width: 44px; height: 44px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .1); color: #fff; font-size: 1.6rem; line-height: 1;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .22); }

