/* ==========================================================
   Parag Dakle — personal site
   Editorial "research notebook" theme: paper, ink, one accent.
   ========================================================== */

:root {
    --bg: #f5f2ea;
    --surface: #fbf9f4;
    --ink: #1c1b18;
    --ink-2: #4a4740;
    --ink-3: #7a766c;
    --rule: #ddd7c9;
    --accent: #b5470f;
    --accent-soft: #f1dccb;
    --bar-muted: #d6cfbf;

    --serif: "Fraunces", Georgia, "Times New Roman", serif;
    --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

    --max: 1120px;
    --gutter: clamp(16px, 4vw, 40px);
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #151412;
        --surface: #1d1c19;
        --ink: #ece7dc;
        --ink-2: #bdb7aa;
        --ink-3: #8a8478;
        --rule: #34312b;
        --accent: #f0915a;
        --accent-soft: #3b2619;
        --bar-muted: #45413a;
        color-scheme: dark;
    }
}
:root[data-theme="dark"] {
    --bg: #151412;
    --surface: #1d1c19;
    --ink: #ece7dc;
    --ink-2: #bdb7aa;
    --ink-3: #8a8478;
    --rule: #34312b;
    --accent: #f0915a;
    --accent-soft: #3b2619;
    --bar-muted: #45413a;
    color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 400 17px/1.6 var(--sans);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-color: var(--rule); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: color .15s, text-decoration-color .15s; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; margin: 0; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: .8em; letter-spacing: .02em; }
.wrap { max-width: var(--max); margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }

.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }

/* ---------- top bar ---------- */
.topbar {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s;
}
.topbar.is-scrolled { border-bottom-color: var(--rule); }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { font-family: var(--serif); font-size: 20px; font-weight: 600; text-decoration: none; letter-spacing: -0.01em; }
.nav { display: flex; gap: 28px; margin-left: auto; }
.nav a { font-size: 14px; text-decoration: none; color: var(--ink-2); position: relative; padding: 4px 0; }
.nav a::after { content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px; background: var(--accent); transform: scaleX(0); transform-origin: left; transition: transform .2s; }
.nav a:hover, .nav a.is-active { color: var(--ink); }
.nav a.is-active::after { transform: scaleX(1); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.btn { display: inline-flex; align-items: center; gap: 6px; font: 500 14px/1 var(--sans); text-decoration: none; border: 1px solid var(--ink); border-radius: 999px; padding: 10px 16px; }
.btn:hover { background: var(--ink); color: var(--bg); }
.btn-small { padding: 8px 14px; font-size: 13px; }

.theme-toggle { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--rule); background: transparent; color: var(--ink); cursor: pointer; padding: 0; }
.theme-toggle:hover { border-color: var(--ink); }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .icon-sun { display: none; }
    :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ---------- hero ---------- */
.hero {
    display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    gap: clamp(32px, 6vw, 88px); align-items: end;
    padding-top: clamp(48px, 9vw, 112px); padding-bottom: clamp(40px, 6vw, 72px);
}
.eyebrow { font-family: var(--mono); font-size: 13px; color: var(--accent); letter-spacing: .04em; margin-bottom: 24px; }
.hero h1 { font-size: clamp(40px, 6.4vw, 76px); line-height: 1.02; letter-spacing: -0.025em; font-weight: 400; margin-bottom: 28px; }
.hero h1 em { font-style: italic; color: var(--accent); }
.lede { font-size: clamp(17px, 1.6vw, 19px); color: var(--ink-2); max-width: 60ch; margin-bottom: 14px; }
.aside { font-size: 15px; color: var(--ink-3); max-width: 60ch; }

.links { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 8px 24px; font-family: var(--mono); font-size: 14px; }
.links a { text-decoration: underline; text-decoration-color: var(--rule); }
.links a:hover { text-decoration-color: currentColor; }

.portrait { margin: 0; }
.portrait img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 30%; border-radius: 4px; filter: saturate(.92); }
.portrait figcaption { margin-top: 10px; font-size: 13px; color: var(--ink-3); }
.portrait figcaption .mono { color: var(--ink); margin-right: 6px; }

