/* ============================================================
   Gaurab Khadka - academic site
   Shared stylesheet. Light default; dark via media query plus an
   explicit [data-theme] override set by the header toggle.
   ============================================================ */

:root {
  --paper:      #fbfbf9;
  --paper-alt:  #f3f3ef;
  --card:       #ffffff;
  --ink:        #1a1c20;
  --ink-soft:   #4a4f57;
  --ink-faint:  #6f747d;
  --rule:       #e2e1db;
  --accent:     #14407f;
  --accent-soft:#e9eef8;
  --mark:       #a8491a;
  --shadow:     0 1px 2px rgba(20, 24, 32, .05), 0 8px 24px -16px rgba(20, 24, 32, .25);

  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans:  "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --measure: 66ch;
  --wide: 1060px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:      #12141a;
    --paper-alt:  #171a21;
    --card:       #181b22;
    --ink:        #e6e8ec;
    --ink-soft:   #b0b6c0;
    --ink-faint:  #8a919d;
    --rule:       #272b34;
    --accent:     #8fb4f0;
    --accent-soft:#1b2433;
    --mark:       #e0a273;
    --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.6);
  }
}

:root[data-theme="dark"] {
  --paper:      #12141a;
  --paper-alt:  #171a21;
  --card:       #181b22;
  --ink:        #e6e8ec;
  --ink-soft:   #b0b6c0;
  --ink-faint:  #8a919d;
  --rule:       #272b34;
  --accent:     #8fb4f0;
  --accent-soft:#1b2433;
  --mark:       #e0a273;
  --shadow:     0 1px 2px rgba(0,0,0,.3), 0 8px 24px -16px rgba(0,0,0,.6);
}

*, *::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; } }

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

h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.22; margin: 0; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
img { max-width: 100%; }

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--accent); color: #fff;
  padding: .6rem 1rem; z-index: 100; border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }

/* ---------- layout ---------- */
.wrap { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 20px; }
.prose { max-width: var(--measure); }

section { padding: 2.75rem 0; border-top: 1px solid var(--rule); }
section.hero { border-top: 0; }

.eyebrow {
  font-family: var(--mono); font-size: .7rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0 0 1.1rem;
}
h2.section-title { font-size: 1.45rem; margin: 0 0 1.4rem; letter-spacing: -.01em; }

/* ---------- header ---------- */
.site-head {
  position: sticky; top: 0; z-index: 50;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
@supports (backdrop-filter: blur(10px)) {
  .site-head { background: color-mix(in srgb, var(--paper) 86%, transparent); backdrop-filter: saturate(180%) blur(10px); }
}
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; gap: 1rem; }
.brand { font-family: var(--serif); font-size: 1.02rem; font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--ink-faint); font-family: var(--sans); font-size: .78rem; font-weight: 400; margin-left: .5rem; }
@media (max-width: 680px) { .brand span { display: none; } }

.site-nav { display: flex; align-items: center; gap: 1.1rem; font-size: .88rem; }
.site-nav a { color: var(--ink-soft); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }
@media (max-width: 720px) { .site-nav .hide-sm { display: none; } }
@media (max-width: 560px) { .site-nav { gap: .8rem; font-size: .85rem; } .site-nav .hide-xs { display: none; } }

.theme-btn {
  background: none; border: 1px solid var(--rule); border-radius: 6px; cursor: pointer;
  color: var(--ink-soft); width: 30px; height: 30px; display: grid; place-items: center; padding: 0; flex: none;
}
.theme-btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.theme-btn svg { width: 15px; height: 15px; }

/* ---------- hero ---------- */
.hero { padding: 3rem 0 2.5rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 3rem; align-items: start; }
@media (max-width: 760px) { .hero-grid { grid-template-columns: 1fr; gap: 1.75rem; } }

.hero h1 { font-size: clamp(2.1rem, 5vw, 2.85rem); letter-spacing: -.02em; margin-bottom: .6rem; }
.hero .lede { font-family: var(--serif); font-size: 1.22rem; line-height: 1.5; color: var(--ink); margin-bottom: 1.1rem; }
.hero .affil { color: var(--ink-soft); font-size: .97rem; }
.hero .affil strong { font-weight: 600; color: var(--ink); }

.portrait {
  width: 190px; height: 190px; border-radius: 4px; object-fit: cover; object-position: 50% 26%;
  border: 1px solid var(--rule); box-shadow: var(--shadow); background: var(--paper-alt);
}
@media (max-width: 760px) { .portrait { width: 136px; height: 136px; } }

