/* ==========================================================
   MFI Soumik — academic homepage
   Light by default, dark via system preference or toggle.
   ========================================================== */

:root {
  --bg: #fbf9f4;
  --surface: #f3efe6;
  --text: #1c1b19;
  --muted: #5c5850;
  --faint: #736e64;
  --rule: #e4ddcf;
  --accent: #8a5a1c;
  --accent-hover: #6b4410;
  --badge-bg: #f1e8d8;
  --badge-text: #6b4410;

  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Source Sans 3', -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --measure: 820px;
  --gutter: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212;
    --surface: #1b1a18;
    --text: #e8e6e1;
    --muted: #aaa69c;
    --faint: #8f8b82;
    --rule: #2c2a26;
    --accent: #d4b07c;
    --accent-hover: #e8cba0;
    --badge-bg: #2a241a;
    --badge-text: #e0c08f;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212;
  --surface: #1b1a18;
  --text: #e8e6e1;
  --muted: #aaa69c;
  --faint: #8f8b82;
  --rule: #2c2a26;
  --accent: #d4b07c;
  --accent-hover: #e8cba0;
  --badge-bg: #2a241a;
  --badge-text: #e0c08f;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2 { font-family: var(--serif); font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; }
p { margin: 0 0 0.9em; }
ul, ol { margin: 0; padding: 0; }
img { max-width: 100%; height: auto; display: block; }

a { color: var(--accent); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
a:hover { color: var(--accent-hover); text-decoration-color: currentColor; }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 var(--gutter); }

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

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
  border-bottom: 1px solid var(--rule);
}
.header-inner { display: flex; align-items: center; gap: 1rem; height: 56px; }
.site-name { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; color: var(--text); text-decoration: none; margin-right: auto; white-space: nowrap; }
.site-name:hover { color: var(--accent); }
.nav-list { display: flex; list-style: none; gap: 1.3rem; }
.nav-list a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.nav-list a:hover { color: var(--text); }

.theme-toggle {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 1px solid var(--rule); border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer;
}
.theme-toggle:hover { color: var(--text); border-color: var(--faint); }
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---------- Sections ---------- */
main.wrap { padding-top: 2.75rem; padding-bottom: 3rem; }
section { margin-bottom: 3.25rem; }
h2 {
  font-size: 1.45rem;
  margin: 0 0 1.1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--rule);
}
section h2 + .section-note { margin-top: -0.6rem; }
.section-note { color: var(--muted); font-size: 0.93rem; }
#edu-h { margin-top: 2.5rem; }

/* ---------- Profile ---------- */
.profile { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 2.5rem; align-items: start; }
.profile h1 { font-size: clamp(1.85rem, 4.2vw, 2.4rem); margin: 0 0 0.35rem; }
.role { color: var(--muted); margin-bottom: 1.3rem; line-height: 1.5; }
.role a { color: var(--muted); }
.role a:hover { color: var(--accent); }
.portrait { width: 220px; height: auto; aspect-ratio: 4 / 5; object-fit: cover; border-radius: 4px; border: 1px solid var(--rule); }

.interests { font-size: 0.95rem; color: var(--muted); }
.label {
  display: inline-block; margin-right: 0.5rem;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text);
}
.callout { border-left: 3px solid var(--accent); padding: 0.4rem 0 0.4rem 0.9rem; background: var(--surface); }

.links { list-style: none; display: flex; flex-wrap: wrap; gap: 0.4rem 1.1rem; margin-top: 1.1rem; font-weight: 600; font-size: 0.95rem; }

/* ---------- News ---------- */
.news { list-style: none; }
.news li { display: grid; grid-template-columns: 5.2rem minmax(0, 1fr); gap: 1rem; padding: 0.42rem 0; }
.news time { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 0.93rem; padding-top: 0.08rem; white-space: nowrap; }
.news strong { font-weight: 600; }

.news-photo { display: inline-flex; align-items: center; gap: 0.4rem; margin-left: 0.35rem; vertical-align: middle; font-size: 0.88rem; }
.news-photo img { width: 26px; height: 34px; object-fit: cover; border-radius: 2px; border: 1px solid var(--rule); }

.news-older { margin-top: 0.4rem; }
.news-older summary { cursor: pointer; color: var(--accent); font-size: 0.93rem; padding: 0.3rem 0; width: fit-content; }
.news-older summary:hover { color: var(--accent-hover); }
.news-older[open] summary { margin-bottom: 0.2rem; }