/* ---------- stats strip ---------- */
.stats { width: min(calc(100% - 2 * var(--gutter)), calc(var(--max) - 2 * var(--gutter))); padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.stat { padding: 20px 16px 22px 0; display: flex; flex-direction: column; gap: 4px; }
.stat + .stat { padding-left: 20px; border-left: 1px solid var(--rule); }
.stat-num { font-family: var(--serif); font-size: clamp(28px, 3.4vw, 40px); line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.stat-label { font-size: 13px; color: var(--ink-3); }

/* ---------- sections ---------- */
.section { padding-top: clamp(72px, 10vw, 128px); }
.section-head { display: grid; grid-template-columns: 160px minmax(0, 1fr); column-gap: 24px; row-gap: 8px; margin-bottom: 40px; align-items: baseline; }
.section-num { font-family: var(--mono); font-size: 13px; color: var(--accent); }
.section-head h2 { font-size: clamp(34px, 4.4vw, 52px); line-height: 1.05; }
.section-sub { grid-column: 2; color: var(--ink-2); max-width: 58ch; }
.scholar { grid-column: 2; margin-top: 6px; font-family: var(--mono); font-size: 13px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 18px; }
.scholar[hidden] { display: none; }
.scholar b { font-weight: 500; color: var(--ink); }
.scholar a { color: var(--ink-3); }
.scholar a:hover { color: var(--accent); }

/* ---------- research ---------- */
.research-top { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 32px; align-items: end; margin-left: 184px; margin-bottom: 24px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-self: end; }
.chip { font: 500 13px/1 var(--sans); color: var(--ink-2); background: transparent; border: 1px solid var(--rule); border-radius: 999px; padding: 9px 14px; cursor: pointer; transition: all .15s; }
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip .count { font-family: var(--mono); font-size: 11px; opacity: .6; margin-left: 6px; }

.chart { margin: 0; position: relative; }
.chart-title { font-size: 13px; color: var(--ink-3); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; }
.chart-title > .mono { color: var(--ink); margin-right: -8px; }
.chart-legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.chart-legend[hidden] { display: none; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.sw-all { background: var(--bar-muted); }
.sw-sel { background: var(--accent); margin-left: 6px; }
.chart-body svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-body .bar-all { fill: var(--bar-muted); }
.chart-body .bar-sel { fill: var(--accent); transition: d .35s ease; }
.chart-body .axis { stroke: var(--ink-3); stroke-width: 1; }
.chart-body .lbl { font: 400 11px var(--mono); fill: var(--ink-3); }
.chart-body .val { font: 500 11px var(--mono); fill: var(--ink); }
.chart-body .hit { fill: transparent; cursor: default; }
.chart-body .col:hover .bar-all { fill: var(--ink-3); }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font: 12px/1.4 var(--sans); padding: 6px 9px; border-radius: 4px; white-space: nowrap; opacity: 0; transform: translate(-50%, -100%); transition: opacity .12s; }
.chart-tip.is-on { opacity: 1; }

.pubs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.pub { display: grid; grid-template-columns: 160px minmax(0, 1fr); column-gap: 24px; padding: 22px 0; border-bottom: 1px solid var(--rule); }
.pub[hidden] { display: none; }
.pub-year { font-family: var(--mono); font-size: 13px; color: var(--ink-3); padding-top: 4px; }
.pub.is-repeat .pub-year { visibility: hidden; }
.pub h3 { font-size: clamp(18px, 1.8vw, 21px); line-height: 1.3; font-weight: 500; margin-bottom: 6px; max-width: 62ch; }
.pub h3 a { text-decoration: none; }
.authors { font-size: 14px; color: var(--ink-3); margin-bottom: 8px; }
.authors b { font-weight: 600; color: var(--ink); }
.pub-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-family: var(--mono); font-size: 12px; }
.venue { color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 3px; }
.pub-meta a { color: var(--ink-2); text-decoration: none; }
.pub-meta a:hover { color: var(--accent); }
.empty { margin-left: 184px; padding: 24px 0; color: var(--ink-3); }

/* ---------- experience ---------- */
.jobs { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.job { display: grid; grid-template-columns: 160px minmax(0, 1fr); column-gap: 24px; padding: 28px 0; border-bottom: 1px solid var(--rule); }
.job-when { font-family: var(--mono); font-size: 13px; color: var(--ink-3); padding-top: 5px; }
.job.is-current .job-when { color: var(--accent); }
.job.is-current .job-when::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: 1px; box-shadow: 0 0 0 3px var(--accent-soft); }
.job h3 { font-size: clamp(21px, 2.2vw, 26px); line-height: 1.25; margin-bottom: 10px; }
.job-role { display: block; font-family: var(--sans); font-size: 15px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; margin-top: 2px; }
.job-body > p { color: var(--ink-2); max-width: 68ch; }
.job-body > p + p { margin-top: 10px; }
.terms, .plain { list-style: none; padding: 0; margin: 0; max-width: 72ch; color: var(--ink-2); }
.terms li { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; padding: 4px 0; font-size: 15px; }
.terms .mono { color: var(--ink-3); padding-top: 2px; }
.terms strong { color: var(--ink); font-weight: 600; }
.plain li { position: relative; padding: 3px 0 3px 18px; font-size: 15px; }
.plain li::before { content: "—"; position: absolute; left: 0; color: var(--ink-3); }
.job .tags { font-family: var(--mono); font-size: 12px; color: var(--ink-3); margin-top: 14px; }

/* ---------- education ---------- */
.degrees { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-left: 184px; }
.degree { background: var(--surface); border: 1px solid var(--rule); border-radius: 6px; padding: 24px; display: flex; flex-direction: column; gap: 6px; }
.degree-when { color: var(--ink-3); margin-bottom: 6px; }
.degree h3 { font-size: 22px; line-height: 1.2; }
.degree p { font-size: 15px; color: var(--ink-2); }
.degree .degree-note { font-size: 13px; color: var(--ink-3); margin-top: auto; padding-top: 10px; }

/* ---------- footer ---------- */
.footer { margin-top: clamp(96px, 12vw, 160px); padding: clamp(56px, 8vw, 96px) 0 40px; background: var(--ink); color: var(--bg); }
.footer .section-num { color: var(--accent); margin-bottom: 20px; }
:root:not([data-theme="dark"]) .footer .section-num { color: #f0915a; }
.footer-cta { font-size: clamp(32px, 5.2vw, 64px); line-height: 1.08; font-weight: 400; letter-spacing: -0.02em; max-width: 18ch; }
.footer-cta a { font-style: italic; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; text-decoration-color: color-mix(in srgb, var(--bg) 35%, transparent); }
.footer-cta a:hover { color: inherit; text-decoration-color: currentColor; }
.footer .links { margin-top: 40px; }
.footer .links a { text-decoration-color: color-mix(in srgb, var(--bg) 30%, transparent); }
.footer .links a:hover { color: inherit; text-decoration-color: currentColor; }
.colophon { margin-top: 56px; font-size: 12px; opacity: .55; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .footer { background: var(--surface); color: var(--ink); border-top: 1px solid var(--rule); }
    :root:not([data-theme="light"]) .footer-cta a,
    :root:not([data-theme="light"]) .footer .links a { text-decoration-color: var(--rule); }
}
:root[data-theme="dark"] .footer { background: var(--surface); color: var(--ink); border-top: 1px solid var(--rule); }
:root[data-theme="dark"] .footer-cta a,
:root[data-theme="dark"] .footer .links a { text-decoration-color: var(--rule); }

/* ---------- reveal on scroll ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .6s ease, transform .6s ease; }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .reveal { opacity: 1; transform: none; transition: none; }
    .chart-body .bar-sel { transition: none; }
}

/* ---------- responsive ---------- */
@media (max-width: 960px) {
    .research-top { grid-template-columns: minmax(0, 1fr); margin-left: 0; }
    .chart { max-width: 420px; }
    .degrees { margin-left: 0; }
    .empty { margin-left: 0; }
    .section-head { grid-template-columns: minmax(0, 1fr); }
    .section-sub, .scholar { grid-column: 1; }
}
@media (max-width: 760px) {
    .nav { display: none; }
    .topbar-actions { margin-left: auto; }
    .hero { grid-template-columns: minmax(0, 1fr); align-items: start; }
    .portrait { order: -1; max-width: 200px; }
    .portrait img { aspect-ratio: 1; border-radius: 50%; }
    .portrait figcaption { display: none; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .stat:nth-child(3) { padding-left: 0; border-left: 0; border-top: 1px solid var(--rule); }
    .stat:nth-child(4) { border-top: 1px solid var(--rule); }
    .pub, .job { grid-template-columns: minmax(0, 1fr); row-gap: 6px; }
    .pub.is-repeat .pub-year { display: none; }
    .degrees { grid-template-columns: minmax(0, 1fr); }
}