.links { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.4rem; }
.links a {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .86rem; text-decoration: none; color: var(--ink-soft);
  border: 1px solid var(--rule); border-radius: 999px; padding: .34rem .85rem; background: var(--card);
}
.links a:hover { color: var(--accent); border-color: var(--accent); }
.links a svg { width: 14px; height: 14px; flex: none; }
.links a.primary { background: var(--accent); border-color: var(--accent); color: var(--paper); }
.links a.primary:hover { filter: brightness(1.1); color: var(--paper); }

/* ---------- news ---------- */
.news { list-style: none; margin: 0; padding: 0; max-width: var(--measure); }
.news li { display: grid; grid-template-columns: 5.6rem 1fr; gap: 1rem; padding: .5rem 0; border-bottom: 1px dotted var(--rule); font-size: .94rem; color: var(--ink-soft); }
.news li:last-child { border-bottom: 0; }
.news time { font-family: var(--mono); font-size: .76rem; color: var(--ink-faint); padding-top: .25rem; }
@media (max-width: 520px) {
  .news li { grid-template-columns: 1fr; gap: .15rem; }
  .news time { padding-top: 0; }
}

/* ---------- research entries ---------- */
.entry { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.75rem; padding: 1.6rem 0; border-bottom: 1px solid var(--rule); }
.entry:last-of-type { border-bottom: 0; }
@media (max-width: 720px) { .entry { grid-template-columns: 1fr; gap: 1rem; } }

.entry-fig {
  border: 1px solid var(--rule); border-radius: 6px; background: var(--paper-alt);
  overflow: hidden; display: grid; place-items: center; min-height: 150px; padding: .6rem;
}
.entry-fig svg { width: 100%; height: auto; display: block; }
.entry-fig img { width: 100%; height: 100%; object-fit: cover; display: block; }

.entry h3 { font-size: 1.18rem; margin-bottom: .3rem; }
.entry h3 a { color: var(--ink); text-decoration: none; }
.entry h3 a:hover { color: var(--accent); text-decoration: underline; }
.entry .q { font-family: var(--serif); font-style: italic; color: var(--ink-soft); margin-bottom: .6rem; }
.entry p { font-size: .95rem; color: var(--ink-soft); }
.entry p strong { color: var(--ink); font-weight: 600; }

.meta { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; margin-bottom: .55rem; }
.pill {
  font-family: var(--mono); font-size: .68rem; letter-spacing: .03em; text-transform: uppercase;
  border: 1px solid var(--rule); border-radius: 3px; padding: .12rem .45rem; color: var(--ink-faint);
}
.pill.live { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.pill.review { border-color: var(--mark); color: var(--mark); }

.more { font-size: .88rem; display: inline-block; margin-top: .25rem; }
.more::after { content: " \2192"; }

/* ---------- publications ---------- */
.pub-group + .pub-group { margin-top: 1.8rem; }
.pub-group h3 { font-size: .8rem; font-family: var(--sans); font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .1em; margin-bottom: .6rem; }
.pub { display: grid; grid-template-columns: 3rem minmax(0, 1fr); gap: .9rem; padding: .85rem 0; border-bottom: 1px solid var(--rule); max-width: var(--measure); }
.pub:last-child { border-bottom: 0; }
.pub .tagno { font-family: var(--mono); font-size: .78rem; color: var(--ink-faint); padding-top: .2rem; }
.pub .title { font-family: var(--serif); font-size: 1.05rem; color: var(--ink); margin-bottom: .2rem; }
.pub .authors { font-size: .9rem; color: var(--ink-soft); }
.pub .authors em { font-style: normal; font-weight: 600; color: var(--ink); }
.pub .venue { font-size: .9rem; color: var(--ink-soft); margin-top: .15rem; }
.pub .note { font-size: .84rem; color: var(--ink-faint); margin-top: .35rem; }
@media (max-width: 520px) { .pub { grid-template-columns: 1fr; gap: .25rem; } }

/* ---------- simple rows (experience, mentoring, service) ---------- */
.rows { max-width: var(--measure); }
.row { padding: .95rem 0; border-bottom: 1px solid var(--rule); }
.row:last-child { border-bottom: 0; }
.row-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .3rem 1rem; align-items: baseline; }
.row-head h3 { font-size: 1.03rem; }
.row-head .when { font-family: var(--mono); font-size: .76rem; color: var(--ink-faint); white-space: nowrap; }
.row .where { font-size: .92rem; color: var(--ink-soft); margin: .1rem 0 .35rem; }
.row p { font-size: .93rem; color: var(--ink-soft); margin: 0; }

