/* Utsha Das — personal website. Plain CSS, no web fonts, no frameworks. */

:root {
  --bg: #fbfaf6;          /* warm off-white, like paper */
  --text: #1f2328;
  --muted: #59636e;
  --line: #e6e1d6;
  --accent: #1f3a5f;      /* deep navy, same as the CV */
  --tint: #e8eef5;        /* pale blue: header, intro, footer, table head */
  --tint-line: #d3dde9;
  --bar: #b2c4da;       /* bars beside section titles, link underlines, bullets */

  /* On wide screens the page has a left column for dates and years,
     like the CV. The photo is the same width, so everything lines up. */
  --gutter: 150px;
  --gap: 28px;
  --indent: calc(var(--gutter) + var(--gap));

  color-scheme: light dark;
}

/* Dark mode. It follows the visitor's system setting until they press the
   light/dark button in the menu (assets/js/theme.js), which sets
   data-theme="light" or "dark" on <html>.
   The dark colours appear twice below; keep the two lists the same. */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121519;
  --text: #e6e8eb;
  --muted: #9aa3ad;
  --line: #2a2f36;
  --accent: #8fb4e3;
  --tint: #1b2431;
  --tint-line: #2b3747;
  --bar: #34506f;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121519;
    --text: #e6e8eb;
    --muted: #9aa3ad;
    --line: #2a2f36;
    --accent: #8fb4e3;
    --tint: #1b2431;
    --tint-line: #2b3747;
    --bar: #34506f;
  }
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 72px;
  -webkit-text-size-adjust: 100%;   /* stop phones enlarging text in landscape */
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: break-word;        /* long links or emails never run off small screens */
}

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

::selection { background: var(--tint-line); }

.wrap { max-width: 900px; margin: 0 auto; padding: 0 20px; }

h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: normal; line-height: 1.2; }
h1 { font-size: 2.4rem; margin: 0 0 6px; color: var(--accent); }
h2 { font-size: 1.55rem; margin: 0 0 18px; color: var(--accent); }
h3 { font-size: 1rem; margin: 0; }
section > h3 { color: var(--accent); }
section > .list + h3 { margin-top: 18px; }   /* space between the lists in "Awards & Activities" */

.muted { color: var(--muted); }

li::marker { color: var(--bar); }

/* ---- Top navigation ---- */
/* The menu stays at the top of the screen while scrolling */
.top { position: sticky; top: 0; z-index: 10; background: var(--tint); border-top: 3px solid var(--accent); border-bottom: 1px solid var(--tint-line); }
.nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 20px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.nav .name { color: var(--accent); font-family: Georgia, "Times New Roman", serif; font-size: 1.15rem; text-decoration: none; }
.nav .links { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-left: auto; font-size: 0.95rem; }
.nav .links a { color: var(--muted); text-decoration: none; }
.nav .links a:hover { color: var(--accent); text-decoration: underline; text-decoration-color: var(--bar); }

/* Light / dark button: a moon in light mode, a sun in dark mode */
.theme-toggle {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--tint-line);
  border-radius: 50%;
  background: var(--bg);
  color: var(--accent);
  cursor: pointer;
}
.theme-toggle[hidden] { display: none; }
.theme-toggle:hover { border-color: var(--bar); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
}

/* ---- Intro: pale band under the menu ---- */
.intro {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 40px 0 38px;
  background: var(--tint);
  /* stretch the band to the full window width without extra HTML */
  box-shadow: 0 0 0 100vmax var(--tint);
  clip-path: inset(0 -100vmax);
}
.photo {
  flex: none;
  width: var(--gutter);
  height: var(--gutter);
  border-radius: 50%;
  object-fit: cover;
  background: var(--line);
  border: 4px solid var(--bg);
  box-shadow: 0 0 0 1px var(--tint-line);
}
.role { margin: 0 0 12px; color: var(--muted); }
.profiles { margin: 0; }

/* ---- Sections ---- */
section { padding: 28px 0; border-bottom: 1px solid var(--line); }
section:last-of-type { border-bottom: 0; }
section p { margin: 0 0 12px; }

/* ---- Citations table ---- */
.cites { border-collapse: collapse; margin: 6px 0 12px; font-size: 0.95rem; }
.cites caption { margin-bottom: 6px; font-weight: 600; text-align: left; }
.cites caption .muted { font-weight: normal; font-size: 0.85rem; }
.cites th, .cites td { padding: 6px 22px 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.cites thead th { background: var(--tint); color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.cites tbody th { font-weight: normal; }
.cites td { font-variant-numeric: tabular-nums; }
.cites td:last-child { color: var(--muted); font-size: 0.85rem; }

/* ---- Publications ---- */
.year h3 { margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); color: var(--accent); font-size: 1.05rem; }
.pubs { margin: 0; padding: 0; list-style: none; }
.pubs li { margin: 0 -10px 4px; padding: 8px 10px; border-radius: 4px; }
.pubs .title, .pubs .authors, .pubs .venue { display: block; }
.pubs .title { font-weight: 600; }
.pubs .authors, .pubs .venue { color: var(--muted); font-size: 0.95rem; }
.pubs .authors strong { color: var(--text); }
.badge {
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--tint);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  vertical-align: 2px;
}
/* Highlight a paper under the mouse (not on touch screens, where it would stick) */
@media (hover: hover) {
  .pubs li:hover { background: var(--tint); }
  .pubs li:hover .badge { background: var(--bg); }
}