/* ---------- Publications ---------- */
.pubs { list-style: none; }
.pub { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr); gap: 1rem; padding: 0.95rem 0; border-bottom: 1px dashed var(--rule); }
.pub:last-child { border-bottom: none; }
.venue {
  align-self: start; justify-self: start;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em;
  background: var(--badge-bg); color: var(--badge-text);
  padding: 0.18rem 0.5rem; border-radius: 3px; white-space: nowrap; margin-top: 0.18rem;
}
.pub p { margin: 0; }
.pub-title { font-weight: 600; line-height: 1.4; }
.pub-authors { color: var(--text); font-size: 0.95rem; margin-top: 0.15rem !important; }
.pub-authors strong { font-weight: 600; text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 3px; }
.pub-venue { color: var(--muted); font-size: 0.93rem; font-style: italic; }
.status, .award { font-style: normal; font-size: 0.8rem; font-weight: 600; color: var(--accent); margin-left: 0.25rem; }
.pub-links { margin-top: 0.3rem !important; display: flex; gap: 0.85rem; font-size: 0.9rem; }
.pub-links a::before { content: "["; color: var(--faint); }
.pub-links a::after  { content: "]"; color: var(--faint); }
.pub-links a { text-decoration: none; }
.pub-links a:hover { text-decoration: underline; }

/* ---------- Experience / Education / Teaching ---------- */
.entries { list-style: none; }
.entry { display: flex; justify-content: space-between; gap: 1.5rem; padding: 0.55rem 0; }
.entry-main { min-width: 0; }
.entry p { margin: 0; }
.entry-title { font-weight: 600; }
.entry-org { color: var(--muted); font-size: 0.95rem; }
.entry-desc { font-size: 0.95rem; margin-top: 0.15rem !important; }
.entry-date { color: var(--faint); font-size: 0.93rem; white-space: nowrap; font-variant-numeric: tabular-nums; text-align: right; padding-top: 0.1rem; }

/* ---------- Awards ---------- */
.plain { list-style: none; }
.plain li { display: grid; grid-template-columns: 3.2rem minmax(0, 1fr); gap: 1rem; padding: 0.3rem 0; }
.yr { color: var(--faint); font-variant-numeric: tabular-nums; font-size: 0.93rem; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--rule); padding: 1.5rem 0 2.5rem; color: var(--faint); font-size: 0.88rem; }
.site-footer p { margin: 0; }

/* ---------- Responsive ---------- */
@media screen and (max-width: 720px) {
  body { font-size: 16px; }
  .nav-list { display: none; }
  .profile { grid-template-columns: 1fr; gap: 1.25rem; }
  .portrait { order: -1; width: 132px; }
  .pub { grid-template-columns: 1fr; gap: 0.4rem; }
  .entry { flex-direction: column; gap: 0.1rem; }
  .entry-date { text-align: left; order: -1; padding-top: 0; }
  .news li { grid-template-columns: 4.6rem minmax(0, 1fr); gap: 0.75rem; }
}

/* ---------- Print ---------- */
@media print {
  :root { --bg: #fff; --text: #000; --muted: #333; --faint: #555; --rule: #ccc; --accent: #000; --badge-bg: #fff; --badge-text: #000; }
  .site-header, .theme-toggle, .skip-link, .news-photo { display: none !important; }
  body { font-size: 11pt; }
  main.wrap { padding-top: 0; }
  section { margin-bottom: 1.5rem; }
  h2 { break-after: avoid; }
  .profile { grid-template-columns: minmax(0,1fr) 120px; }
  .portrait { width: 120px; }
  .pub, .entry { break-inside: avoid; }
  .news-older { display: block; }
  .news-older summary { display: none; }
  .news-older:not([open]) > .news { display: block; }
  a { color: #000; text-decoration: none; }
  .venue { border: 1px solid #999; }
}

/* ---------- Beyond research ---------- */
.beyond { display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 2rem; align-items: start; }
.moment { margin: 0; }
.moment img { width: 180px; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 4px; border: 1px solid var(--rule); }
.moment figcaption { margin-top: 0.45rem; font-size: 0.85rem; color: var(--faint); line-height: 1.4; }
@media screen and (max-width: 720px) {
  .beyond { grid-template-columns: 1fr; gap: 1rem; }
  .moment img { width: 160px; }
}
@media print { .moment { display: none; } .beyond { grid-template-columns: 1fr; } }

/* ---------- Affiliation logos ---------- */
.affiliations { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin-top: 1.4rem; padding-top: 1.1rem; border-top: 1px solid var(--rule); }
.affiliations li { display: flex; align-items: center; gap: 0.55rem; font-size: 0.85rem; color: var(--muted); }
.affiliations img { width: 44px; height: 44px; object-fit: contain; }
.affiliations img.logo-solid { border-radius: 6px; }
:root[data-theme="dark"] .affiliations img:not(.logo-solid) { background: #fff; border-radius: 6px; padding: 3px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .affiliations img:not(.logo-solid) { background: #fff; border-radius: 6px; padding: 3px; }
}