.kw { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .2rem; }
.kw span {
  font-size: .82rem; color: var(--ink-soft); background: var(--paper-alt);
  border: 1px solid var(--rule); border-radius: 999px; padding: .22rem .7rem;
}

/* ---------- cards (engineering page) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 1rem; }
.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: 8px; padding: 1.1rem 1.2rem;
  box-shadow: var(--shadow);
}
.card h3 { font-size: 1.02rem; margin-bottom: .35rem; }
.card p { font-size: .9rem; color: var(--ink-soft); margin-bottom: .6rem; }
.card .foot { font-size: .84rem; color: var(--ink-faint); }

.compact { list-style: none; margin: 0; padding: 0; max-width: var(--measure); }
.compact li { padding: .55rem 0; border-bottom: 1px dotted var(--rule); font-size: .93rem; color: var(--ink-soft); }
.compact li:last-child { border-bottom: 0; }
.compact strong { color: var(--ink); font-weight: 600; }

/* ---------- detail pages ---------- */
.page-head { padding: 2.4rem 0 1.6rem; }
.back { font-size: .85rem; color: var(--ink-faint); text-decoration: none; display: inline-block; margin-bottom: 1rem; }
.back::before { content: "\2190  "; }
.back:hover { color: var(--accent); }
.page-head h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); letter-spacing: -.02em; margin-bottom: .5rem; }
.page-head .sub { font-family: var(--serif); font-size: 1.12rem; color: var(--ink-soft); max-width: var(--measure); margin: 0; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem 1.6rem; margin: 1.6rem 0 0; padding: 1.1rem 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.facts div { font-size: .9rem; }
.facts .k { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .2rem; }
.facts .v { color: var(--ink); }

article.body { max-width: var(--measure); padding: 2rem 0 1rem; }
article.body h2 { font-size: 1.3rem; margin: 2rem 0 .7rem; }
article.body h2:first-child { margin-top: 0; }
article.body h3 { font-size: 1.05rem; margin: 1.4rem 0 .4rem; }
article.body p, article.body li { color: var(--ink-soft); }
article.body strong { color: var(--ink); font-weight: 600; }
article.body ul { padding-left: 1.15rem; margin: 0 0 1rem; }
article.body li { margin-bottom: .45rem; }

figure.diagram { margin: 1.75rem 0; max-width: 100%; }
figure.diagram .frame { border: 1px solid var(--rule); border-radius: 8px; background: var(--paper-alt); padding: 1.1rem; }
/* Figures whose artwork has a light background of its own: keep the plate white in dark mode
   so black labels stay readable. */
figure.diagram .frame.plate { background: #fff; padding: .75rem; }
figure.diagram .frame.plate img { border-radius: 3px; }
figure.diagram img { width: 100%; height: auto; display: block; }
figure.diagram svg { width: 100%; height: auto; display: block; }
figure.diagram figcaption { font-size: .84rem; color: var(--ink-faint); margin-top: .55rem; line-height: 1.5; }

.callout {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  padding: .9rem 1.1rem; border-radius: 0 6px 6px 0; margin: 1.5rem 0; font-size: .93rem; color: var(--ink-soft);
}
.callout strong { color: var(--ink); }
.callout p:last-child { margin-bottom: 0; }

/* ---------- contact + footer ---------- */
.contact-grid { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; }
.contact-grid div { font-size: .94rem; }
.contact-grid .k { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: .2rem; }

.site-foot { border-top: 1px solid var(--rule); padding: 1.8rem 0 2.4rem; margin-top: 1rem; color: var(--ink-faint); font-size: .84rem; }
.site-foot .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .6rem; }
.site-foot a { color: var(--ink-faint); }

/* ---------- SVG diagram tokens (figures follow the theme) ---------- */
.dg-box { fill: var(--card); stroke: var(--rule); }
.dg-box-accent { fill: var(--accent-soft); stroke: var(--accent); }
.dg-text { fill: var(--ink); font-family: var(--sans); }
.dg-sub { fill: var(--ink-faint); font-family: var(--sans); }
.dg-line { stroke: var(--ink-faint); fill: none; }
.dg-arrow { fill: var(--ink-faint); }
.dg-accent-line { stroke: var(--accent); fill: none; }