/* ---- Experience / education entries ---- */
.entry { margin: 0 0 22px; }
.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 12px; }
.date { color: var(--accent); font-size: 0.9rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.org { margin: 0; color: var(--muted); }
.entry ul, .list { margin: 6px 0 0; padding-left: 20px; }
.list li { margin: 0 0 6px; }

footer {
  margin-top: 12px;
  background: var(--tint);
  border-top: 1px solid var(--tint-line);
  color: var(--muted);
  font-size: 0.9rem;
}
footer .wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  padding-top: 20px;
  padding-bottom: 32px;
}
footer strong { color: var(--text); }
/* Visitors by country: a small table under the counter, with each country's
   flag (assets/flags/, from flag-icons) */
.countries { flex-basis: 100%; margin-top: 10px; font-size: 0.85rem; }
.country-table { width: 100%; max-width: 420px; border-collapse: collapse; }
.country-table caption { padding: 0 0 6px; text-align: left; font-weight: 600; color: var(--text); }
.country-table th, .country-table td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--tint-line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.country-table th:first-child { padding-left: 0; text-align: left; }
.country-table thead th { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.country-table tbody th { font-weight: normal; color: var(--text); }
.country-table td:last-child { padding-right: 0; }
.country-table .country { display: flex; align-items: center; gap: 8px; }
.country-table .flag {
  flex: none;
  width: 20px;
  height: 15px;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);   /* edge for white flags (Japan) */
}
.country-table .no-flag { box-sizing: border-box; border: 1px dashed var(--muted); box-shadow: none; opacity: 0.6; }
.country-table .other th { color: var(--muted); }
.countries .geo-credit { display: block; margin-top: 6px; font-size: 0.78rem; opacity: 0.8; }
.countries .geo-credit a { color: inherit; }

/* ---- Wide screens: CV-style left column ---- */
@media (min-width: 760px) {
  section { padding: 30px 0 22px var(--indent); border-bottom: 0; }

  /* section title with a bar in the left column */
  section > h2 { position: relative; }
  section > h2::before {
    content: "";
    position: absolute;
    left: calc(-1 * var(--indent));
    top: calc(50% - 3px);
    width: var(--gutter);
    height: 6px;
    background: var(--bar);
  }

  /* dates sit in the left column, level with the job title */
  .entry {
    display: grid;
    grid-template-columns: var(--gutter) 1fr;
    column-gap: var(--gap);
    align-items: baseline;
    margin-left: calc(-1 * var(--indent));
  }
  .entry-head { display: contents; }
  .entry .date { grid-column: 1; grid-row: 1; text-align: right; }
  .entry h3, .entry .org, .entry ul { grid-column: 2; }

  /* years sit in the left column and stay in view while their papers scroll past */
  .year {
    display: grid;
    grid-template-columns: var(--gutter) 1fr;
    column-gap: var(--gap);
    margin: 0 0 14px calc(-1 * var(--indent));
  }
  .year h3 {
    position: sticky;
    top: 76px;
    align-self: start;
    margin: 0;
    padding: 6px 0 0;
    border: 0;
    text-align: right;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.4rem;
    font-weight: normal;
  }
  #pub-list { margin-top: 18px; }

  /* Justified text (straight edges on both sides). Hyphenation keeps the gaps
     between words even. Not on phones, where the column is too narrow, and not
     for papers, whose titles and venue names can't be hyphenated. */
  section p, section li { text-align: justify; -webkit-hyphens: auto; hyphens: auto; }
  .pubs li { text-align: left; -webkit-hyphens: manual; hyphens: manual; }

  footer .wrap { padding-left: calc(20px + var(--indent)); }
}

/* ---- Phones and small tablets ---- */
@media (max-width: 699px) {
  /* Menu on one short row, so it can stay on screen. The links scroll
     sideways between the name and the light/dark button.
     Each link is about 46px tall, an easy target for a thumb. */
  .nav { flex-wrap: nowrap; gap: 0 14px; padding-top: 0; padding-bottom: 0; }
  .nav .links {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    gap: 0 18px;
    padding-right: 24px;
    overflow-x: auto;
    scrollbar-width: none;
    /* fade the right edge, so it's clear more links are there */
    -webkit-mask-image: linear-gradient(to left, transparent, #000 32px);
    mask-image: linear-gradient(to left, transparent, #000 32px);
  }
  .nav .links::-webkit-scrollbar { display: none; }
  .nav .name, .nav .links a { flex: none; padding: 11px 0; white-space: nowrap; }
}

@media (max-width: 600px) {
  .wrap { padding: 0 16px; }
  .intro { flex-direction: column; align-items: flex-start; gap: 16px; padding-top: 28px; padding-bottom: 28px; }
  .photo { width: 120px; height: 120px; }
  h1 { font-size: 2rem; }
  .profiles { line-height: 2.1; }   /* more room between the links, for fingers */

  .cites { width: 100%; }
  .cites th, .cites td { padding-right: 12px; }
  .cites thead th { white-space: nowrap; }
}
